summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/CacheManager.cpp
diff options
context:
space:
mode:
authorAndroid Build Role Account android-build-prod <android-build-team-robot@google.com>2019-02-06 20:09:38 +0000
committerAndroid Build Role Account android-build-prod <android-build-team-robot@google.com>2019-02-06 20:09:38 +0000
commit114b3698af80bf897e3f48457a3fdea3ed9223f7 (patch)
tree3d22b3fafeb8c4ca74e031a256fed486b0310c94 /libs/hwui/renderthread/CacheManager.cpp
parent58b873b300569d954f41511e37f64da0c4e6121e (diff)
parent27a41dc15a27a20aadf47b3b239dc2786d8afba4 (diff)
Snap for 5287745 from 27a41dc15a27a20aadf47b3b239dc2786d8afba4 to q-keystone-qcom-release
Change-Id: I541ba77fba68673bb4696a252fa9e23195b9d41e
Diffstat (limited to 'libs/hwui/renderthread/CacheManager.cpp')
-rw-r--r--libs/hwui/renderthread/CacheManager.cpp29
1 files changed, 5 insertions, 24 deletions
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 <gui/Surface.h>
#include <math.h>
#include <set>
+#include <SkMathPriv.h>
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()) {