summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2018-04-02 13:36:45 -0400
committerDerek Sollenberger <djsollen@google.com>2018-04-03 11:53:43 -0400
commitb1f27aae89a9da9fbf3cb15a47f1a401db5a7974 (patch)
treeb0699bbb1fad7dc0649bfd03b1956b52834949ef /libs/hwui/renderthread
parent600fe676f7a164107a7501451483f5ffc2bbdd12 (diff)
Free up all scratch resources when the app's UI is hidden
Bug: 73808481 Test: hwui_unit_tests Change-Id: I9f191c776a936c1be40702ff0924c7ad054526d5
Diffstat (limited to 'libs/hwui/renderthread')
-rw-r--r--libs/hwui/renderthread/CacheManager.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index 32d4c77c5fc3..3ca92953e5f7 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -151,7 +151,12 @@ void CacheManager::trimMemory(TrimMemoryMode mode) {
mGrContext->freeGpuResources();
break;
case TrimMemoryMode::UiHidden:
- mGrContext->purgeUnlockedResources(mMaxResourceBytes - mBackgroundResourceBytes, true);
+ // Here we purge all the unlocked scratch resources and then toggle the resources cache
+ // limits between the background and max amounts. This causes the unlocked resources
+ // that have persistent data to be purged in LRU order.
+ mGrContext->purgeUnlockedResources(true);
+ mGrContext->setResourceCacheLimits(mMaxResources, mBackgroundResourceBytes);
+ mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes);
break;
}
}
@@ -161,7 +166,10 @@ void CacheManager::trimStaleResources() {
return;
}
mGrContext->flush();
- mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30));
+ // Here we purge all the unlocked scratch resources (leaving those resources w/ persistent data)
+ // and then purge those w/ persistent data based on age.
+ mGrContext->purgeUnlockedResources(true);
+ mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(10));
}
sp<skiapipeline::VectorDrawableAtlas> CacheManager::acquireVectorDrawableAtlas() {