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

Side by Side Diff: gm/srcmode.cpp

Issue 137993012: use some helper Make functions to initialize SkImageInfo (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | « gm/image.cpp ('k') | include/core/SkImageInfo.h » ('j') | 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 "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 canvas->translate(W * 5 / 4, 0); 110 canvas->translate(W * 5 / 4, 0);
111 } 111 }
112 } 112 }
113 canvas->restore(); 113 canvas->restore();
114 canvas->translate(0, (H * 5 / 4) * SK_ARRAY_COUNT(procs)); 114 canvas->translate(0, (H * 5 / 4) * SK_ARRAY_COUNT(procs));
115 } 115 }
116 } 116 }
117 117
118 static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size, 118 static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size,
119 bool skipGPU) { 119 bool skipGPU) {
120 SkImageInfo info = { 120 SkImageInfo info = SkImageInfo::MakeN32Premul(size);
121 size.width(),
122 size.height(),
123 kPMColor_SkColorType,
124 kPremul_SkAlphaType
125 };
126 #if SK_SUPPORT_GPU 121 #if SK_SUPPORT_GPU
127 SkBaseDevice* dev = canvas->getDevice(); 122 SkBaseDevice* dev = canvas->getDevice();
128 if (!skipGPU && dev->accessRenderTarget()) { 123 if (!skipGPU && dev->accessRenderTarget()) {
129 SkGpuDevice* gd = (SkGpuDevice*)dev; 124 SkGpuDevice* gd = (SkGpuDevice*)dev;
130 GrContext* ctx = gd->context(); 125 GrContext* ctx = gd->context();
131 return SkSurface::NewRenderTarget(ctx, info, 0); 126 return SkSurface::NewRenderTarget(ctx, info, 0);
132 } 127 }
133 #endif 128 #endif
134 return SkSurface::NewRaster(info); 129 return SkSurface::NewRaster(info);
135 } 130 }
136 131
137 virtual void onDraw(SkCanvas* canvas) { 132 virtual void onDraw(SkCanvas* canvas) {
138 SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(), 133 SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(),
139 this->isCanvasDeferred())); 134 this->isCanvasDeferred()));
140 surf->getCanvas()->drawColor(SK_ColorWHITE); 135 surf->getCanvas()->drawColor(SK_ColorWHITE);
141 this->drawContent(surf->getCanvas()); 136 this->drawContent(surf->getCanvas());
142 surf->draw(canvas, 0, 0, NULL); 137 surf->draw(canvas, 0, 0, NULL);
143 } 138 }
144 139
145 private: 140 private:
146 typedef skiagm::GM INHERITED; 141 typedef skiagm::GM INHERITED;
147 }; 142 };
148 143
149 /////////////////////////////////////////////////////////////////////////////// 144 ///////////////////////////////////////////////////////////////////////////////
150 145
151 DEF_GM(return new SrcModeGM;) 146 DEF_GM(return new SrcModeGM;)
OLDNEW
« no previous file with comments | « gm/image.cpp ('k') | include/core/SkImageInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698