From 43d0613325bca5fb8843f0214f7342aa50f26a1f Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Fri, 21 Dec 2018 13:14:15 -0500 Subject: Change formula for font cache size Set font cache size to one screen buffer size. For Pixel 2 XL this increased the texture size from 3670016 to 4194304. Skia can allocate up to 4 textures of that size. Test: UiBenchJankTests#testInflatingEmojiListViewFling Bug: 121157706 Change-Id: I7af1f184c6dbc10b45a8ef80a04200d518fbaa0e --- libs/hwui/renderthread/CacheManager.cpp | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 7acc44ca65b7..6c04232ab7f5 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace android { namespace uirenderer { @@ -42,11 +43,6 @@ namespace renderthread { #define SURFACE_SIZE_MULTIPLIER (12.0f * 4.0f) #define BACKGROUND_RETENTION_PERCENTAGE (0.5f) -// for super large fonts we will draw them as paths so no need to keep linearly -// increasing the font cache size. -#define FONT_CACHE_MIN_MB (0.5f) -#define FONT_CACHE_MAX_MB (4.0f) - CacheManager::CacheManager(const DisplayInfo& display) : mMaxSurfaceArea(display.w * display.h) { mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas( mMaxSurfaceArea / 2, @@ -106,25 +102,10 @@ public: void CacheManager::configureContext(GrContextOptions* contextOptions, const void* identity, ssize_t size) { contextOptions->fAllowPathMaskCaching = true; - float screenMP = mMaxSurfaceArea / 1024.0f / 1024.0f; - float fontCacheMB = 0; - float decimalVal = std::modf(screenMP, &fontCacheMB); - - // This is a basic heuristic to size the cache to a multiple of 512 KB - if (decimalVal > 0.8f) { - fontCacheMB += 1.0f; - } else if (decimalVal > 0.5f) { - fontCacheMB += 0.5f; - } - - // set limits on min/max size of the cache - fontCacheMB = std::max(FONT_CACHE_MIN_MB, std::min(FONT_CACHE_MAX_MB, fontCacheMB)); - - // We must currently set the size of the text cache based on the size of the - // display even though we like to be dynamicallysizing it to the size of the window. - // Skia's implementation doesn't provide a mechanism to resize the font cache due to - // the potential cost of recreating the glyphs. - contextOptions->fGlyphCacheTextureMaximumBytes = fontCacheMB * 1024 * 1024; + // This sets the maximum size for a single texture atlas in the GPU font cache. If necessary, + // the cache can allocate additional textures that are counted against the total cache limits + // provided to Skia. + contextOptions->fGlyphCacheTextureMaximumBytes = GrNextSizePow2(mMaxSurfaceArea); if (mTaskManager.canRunTasks()) { if (!mTaskProcessor.get()) { -- cgit v1.2.3