Loading libs/hwui/FontRenderer.cpp +39 −2 Original line number Diff line number Diff line Loading @@ -85,9 +85,12 @@ Font::~Font() { } } void Font::invalidateTextureCache() { void Font::invalidateTextureCache(CacheTextureLine *cacheLine) { for (uint32_t i = 0; i < mCachedGlyphs.size(); i++) { mCachedGlyphs.valueAt(i)->mIsValid = false; CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueAt(i); if (cacheLine == NULL || cachedGlyph->mCachedTextureLine == cacheLine) { cachedGlyph->mIsValid = false; } } } Loading Loading @@ -414,6 +417,40 @@ void FontRenderer::flushAllAndInvalidate() { } } void FontRenderer::deallocateTextureMemory(CacheTexture *cacheTexture) { if (cacheTexture && cacheTexture->mTexture) { glDeleteTextures(1, &cacheTexture->mTextureId); delete cacheTexture->mTexture; cacheTexture->mTexture = NULL; } } void FontRenderer::flushLargeCaches() { if ((!mCacheTexture128 || !mCacheTexture128->mTexture) && (!mCacheTexture256 || !mCacheTexture256->mTexture) && (!mCacheTexture512 || !mCacheTexture512->mTexture)) { // Typical case; no large glyph caches allocated return; } for (uint32_t i = 0; i < mCacheLines.size(); i++) { CacheTextureLine* cacheLine = mCacheLines[i]; if ((cacheLine->mCacheTexture == mCacheTexture128 || cacheLine->mCacheTexture == mCacheTexture256 || cacheLine->mCacheTexture == mCacheTexture512) && cacheLine->mCacheTexture->mTexture != NULL) { cacheLine->mCurrentCol = 0; for (uint32_t i = 0; i < mActiveFonts.size(); i++) { mActiveFonts[i]->invalidateTextureCache(cacheLine); } } } deallocateTextureMemory(mCacheTexture128); deallocateTextureMemory(mCacheTexture256); deallocateTextureMemory(mCacheTexture512); } void FontRenderer::allocateTextureMemory(CacheTexture *cacheTexture) { int width = cacheTexture->mWidth; int height = cacheTexture->mHeight; Loading libs/hwui/FontRenderer.h +3 −1 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ protected: // 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); Loading Loading @@ -219,6 +219,7 @@ public: void init(); void deinit(); void flushLargeCaches(); void setGammaTable(const uint8_t* gammaTable) { mGammaTable = gammaTable; Loading Loading @@ -286,6 +287,7 @@ protected: 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, Loading libs/hwui/GammaFontRenderer.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,13 @@ void GammaFontRenderer::flush() { delete mRenderers[min]; mRenderers[min] = NULL; // Also eliminate the caches for large glyphs, as they consume significant memory for (int i = 0; i < kGammaCount; ++i) { if (mRenderers[i]) { mRenderers[i]->flushLargeCaches(); } } } FontRenderer* GammaFontRenderer::getRenderer(Gamma gamma) { Loading Loading
libs/hwui/FontRenderer.cpp +39 −2 Original line number Diff line number Diff line Loading @@ -85,9 +85,12 @@ Font::~Font() { } } void Font::invalidateTextureCache() { void Font::invalidateTextureCache(CacheTextureLine *cacheLine) { for (uint32_t i = 0; i < mCachedGlyphs.size(); i++) { mCachedGlyphs.valueAt(i)->mIsValid = false; CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueAt(i); if (cacheLine == NULL || cachedGlyph->mCachedTextureLine == cacheLine) { cachedGlyph->mIsValid = false; } } } Loading Loading @@ -414,6 +417,40 @@ void FontRenderer::flushAllAndInvalidate() { } } void FontRenderer::deallocateTextureMemory(CacheTexture *cacheTexture) { if (cacheTexture && cacheTexture->mTexture) { glDeleteTextures(1, &cacheTexture->mTextureId); delete cacheTexture->mTexture; cacheTexture->mTexture = NULL; } } void FontRenderer::flushLargeCaches() { if ((!mCacheTexture128 || !mCacheTexture128->mTexture) && (!mCacheTexture256 || !mCacheTexture256->mTexture) && (!mCacheTexture512 || !mCacheTexture512->mTexture)) { // Typical case; no large glyph caches allocated return; } for (uint32_t i = 0; i < mCacheLines.size(); i++) { CacheTextureLine* cacheLine = mCacheLines[i]; if ((cacheLine->mCacheTexture == mCacheTexture128 || cacheLine->mCacheTexture == mCacheTexture256 || cacheLine->mCacheTexture == mCacheTexture512) && cacheLine->mCacheTexture->mTexture != NULL) { cacheLine->mCurrentCol = 0; for (uint32_t i = 0; i < mActiveFonts.size(); i++) { mActiveFonts[i]->invalidateTextureCache(cacheLine); } } } deallocateTextureMemory(mCacheTexture128); deallocateTextureMemory(mCacheTexture256); deallocateTextureMemory(mCacheTexture512); } void FontRenderer::allocateTextureMemory(CacheTexture *cacheTexture) { int width = cacheTexture->mWidth; int height = cacheTexture->mHeight; Loading
libs/hwui/FontRenderer.h +3 −1 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ protected: // 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); Loading Loading @@ -219,6 +219,7 @@ public: void init(); void deinit(); void flushLargeCaches(); void setGammaTable(const uint8_t* gammaTable) { mGammaTable = gammaTable; Loading Loading @@ -286,6 +287,7 @@ protected: 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, Loading
libs/hwui/GammaFontRenderer.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,13 @@ void GammaFontRenderer::flush() { delete mRenderers[min]; mRenderers[min] = NULL; // Also eliminate the caches for large glyphs, as they consume significant memory for (int i = 0; i < kGammaCount; ++i) { if (mRenderers[i]) { mRenderers[i]->flushLargeCaches(); } } } FontRenderer* GammaFontRenderer::getRenderer(Gamma gamma) { Loading