diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-16 13:41:45 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-16 13:41:45 +0000 |
commit | aef73617d1bcede80145a13639668f958a3863d8 (patch) | |
tree | 0cbb50e44983b8b7d6011ff4813dda46903510a4 /gm | |
parent | 13201e74f43b9c5fa173339eb36de515370e6973 (diff) |
flag the GM if we're in deferred-canvas mode, to work-around bug trying to
get the context from its device.
git-svn-id: http://skia.googlecode.com/svn/trunk@6452 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r-- | gm/gm.cpp | 1 | ||||
-rw-r--r-- | gm/gm.h | 6 | ||||
-rw-r--r-- | gm/gmmain.cpp | 17 | ||||
-rw-r--r-- | gm/srcmode.cpp | 8 |
4 files changed, 21 insertions, 11 deletions
@@ -12,6 +12,7 @@ SkString GM::gResourcePath; GM::GM() { fBGColor = SK_ColorWHITE; + fCanvasIsDeferred = false; } GM::~GM() {} @@ -71,6 +71,11 @@ namespace skiagm { gResourcePath = resourcePath; } + bool isCanvasDeferred() const { return fCanvasIsDeferred; } + void setCanvasIsDeferred(bool isDeferred) { + fCanvasIsDeferred = isDeferred; + } + protected: static SkString gResourcePath; @@ -84,6 +89,7 @@ namespace skiagm { private: SkString fShortName; SkColor fBGColor; + bool fCanvasIsDeferred; // work-around problem in srcmode.cpp }; typedef SkTRegistry<GM*, void*> GMRegistry; diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 39b8b17c8a..d4d2154835 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -379,13 +379,14 @@ public: } } - static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF = false) { + static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF, bool isDeferred) { SkAutoCanvasRestore acr(canvas, true); if (!isPDF) { canvas->concat(gm->getInitialTransform()); } installFilter(canvas); + gm->setCanvasIsDeferred(isDeferred); gm->draw(canvas); canvas->setDrawFilter(NULL); } @@ -407,7 +408,7 @@ public: } else { canvas.reset(new SkCanvas(device)); } - invokeGM(gm, canvas); + invokeGM(gm, canvas, false, deferred); canvas->flush(); } #if SK_SUPPORT_GPU @@ -421,7 +422,7 @@ public: } else { canvas.reset(new SkCanvas(device)); } - invokeGM(gm, canvas); + invokeGM(gm, canvas, false, deferred); // the device is as large as the current rendertarget, so // we explicitly only readback the amount we expect (in // size) overwrite our previous allocation @@ -463,7 +464,7 @@ public: SkAutoUnref aur(dev); SkCanvas c(dev); - invokeGM(gm, &c, true); + invokeGM(gm, &c, true, false); SkPDFDocument doc; doc.appendPage(dev); @@ -489,7 +490,7 @@ public: SkCanvas c(dev); dev->beginPortfolio(&xps); dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); - invokeGM(gm, &c); + invokeGM(gm, &c, false, false); dev->endSheet(); dev->endPortfolio(); @@ -621,7 +622,7 @@ public: SkPicture* pict = new SkPicture; SkISize size = gm->getISize(); SkCanvas* cv = pict->beginRecording(size.width(), size.height()); - invokeGM(gm, cv); + invokeGM(gm, cv, false, false); pict->endRecording(); return pict; @@ -722,7 +723,7 @@ public: SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording( &pipeController, gPipeWritingFlagCombos[i].flags); - invokeGM(gm, pipeCanvas); + invokeGM(gm, pipeCanvas, false, false); writer.endRecording(); SkString string("-pipe"); string.append(gPipeWritingFlagCombos[i].name); @@ -749,7 +750,7 @@ public: SkGPipeWriter writer; SkCanvas* pipeCanvas = writer.startRecording( &pipeController, gPipeWritingFlagCombos[i].flags); - invokeGM(gm, pipeCanvas); + invokeGM(gm, pipeCanvas, false, false); writer.endRecording(); SkString string("-tiled pipe"); string.append(gPipeWritingFlagCombos[i].name); diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp index 6eba098f42..c99a6b2f9d 100644 --- a/gm/srcmode.cpp +++ b/gm/srcmode.cpp @@ -115,7 +115,8 @@ protected: } } - static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size) { + static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size, + bool skipGPU) { SkImage::Info info = { size.width(), size.height(), @@ -124,7 +125,7 @@ protected: }; #if SK_SUPPORT_GPU SkDevice* dev = canvas->getDevice(); - if (dev->accessRenderTarget()) { + if (!skipGPU && dev->accessRenderTarget()) { SkGpuDevice* gd = (SkGpuDevice*)dev; GrContext* ctx = gd->context(); return SkSurface::NewRenderTarget(ctx, info, 0); @@ -134,7 +135,8 @@ protected: } virtual void onDraw(SkCanvas* canvas) { - SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize())); + SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(), + this->isCanvasDeferred())); surf->getCanvas()->drawColor(SK_ColorWHITE); this->drawContent(surf->getCanvas()); surf->draw(canvas, 0, 0, NULL); |