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

Side by Side Diff: gm/gammatext.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/fontscalerdistortable.cpp ('k') | gm/giantbitmap.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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 #include "SkTypeface.h" 12 #include "SkTypeface.h"
13 13
14 static SkShader* make_heatGradient(const SkPoint pts[2]) { 14 static SkShader* make_heatGradient(const SkPoint pts[2]) {
15 const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE }; 15 const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE };
16 16
17 return SkGradientShader::CreateLinear(pts, bw, NULL, 17 return SkGradientShader::CreateLinear(pts, bw, nullptr,
18 SK_ARRAY_COUNT(bw), 18 SK_ARRAY_COUNT(bw),
19 SkShader::kClamp_TileMode); 19 SkShader::kClamp_TileMode);
20 } 20 }
21 21
22 static bool setFont(SkPaint* paint, const char name[]) { 22 static bool setFont(SkPaint* paint, const char name[]) {
23 SkTypeface* tf = SkTypeface::CreateFromName(name, SkTypeface::kNormal); 23 SkTypeface* tf = SkTypeface::CreateFromName(name, SkTypeface::kNormal);
24 if (tf) { 24 if (tf) {
25 paint->setTypeface(tf)->unref(); 25 paint->setTypeface(tf)->unref();
26 return true; 26 return true;
27 } 27 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 DEF_GM( return new GammaTextGM; ) 100 DEF_GM( return new GammaTextGM; )
101 101
102 ////////////////////////////////////////////////////////////////////////////// 102 //////////////////////////////////////////////////////////////////////////////
103 103
104 static SkShader* make_gradient(SkColor c) { 104 static SkShader* make_gradient(SkColor c) {
105 const SkPoint pts[] = { { 0, 0 }, { 240, 0 } }; 105 const SkPoint pts[] = { { 0, 0 }, { 240, 0 } };
106 SkColor colors[2]; 106 SkColor colors[2];
107 colors[0] = c; 107 colors[0] = c;
108 colors[1] = SkColorSetA(c, 0); 108 colors[1] = SkColorSetA(c, 0);
109 return SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp _TileMode); 109 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kCl amp_TileMode);
110 } 110 }
111 111
112 static void set_face(SkPaint* paint) { 112 static void set_face(SkPaint* paint) {
113 SkTypeface* face = SkTypeface::CreateFromName("serif", SkTypeface::kItalic); 113 SkTypeface* face = SkTypeface::CreateFromName("serif", SkTypeface::kItalic);
114 SkSafeUnref(paint->setTypeface(face)); 114 SkSafeUnref(paint->setTypeface(face));
115 } 115 }
116 116
117 static void draw_pair(SkCanvas* canvas, SkPaint* paint, SkShader* shader) { 117 static void draw_pair(SkCanvas* canvas, SkPaint* paint, SkShader* shader) {
118 const char text[] = "Now is the time for all good"; 118 const char text[] = "Now is the time for all good";
119 const size_t len = strlen(text); 119 const size_t len = strlen(text);
120 120
121 paint->setShader(NULL); 121 paint->setShader(nullptr);
122 canvas->drawText(text, len, 10, 20, *paint); 122 canvas->drawText(text, len, 10, 20, *paint);
123 paint->setShader(SkShader::CreateColorShader(paint->getColor()))->unref(); 123 paint->setShader(SkShader::CreateColorShader(paint->getColor()))->unref();
124 canvas->drawText(text, len, 10, 40, *paint); 124 canvas->drawText(text, len, 10, 40, *paint);
125 paint->setShader(shader); 125 paint->setShader(shader);
126 canvas->drawText(text, len, 10, 60, *paint); 126 canvas->drawText(text, len, 10, 60, *paint);
127 } 127 }
128 128
129 class GammaShaderTextGM : public skiagm::GM { 129 class GammaShaderTextGM : public skiagm::GM {
130 SkShader* fShaders[3]; 130 SkShader* fShaders[3];
131 SkColor fColors[3]; 131 SkColor fColors[3];
132 132
133 public: 133 public:
134 GammaShaderTextGM() { 134 GammaShaderTextGM() {
135 const SkColor colors[] = { SK_ColorBLACK, SK_ColorRED, SK_ColorBLUE }; 135 const SkColor colors[] = { SK_ColorBLACK, SK_ColorRED, SK_ColorBLUE };
136 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { 136 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) {
137 fShaders[i] = NULL; 137 fShaders[i] = nullptr;
138 fColors[i] = colors[i]; 138 fColors[i] = colors[i];
139 } 139 }
140 } 140 }
141 141
142 ~GammaShaderTextGM() override { 142 ~GammaShaderTextGM() override {
143 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { 143 for (size_t i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) {
144 SkSafeUnref(fShaders[i]); 144 SkSafeUnref(fShaders[i]);
145 } 145 }
146 } 146 }
147 147
(...skipping 25 matching lines...) Expand all
173 canvas->translate(0, 80); 173 canvas->translate(0, 80);
174 } 174 }
175 } 175 }
176 176
177 private: 177 private:
178 typedef skiagm::GM INHERITED; 178 typedef skiagm::GM INHERITED;
179 }; 179 };
180 180
181 DEF_GM( return new GammaShaderTextGM; ) 181 DEF_GM( return new GammaShaderTextGM; )
182 182
OLDNEW
« no previous file with comments | « gm/fontscalerdistortable.cpp ('k') | gm/giantbitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698