aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpuResource.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-09-24 07:07:40 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-24 07:07:40 -0700
commitc6363ef7b4763b36a9a0d255bc775a973d2fc7a5 (patch)
treee2d6420f53f3904a0163e2cf01f13fc5fec52406 /src/gpu/GrGpuResource.cpp
parent14eaaa61ca83ac894934df534b001f4cbeb9eb40 (diff)
Make methods on GrGpuResource safe to call on abandoned resource
BUG=chromium:528908 Review URL: https://codereview.chromium.org/1367533004
Diffstat (limited to 'src/gpu/GrGpuResource.cpp')
-rw-r--r--src/gpu/GrGpuResource.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index f8cb529314..a227fd2c0f 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -46,6 +46,9 @@ void GrGpuResource::release() {
}
void GrGpuResource::abandon() {
+ if (this->wasDestroyed()) {
+ return;
+ }
SkASSERT(fGpu);
this->onAbandon();
get_resource_cache(fGpu)->resourceAccess().removeResource(this);
@@ -104,6 +107,9 @@ void GrGpuResource::didChangeGpuMemorySize() const {
}
void GrGpuResource::removeUniqueKey() {
+ if (this->wasDestroyed()) {
+ return;
+ }
SkASSERT(fUniqueKey.isValid());
get_resource_cache(fGpu)->resourceAccess().removeUniqueKey(this);
}
@@ -177,14 +183,15 @@ void GrGpuResource::removeScratchKey() {
}
void GrGpuResource::makeBudgeted() {
- if (GrGpuResource::kUncached_LifeCycle == fLifeCycle) {
+ if (!this->wasDestroyed() && GrGpuResource::kUncached_LifeCycle == fLifeCycle) {
fLifeCycle = kCached_LifeCycle;
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
}
}
void GrGpuResource::makeUnbudgeted() {
- if (GrGpuResource::kCached_LifeCycle == fLifeCycle && !fUniqueKey.isValid()) {
+ if (!this->wasDestroyed() && GrGpuResource::kCached_LifeCycle == fLifeCycle &&
+ !fUniqueKey.isValid()) {
fLifeCycle = kUncached_LifeCycle;
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
}