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

Unified Diff: src/gpu/GrGpuResource.cpp

Issue 1032873002: Add mechanism to proactively purge old resources in GrResourceCache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment Created 5 years, 8 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 | « src/gpu/GrContext.cpp ('k') | src/gpu/GrResourceCache.h » ('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 a2fc7b3b3507a7ca2aaccf009c4b94f28a249d92..52fe1e57d68b9e8c7d383ffc21aa5f3d2be58534 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -105,14 +105,39 @@ void GrGpuResource::setUniqueKey(const GrUniqueKey& key) {
get_resource_cache(fGpu)->resourceAccess().changeUniqueKey(this, key);
}
-void GrGpuResource::notifyIsPurgeable() const {
+void GrGpuResource::notifyAllCntsAreZero(CntType lastCntTypeToReachZero) const {
if (this->wasDestroyed()) {
// We've already been removed from the cache. Goodbye cruel world!
SkDELETE(this);
- } else {
- GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
- get_resource_cache(fGpu)->resourceAccess().notifyPurgeable(mutableThis);
+ return;
}
+
+ // We should have already handled this fully in notifyRefCntIsZero().
+ SkASSERT(kRef_CntType != lastCntTypeToReachZero);
+
+ GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
+ static const uint32_t kFlag =
+ GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag;
+ get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis, kFlag);
+}
+
+bool GrGpuResource::notifyRefCountIsZero() const {
+ if (this->wasDestroyed()) {
+ // handle this in notifyAllCntsAreZero().
+ return true;
+ }
+
+ GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
+ uint32_t flags =
+ GrResourceCache::ResourceAccess::kRefCntReachedZero_RefNotificationFlag;
+ if (!this->internalHasPendingIO()) {
+ flags |= GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag;
+ }
+ get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis, flags);
+
+ // There is no need to call our notifyAllCntsAreZero function at this point since we already
+ // told the cache about the state of cnts.
+ return false;
}
void GrGpuResource::setScratchKey(const GrScratchKey& scratchKey) {
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698