aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-30 20:00:13 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-30 20:00:13 +0000
commitb18e58c065cad6eb273ee23ef4d68a03791ef3af (patch)
tree8c6da34e243c975fcd2040182373ad849348473a
parent78d6cf9f434d3351b19de14f1eab424c23f0ab6d (diff)
New radial gradient GM to observe banding and dithering effects.
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
-rw-r--r--gm/gradients.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index aac8a96940..f2fc082213 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -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);
}