diff options
Diffstat (limited to 'libs/hwui/renderthread/CacheManager.cpp')
-rw-r--r-- | libs/hwui/renderthread/CacheManager.cpp | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 1b638c12ac7b..eaed46c44e5d 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -16,6 +16,7 @@ #include "CacheManager.h" +#include "DeviceInfo.h" #include "Layer.h" #include "Properties.h" #include "RenderThread.h" @@ -28,7 +29,6 @@ #include <SkExecutor.h> #include <SkGraphics.h> #include <SkMathPriv.h> -#include <gui/Surface.h> #include <math.h> #include <set> @@ -40,11 +40,11 @@ namespace renderthread { // to the screen resolution. This is meant to be a conservative default based on // that analysis. The 4.0f is used because the default pixel format is assumed to // be ARGB_8888. -#define SURFACE_SIZE_MULTIPLIER (12.0f * 4.0f) +#define SURFACE_SIZE_MULTIPLIER (5.0f * 4.0f) #define BACKGROUND_RETENTION_PERCENTAGE (0.5f) -CacheManager::CacheManager(const DisplayInfo& display) - : mMaxSurfaceArea(display.w * display.h) +CacheManager::CacheManager() + : mMaxSurfaceArea(DeviceInfo::getWidth() * DeviceInfo::getHeight()) , mMaxResourceBytes(mMaxSurfaceArea * SURFACE_SIZE_MULTIPLIER) , mBackgroundResourceBytes(mMaxResourceBytes * BACKGROUND_RETENTION_PERCENTAGE) // This sets the maximum size for a single texture atlas in the GPU font cache. If @@ -53,14 +53,10 @@ CacheManager::CacheManager(const DisplayInfo& display) , mMaxGpuFontAtlasBytes(GrNextSizePow2(mMaxSurfaceArea)) // This sets the maximum size of the CPU font cache to be at least the same size as the // total number of GPU font caches (i.e. 4 separate GPU atlases). - , mMaxCpuFontCacheBytes(std::max(mMaxGpuFontAtlasBytes*4, SkGraphics::GetFontCacheLimit())) + , mMaxCpuFontCacheBytes( + std::max(mMaxGpuFontAtlasBytes * 4, SkGraphics::GetFontCacheLimit())) , mBackgroundCpuFontCacheBytes(mMaxCpuFontCacheBytes * BACKGROUND_RETENTION_PERCENTAGE) { - SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); - - mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas( - mMaxSurfaceArea / 2, - skiapipeline::VectorDrawableAtlas::StorageMode::disallowSharedSurface); } void CacheManager::reset(sk_sp<GrContext> context) { @@ -70,17 +66,13 @@ void CacheManager::reset(sk_sp<GrContext> context) { if (context) { mGrContext = std::move(context); - mGrContext->getResourceCacheLimits(&mMaxResources, nullptr); - mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes); + mGrContext->setResourceCacheLimit(mMaxResourceBytes); } } void CacheManager::destroy() { // cleanup any caches here as the GrContext is about to go away... mGrContext.reset(nullptr); - mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas( - mMaxSurfaceArea / 2, - skiapipeline::VectorDrawableAtlas::StorageMode::disallowSharedSurface); } class CommonPoolExecutor : public SkExecutor { @@ -111,7 +103,6 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { switch (mode) { case TrimMemoryMode::Complete: - mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas(mMaxSurfaceArea / 2); mGrContext->freeGpuResources(); SkGraphics::PurgeAllCaches(); break; @@ -120,8 +111,8 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { // 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); + mGrContext->setResourceCacheLimit(mBackgroundResourceBytes); + mGrContext->setResourceCacheLimit(mMaxResourceBytes); SkGraphics::SetFontCacheLimit(mBackgroundCpuFontCacheBytes); SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); break; @@ -140,16 +131,6 @@ void CacheManager::trimStaleResources() { mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30)); } -sp<skiapipeline::VectorDrawableAtlas> CacheManager::acquireVectorDrawableAtlas() { - LOG_ALWAYS_FATAL_IF(mVectorDrawableAtlas.get() == nullptr); - LOG_ALWAYS_FATAL_IF(mGrContext == nullptr); - - /** - * TODO: define memory conditions where we clear the cache (e.g. surface->reset()) - */ - return mVectorDrawableAtlas; -} - void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) { if (!mGrContext) { log.appendFormat("No valid cache instance.\n"); @@ -178,8 +159,6 @@ void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) log.appendFormat("Other Caches:\n"); log.appendFormat(" Current / Maximum\n"); - log.appendFormat(" VectorDrawableAtlas %6.2f kB / %6.2f KB (entries = %zu)\n", 0.0f, 0.0f, - (size_t)0); if (renderState) { if (renderState->mActiveLayers.size() > 0) { |