OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * We are trying to test those. We could use saveLayer() to create small SkG
puDevices but | 118 * We are trying to test those. We could use saveLayer() to create small SkG
puDevices but |
119 * saveLayer() uses the texture cache. This means that the actual render tar
get may be larger | 119 * saveLayer() uses the texture cache. This means that the actual render tar
get may be larger |
120 * than the layer. Because the clip will contain the layer's bounds, no draw
s will be full-RT. | 120 * than the layer. Because the clip will contain the layer's bounds, no draw
s will be full-RT. |
121 * So when running on a GPU canvas we explicitly create a temporary canvas u
sing a texture with | 121 * So when running on a GPU canvas we explicitly create a temporary canvas u
sing a texture with |
122 * dimensions exactly matching the layer size. | 122 * dimensions exactly matching the layer size. |
123 */ | 123 */ |
124 SkCanvas* possiblyCreateTempCanvas(SkCanvas* baseCanvas, int w, int h) { | 124 SkCanvas* possiblyCreateTempCanvas(SkCanvas* baseCanvas, int w, int h) { |
125 SkCanvas* tempCanvas = NULL; | 125 SkCanvas* tempCanvas = NULL; |
126 #if SK_SUPPORT_GPU | 126 #if SK_SUPPORT_GPU |
127 GrContext* context = baseCanvas->getGrContext(); | 127 GrContext* context = baseCanvas->getGrContext(); |
128 if (context) { | 128 SkImageInfo baseInfo = baseCanvas->imageInfo(); |
129 GrSurfaceDesc desc; | 129 SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInf
o.alphaType(), |
130 desc.fWidth = w; | 130 baseInfo.profileType()); |
131 desc.fHeight = h; | 131 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkSu
rface::kNo_Budgeted, |
132 desc.fConfig = SkImageInfo2GrPixelConfig(baseCanvas->imageInfo()); | 132 info, 0, NULL)); |
133 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 133 if (surface) { |
134 SkAutoTUnref<GrSurface> surface(context->createUncachedTexture(desc,
NULL, 0)); | 134 tempCanvas = SkRef(surface->getCanvas()); |
135 SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(surface.get(), | |
136 SkSurfaceProps(SkSurfaceProps::kLegacy
FontHost_InitType))); | |
137 if (device.get()) { | |
138 tempCanvas = SkNEW_ARGS(SkCanvas, (device.get())); | |
139 } | |
140 } | 135 } |
141 #endif | 136 #endif |
142 return tempCanvas; | 137 return tempCanvas; |
143 } | 138 } |
144 | 139 |
145 void drawMode(SkCanvas* canvas, | 140 void drawMode(SkCanvas* canvas, |
146 int x, int y, int w, int h, | 141 int x, int y, int w, int h, |
147 const SkPaint& modePaint, SkCanvas* layerCanvas) { | 142 const SkPaint& modePaint, SkCanvas* layerCanvas) { |
148 canvas->save(); | 143 canvas->save(); |
149 | 144 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 SkAutoTUnref<SkShader> fBmpShader; | 233 SkAutoTUnref<SkShader> fBmpShader; |
239 | 234 |
240 typedef GM INHERITED; | 235 typedef GM INHERITED; |
241 }; | 236 }; |
242 | 237 |
243 ////////////////////////////////////////////////////////////////////////////// | 238 ////////////////////////////////////////////////////////////////////////////// |
244 | 239 |
245 DEF_GM(return new Xfermodes3GM;) | 240 DEF_GM(return new Xfermodes3GM;) |
246 | 241 |
247 } | 242 } |
OLD | NEW |