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 #include "SkLinearGradient.h" | 10 #include "SkLinearGradient.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 fShader = SkGradientShader::MakeRadial(center, kRadius, gColors, nullptr
, 2, | 503 fShader = SkGradientShader::MakeRadial(center, kRadius, gColors, nullptr
, 2, |
504 SkShader::kClamp_TileMode); | 504 SkShader::kClamp_TileMode); |
505 } | 505 } |
506 | 506 |
507 void onDraw(SkCanvas* canvas) override { | 507 void onDraw(SkCanvas* canvas) override { |
508 SkPaint paint; | 508 SkPaint paint; |
509 paint.setShader(fShader); | 509 paint.setShader(fShader); |
510 paint.setDither(fDither); | 510 paint.setDither(fDither); |
511 canvas->drawRect(SkRect::MakeWH(500, 500), paint); | 511 canvas->drawRect(SkRect::MakeWH(500, 500), paint); |
512 } | 512 } |
513 | 513 |
514 private: | 514 private: |
515 sk_sp<SkShader> fShader; | 515 sk_sp<SkShader> fShader; |
516 bool fDither; | 516 bool fDither; |
517 | 517 |
518 typedef GM INHERITED; | 518 typedef GM INHERITED; |
519 }; | 519 }; |
520 DEF_GM( return new RadialGradient3GM(true); ) | 520 DEF_GM( return new RadialGradient3GM(true); ) |
521 DEF_GM( return new RadialGradient3GM(false); ) | 521 DEF_GM( return new RadialGradient3GM(false); ) |
522 | 522 |
523 class RadialGradient4GM : public GM { | 523 class RadialGradient4GM : public GM { |
(...skipping 17 matching lines...) Expand all Loading... |
541 SK_ARRAY_COUNT(gColors), SkShader
::kClamp_TileMode); | 541 SK_ARRAY_COUNT(gColors), SkShader
::kClamp_TileMode); |
542 } | 542 } |
543 | 543 |
544 void onDraw(SkCanvas* canvas) override { | 544 void onDraw(SkCanvas* canvas) override { |
545 SkPaint paint; | 545 SkPaint paint; |
546 paint.setAntiAlias(true); | 546 paint.setAntiAlias(true); |
547 paint.setDither(fDither); | 547 paint.setDither(fDither); |
548 paint.setShader(fShader); | 548 paint.setShader(fShader); |
549 canvas->drawRect(SkRect::MakeWH(500, 500), paint); | 549 canvas->drawRect(SkRect::MakeWH(500, 500), paint); |
550 } | 550 } |
551 | 551 |
552 private: | 552 private: |
553 sk_sp<SkShader> fShader; | 553 sk_sp<SkShader> fShader; |
554 bool fDither; | 554 bool fDither; |
555 | 555 |
556 typedef GM INHERITED; | 556 typedef GM INHERITED; |
557 }; | 557 }; |
558 DEF_GM( return new RadialGradient4GM(true); ) | 558 DEF_GM( return new RadialGradient4GM(true); ) |
559 DEF_GM( return new RadialGradient4GM(false); ) | 559 DEF_GM( return new RadialGradient4GM(false); ) |
560 | 560 |
561 class LinearGradientGM : public GM { | 561 class LinearGradientGM : public GM { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 void onDraw(SkCanvas* canvas) override { | 593 void onDraw(SkCanvas* canvas) override { |
594 SkPaint paint; | 594 SkPaint paint; |
595 paint.setAntiAlias(true); | 595 paint.setAntiAlias(true); |
596 paint.setDither(fDither); | 596 paint.setDither(fDither); |
597 for (int index = 0; index < (int) SK_ARRAY_COUNT(fShader); ++index) { | 597 for (int index = 0; index < (int) SK_ARRAY_COUNT(fShader); ++index) { |
598 paint.setShader(fShader[index]); | 598 paint.setShader(fShader[index]); |
599 canvas->drawRect(SkRect::MakeLTRB(0, index * kHeight, kMinWidth + in
dex * kWidthBump, | 599 canvas->drawRect(SkRect::MakeLTRB(0, index * kHeight, kMinWidth + in
dex * kWidthBump, |
600 (index + 1) * kHeight), paint); | 600 (index + 1) * kHeight), paint); |
601 } | 601 } |
602 } | 602 } |
603 | 603 |
604 private: | 604 private: |
605 sk_sp<SkShader> fShader[100]; | 605 sk_sp<SkShader> fShader[100]; |
606 bool fDither; | 606 bool fDither; |
607 | 607 |
608 typedef GM INHERITED; | 608 typedef GM INHERITED; |
609 }; | 609 }; |
610 DEF_GM( return new LinearGradientGM(true); ) | 610 DEF_GM( return new LinearGradientGM(true); ) |
611 DEF_GM( return new LinearGradientGM(false); ) | 611 DEF_GM( return new LinearGradientGM(false); ) |
612 | 612 |
613 class LinearGradientTinyGM : public GM { | 613 class LinearGradientTinyGM : public GM { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); | 786 canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); |
787 } | 787 } |
788 | 788 |
789 DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) { | 789 DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) { |
790 draw_many_stops(canvas, 0); | 790 draw_many_stops(canvas, 0); |
791 } | 791 } |
792 | 792 |
793 DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) { | 793 DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) { |
794 draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag); | 794 draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag); |
795 } | 795 } |
OLD | NEW |