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

Unified Diff: src/gpu/GrContext.cpp

Issue 1414773002: Add the machinery to GrDrawTarget to enable topological sorting (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up Created 5 years, 2 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 | « no previous file | src/gpu/GrDrawTarget.h » ('j') | src/gpu/GrDrawTarget.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | src/gpu/GrDrawTarget.h » ('j') | src/gpu/GrDrawTarget.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698