diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-15 17:24:23 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-15 17:24:23 +0000 |
commit | 86eca4774b3cad67a7f5a5ed25c3aa16dfbe4e99 (patch) | |
tree | df42d02f491a1328eae4585c68d233fbfca6658c /gm/srcmode.cpp | |
parent | fe830a46411a4f0fe6e3e81ce1817cefab788730 (diff) |
draw offscreen so we can see the alpha-channel we are writing
todo: know when to use a gpu-surface
git-svn-id: http://skia.googlecode.com/svn/trunk@6436 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/srcmode.cpp')
-rw-r--r-- | gm/srcmode.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp index 5ac102e63e..39f209be57 100644 --- a/gm/srcmode.cpp +++ b/gm/srcmode.cpp @@ -8,6 +8,7 @@ #include "gm.h" #include "SkCanvas.h" #include "SkGradientShader.h" +#include "SkSurface.h" #define W SkIntToScalar(80) #define H SkIntToScalar(60) @@ -56,7 +57,7 @@ class SrcModeGM : public skiagm::GM { SkPath fPath; public: SrcModeGM() { - this->setBGColor(0xFFDDDDDD); + this->setBGColor(SK_ColorBLACK); } protected: @@ -68,7 +69,7 @@ protected: return SkISize::Make(640, 760); } - virtual void onDraw(SkCanvas* canvas) { + void drawContent(SkCanvas* canvas) { canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); SkPaint paint; @@ -107,6 +108,24 @@ protected: } } + static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size) { + SkImage::Info info = { + size.width(), + size.height(), + SkImage::kPMColor_ColorType, + SkImage::kPremul_AlphaType + }; + return SkSurface::NewRaster(info); + } + + virtual void onDraw(SkCanvas* canvas) { + SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize())); + surf->getCanvas()->drawColor(SK_ColorWHITE); + this->drawContent(surf->getCanvas()); + surf->draw(canvas, 0, 0, NULL); + + } + private: typedef skiagm::GM INHERITED; }; |