diff options
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; }; |