aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gradients.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-08-03 12:55:41 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-04 15:24:43 +0000
commit36f054ace3d8726cb4f9f46f38340bcffc830336 (patch)
tree32a3fcaa6a149aa0e6af3aed5cf23824790f7c20 /gm/gradients.cpp
parent121ad19a7ecefa6fc814cfc24d2625df2178b61c (diff)
GrGradientEffect::onIsEqual() must also consider tiling
Without this fix, the newly added GM draws incorrectly. Change-Id: Ic159ab3201c10369ad5f8151186245d8d076cc25 Reviewed-on: https://skia-review.googlesource.com/30484 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'gm/gradients.cpp')
-rw-r--r--gm/gradients.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index 00dbb8f42f..2a1f9031bb 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -1072,3 +1072,49 @@ DEF_SIMPLE_GM(sweep_tiling, canvas, 690, 512) {
canvas->translate(0, size * 1.1f);
}
}
+
+// Exercises the special-case Ganesh gradient effects.
+DEF_SIMPLE_GM(gradients_interesting, canvas, 640, 1080) {
+ static const SkColor colors2[] = { SK_ColorRED, SK_ColorBLUE };
+ static const SkColor colors3[] = { SK_ColorRED, SK_ColorYELLOW, SK_ColorBLUE };
+ static const SkColor colors4[] = { SK_ColorRED, SK_ColorYELLOW, SK_ColorYELLOW, SK_ColorBLUE };
+
+ static const SkScalar hardLeft[] = { 0, 0, 1 };
+ static const SkScalar hardRight[] = { 0, 1, 1 };
+ static const SkScalar hardCenter[] = { 0, .5f, .5f, 1 };
+
+ static const struct {
+ const SkColor* colors;
+ const SkScalar* pos;
+ int count;
+ } configs[] = {
+ { colors2, nullptr, 2 }, // kTwo_ColorType
+ { colors3, nullptr, 3 }, // kThree_ColorType
+ { colors3, hardLeft, 3 }, // kHardStopLeftEdged_ColorType
+ { colors3, hardRight, 3 }, // kHardStopRightEdged_ColorType
+ { colors4, hardCenter, 4 }, // kSingleHardStop_ColorType
+ };
+
+ static const SkShader::TileMode modes[] = {
+ SkShader::kClamp_TileMode,
+ SkShader::kRepeat_TileMode,
+ SkShader::kMirror_TileMode,
+ };
+
+ static constexpr SkScalar size = 200;
+ static const SkPoint pts[] = { { size / 3, size / 3 }, { size * 2 / 3, size * 2 / 3} };
+
+ SkPaint p;
+ for (const auto& cfg : configs) {
+ {
+ SkAutoCanvasRestore acr(canvas, true);
+ for (auto mode : modes) {
+ p.setShader(SkGradientShader::MakeLinear(pts, cfg.colors, cfg.pos, cfg.count,
+ mode));
+ canvas->drawRect(SkRect::MakeWH(size, size), p);
+ canvas->translate(size * 1.1f, 0);
+ }
+ }
+ canvas->translate(0, size * 1.1f);
+ }
+}