Fix ref cnt'ing issue in GrProgramElement.

Drop ref on GrGpuResources when GrProgramElement loses its last ref and already has a pending execution.

BUG=skia:2889

Review URL: https://codereview.chromium.org/612293003
This commit is contained in:
bsalomon 2014-10-03 05:31:41 -07:00 committed by Commit bot
parent 6a6567458b
commit d012877a6d
2 changed files with 15 additions and 5 deletions

View File

@ -44,8 +44,12 @@ public:
void unref() const {
this->validate();
--fRefCnt;
if (0 == fRefCnt && 0 == fPendingExecutions) {
if (0 == fRefCnt) {
if (0 == fPendingExecutions) {
SkDELETE(this);
} else {
this->removeRefs();
}
}
}
@ -80,6 +84,8 @@ private:
void completedExecution() const;
void removeRefs() const;
mutable int32_t fRefCnt;
// Count of deferred executions not yet issued to the 3D API.
mutable int32_t fPendingExecutions;

View File

@ -31,9 +31,7 @@ void GrProgramElement::convertRefToPendingExecution() const {
++fPendingExecutions;
this->unref();
if (0 == fRefCnt) {
for (int i = 0; i < fGpuResources.count(); ++i) {
fGpuResources[i]->removeRef();
}
this->removeRefs();
}
}
@ -53,3 +51,9 @@ void GrProgramElement::completedExecution() const {
}
}
}
void GrProgramElement::removeRefs() const {
for (int i = 0; i < fGpuResources.count(); ++i) {
fGpuResources[i]->removeRef();
}
}