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
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp
index 5ac102e..39f209b 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 @@
     SkPath fPath;
 public:
     SrcModeGM() {
-        this->setBGColor(0xFFDDDDDD);
+        this->setBGColor(SK_ColorBLACK);
     }
 
 protected:
@@ -68,7 +69,7 @@
         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 @@
         }
     }
 
+    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;
 };