Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index dfbe2fc46ad1ec1028f3f14642c1629f0a42c9bd..401159ccb7825fb7f11048ea5cb81375e49bb297 100644 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -45,7 +45,7 @@ |
#include "SkTLazy.h" |
#include "SkTLS.h" |
#include "SkTraceEvent.h" |
- |
+#include "SkTTopoSort.h" |
#include "batches/GrBatch.h" |
@@ -95,9 +95,45 @@ void GrDrawingManager::reset() { |
} |
void GrDrawingManager::flush() { |
+ |
+ struct TopoSortTraits { |
+ static void Output(GrDrawTarget* dt, int /* index */) { |
+ dt->setFlag(GrDrawTarget::kWasOutput_Flag); |
+ } |
+ static bool WasOutput(const GrDrawTarget* dt) { |
+ return dt->isSetFlag(GrDrawTarget::kWasOutput_Flag); |
+ } |
+ static void SetTempMark(GrDrawTarget* dt) { |
+ dt->setFlag(GrDrawTarget::kTempMark_Flag); |
+ } |
+ static void ResetTempMark(GrDrawTarget* dt) { |
+ dt->resetFlag(GrDrawTarget::kTempMark_Flag); |
+ } |
+ static bool IsTempMarked(const GrDrawTarget* dt) { |
+ return dt->isSetFlag(GrDrawTarget::kTempMark_Flag); |
+ } |
+ static int NumDependencies(const GrDrawTarget* dt) { |
+ return dt->numDependencies(); |
+ } |
+ static GrDrawTarget* Dependency(GrDrawTarget* dt, int index) { |
+ return dt->dependency(index); |
+ } |
+ }; |
+ |
+ SkDEBUGCODE(bool result =) SkTTopoSort<GrDrawTarget, TopoSortTraits>(&fDrawTargets); |
+ SkASSERT(result); |
+ |
for (int i = 0; i < fDrawTargets.count(); ++i) { |
fDrawTargets[i]->flush(); |
} |
+ |
+#ifndef ENABLE_MDB |
+ // When MDB is disabled we keep reusing the same drawTarget |
+ if (fDrawTargets.count()) { |
+ SkASSERT(fDrawTargets.count() == 1); |
+ fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
+ } |
+#endif |
} |
GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, |
@@ -131,8 +167,8 @@ GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, |
GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
SkASSERT(fContext); |
- // When MDB is disabled we always just return the single drawTarget |
#ifndef ENABLE_MDB |
+ // When MDB is disabled we always just return the single drawTarget |
if (fDrawTargets.count()) { |
SkASSERT(fDrawTargets.count() == 1); |
// DrawingManager gets the creation ref - this ref is for the caller |