@@ -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+
138166bool GrOpList::isInstantiated () const { return fTarget .get ()->isInstantiated (); }
139167
140168bool 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