OLD | NEW |
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 "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 int fCount; | 35 int fCount; |
36 const SkColor* fColors; | 36 const SkColor* fColors; |
37 const SkScalar* fPos; | 37 const SkScalar* fPos; |
38 }; | 38 }; |
39 | 39 |
40 static const SkColor gColors[] = { | 40 static const SkColor gColors[] = { |
41 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK | 41 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK |
42 }; | 42 }; |
43 | 43 |
44 static const GradData gGradData[] = { | 44 static const GradData gGradData[] = { |
45 { 2, gColors, NULL }, | 45 { 2, gColors, nullptr }, |
46 { 5, gColors, NULL }, | 46 { 5, gColors, nullptr }, |
47 }; | 47 }; |
48 | 48 |
49 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { | 49 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { |
50 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo
unt, tm); | 50 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo
unt, tm); |
51 } | 51 } |
52 | 52 |
53 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { | 53 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { |
54 SkPoint center; | 54 SkPoint center; |
55 center.set(SkScalarAve(pts[0].fX, pts[1].fX), | 55 center.set(SkScalarAve(pts[0].fX, pts[1].fX), |
56 SkScalarAve(pts[0].fY, pts[1].fY)); | 56 SkScalarAve(pts[0].fY, pts[1].fY)); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 int i = 2*s; | 167 int i = 2*s; |
168 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 168 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
169 SkIntToScalar((i % testsPerCol) * rowHeight)); | 169 SkIntToScalar((i % testsPerCol) * rowHeight)); |
170 paint.setShader(shaders[s])->unref(); | 170 paint.setShader(shaders[s])->unref(); |
171 canvas->drawText(text, textLen, 0, textBase, paint); | 171 canvas->drawText(text, textLen, 0, textBase, paint); |
172 canvas->restore(); | 172 canvas->restore(); |
173 canvas->save(); | 173 canvas->save(); |
174 ++i; | 174 ++i; |
175 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 175 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
176 SkIntToScalar((i % testsPerCol) * rowHeight)); | 176 SkIntToScalar((i % testsPerCol) * rowHeight)); |
177 canvas->drawTextOnPath(text, textLen, path, NULL, paint); | 177 canvas->drawTextOnPath(text, textLen, path, nullptr, paint); |
178 canvas->restore(); | 178 canvas->restore(); |
179 } | 179 } |
180 canvas->restore(); | 180 canvas->restore(); |
181 | 181 |
182 } | 182 } |
183 | 183 |
184 private: | 184 private: |
185 typedef GM INHERITED; | 185 typedef GM INHERITED; |
186 }; | 186 }; |
187 | 187 |
188 /////////////////////////////////////////////////////////////////////////////// | 188 /////////////////////////////////////////////////////////////////////////////// |
189 | 189 |
190 static GM* MyFactory(void*) { return new ShaderTextGM; } | 190 static GM* MyFactory(void*) { return new ShaderTextGM; } |
191 static GMRegistry reg(MyFactory); | 191 static GMRegistry reg(MyFactory); |
192 } | 192 } |
OLD | NEW |