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 "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 | 10 |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 SkPaint paint; | 453 SkPaint paint; |
454 paint.setShader(fShader); | 454 paint.setShader(fShader); |
455 canvas->drawRect(SkRect::MakeWH(500, 500), paint); | 455 canvas->drawRect(SkRect::MakeWH(500, 500), paint); |
456 } | 456 } |
457 | 457 |
458 private: | 458 private: |
459 typedef GM INHERITED; | 459 typedef GM INHERITED; |
460 }; | 460 }; |
461 DEF_GM( return new RadialGradient3GM; ) | 461 DEF_GM( return new RadialGradient3GM; ) |
462 | 462 |
| 463 class RadialGradient4GM : public GM { |
| 464 SkAutoTUnref<SkShader> fShader; |
| 465 |
| 466 protected: |
| 467 SkString onShortName() override { return SkString("radial_gradient4"); } |
| 468 |
| 469 SkISize onISize() override { return SkISize::Make(500, 500); } |
| 470 |
| 471 void onOnceBeforeDraw() override { |
| 472 const SkPoint center = { 250, 250 }; |
| 473 const SkScalar kRadius = 250; |
| 474 const SkColor colors[] = { SK_ColorRED, SK_ColorRED, SK_ColorWHITE, SK_C
olorWHITE, |
| 475 SK_ColorRED }; |
| 476 const SkScalar pos[] = { 0, .4f, .4f, .8f, .8f, 1 }; |
| 477 fShader.reset(SkGradientShader::CreateRadial(center, kRadius, colors, po
s, |
| 478 SK_ARRAY_COUNT(gColors), SkShader::kClamp_TileMode)); |
| 479 } |
| 480 |
| 481 void onDraw(SkCanvas* canvas) override { |
| 482 SkPaint paint; |
| 483 paint.setAntiAlias(true); |
| 484 paint.setShader(fShader); |
| 485 canvas->drawRect(SkRect::MakeWH(500, 500), paint); |
| 486 } |
| 487 |
| 488 private: |
| 489 typedef GM INHERITED; |
| 490 }; |
| 491 DEF_GM( return new RadialGradient4GM; ) |
| 492 |
463 } | 493 } |
OLD | NEW |