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

Side by Side Diff: gm/xfermodes3.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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
« no previous file with comments | « gm/xfermodes2.cpp ('k') | gm/yuvtorgbeffect.cpp » ('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 /* 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 private: 115 private:
116 /** 116 /**
117 * GrContext has optimizations around full rendertarget draws that can be re placed with clears. 117 * GrContext has optimizations around full rendertarget draws that can be re placed with clears.
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 = nullptr;
126 #if SK_SUPPORT_GPU 126 #if SK_SUPPORT_GPU
127 GrContext* context = baseCanvas->getGrContext(); 127 GrContext* context = baseCanvas->getGrContext();
128 SkImageInfo baseInfo = baseCanvas->imageInfo(); 128 SkImageInfo baseInfo = baseCanvas->imageInfo();
129 SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInf o.alphaType(), 129 SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInf o.alphaType(),
130 baseInfo.profileType()); 130 baseInfo.profileType());
131 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkSu rface::kNo_Budgeted, 131 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkSu rface::kNo_Budgeted,
132 info, 0, NULL)); 132 info, 0, nullptr));
133 if (surface) { 133 if (surface) {
134 tempCanvas = SkRef(surface->getCanvas()); 134 tempCanvas = SkRef(surface->getCanvas());
135 } 135 }
136 #endif 136 #endif
137 return tempCanvas; 137 return tempCanvas;
138 } 138 }
139 139
140 void drawMode(SkCanvas* canvas, 140 void drawMode(SkCanvas* canvas,
141 int x, int y, int w, int h, 141 int x, int y, int w, int h,
142 const SkPaint& modePaint, SkCanvas* layerCanvas) { 142 const SkPaint& modePaint, SkCanvas* layerCanvas) {
143 canvas->save(); 143 canvas->save();
144 144
145 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 145 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
146 146
147 SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)); 147 SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h));
148 148
149 SkCanvas* modeCanvas; 149 SkCanvas* modeCanvas;
150 if (NULL == layerCanvas) { 150 if (nullptr == layerCanvas) {
151 canvas->saveLayer(&r, NULL); 151 canvas->saveLayer(&r, nullptr);
152 modeCanvas = canvas; 152 modeCanvas = canvas;
153 } else { 153 } else {
154 modeCanvas = layerCanvas; 154 modeCanvas = layerCanvas;
155 } 155 }
156 156
157 SkPaint bgPaint; 157 SkPaint bgPaint;
158 bgPaint.setAntiAlias(false); 158 bgPaint.setAntiAlias(false);
159 bgPaint.setShader(fBGShader); 159 bgPaint.setShader(fBGShader);
160 modeCanvas->drawRect(r, bgPaint); 160 modeCanvas->drawRect(r, bgPaint);
161 modeCanvas->drawRect(r, modePaint); 161 modeCanvas->drawRect(r, modePaint);
162 modeCanvas = NULL; 162 modeCanvas = nullptr;
163 163
164 if (NULL == layerCanvas) { 164 if (nullptr == layerCanvas) {
165 canvas->restore(); 165 canvas->restore();
166 } else { 166 } else {
167 SkAutoROCanvasPixels ropixels(layerCanvas); 167 SkAutoROCanvasPixels ropixels(layerCanvas);
168 SkBitmap bitmap; 168 SkBitmap bitmap;
169 if (ropixels.asROBitmap(&bitmap)) { 169 if (ropixels.asROBitmap(&bitmap)) {
170 canvas->drawBitmap(bitmap, 0, 0); 170 canvas->drawBitmap(bitmap, 0, 0);
171 } 171 }
172 } 172 }
173 173
174 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); 174 r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
(...skipping 23 matching lines...) Expand all
198 SkShader::kRepeat_TileMode, 198 SkShader::kRepeat_TileMode,
199 &lm)); 199 &lm));
200 200
201 SkPaint bmpPaint; 201 SkPaint bmpPaint;
202 static const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar (kSize) / 2 }; 202 static const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar (kSize) / 2 };
203 static const SkColor kColors[] = { SK_ColorTRANSPARENT, 0x80800000, 203 static const SkColor kColors[] = { SK_ColorTRANSPARENT, 0x80800000,
204 0xF020F060, SK_ColorWHITE }; 204 0xF020F060, SK_ColorWHITE };
205 bmpPaint.setShader(SkGradientShader::CreateRadial(kCenter, 205 bmpPaint.setShader(SkGradientShader::CreateRadial(kCenter,
206 3 * SkIntToScalar(kSiz e) / 4, 206 3 * SkIntToScalar(kSiz e) / 4,
207 kColors, 207 kColors,
208 NULL, 208 nullptr,
209 SK_ARRAY_COUNT(kColors ), 209 SK_ARRAY_COUNT(kColors ),
210 SkShader::kRepeat_Tile Mode))->unref(); 210 SkShader::kRepeat_Tile Mode))->unref();
211 211
212 SkBitmap bmp; 212 SkBitmap bmp;
213 bmp.allocN32Pixels(kSize, kSize); 213 bmp.allocN32Pixels(kSize, kSize);
214 SkCanvas bmpCanvas(bmp); 214 SkCanvas bmpCanvas(bmp);
215 215
216 bmpCanvas.clear(SK_ColorTRANSPARENT); 216 bmpCanvas.clear(SK_ColorTRANSPARENT);
217 SkRect rect = { SkIntToScalar(kSize) / 8, SkIntToScalar(kSize) / 8, 217 SkRect rect = { SkIntToScalar(kSize) / 8, SkIntToScalar(kSize) / 8,
218 7 * SkIntToScalar(kSize) / 8, 7 * SkIntToScalar(kSize) / 8}; 218 7 * SkIntToScalar(kSize) / 8, 7 * SkIntToScalar(kSize) / 8};
(...skipping 14 matching lines...) Expand all
233 SkAutoTUnref<SkShader> fBmpShader; 233 SkAutoTUnref<SkShader> fBmpShader;
234 234
235 typedef GM INHERITED; 235 typedef GM INHERITED;
236 }; 236 };
237 237
238 ////////////////////////////////////////////////////////////////////////////// 238 //////////////////////////////////////////////////////////////////////////////
239 239
240 DEF_GM(return new Xfermodes3GM;) 240 DEF_GM(return new Xfermodes3GM;)
241 241
242 } 242 }
OLDNEW
« no previous file with comments | « gm/xfermodes2.cpp ('k') | gm/yuvtorgbeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698