add radial gradient hard stop test
authorcaryclark <caryclark@google.com>
Thu, 30 Jul 2015 13:41:39 +0000 (06:41 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 30 Jul 2015 13:41:39 +0000 (06:41 -0700)
TBR=reed@google.com
BUG=skia:4140

Review URL: https://codereview.chromium.org/1269723002

gm/gradients.cpp

index 2c7036d3b968189a1fb74157430acbf5dc5e6940..02217c9d6587c8644f51b1c6a94a17cd885e149f 100644 (file)
@@ -460,4 +460,34 @@ private:
 };
 DEF_GM( return new RadialGradient3GM; )
 
+class RadialGradient4GM : public GM {
+    SkAutoTUnref<SkShader> fShader;
+
+protected:
+    SkString onShortName() override { return SkString("radial_gradient4"); }
+
+    SkISize onISize() override { return SkISize::Make(500, 500); }
+
+    void onOnceBeforeDraw() override {
+        const SkPoint center = { 250, 250 };
+        const SkScalar kRadius = 250;
+        const SkColor colors[] = { SK_ColorRED, SK_ColorRED, SK_ColorWHITE, SK_ColorWHITE,
+                SK_ColorRED };
+        const SkScalar pos[] = { 0, .4f, .4f, .8f, .8f, 1 };
+        fShader.reset(SkGradientShader::CreateRadial(center, kRadius, colors, pos, 
+                SK_ARRAY_COUNT(gColors), SkShader::kClamp_TileMode));
+    }
+
+    void onDraw(SkCanvas* canvas) override {
+        SkPaint paint;
+        paint.setAntiAlias(true);
+        paint.setShader(fShader);
+        canvas->drawRect(SkRect::MakeWH(500, 500), paint);
+    }
+    
+private:
+    typedef GM INHERITED;
+};
+DEF_GM( return new RadialGradient4GM; )
+
 }