Add list of dependents to GrOpList class

This is pulled out of: https://skia-review.googlesource.com/c/skia/+/143113 (Reduce arbitrary opList splitting when sorting (take 3)) and is necessary for incremental tological sorting of opLists.

Change-Id: I080cee2c54f5a61dceea67037242f6c6b3e01b8d
Reviewed-on: https://skia-review.googlesource.com/145641
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2018-08-06 16:56:26 -04:00 committed by Skia Commit-Bot
parent 01d9a344b5
commit e6d0618f67
2 changed files with 39 additions and 0 deletions

View File

@ -117,6 +117,9 @@ private:
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 @@ private:
// '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;
};

View File

@ -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