aboutsummaryrefslogtreecommitdiffstats
path: root/gm/gradients.cpp
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2012-03-06 09:06:43 -0500
committerDerek Sollenberger <derek@android.com>2012-03-06 09:44:47 -0500
commit4f1dae40e24d57d647db01443b8bf2410514b8b5 (patch)
tree594df3f3fc6c1d90a76691a75763ae1beacfdf98 /gm/gradients.cpp
parent1cab2921ab279367f8206cdadc9259d12e603548 (diff)
downloadexternal_skia-4f1dae40e24d57d647db01443b8bf2410514b8b5.zip
external_skia-4f1dae40e24d57d647db01443b8bf2410514b8b5.tar.gz
external_skia-4f1dae40e24d57d647db01443b8bf2410514b8b5.tar.bz2
Skia Merge (revision 3312)
This CL also includes changes made to Android's copy of Skia in their J release branch. Change-Id: Ib2baecf48004951a3ad4a1574cdc38790c814cbc
Diffstat (limited to 'gm/gradients.cpp')
-rw-r--r--gm/gradients.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index aac8a96..3eb5633 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -213,6 +213,48 @@ 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, 1280); }
+ void drawBG(SkCanvas* canvas) {
+ canvas->drawColor(0xFF000000);
+ }
+ virtual void onDraw(SkCanvas* canvas) {
+ const SkISize dim = this->getISize();
+
+ this->drawBG(canvas);
+
+ SkPaint paint;
+ paint.setDither(true);
+ SkPoint center;
+ center.set(SkIntToScalar(dim.width())/2, SkIntToScalar(dim.height())/2);
+ SkScalar radius = SkIntToScalar(dim.width())/2;
+ const SkColor colors[] = { 0x7f7f7f7f, 0x7f7f7f7f, 0xb2000000 };
+ const SkScalar pos[] = { SkFloatToScalar(0.0),
+ SkFloatToScalar(0.35),
+ SkFloatToScalar(1.0) };
+ SkShader* shader =
+ SkGradientShader::CreateRadial(center, radius, colors,
+ pos, SK_ARRAY_COUNT(pos),
+ SkShader::kClamp_TileMode);
+ paint.setShader(shader)->unref();
+ SkRect r = {
+ 0, 0, SkIntToScalar(dim.width()), SkIntToScalar(dim.height())
+ };
+ canvas->drawRect(r, paint);
+ }
+private:
+ typedef GM INHERITED;
+};
+
+
///////////////////////////////////////////////////////////////////////////////
@@ -225,5 +267,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);
}