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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 int fCount; | 43 int fCount; |
44 const SkColor* fColors; | 44 const SkColor* fColors; |
45 const SkScalar* fPos; | 45 const SkScalar* fPos; |
46 }; | 46 }; |
47 | 47 |
48 static const SkColor gColors[] = { | 48 static const SkColor gColors[] = { |
49 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK | 49 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK |
50 }; | 50 }; |
51 | 51 |
52 static const GradData gGradData[] = { | 52 static const GradData gGradData[] = { |
53 { 2, gColors, NULL }, | 53 { 2, gColors, nullptr }, |
54 { 5, gColors, NULL }, | 54 { 5, gColors, nullptr }, |
55 }; | 55 }; |
56 | 56 |
57 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { | 57 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { |
58 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo
unt, tm); | 58 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo
unt, tm); |
59 } | 59 } |
60 | 60 |
61 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { | 61 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader
::TileMode tm) { |
62 SkPoint center; | 62 SkPoint center; |
63 center.set(SkScalarAve(pts[0].fX, pts[1].fX), | 63 center.set(SkScalarAve(pts[0].fX, pts[1].fX), |
64 SkScalarAve(pts[0].fY, pts[1].fY)); | 64 SkScalarAve(pts[0].fY, pts[1].fY)); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 size_t i = 2*s; | 175 size_t i = 2*s; |
176 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 176 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
177 SkIntToScalar((i % testsPerCol) * rowHeight)); | 177 SkIntToScalar((i % testsPerCol) * rowHeight)); |
178 paint.setShader(shaders[s])->unref(); | 178 paint.setShader(shaders[s])->unref(); |
179 canvas->drawText(text, textLen, 0, textBase, paint); | 179 canvas->drawText(text, textLen, 0, textBase, paint); |
180 canvas->restore(); | 180 canvas->restore(); |
181 canvas->save(); | 181 canvas->save(); |
182 ++i; | 182 ++i; |
183 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), | 183 canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth), |
184 SkIntToScalar((i % testsPerCol) * rowHeight)); | 184 SkIntToScalar((i % testsPerCol) * rowHeight)); |
185 canvas->drawTextOnPath(text, textLen, path, NULL, paint); | 185 canvas->drawTextOnPath(text, textLen, path, nullptr, paint); |
186 canvas->restore(); | 186 canvas->restore(); |
187 } | 187 } |
188 canvas->restore(); | 188 canvas->restore(); |
189 } | 189 } |
190 | 190 |
191 private: | 191 private: |
192 typedef SampleView INHERITED; | 192 typedef SampleView INHERITED; |
193 }; | 193 }; |
194 | 194 |
195 /////////////////////////////////////////////////////////////////////////////// | 195 /////////////////////////////////////////////////////////////////////////////// |
196 | 196 |
197 static SkView* MyFactory() { return new ShaderTextView; } | 197 static SkView* MyFactory() { return new ShaderTextView; } |
198 static SkViewRegister reg(MyFactory); | 198 static SkViewRegister reg(MyFactory); |
OLD | NEW |