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

Side by Side Diff: tools/PictureRenderer.cpp

Issue 13947016: Simplify bench pictures render target creation. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "PictureRenderer.h" 8 #include "PictureRenderer.h"
9 #include "picture_utils.h" 9 #include "picture_utils.h"
10 #include "SamplePipeControllers.h" 10 #include "SamplePipeControllers.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 sk_tools::setup_bitmap(&bitmap, width, height); 105 sk_tools::setup_bitmap(&bitmap, width, height);
106 canvas = SkNEW_ARGS(SkCanvas, (bitmap)); 106 canvas = SkNEW_ARGS(SkCanvas, (bitmap));
107 } 107 }
108 break; 108 break;
109 #if SK_SUPPORT_GPU 109 #if SK_SUPPORT_GPU
110 #if SK_ANGLE 110 #if SK_ANGLE
111 case kAngle_DeviceType: 111 case kAngle_DeviceType:
112 // fall through 112 // fall through
113 #endif 113 #endif
114 case kGPU_DeviceType: { 114 case kGPU_DeviceType: {
115 SkAutoTUnref<GrRenderTarget> rt; 115 SkAutoTUnref<GrSurface> target;
116 bool grSuccess = false;
117 if (fGrContext) { 116 if (fGrContext) {
118 // create a render target to back the device 117 // create a render target to back the device
119 GrTextureDesc desc; 118 GrTextureDesc desc;
120 desc.fConfig = kSkia8888_GrPixelConfig; 119 desc.fConfig = kSkia8888_GrPixelConfig;
121 desc.fFlags = kRenderTarget_GrTextureFlagBit; 120 desc.fFlags = kRenderTarget_GrTextureFlagBit;
122 desc.fWidth = width; 121 desc.fWidth = width;
123 desc.fHeight = height; 122 desc.fHeight = height;
124 desc.fSampleCnt = 0; 123 desc.fSampleCnt = 0;
125 GrTexture* tex = fGrContext->createUncachedTexture(desc, NULL, 0 ); 124 target.reset(fGrContext->createUncachedTexture(desc, NULL, 0));
126 if (tex) {
127 rt.reset(tex->asRenderTarget());
128 rt.get()->ref();
129 tex->unref();
130 grSuccess = NULL != rt.get();
131 }
132 } 125 }
133 if (!grSuccess) { 126 if (NULL == target.get()) {
134 SkASSERT(0); 127 SkASSERT(0);
135 return NULL; 128 return NULL;
136 } 129 }
137 130
138 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (fGrContext , rt))); 131 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(target));
139 canvas = SkNEW_ARGS(SkCanvas, (device.get())); 132 canvas = SkNEW_ARGS(SkCanvas, (device.get()));
140 break; 133 break;
141 } 134 }
142 #endif 135 #endif
143 default: 136 default:
144 SkASSERT(0); 137 SkASSERT(0);
145 return NULL; 138 return NULL;
146 } 139 }
147 setUpFilter(canvas, fDrawFilters); 140 setUpFilter(canvas, fDrawFilters);
148 this->scaleToScaleFactor(canvas); 141 this->scaleToScaleFactor(canvas);
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 virtual SkString getConfigNameInternal() SK_OVERRIDE { 842 virtual SkString getConfigNameInternal() SK_OVERRIDE {
850 return SkString("picture_clone"); 843 return SkString("picture_clone");
851 } 844 }
852 }; 845 };
853 846
854 PictureRenderer* CreatePictureCloneRenderer() { 847 PictureRenderer* CreatePictureCloneRenderer() {
855 return SkNEW(PictureCloneRenderer); 848 return SkNEW(PictureCloneRenderer);
856 } 849 }
857 850
858 } // namespace sk_tools 851 } // namespace sk_tools
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698