aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceCache.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-03-22 14:53:13 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-22 20:08:21 +0000
commit5e150851d0dd5ddb161449b44edf1bf52d18ac5a (patch)
treee081248e324c50b9ade1569fb3a5ac85450af40b /src/gpu/GrResourceCache.cpp
parentb8e752198dde333e71cb1a9578cd3dfd404dd06c (diff)
Revert "Revert "Add a new GrResourceCache purging mechanism for purging unused resources.""
This reverts commit 20c322ef0cd04cf8e2592879d05d9f4e6cb19596. Change-Id: I6df9a8594484837672308dc2c21c7c29b76ffa2c Reviewed-on: https://skia-review.googlesource.com/10013 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrResourceCache.cpp')
-rw-r--r--src/gpu/GrResourceCache.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 9462a7384d..596af6d623 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(GrStdSteadyClock::time_point purgeTime) {
+ while (fPurgeableQueue.count()) {
+ const GrStdSteadyClock::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) {