diff options
Diffstat (limited to 'src/gpu/GrResourceCache.cpp')
-rw-r--r-- | src/gpu/GrResourceCache.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index 9462a7384d..97d3b96808 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -365,6 +365,7 @@ void GrResourceCache::notifyCntReachedZero(GrGpuResource* resource, uint32_t fla this->removeFromNonpurgeableArray(resource); fPurgeableQueue.insert(resource); resource->cacheAccess().setFlushCntWhenResourceBecamePurgeable(fExternalFlushCnt); + resource->cacheAccess().setTimeWhenResourceBecomePurgeable(); if (SkBudgeted::kNo == resource->resourcePriv().isBudgeted()) { // Check whether this resource could still be used as a scratch resource. @@ -504,6 +505,24 @@ void GrResourceCache::purgeAllUnlocked() { this->validate(); } +void GrResourceCache::purgeResourcesNotUsedSince(std::chrono::steady_clock::time_point purgeTime) { + while (fPurgeableQueue.count()) { + const std::chrono::steady_clock::time_point resourceTime = + fPurgeableQueue.peek()->cacheAccess().timeWhenResourceBecamePurgeable(); + if (resourceTime >= purgeTime) { + // Resources were given both LRU timestamps and tagged with a frame number when + // they first became purgeable. The LRU timestamp won't change again until the + // resource is made non-purgeable again. So, at this point all the remaining + // resources in the timestamp-sorted queue will have a frame number >= to this + // one. + break; + } + GrGpuResource* resource = fPurgeableQueue.peek(); + SkASSERT(resource->isPurgeable()); + resource->cacheAccess().release(); + } +} + void GrResourceCache::processInvalidUniqueKeys( const SkTArray<GrUniqueKeyInvalidatedMessage>& msgs) { for (int i = 0; i < msgs.count(); ++i) { |