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

Unified Diff: gm/gradients.cpp

Issue 1734343004: add gm to illustrate bug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months 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 | no next file » | 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 5fb3465913bf345326473a8baf89364f7b5cc72b..eeb5bcb9ff86ccba7e8116b6e501667b12bff702 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -304,6 +304,42 @@ private:
DEF_GM( return new GradientsDegenrate2PointGM(true); )
DEF_GM( return new GradientsDegenrate2PointGM(false); )
+/* bug.skia.org/517
+<canvas id="canvas"></canvas>
+<script>
+var c = document.getElementById("canvas");
+var ctx = c.getContext("2d");
+ctx.fillStyle = '#ff0';
+ctx.fillRect(0, 0, 100, 50);
+
+var g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10);
+g.addColorStop(0, '#0f0');
+g.addColorStop(0.003, '#f00'); // 0.004 makes this work
+g.addColorStop(1, '#ff0');
+ctx.fillStyle = g;
+ctx.fillRect(0, 0, 100, 50);
+</script>
+*/
+
+// should draw only green
+DEF_SIMPLE_GM(small_color_stop, canvas, 100, 150) {
+ SkColor colors[] = { SK_ColorGREEN, SK_ColorRED, SK_ColorYELLOW };
+ SkScalar pos[] = { 0, 0.003f, SK_Scalar1 }; // 0.004f makes this work
+ SkPoint c0 = { 200, 25 };
+ SkScalar r0 = 20;
+ SkPoint c1 = { 200, 25 };
+ SkScalar r1 = 10;
+ SkShader* s = SkGradientShader::CreateTwoPointConical(c0, r0, c1, r1, colors,
+ pos, SK_ARRAY_COUNT(pos),
+ SkShader::kClamp_TileMode);
+ SkPaint paint;
+ paint.setColor(SK_ColorYELLOW);
+ canvas->drawRect(SkRect::MakeWH(100, 150), paint);
+ paint.setShader(s)->unref();
+ canvas->drawRect(SkRect::MakeWH(100, 150), paint);
+}
+
+
/// Tests correctness of *optimized* codepaths in gradients.
class ClampedGradientsGM : public GM {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698