Skip to content

Commit 521dc51

Browse files
author
Romain Guy
committed
Don't invalidate all the glyphs when flushing large textures
FontRenderer::flushLargeCaches identifies the large textures used to cache glyphs and visits all the known fonts to mark their glyphs invalid if they belong to one of these large textures. Unfortunately, Font::invalidateTextureCache had a logic error which would make it mark *all glyphs* as invalid, not matter what texture they belong to. This means that any large cache flush would cause all glyphs to be invalidate, thus forcing the rendering system to recreate them on the next draw. Font::invalidateTextureCache is supposed to behave this way: - If the specified cacheTexture is NULL (default value), mark all glyphs as invalid (see FontRenderer::flushAllAndInvalidate()) - If cacheTexture is *not* NULL, invalidate only the glyphs for which glyph.cacheTexture == cacheTexture. The previous condition read: if (cacheTexture || glyph.cacheTexture == cacheTexture) This test *always* passes. Change-Id: I418886cb594c81c6178d0f9e9953d975e991cf22
1 parent 6c8c6d9 commit 521dc51

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libs/hwui/font/Font.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Font::~Font() {
5151
void Font::invalidateTextureCache(CacheTexture* cacheTexture) {
5252
for (uint32_t i = 0; i < mCachedGlyphs.size(); i++) {
5353
CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueAt(i);
54-
if (cacheTexture || cachedGlyph->mCacheTexture == cacheTexture) {
54+
if (!cacheTexture || cachedGlyph->mCacheTexture == cacheTexture) {
5555
cachedGlyph->mIsValid = false;
5656
}
5757
}

0 commit comments

Comments
 (0)