Index: src/gpu/GrDrawingManager.cpp |
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp |
index 74459daa48b0514fe51d599bedd960cf7c7a2bc2..73b7d1695eb4055f80ee7c49fc5b653dbdc39af9 100644 |
--- a/src/gpu/GrDrawingManager.cpp |
+++ b/src/gpu/GrDrawingManager.cpp |
@@ -14,10 +14,12 @@ |
#include "GrStencilAndCoverTextContext.h" |
#include "SkTTopoSort.h" |
-//#define ENABLE_MDB 1 |
void GrDrawingManager::cleanup() { |
for (int i = 0; i < fDrawTargets.count(); ++i) { |
+ fDrawTargets[i]->makeClosed(); // no drawTarget should receive a new command after this |
+ fDrawTargets[i]->clearRT(); |
+ |
fDrawTargets[i]->unref(); |
} |
@@ -85,17 +87,25 @@ void GrDrawingManager::flush() { |
SkASSERT(fFlushState.lastFlushedToken() == fFlushState.currentToken()); |
+ for (int i = 0; i < fDrawTargets.count(); ++i) { |
+ fDrawTargets[i]->reset(); |
+#ifdef ENABLE_MDB |
+ fDrawTargets[i]->unref(); |
+#endif |
+ } |
+ |
#ifndef ENABLE_MDB |
// When MDB is disabled we keep reusing the same drawTarget |
if (fDrawTargets.count()) { |
SkASSERT(fDrawTargets.count() == 1); |
+ // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnmarked check |
+ // won't bark |
fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
} |
+#else |
+ fDrawTargets.reset(); |
#endif |
- for (int i = 0; i < fDrawTargets.count(); ++i) { |
- fDrawTargets[i]->reset(); |
- } |
fFlushState.reset(); |
} |
@@ -134,6 +144,9 @@ GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
// When MDB is disabled we always just return the single drawTarget |
if (fDrawTargets.count()) { |
SkASSERT(fDrawTargets.count() == 1); |
+ // In the non-MDB-world the same drawTarget gets reused for multiple render targets. |
+ // Update this pointer so all the asserts are happy |
+ rt->setLastDrawTarget(fDrawTargets[0]); |
// DrawingManager gets the creation ref - this ref is for the caller |
return SkRef(fDrawTargets[0]); |
} |