Index: gm/srcmode.cpp |
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp |
index 6aa236f3f4321c19fafb15d7d720f3234d46a6ed..a8e02017e1c0d81ddce63f702c55a3c9cbf99b92 100644 |
--- a/gm/srcmode.cpp |
+++ b/gm/srcmode.cpp |
@@ -115,18 +115,21 @@ protected: |
} |
} |
- 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) { |