diff --git a/include/private/GrOpList.h b/include/private/GrOpList.h index 26d33659880ed..c5a84d7c3b2ac 100644 --- a/include/private/GrOpList.h +++ b/include/private/GrOpList.h @@ -117,6 +117,9 @@ class GrOpList : public SkRefCnt { friend class GrDrawingManager; // for resetFlag, TopoSortTraits & gatherProxyIntervals void addDependency(GrOpList* dependedOn); + void addDependent(GrOpList* dependent); + SkDEBUGCODE(bool isDependedent(const GrOpList* dependent) const); + SkDEBUGCODE(void validate() const); // Remove all Ops which reference proxies that have not been instantiated. virtual void purgeOpsWithUninstantiatedProxies() = 0; @@ -177,6 +180,8 @@ class GrOpList : public SkRefCnt { // 'this' GrOpList relies on the output of the GrOpLists in 'fDependencies' SkSTArray<1, GrOpList*, true> fDependencies; + // 'this' GrOpList's output is relied on by the GrOpLists in 'fDependents' + SkSTArray<1, GrOpList*, true> fDependents; typedef SkRefCnt INHERITED; }; diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp index 9f2ee4a4f24d7..9eac0911bd4cf 100644 --- a/src/gpu/GrOpList.cpp +++ b/src/gpu/GrOpList.cpp @@ -97,6 +97,9 @@ void GrOpList::addDependency(GrOpList* dependedOn) { } fDependencies.push_back(dependedOn); + dependedOn->addDependent(this); + + SkDEBUGCODE(this->validate()); } // Convert from a GrSurface-based dependency to a GrOpList one @@ -135,6 +138,31 @@ bool GrOpList::dependsOn(const GrOpList* dependedOn) const { return false; } + +void GrOpList::addDependent(GrOpList* dependent) { + fDependents.push_back(dependent); +} + +#ifdef SK_DEBUG +bool GrOpList::isDependedent(const GrOpList* dependent) const { + for (int i = 0; i < fDependents.count(); ++i) { + if (fDependents[i] == dependent) { + return true; + } + } + + return false; +} + +void GrOpList::validate() const { + // TODO: check for loops and duplicates + + for (int i = 0; i < fDependencies.count(); ++i) { + SkASSERT(fDependencies[i]->isDependedent(this)); + } +} +#endif + bool GrOpList::isInstantiated() const { return fTarget.get()->isInstantiated(); } bool GrOpList::isFullyInstantiated() const { @@ -181,6 +209,12 @@ void GrOpList::dump(bool printDependencies) const { SkDebugf("%d, ", fDependencies[i]->fUniqueID); } SkDebugf("\n"); + + SkDebugf("(%d) Rely On Me: ", fDependents.count()); + for (int i = 0; i < fDependents.count(); ++i) { + SkDebugf("%d, ", fDependents[i]->fUniqueID); + } + SkDebugf("\n"); } } #endif