Change the meaning of GrBudgetedType::kUnbudgetedUncacheable.
kUnbudgetedCacheable now means that the resource is never purged
until its unique key is removed.
This fixes an issue where a cached texture for a promise image
might get purged by cache pressure. This in turn could cause
Skia to call the promise image's Fulfill proc multiple times with
no intervening Release calls. The balancing Release calls would
occur, but the policy is that each Fulfill should be balanced by
Release *before* another Fulfill.
Update/add unit tests.
Bug: chromium:922851
Change-Id: I6411e413b3104721ca4bb6e7f07b3b73d14cbcf9
Reviewed-on: https://skia-review.googlesource.com/c/186361
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrGpuResourceCacheAccess.h b/src/gpu/GrGpuResourceCacheAccess.h
index 3765c6e..e80b9b5 100644
--- a/src/gpu/GrGpuResourceCacheAccess.h
+++ b/src/gpu/GrGpuResourceCacheAccess.h
@@ -30,17 +30,11 @@
}
/**
- * Called by GrResourceCache when a resource becomes purgeable regardless of whether the cache
- * has decided to keep the resource ot purge it immediately.
- */
- void becamePurgeable() { fResource->becamePurgeable(); }
-
- /**
* Called by the cache to delete the resource under normal circumstances.
*/
void release() {
fResource->release();
- if (fResource->isPurgeable()) {
+ if (!fResource->hasRefOrPendingIO()) {
delete fResource;
}
}
@@ -50,7 +44,7 @@
*/
void abandon() {
fResource->abandon();
- if (fResource->isPurgeable()) {
+ if (!fResource->hasRefOrPendingIO()) {
delete fResource;
}
}