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

Side by Side Diff: samplecode/SampleGradients.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 | « samplecode/SampleFuzz.cpp ('k') | samplecode/SampleHT.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 2011 Google Inc. 3 * Copyright 2011 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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 12
13 static SkShader* setgrad(const SkRect& r, SkColor c0, SkColor c1) { 13 static SkShader* setgrad(const SkRect& r, SkColor c0, SkColor c1) {
14 SkColor colors[] = { c0, c1 }; 14 SkColor colors[] = { c0, c1 };
15 SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } }; 15 SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } };
16 return SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp _TileMode); 16 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kCl amp_TileMode);
17 } 17 }
18 18
19 static void test_alphagradients(SkCanvas* canvas) { 19 static void test_alphagradients(SkCanvas* canvas) {
20 SkRect r; 20 SkRect r;
21 r.set(SkIntToScalar(10), SkIntToScalar(10), 21 r.set(SkIntToScalar(10), SkIntToScalar(10),
22 SkIntToScalar(410), SkIntToScalar(30)); 22 SkIntToScalar(410), SkIntToScalar(30));
23 SkPaint p, p2; 23 SkPaint p, p2;
24 p2.setStyle(SkPaint::kStroke_Style); 24 p2.setStyle(SkPaint::kStroke_Style);
25 25
26 p.setShader(setgrad(r, 0xFF00FF00, 0x0000FF00))->unref(); 26 p.setShader(setgrad(r, 0xFF00FF00, 0x0000FF00))->unref();
(...skipping 22 matching lines...) Expand all
49 static const SkColor gColors[] = { 49 static const SkColor gColors[] = {
50 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK 50 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK
51 }; 51 };
52 static const SkScalar gPos0[] = { 0, SK_Scalar1 }; 52 static const SkScalar gPos0[] = { 0, SK_Scalar1 };
53 static const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 }; 53 static const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
54 static const SkScalar gPos2[] = { 54 static const SkScalar gPos2[] = {
55 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1 55 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1
56 }; 56 };
57 57
58 static const GradData gGradData[] = { 58 static const GradData gGradData[] = {
59 { 2, gColors, NULL }, 59 { 2, gColors, nullptr },
60 { 2, gColors, gPos0 }, 60 { 2, gColors, gPos0 },
61 { 2, gColors, gPos1 }, 61 { 2, gColors, gPos1 },
62 { 5, gColors, NULL }, 62 { 5, gColors, nullptr },
63 { 5, gColors, gPos2 } 63 { 5, gColors, gPos2 }
64 }; 64 };
65 65
66 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) { 66 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
67 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm); 67 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm);
68 } 68 }
69 69
70 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) { 70 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
71 SkPoint center; 71 SkPoint center;
72 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 72 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 canvas->restore(); 158 canvas->restore();
159 canvas->translate(SK_ARRAY_COUNT(gGradData)*SkIntToScalar(120), 0); 159 canvas->translate(SK_ARRAY_COUNT(gGradData)*SkIntToScalar(120), 0);
160 } 160 }
161 canvas->restore(); 161 canvas->restore();
162 162
163 canvas->translate(0, SkIntToScalar(370)); 163 canvas->translate(0, SkIntToScalar(370));
164 if (false) { // avoid bit rot, suppress warning 164 if (false) { // avoid bit rot, suppress warning
165 test_alphagradients(canvas); 165 test_alphagradients(canvas);
166 } 166 }
167 this->inval(NULL); 167 this->inval(nullptr);
168 } 168 }
169 169
170 private: 170 private:
171 typedef SampleView INHERITED; 171 typedef SampleView INHERITED;
172 }; 172 };
173 173
174 /////////////////////////////////////////////////////////////////////////////// 174 ///////////////////////////////////////////////////////////////////////////////
175 175
176 static SkView* MyFactory() { return new GradientsView; } 176 static SkView* MyFactory() { return new GradientsView; }
177 static SkViewRegister reg(MyFactory); 177 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleFuzz.cpp ('k') | samplecode/SampleHT.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698