diff options
Diffstat (limited to 'libs/hwui/renderthread/CacheManager.cpp')
-rw-r--r-- | libs/hwui/renderthread/CacheManager.cpp | 12 |
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() { |