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

Side by Side Diff: gm/image.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/hairmodes.cpp ('k') | gm/imagealphathreshold.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkData.h" 9 #include "SkData.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 #include "SkSurface.h" 13 #include "SkSurface.h"
14 14
15 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
16 #include "GrContext.h" 16 #include "GrContext.h"
17 #endif 17 #endif
18 18
19 static void drawJpeg(SkCanvas* canvas, const SkISize& size) { 19 static void drawJpeg(SkCanvas* canvas, const SkISize& size) {
20 // TODO: Make this draw a file that is checked in, so it can 20 // TODO: Make this draw a file that is checked in, so it can
21 // be exercised on machines other than mike's. Will require a 21 // be exercised on machines other than mike's. Will require a
22 // rebaseline. 22 // rebaseline.
23 SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.goo gle.jpeg")); 23 SkAutoDataUnref data(SkData::NewFromFileName("/Users/mike/Downloads/skia.goo gle.jpeg"));
24 if (NULL == data.get()) { 24 if (nullptr == data.get()) {
25 return; 25 return;
26 } 26 }
27 SkImage* image = SkImage::NewFromEncoded(data); 27 SkImage* image = SkImage::NewFromEncoded(data);
28 if (image) { 28 if (image) {
29 SkAutoCanvasRestore acr(canvas, true); 29 SkAutoCanvasRestore acr(canvas, true);
30 canvas->scale(size.width() * 1.0f / image->width(), 30 canvas->scale(size.width() * 1.0f / image->width(),
31 size.height() * 1.0f / image->height()); 31 size.height() * 1.0f / image->height());
32 canvas->drawImage(image, 0, 0, NULL); 32 canvas->drawImage(image, 0, 0, nullptr);
33 image->unref(); 33 image->unref();
34 } 34 }
35 } 35 }
36 36
37 static void drawContents(SkSurface* surface, SkColor fillC) { 37 static void drawContents(SkSurface* surface, SkColor fillC) {
38 SkSize size = SkSize::Make(SkIntToScalar(surface->width()), 38 SkSize size = SkSize::Make(SkIntToScalar(surface->width()),
39 SkIntToScalar(surface->height())); 39 SkIntToScalar(surface->height()));
40 SkCanvas* canvas = surface->getCanvas(); 40 SkCanvas* canvas = surface->getCanvas();
41 41
42 SkScalar stroke = size.fWidth / 10; 42 SkScalar stroke = size.fWidth / 10;
(...skipping 26 matching lines...) Expand all
69 69
70 // since we've drawn after we snapped imgR, imgG will be a different obj 70 // since we've drawn after we snapped imgR, imgG will be a different obj
71 SkASSERT(imgR != imgG); 71 SkASSERT(imgR != imgG);
72 72
73 drawContents(surf, SK_ColorBLUE); 73 drawContents(surf, SK_ColorBLUE);
74 74
75 SkPaint paint; 75 SkPaint paint;
76 // paint.setFilterBitmap(true); 76 // paint.setFilterBitmap(true);
77 // paint.setAlpha(0x80); 77 // paint.setAlpha(0x80);
78 78
79 canvas->drawImage(imgR, 0, 0, usePaint ? &paint : NULL); 79 canvas->drawImage(imgR, 0, 0, usePaint ? &paint : nullptr);
80 canvas->drawImage(imgG, 0, 80, usePaint ? &paint : NULL); 80 canvas->drawImage(imgG, 0, 80, usePaint ? &paint : nullptr);
81 surf->draw(canvas, 0, 160, usePaint ? &paint : NULL); 81 surf->draw(canvas, 0, 160, usePaint ? &paint : nullptr);
82 82
83 SkRect src1, src2, src3; 83 SkRect src1, src2, src3;
84 src1.iset(0, 0, surf->width(), surf->height()); 84 src1.iset(0, 0, surf->width(), surf->height());
85 src2.iset(-surf->width() / 2, -surf->height() / 2, 85 src2.iset(-surf->width() / 2, -surf->height() / 2,
86 surf->width(), surf->height()); 86 surf->width(), surf->height());
87 src3.iset(0, 0, surf->width() / 2, surf->height() / 2); 87 src3.iset(0, 0, surf->width() / 2, surf->height() / 2);
88 88
89 SkRect dst1, dst2, dst3, dst4; 89 SkRect dst1, dst2, dst3, dst4;
90 dst1.set(0, 240, 65, 305); 90 dst1.set(0, 240, 65, 305);
91 dst2.set(0, 320, 65, 385); 91 dst2.set(0, 320, 65, 385);
92 dst3.set(0, 400, 65, 465); 92 dst3.set(0, 400, 65, 465);
93 dst4.set(0, 480, 65, 545); 93 dst4.set(0, 480, 65, 545);
94 94
95 canvas->drawImageRect(imgR, src1, dst1, usePaint ? &paint : NULL); 95 canvas->drawImageRect(imgR, src1, dst1, usePaint ? &paint : nullptr);
96 canvas->drawImageRect(imgG, src2, dst2, usePaint ? &paint : NULL); 96 canvas->drawImageRect(imgG, src2, dst2, usePaint ? &paint : nullptr);
97 canvas->drawImageRect(imgR, src3, dst3, usePaint ? &paint : NULL); 97 canvas->drawImageRect(imgR, src3, dst3, usePaint ? &paint : nullptr);
98 canvas->drawImageRect(imgG, dst4, usePaint ? &paint : NULL); 98 canvas->drawImageRect(imgG, dst4, usePaint ? &paint : nullptr);
99 99
100 imgG->unref(); 100 imgG->unref();
101 imgR->unref(); 101 imgR->unref();
102 } 102 }
103 103
104 class ImageGM : public skiagm::GM { 104 class ImageGM : public skiagm::GM {
105 void* fBuffer; 105 void* fBuffer;
106 size_t fBufferSize; 106 size_t fBufferSize;
107 SkSize fSize; 107 SkSize fSize;
108 enum { 108 enum {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 void drawResized(SkCanvas* canvas, SkImage* image, int newW, int newH, const SkIRect* subset, 234 void drawResized(SkCanvas* canvas, SkImage* image, int newW, int newH, const SkIRect* subset,
235 SkFilterQuality fq) { 235 SkFilterQuality fq) {
236 // canvas method 236 // canvas method
237 SkPaint paint; 237 SkPaint paint;
238 paint.setFilterQuality(fq); 238 paint.setFilterQuality(fq);
239 SkRect dstR = SkRect::MakeWH(SkIntToScalar(newW), SkIntToScalar(newH)); 239 SkRect dstR = SkRect::MakeWH(SkIntToScalar(newW), SkIntToScalar(newH));
240 SkRect srcR; 240 SkRect srcR;
241 if (subset) { 241 if (subset) {
242 srcR.set(*subset); 242 srcR.set(*subset);
243 } 243 }
244 canvas->legacy_drawImageRect(image, subset ? &srcR : NULL, dstR, &paint) ; 244 canvas->legacy_drawImageRect(image, subset ? &srcR : nullptr, dstR, &pai nt);
245 canvas->translate(newW + 20.0f, 0); 245 canvas->translate(newW + 20.0f, 0);
246 246
247 // image method 247 // image method
248 SkAutoTUnref<SkImage> image2(image->newImage(newW, newH, subset, fq)); 248 SkAutoTUnref<SkImage> image2(image->newImage(newW, newH, subset, fq));
249 canvas->drawImage(image2, 0, 0, NULL); 249 canvas->drawImage(image2, 0, 0, nullptr);
250 canvas->translate(image2->width() + 20.0f, 0); 250 canvas->translate(image2->width() + 20.0f, 0);
251 } 251 }
252 252
253 void drawImage(SkCanvas* canvas, SkImage* image, SkFilterQuality fq) { 253 void drawImage(SkCanvas* canvas, SkImage* image, SkFilterQuality fq) {
254 254
255 canvas->drawImage(image, 0, 0, NULL); 255 canvas->drawImage(image, 0, 0, nullptr);
256 canvas->translate(image->width() + 20.0f, 0); 256 canvas->translate(image->width() + 20.0f, 0);
257 this->drawResized(canvas, image, image->width()*4/10, image->height()*4/ 10, NULL, fq); 257 this->drawResized(canvas, image, image->width()*4/10, image->height()*4/ 10, nullptr, fq);
258 258
259 SkIRect subset = SkIRect::MakeLTRB(W/4, H/4, W/2, H/2); 259 SkIRect subset = SkIRect::MakeLTRB(W/4, H/4, W/2, H/2);
260 this->drawResized(canvas, image, W, H, &subset, fq); 260 this->drawResized(canvas, image, W, H, &subset, fq);
261 } 261 }
262 262
263 void onDraw(SkCanvas* canvas) override { 263 void onDraw(SkCanvas* canvas) override {
264 canvas->translate(10, 10); 264 canvas->translate(10, 10);
265 265
266 SkAutoTUnref<SkImage> image(this->makeImage(canvas)); 266 SkAutoTUnref<SkImage> image(this->makeImage(canvas));
267 267
(...skipping 10 matching lines...) Expand all
278 } 278 }
279 canvas->translate(0, image->height() + 20.0f); 279 canvas->translate(0, image->height() + 20.0f);
280 } 280 }
281 } 281 }
282 282
283 private: 283 private:
284 typedef skiagm::GM INHERITED; 284 typedef skiagm::GM INHERITED;
285 }; 285 };
286 DEF_GM( return new ImageResizeGM; ) 286 DEF_GM( return new ImageResizeGM; )
287 287
OLDNEW
« no previous file with comments | « gm/hairmodes.cpp ('k') | gm/imagealphathreshold.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698