Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Unified Diff: src/gpu/GrGpuResource.cpp

Issue 1367533004: Make methods on GrGpuResource safe to call on abandoned resource (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGpuResource.cpp
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index f8cb529314daa6b963d080755047bf82a2911576..a227fd2c0f5ad81ece6dda893a43aa621310cd75 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);
}
« no previous file with comments | « no previous file | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698