Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: gm/xfermodes3.cpp

Issue 355193006: stop calling SkCanvas::getDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 * GrContext has optimizations around full rendertarget draws that can be re placed with clears. 116 * GrContext has optimizations around full rendertarget draws that can be re placed with clears.
117 * We are trying to test those. We could use saveLayer() to create small SkG puDevices but 117 * We are trying to test those. We could use saveLayer() to create small SkG puDevices but
118 * saveLayer() uses the texture cache. This means that the actual render tar get may be larger 118 * saveLayer() uses the texture cache. This means that the actual render tar get may be larger
119 * than the layer. Because the clip will contain the layer's bounds, no draw s will be full-RT. 119 * than the layer. Because the clip will contain the layer's bounds, no draw s will be full-RT.
120 * So when running on a GPU canvas we explicitly create a temporary canvas u sing a texture with 120 * So when running on a GPU canvas we explicitly create a temporary canvas u sing a texture with
121 * dimensions exactly matching the layer size. 121 * dimensions exactly matching the layer size.
122 */ 122 */
123 SkCanvas* possiblyCreateTempCanvas(SkCanvas* baseCanvas, int w, int h) { 123 SkCanvas* possiblyCreateTempCanvas(SkCanvas* baseCanvas, int w, int h) {
124 SkCanvas* tempCanvas = NULL; 124 SkCanvas* tempCanvas = NULL;
125 #if SK_SUPPORT_GPU 125 #if SK_SUPPORT_GPU
126 GrRenderTarget* rt = baseCanvas->getDevice()->accessRenderTarget(); 126 GrContext* context = baseCanvas->getGrContext();
127 if (NULL != rt) { 127 if (NULL != context) {
128 GrContext* context = rt->getContext();
129 GrTextureDesc desc; 128 GrTextureDesc desc;
130 desc.fWidth = w; 129 desc.fWidth = w;
131 desc.fHeight = h; 130 desc.fHeight = h;
132 desc.fConfig = rt->config(); 131 desc.fConfig = SkImageInfo2GrPixelConfig(baseCanvas->imageInfo());
133 desc.fFlags = kRenderTarget_GrTextureFlagBit; 132 desc.fFlags = kRenderTarget_GrTextureFlagBit;
134 SkAutoTUnref<GrSurface> surface(context->createUncachedTexture(desc, NULL, 0)); 133 SkAutoTUnref<GrSurface> surface(context->createUncachedTexture(desc, NULL, 0));
135 SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(surface.get()) ); 134 SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(surface.get()) );
136 if (NULL != device.get()) { 135 if (NULL != device.get()) {
137 tempCanvas = SkNEW_ARGS(SkCanvas, (device.get())); 136 tempCanvas = SkNEW_ARGS(SkCanvas, (device.get()));
138 } 137 }
139 } 138 }
140 #endif 139 #endif
141 return tempCanvas; 140 return tempCanvas;
142 } 141 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 SkAutoTUnref<SkShader> fBmpShader; 236 SkAutoTUnref<SkShader> fBmpShader;
238 237
239 typedef GM INHERITED; 238 typedef GM INHERITED;
240 }; 239 };
241 240
242 ////////////////////////////////////////////////////////////////////////////// 241 //////////////////////////////////////////////////////////////////////////////
243 242
244 DEF_GM(return new Xfermodes3GM;) 243 DEF_GM(return new Xfermodes3GM;)
245 244
246 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698