Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: gm/srcmode.cpp

Issue 355193006: stop calling SkCanvas::getDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: guard gpu code in no-gpu build Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/DeferredSurfaceCopyBench.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « bench/DeferredSurfaceCopyBench.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698