New radial gradient GM to observe banding and dithering effects.
authortomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 30 Jan 2012 20:00:13 +0000 (20:00 +0000)
committertomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 30 Jan 2012 20:00:13 +0000 (20:00 +0000)
Gray transparent disk in the center, shading to black transparent at edges.

git-svn-id: http://skia.googlecode.com/svn/trunk@3107 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/gradients.cpp

index aac8a96940ae8f2e3ae17342ec55ba22c50a4c50..f2fc082213e5d435efe8e918e59b2e2de2c221bc 100644 (file)
@@ -213,6 +213,41 @@ private:
     typedef GM INHERITED;
 };
 
+/// Checks quality of large radial gradients, which may display
+/// some banding.
+
+class RadialGradientGM : public GM {
+public:
+    RadialGradientGM() {}
+
+protected:
+    SkString onShortName() { return SkString("radial_gradient"); }
+    virtual SkISize onISize() { return make_isize(1280, 1024); }
+    void drawBG(SkCanvas* canvas) {
+        canvas->drawColor(0xFF000000);
+    }
+    virtual void onDraw(SkCanvas* canvas) {
+        this->drawBG(canvas);
+        SkPaint paint;
+        paint.setDither(true);
+        SkPoint center;
+        center.set(SkIntToScalar(640), SkIntToScalar(512));
+        SkScalar radius = SkIntToScalar(640);
+        SkColor colors [3] = { 0x7f7f7f7f, 0x7f7f7f7f, 0xb2000000 };
+        SkScalar pos [3] = { 0.0, 0.35, 1.0 };
+        SkShader* shader =
+            SkGradientShader::CreateRadial(center, radius, colors,
+                                           pos, 3, SkShader::kClamp_TileMode);
+        paint.setShader(shader)->unref();
+        SkRect r = { 0, 0, SkIntToScalar(1280), SkIntToScalar(1024) };
+        canvas->drawRect(r, paint);
+    }
+private:
+    typedef GM INHERITED;
+};
+
+
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -225,5 +260,7 @@ static GMRegistry reg2(MyFactory2);
 static GM* MyFactory3(void*) { return new ClampedGradientsGM; }
 static GMRegistry reg3(MyFactory3);
 
+static GM* MyFactory4(void*) { return new RadialGradientGM; }
+static GMRegistry reg4(MyFactory4);
 }