Add time-based purging to the GrThreadSafeUniquelyKeyedProxyViewCache
Bug: 1108408
Change-Id: I7dd4a3b1b20f3267903dd7f303a2d639b562d84a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318761
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h b/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h
index 34ee704..691ba4a 100644
--- a/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h
+++ b/src/gpu/GrThreadSafeUniquelyKeyedProxyViewCache.h
@@ -57,6 +57,9 @@
//
// For GrContext::setResourceCacheLimit, if an initial pass through the resource cache doesn't
// reach the budget, uniquely held resources in this cache will be released in LRU to MRU order.
+//
+// For GrContext::performDeferredCleanup, any uniquely held resources that haven't been accessed
+// w/in 'msNotUsed' will be released from this cache prior to the resource cache being cleaned.
class GrThreadSafeUniquelyKeyedProxyViewCache {
public:
GrThreadSafeUniquelyKeyedProxyViewCache();
@@ -70,10 +73,13 @@
void dropAllRefs() SK_EXCLUDES(fSpinLock);
- // Drop uniquely held refs subject to some requirement (e.g., budget, time last accessed).
- // A null parameter means drop all uniquely held refs
+ // Drop uniquely held refs until under the resource cache's budget.
+ // A null parameter means drop all uniquely held refs.
void dropUniqueRefs(GrResourceCache* resourceCache) SK_EXCLUDES(fSpinLock);
+ // Drop uniquely held refs that were last accessed before 'purgeTime'
+ void dropUniqueRefsOlderThan(GrStdSteadyClock::time_point purgeTime) SK_EXCLUDES(fSpinLock);
+
GrSurfaceProxyView find(const GrUniqueKey&) SK_EXCLUDES(fSpinLock);
GrSurfaceProxyView add(const GrUniqueKey&, const GrSurfaceProxyView&) SK_EXCLUDES(fSpinLock);
@@ -83,8 +89,9 @@
Entry(const GrUniqueKey& key, const GrSurfaceProxyView& view) : fKey(key), fView(view) {}
// Note: the unique key is stored here bc it is never attached to a proxy or a GrTexture
- GrUniqueKey fKey;
- GrSurfaceProxyView fView;
+ GrUniqueKey fKey;
+ GrSurfaceProxyView fView;
+ GrStdSteadyClock::time_point fLastAccess;
SK_DECLARE_INTERNAL_LLIST_INTERFACE(Entry);