Weed out duplicates from the proxy version of addDependency

Change-Id: Ic1c8e0cf2a72c1cac8dadcfb7359dd1356671b11
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242389
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2019-09-18 10:26:16 -06:00 committed by Skia Commit-Bot
parent 8dc7d6cb30
commit dc9a74f640

View File

@ -75,10 +75,7 @@ void GrRenderTask::prepare(GrOpFlushState* flushState) {
// Add a GrRenderTask-based dependency // Add a GrRenderTask-based dependency
void GrRenderTask::addDependency(GrRenderTask* dependedOn) { void GrRenderTask::addDependency(GrRenderTask* dependedOn) {
SkASSERT(!dependedOn->dependsOn(this)); // loops are bad SkASSERT(!dependedOn->dependsOn(this)); // loops are bad
SkASSERT(!this->dependsOn(dependedOn)); // caller should weed out duplicates
if (this->dependsOn(dependedOn)) {
return; // don't add duplicate dependencies
}
fDependencies.push_back(dependedOn); fDependencies.push_back(dependedOn);
dependedOn->addDependent(this); dependedOn->addDependent(this);
@ -88,10 +85,12 @@ void GrRenderTask::addDependency(GrRenderTask* dependedOn) {
void GrRenderTask::addDependenciesFromOtherTask(GrRenderTask* otherTask) { void GrRenderTask::addDependenciesFromOtherTask(GrRenderTask* otherTask) {
SkASSERT(otherTask); SkASSERT(otherTask);
for (int i = 0; i < otherTask->fDependencies.count(); ++i) { for (GrRenderTask* task : otherTask->fDependencies) {
// The task should not be adding a dependency to itself. // The task should not be adding a dependency to itself.
SkASSERT(otherTask->fDependencies[i] != this); SkASSERT(task != this);
this->addDependency(otherTask->fDependencies[i]); if (!this->dependsOn(task)) {
this->addDependency(task);
}
} }
} }
@ -115,6 +114,10 @@ void GrRenderTask::addDependency(GrSurfaceProxy* dependedOn, GrMipMapped mipMapp
return; return;
} }
if (this->dependsOn(dependedOnTask)) {
return; // don't add duplicate dependencies
}
if (dependedOnTask) { if (dependedOnTask) {
// We are closing 'dependedOnTask' here bc the current contents of it are what 'this' // We are closing 'dependedOnTask' here bc the current contents of it are what 'this'
// renderTask depends on. We need a break in 'dependedOnTask' so that the usage of // renderTask depends on. We need a break in 'dependedOnTask' so that the usage of