aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-10-03 05:31:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-03 05:31:41 -0700
commitd012877a6d30ae768f9ccf3239ba09d730cbb6a5 (patch)
treec5ef04402934c788091c9d94ec058ed88ffb352b
parent6a6567458b303237dd9a528a24829ca849adc1db (diff)
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
-rw-r--r--include/gpu/GrProgramElement.h10
-rw-r--r--src/gpu/GrProgramElement.cpp10
2 files changed, 15 insertions, 5 deletions
diff --git a/include/gpu/GrProgramElement.h b/include/gpu/GrProgramElement.h
index 245dcd5fbc..2cdd1cc563 100644
--- a/include/gpu/GrProgramElement.h
+++ b/include/gpu/GrProgramElement.h
@@ -44,8 +44,12 @@ public:
void unref() const {
this->validate();
--fRefCnt;
- if (0 == fRefCnt && 0 == fPendingExecutions) {
- SkDELETE(this);
+ 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;
diff --git a/src/gpu/GrProgramElement.cpp b/src/gpu/GrProgramElement.cpp
index 2c3085f7e4..89d53e28db 100644
--- a/src/gpu/GrProgramElement.cpp
+++ b/src/gpu/GrProgramElement.cpp
@@ -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();
+ }
+}