stop calling SkCanvas::getDevice

BUG=skia:
R=bsalomon@google.com, robertphillips@google.com, junov@google.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/355193006
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp
index 6aa236f..a8e0201 100644
--- a/gm/srcmode.cpp
+++ b/gm/srcmode.cpp
@@ -115,18 +115,21 @@
         }
     }
 
-    static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size,
-                                     bool skipGPU) {
+    static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size, bool skipGPU) {
         SkImageInfo info = SkImageInfo::MakeN32Premul(size);
+
+        bool callNewSurface = true;
 #if SK_SUPPORT_GPU
-        SkBaseDevice* dev = canvas->getDevice();
-        if (!skipGPU && dev->accessRenderTarget()) {
-            SkGpuDevice* gd = (SkGpuDevice*)dev;
-            GrContext* ctx = gd->context();
-            return SkSurface::NewRenderTarget(ctx, info, 0);
+        if (canvas->getGrContext() && skipGPU) {
+            callNewSurface = false;
         }
 #endif
-        return SkSurface::NewRaster(info);
+        SkSurface* surface = callNewSurface ? canvas->newSurface(info) : NULL;
+        if (NULL == surface) {
+            // picture canvas will return null, so fall-back to raster
+            surface = SkSurface::NewRaster(info);
+        }
+        return surface;
     }
 
     virtual void onDraw(SkCanvas* canvas) {