Skip to content

Commit

Permalink
Add list of dependents to GrOpList class
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rphilli authored and Skia Commit-Bot committed Aug 7, 2018
1 parent 01d9a34 commit e6d0618
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/private/GrOpList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand Down
34 changes: 34 additions & 0 deletions src/gpu/GrOpList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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

0 comments on commit e6d0618

Please sign in to comment.