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: gm/gradients_no_texture.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/gradients.cpp ('k') | gm/gradtext.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 2013 Google Inc. 2 * Copyright 2013 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 #include "gm.h" 7 #include "gm.h"
8 #include "SkGradientShader.h" 8 #include "SkGradientShader.h"
9 9
10 using namespace skiagm; 10 using namespace skiagm;
11 11
12 struct GradData { 12 struct GradData {
13 int fCount; 13 int fCount;
14 const SkColor* fColors; 14 const SkColor* fColors;
15 const SkScalar* fPos; 15 const SkScalar* fPos;
16 }; 16 };
17 17
18 static const SkColor gColors[] = { 18 static const SkColor gColors[] = {
19 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, 19 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE,
20 }; 20 };
21 21
22 static const GradData gGradData[] = { 22 static const GradData gGradData[] = {
23 { 1, gColors, NULL }, 23 { 1, gColors, nullptr },
24 { 2, gColors, NULL }, 24 { 2, gColors, nullptr },
25 { 3, gColors, NULL }, 25 { 3, gColors, nullptr },
26 { 4, gColors, NULL }, 26 { 4, gColors, nullptr },
27 }; 27 };
28 28
29 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) { 29 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
30 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm); 30 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm);
31 } 31 }
32 32
33 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) { 33 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
34 SkPoint center; 34 SkPoint center;
35 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 35 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
36 SkScalarAve(pts[0].fY, pts[1].fY)); 36 SkScalarAve(pts[0].fY, pts[1].fY));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 typedef GM INHERITED; 119 typedef GM INHERITED;
120 }; 120 };
121 121
122 /////////////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////////////
123 123
124 struct ColorPos { 124 struct ColorPos {
125 SkColor* fColors; 125 SkColor* fColors;
126 SkScalar* fPos; 126 SkScalar* fPos;
127 int fCount; 127 int fCount;
128 128
129 ColorPos() : fColors(NULL), fPos(NULL), fCount(0) {} 129 ColorPos() : fColors(nullptr), fPos(nullptr), fCount(0) {}
130 ~ColorPos() { 130 ~ColorPos() {
131 delete[] fColors; 131 delete[] fColors;
132 delete[] fPos; 132 delete[] fPos;
133 } 133 }
134 134
135 void construct(const SkColor colors[], const SkScalar pos[], int count) { 135 void construct(const SkColor colors[], const SkScalar pos[], int count) {
136 fColors = new SkColor[count]; 136 fColors = new SkColor[count];
137 memcpy(fColors, colors, count * sizeof(SkColor)); 137 memcpy(fColors, colors, count * sizeof(SkColor));
138 if (pos) { 138 if (pos) {
139 fPos = new SkScalar[count]; 139 fPos = new SkScalar[count];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 rec->construct(colors, pos, N); 174 rec->construct(colors, pos, N);
175 } 175 }
176 176
177 static void make1(ColorPos* rec) { 177 static void make1(ColorPos* rec) {
178 const SkColor colors[] = { 178 const SkColor colors[] = {
179 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE, 179 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE,
180 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE, 180 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE,
181 SK_ColorBLACK, 181 SK_ColorBLACK,
182 }; 182 };
183 rec->construct(colors, NULL, SK_ARRAY_COUNT(colors)); 183 rec->construct(colors, nullptr, SK_ARRAY_COUNT(colors));
184 } 184 }
185 185
186 static void make2(ColorPos* rec) { 186 static void make2(ColorPos* rec) {
187 const SkColor colors[] = { 187 const SkColor colors[] = {
188 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE, 188 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE,
189 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE, 189 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE,
190 SK_ColorBLACK, 190 SK_ColorBLACK,
191 }; 191 };
192 const int N = SK_ARRAY_COUNT(colors); 192 const int N = SK_ARRAY_COUNT(colors);
193 SkScalar pos[N]; 193 SkScalar pos[N];
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 244
245 private: 245 private:
246 typedef GM INHERITED; 246 typedef GM INHERITED;
247 }; 247 };
248 248
249 /////////////////////////////////////////////////////////////////////////////// 249 ///////////////////////////////////////////////////////////////////////////////
250 250
251 DEF_GM(return new GradientsNoTextureGM); 251 DEF_GM(return new GradientsNoTextureGM);
252 DEF_GM(return new GradientsManyColorsGM); 252 DEF_GM(return new GradientsManyColorsGM);
OLDNEW
« no previous file with comments | « gm/gradients.cpp ('k') | gm/gradtext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698