Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1655)

Unified Diff: gm/gradients.cpp

Issue 2472483002: Sk4fLinearGradient fuzzer fixes (Closed)
Patch Set: GM Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/effects/gradients/Sk4fLinearGradient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gradients.cpp
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index 45b6564a64e0ff71ba55af08acfbf047d70a32fe..8ae1dd7901e45cd6044ca2968b7b8cb8cba324c9 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);
+}
« no previous file with comments | « no previous file | src/effects/gradients/Sk4fLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698