Add Drawing Manager guards against re-entrant flushes
authorjoshualitt <joshualitt@chromium.org>
Fri, 18 Dec 2015 17:59:46 +0000 (09:59 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 18 Dec 2015 17:59:46 +0000 (09:59 -0800)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1538013002

Review URL: https://codereview.chromium.org/1538013002

src/gpu/GrDrawTarget.cpp
src/gpu/GrDrawTarget.h
src/gpu/GrDrawingManager.cpp
src/gpu/GrDrawingManager.h

index 55f6624..3918ce2 100644 (file)
@@ -39,7 +39,6 @@ GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r
                            const Options& options)
     : fGpu(SkRef(gpu))
     , fResourceProvider(resourceProvider)
-    , fFlushing(false)
     , fFlags(0)
     , fRenderTarget(rt) {
     // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
@@ -183,11 +182,6 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
 }
 
 void GrDrawTarget::prepareBatches(GrBatchFlushState* flushState) {
-    if (fFlushing) {
-        return;
-    }
-    fFlushing = true;
-
     // Semi-usually the drawTargets are already closed at this point, but sometimes Ganesh
     // needs to flush mid-draw. In that case, the SkGpuDevice's drawTargets won't be closed
     // but need to be flushed anyway. Closing such drawTargets here will mean new
@@ -216,8 +210,6 @@ void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
         }
         fBatches[i]->draw(flushState);
     }
-
-    fFlushing = false;
 }
 
 void GrDrawTarget::reset() {
index 42a6e79..7117ad3 100644 (file)
@@ -288,7 +288,6 @@ private:
     GrContext*                                  fContext;
     GrGpu*                                      fGpu;
     GrResourceProvider*                         fResourceProvider;
-    bool                                        fFlushing;
 
     SkDEBUGCODE(int                             fDebugID;)
     uint32_t                                    fFlags;
index 6e84f22..7aa0fdb 100644 (file)
@@ -64,6 +64,11 @@ void GrDrawingManager::reset() {
 }
 
 void GrDrawingManager::flush() {
+    if (fFlushing) {
+        return;
+    }
+    fFlushing = true;
+
     SkDEBUGCODE(bool result =) 
                         SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(&fDrawTargets);
     SkASSERT(result);
@@ -107,6 +112,7 @@ void GrDrawingManager::flush() {
 #endif
 
     fFlushState.reset();
+    fFlushing = false;
 }
 
 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props,
index 672f7b0..c72dad9 100644 (file)
@@ -60,7 +60,8 @@ private:
         , fNVPRTextContext(nullptr)
         , fPathRendererChain(nullptr)
         , fSoftwarePathRenderer(nullptr)
-        , fFlushState(context->getGpu(), context->resourceProvider()) {
+        , fFlushState(context->getGpu(), context->resourceProvider())
+        , fFlushing(false) {
         sk_bzero(fTextContexts, sizeof(fTextContexts));
     }
 
@@ -87,6 +88,7 @@ private:
     GrSoftwarePathRenderer*     fSoftwarePathRenderer;
 
     GrBatchFlushState           fFlushState;
+    bool                        fFlushing;
 };
 
 #endif