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

Unified Diff: src/gpu/GrGpuResourceCacheAccess.h

Issue 870743002: Allow unbudgeted resources to be recycled by the cache as scratch. (Closed) Base URL: https://skia.googlesource.com/skia.git@ckey
Patch Set: rebase Created 5 years, 11 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
Index: src/gpu/GrGpuResourceCacheAccess.h
diff --git a/src/gpu/GrGpuResourceCacheAccess.h b/src/gpu/GrGpuResourceCacheAccess.h
index 33fe1ad93a36cc58e4dca4e6b30d233c07d39d2d..474438fa9ce29407c044feb5df030a40e9a7d8cb 100644
--- a/src/gpu/GrGpuResourceCacheAccess.h
+++ b/src/gpu/GrGpuResourceCacheAccess.h
@@ -29,11 +29,12 @@ public:
}
/**
- * Is the resource currently cached as scratch? This means it has a valid scratch key and does
- * not have a content key.
+ * Is the resource currently cached as scratch? This means it is cached, has a valid scratch
+ * key, and does not have a content key.
*/
bool isScratch() const {
- return !this->getContentKey().isValid() && fResource->fScratchKey.isValid();
+ return !this->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
+ this->isBudgeted();
}
/**
@@ -62,7 +63,11 @@ public:
/**
* Does the resource count against the resource budget?
*/
- bool isBudgeted() const { return GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle; }
+ bool isBudgeted() const {
+ bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle;
+ SkASSERT(ret || !this->getContentKey().isValid());
+ return ret;
+ }
/**
* If the resource is uncached make it cached. Has no effect on resources that are wrapped or
@@ -71,6 +76,12 @@ public:
void makeBudgeted() { fResource->makeBudgeted(); }
/**
+ * If the resource is cached make it uncached. Has no effect on resources that are wrapped or
+ * already uncached. Furthermore, resources with content keys cannot be made unbudgeted.
+ */
+ void makeUnbudgeted() { fResource->makeUnbudgeted(); }
+
+ /**
* Called by the cache to delete the resource under normal circumstances.
*/
void release() {

Powered by Google App Engine
This is Rietveld 408576698