aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-11-01 13:41:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-01 13:41:34 -0700
commitafac581523af9de5e0af0af1dc128cac1b846006 (patch)
treec4c8965d894e64eae842ad4a6bc0205b3d24c465 /gm
parent08ed0d4926e65f41e6db57dbf72efc871eb4d51e (diff)
Sk4fLinearGradient fuzzer fixes
1) update in_range() to actually follow the documented rules regarding interval open/close endpoints 2) detect cases where the intervals provide negligible advance and fall back to using a color average BUG=skia:5647 R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2472483002 Review-Url: https://codereview.chromium.org/2472483002
Diffstat (limited to 'gm')
-rw-r--r--gm/gradients.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index 45b6564a64..8ae1dd7901 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -919,3 +919,20 @@ DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) {
DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) {
draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag);
}
+
+static void draw_subpixel_gradient(SkCanvas* canvas, uint32_t flags) {
+ const SkPoint pts[] = { {50, 50}, {50.1f, 50.1f}};
+ SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
+ SkPaint p;
+ p.setShader(SkGradientShader::MakeLinear(
+ pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kRepeat_TileMode, flags, nullptr));
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p);
+}
+
+DEF_SIMPLE_GM(gradient_subpixel, canvas, 500, 500) {
+ draw_subpixel_gradient(canvas, 0);
+}
+
+DEF_SIMPLE_GM(gradient_subpixel_4f, canvas, 500, 500) {
+ draw_subpixel_gradient(canvas, SkLinearGradient::kForce4fContext_PrivateFlag);
+}