new gm for composeshader, exercising alpha

BUG=skia:
R=scroggo@google.com

Author: reed@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@14567 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-05-05 16:19:08 +00:00
parent 4e332f82fc
commit ec7d673999

View File

@ -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