diff options
author | 2016-02-26 05:59:40 -0800 | |
---|---|---|
committer | 2016-02-26 05:59:40 -0800 | |
commit | cb10071171b1db9313bf47b25f0c8567c154f590 (patch) | |
tree | 5022ddb26418905aaa42026953d8c033358af812 /gm/gradients.cpp | |
parent | 952538ed50661ad7dff6ec2b7af3f921e1d91b52 (diff) |
add gm to illustrate bug
TBR=reed@google.com
BUG=skia:517
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1734343004
Review URL: https://codereview.chromium.org/1734343004
Diffstat (limited to 'gm/gradients.cpp')
-rw-r--r-- | gm/gradients.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gm/gradients.cpp b/gm/gradients.cpp index 5fb3465913..eeb5bcb9ff 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 { |