De-allocate caches for large glyphs when trimming memory
Currently, font renderers eliminate some texture caches when
memory is trimmed. This change makes it go further by eliminating the
large-glyph caches for all font renderers. These caches are
only allocated as needed, but continue to consume large amounts of
memory (CPU and GPU) after that allocation. De-allocating this memory
on a trim operation should prevent background apps from holding onto
this memory in the possible case that they have allocated it by drawing
large glyphs.
Change-Id: Id7a3ab49b244e036b442d87252fb40aeca8fdb26
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 9f32747..005cdde 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -180,7 +180,7 @@
// Cache of glyphs
DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs;
- void invalidateTextureCache();
+ void invalidateTextureCache(CacheTextureLine *cacheLine = NULL);
CachedGlyphInfo* cacheGlyph(SkPaint* paint, glyph_t glyph);
void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyphInfo *glyph);
@@ -219,6 +219,7 @@
void init();
void deinit();
+ void flushLargeCaches();
void setGammaTable(const uint8_t* gammaTable) {
mGammaTable = gammaTable;
@@ -286,6 +287,7 @@
const uint8_t* mGammaTable;
void allocateTextureMemory(CacheTexture* cacheTexture);
+ void deallocateTextureMemory(CacheTexture* cacheTexture);
void initTextTexture();
CacheTexture *createCacheTexture(int width, int height, bool allocate);
void cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyph,