Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e6d0618

Browse files
rphilliSkia Commit-Bot
authored and
Skia Commit-Bot
committed
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 <[email protected]> Commit-Queue: Robert Phillips <[email protected]>
1 parent 01d9a34 commit e6d0618

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

include/private/GrOpList.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class GrOpList : public SkRefCnt {
117117
friend class GrDrawingManager; // for resetFlag, TopoSortTraits & gatherProxyIntervals
118118

119119
void addDependency(GrOpList* dependedOn);
120+
void addDependent(GrOpList* dependent);
121+
SkDEBUGCODE(bool isDependedent(const GrOpList* dependent) const);
122+
SkDEBUGCODE(void validate() const);
120123

121124
// Remove all Ops which reference proxies that have not been instantiated.
122125
virtual void purgeOpsWithUninstantiatedProxies() = 0;
@@ -177,6 +180,8 @@ class GrOpList : public SkRefCnt {
177180

178181
// 'this' GrOpList relies on the output of the GrOpLists in 'fDependencies'
179182
SkSTArray<1, GrOpList*, true> fDependencies;
183+
// 'this' GrOpList's output is relied on by the GrOpLists in 'fDependents'
184+
SkSTArray<1, GrOpList*, true> fDependents;
180185

181186
typedef SkRefCnt INHERITED;
182187
};

src/gpu/GrOpList.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ void GrOpList::addDependency(GrOpList* dependedOn) {
9797
}
9898

9999
fDependencies.push_back(dependedOn);
100+
dependedOn->addDependent(this);
101+
102+
SkDEBUGCODE(this->validate());
100103
}
101104

102105
// Convert from a GrSurface-based dependency to a GrOpList one
@@ -135,6 +138,31 @@ bool GrOpList::dependsOn(const GrOpList* dependedOn) const {
135138
return false;
136139
}
137140

141+
142+
void GrOpList::addDependent(GrOpList* dependent) {
143+
fDependents.push_back(dependent);
144+
}
145+
146+
#ifdef SK_DEBUG
147+
bool GrOpList::isDependedent(const GrOpList* dependent) const {
148+
for (int i = 0; i < fDependents.count(); ++i) {
149+
if (fDependents[i] == dependent) {
150+
return true;
151+
}
152+
}
153+
154+
return false;
155+
}
156+
157+
void GrOpList::validate() const {
158+
// TODO: check for loops and duplicates
159+
160+
for (int i = 0; i < fDependencies.count(); ++i) {
161+
SkASSERT(fDependencies[i]->isDependedent(this));
162+
}
163+
}
164+
#endif
165+
138166
bool GrOpList::isInstantiated() const { return fTarget.get()->isInstantiated(); }
139167

140168
bool GrOpList::isFullyInstantiated() const {
@@ -181,6 +209,12 @@ void GrOpList::dump(bool printDependencies) const {
181209
SkDebugf("%d, ", fDependencies[i]->fUniqueID);
182210
}
183211
SkDebugf("\n");
212+
213+
SkDebugf("(%d) Rely On Me: ", fDependents.count());
214+
for (int i = 0; i < fDependents.count(); ++i) {
215+
SkDebugf("%d, ", fDependents[i]->fUniqueID);
216+
}
217+
SkDebugf("\n");
184218
}
185219
}
186220
#endif

0 commit comments

Comments
 (0)