OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 | 8 |
9 #include "gm.h" | 9 #include "gm.h" |
10 #include "SkTArray.h" | 10 #include "SkTArray.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 fPaints[i].setColor(color); | 239 fPaints[i].setColor(color); |
240 | 240 |
241 canvas->drawOval(oval, fPaints[i]); | 241 canvas->drawOval(oval, fPaints[i]); |
242 canvas->restore(); | 242 canvas->restore(); |
243 } | 243 } |
244 | 244 |
245 // radial gradient | 245 // radial gradient |
246 SkPoint center = SkPoint::Make(SkIntToScalar(0), SkIntToScalar(0)); | 246 SkPoint center = SkPoint::Make(SkIntToScalar(0), SkIntToScalar(0)); |
247 SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN }; | 247 SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN }; |
248 SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 }; | 248 SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 }; |
249 auto shader = SkGradientShader::MakeRadial(center, 20, colors, pos, SK_A
RRAY_COUNT(colors), | 249 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, |
250 SkShader::kClamp_TileMode); | 250 SkIntToScalar(20), |
| 251 colors, |
| 252 pos, |
| 253 SK_ARRAY_COUNT(colors), |
| 254 SkShader::kClamp_TileMode))
; |
251 | 255 |
252 for (int i = 0; i < fPaints.count(); ++i) { | 256 for (int i = 0; i < fPaints.count(); ++i) { |
253 canvas->save(); | 257 canvas->save(); |
254 // position the path, and make it at off-integer coords. | 258 // position the path, and make it at off-integer coords. |
255 canvas->translate(kXStart + SK_Scalar1 * kXStep * 0 + SK_Scalar1 / 4
, | 259 canvas->translate(kXStart + SK_Scalar1 * kXStep * 0 + SK_Scalar1 / 4
, |
256 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1
/ 4 + | 260 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1
/ 4 + |
257 SK_ScalarHalf * kYStep); | 261 SK_ScalarHalf * kYStep); |
258 | 262 |
259 SkColor color = genColor(&rand); | 263 SkColor color = genColor(&rand); |
260 fPaints[i].setColor(color); | 264 fPaints[i].setColor(color); |
(...skipping 14 matching lines...) Expand all Loading... |
275 | 279 |
276 typedef GM INHERITED; | 280 typedef GM INHERITED; |
277 }; | 281 }; |
278 | 282 |
279 ////////////////////////////////////////////////////////////////////////////// | 283 ////////////////////////////////////////////////////////////////////////////// |
280 | 284 |
281 static GM* MyFactory(void*) { return new OvalGM; } | 285 static GM* MyFactory(void*) { return new OvalGM; } |
282 static GMRegistry reg(MyFactory); | 286 static GMRegistry reg(MyFactory); |
283 | 287 |
284 } | 288 } |
OLD | NEW |