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

Side by Side Diff: gm/ninepatchstretch.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/multipicturedraw.cpp ('k') | gm/offsetimagefilter.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 "SkSurface.h" 9 #include "SkSurface.h"
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 protected: 63 protected:
64 SkString onShortName() override { 64 SkString onShortName() override {
65 return SkString("ninepatch-stretch"); 65 return SkString("ninepatch-stretch");
66 } 66 }
67 67
68 SkISize onISize() override { 68 SkISize onISize() override {
69 return SkISize::Make(760, 400); 69 return SkISize::Make(760, 400);
70 } 70 }
71 71
72 void onDraw(SkCanvas* canvas) override { 72 void onDraw(SkCanvas* canvas) override {
73 if (NULL == fBitmap.pixelRef()) { 73 if (nullptr == fBitmap.pixelRef()) {
74 fImage.reset(make_image(canvas, &fCenter)); 74 fImage.reset(make_image(canvas, &fCenter));
75 image_to_bitmap(fImage, &fBitmap); 75 image_to_bitmap(fImage, &fBitmap);
76 } 76 }
77 77
78 // amount of bm that should not be stretched (unless we have to) 78 // amount of bm that should not be stretched (unless we have to)
79 const SkScalar fixed = SkIntToScalar(fBitmap.width() - fCenter.width()); 79 const SkScalar fixed = SkIntToScalar(fBitmap.width() - fCenter.width());
80 80
81 const SkTSize<SkScalar> size[] = { 81 const SkTSize<SkScalar> size[] = {
82 { fixed * 4 / 5, fixed * 4 / 5 }, // shrink in both axes 82 { fixed * 4 / 5, fixed * 4 / 5 }, // shrink in both axes
83 { fixed * 4 / 5, fixed * 4 }, // shrink in X 83 { fixed * 4 / 5, fixed * 4 }, // shrink in X
84 { fixed * 4, fixed * 4 / 5 }, // shrink in Y 84 { fixed * 4, fixed * 4 / 5 }, // shrink in Y
85 { fixed * 4, fixed * 4 } 85 { fixed * 4, fixed * 4 }
86 }; 86 };
87 87
88 canvas->drawBitmap(fBitmap, 10, 10, NULL); 88 canvas->drawBitmap(fBitmap, 10, 10, nullptr);
89 89
90 SkScalar x = SkIntToScalar(100); 90 SkScalar x = SkIntToScalar(100);
91 SkScalar y = SkIntToScalar(100); 91 SkScalar y = SkIntToScalar(100);
92 92
93 SkPaint paint; 93 SkPaint paint;
94 paint.setFilterQuality(kLow_SkFilterQuality); 94 paint.setFilterQuality(kLow_SkFilterQuality);
95 95
96 for (int iy = 0; iy < 2; ++iy) { 96 for (int iy = 0; iy < 2; ++iy) {
97 for (int ix = 0; ix < 2; ++ix) { 97 for (int ix = 0; ix < 2; ++ix) {
98 int i = ix * 2 + iy; 98 int i = ix * 2 + iy;
99 SkRect r = SkRect::MakeXYWH(x + ix * fixed, y + iy * fixed, 99 SkRect r = SkRect::MakeXYWH(x + ix * fixed, y + iy * fixed,
100 size[i].width(), size[i].height()); 100 size[i].width(), size[i].height());
101 canvas->drawBitmapNine(fBitmap, fCenter, r, &paint); 101 canvas->drawBitmapNine(fBitmap, fCenter, r, &paint);
102 canvas->drawImageNine(fImage, fCenter, r.makeOffset(360, 0), &pa int); 102 canvas->drawImageNine(fImage, fCenter, r.makeOffset(360, 0), &pa int);
103 103
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 private: 108 private:
109 typedef skiagm::GM INHERITED; 109 typedef skiagm::GM INHERITED;
110 }; 110 };
111 DEF_GM( return new NinePatchStretchGM; ) 111 DEF_GM( return new NinePatchStretchGM; )
112 112
OLDNEW
« no previous file with comments | « gm/multipicturedraw.cpp ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698