Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: gm/composeshader.cpp

Issue 262193004: new gm for composeshader, exercising alpha (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/composeshader.cpp
diff --git a/gm/composeshader.cpp b/gm/composeshader.cpp
index b40e2263d60e23650e2d1fb3aa35967adb820534..b5607d511b9bcf92704ef1eb212a0f87990b2ead 100644
--- a/gm/composeshader.cpp
+++ b/gm/composeshader.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2012 Google Inc.
*
@@ -16,11 +15,9 @@
#include "SkString.h"
#include "SkXfermode.h"
-namespace skiagm {
-
-class ShaderGM : public GM {
+class ComposeShaderGM : public skiagm::GM {
public:
- ShaderGM() {
+ ComposeShaderGM() {
SkPoint pts[2];
SkColor colors[2];
@@ -46,7 +43,7 @@ public:
mode->unref();
}
- virtual ~ShaderGM() {
+ virtual ~ComposeShaderGM() {
SkSafeUnref(fShader);
}
@@ -60,7 +57,7 @@ protected:
}
virtual SkISize onISize() SK_OVERRIDE {
- return make_isize(120, 120);
+ return SkISize::Make(120, 120);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
@@ -73,14 +70,47 @@ protected:
canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), paint);
}
-private:
+protected:
SkShader* fShader;
+
+private:
typedef GM INHERITED ;
};
+class ComposeShaderAlphaGM : public ComposeShaderGM {
+public:
+ ComposeShaderAlphaGM() {}
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("composeshader_alpha");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(120, 1024);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ paint.setColor(SK_ColorGREEN);
+
+ const SkRect r = SkRect::MakeXYWH(5, 5, 100, 100);
+ for (int alpha = 0xFF; alpha > 0; alpha -= 0x20) {
+ paint.setAlpha(0xFF);
+ paint.setShader(NULL);
+ canvas->drawRect(r, paint);
+
+ paint.setAlpha(alpha);
+ paint.setShader(fShader);
+ canvas->drawRect(r, paint);
+
+ canvas->translate(r.width() + 5, 0);
+ }
+ }
+};
+
//////////////////////////////////////////////////////////////////////////////
-static GM* MyFactory(void*) { return new ShaderGM; }
-static GMRegistry reg(MyFactory);
+DEF_GM( return new ComposeShaderGM; )
+DEF_GM( return new ComposeShaderAlphaGM; )
-} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698