diff options
Diffstat (limited to 'libs/hwui/FontRenderer.cpp')
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 34245b0..8462307 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -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; + } } } @@ -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; |