From 2efd5c5886d9acf747bc92f888d731ed558aabcc Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Wed, 15 Aug 2012 13:15:16 -0700 Subject: [PATCH] Glyph cache optimization Precaching at startup was not working. One-liner fix to init the caches so that precaching would kick in earlier, saving time at startup by avoiding the multiple-upload issue of caching at render time. Issue #6893691 long app launch time on manta for some apps comparing to nakasi/stingray Change-Id: Ie5c7f0536ec8ea371c7892e5e09c1db14795531c --- libs/hwui/FontRenderer.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index a596fa9464675..b352ffc538ae5 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -699,7 +699,6 @@ void FontRenderer::flushAllAndInvalidate() { } #if DEBUG_FONT_RENDERER - ALOGD("FontRenderer: flushAllAndInvalidatel"); // Erase caches, just as a debugging facility if (mCacheTextureSmall && mCacheTextureSmall->mTexture) { memset(mCacheTextureSmall->mTexture, 0, @@ -792,14 +791,12 @@ void FontRenderer::allocateTextureMemory(CacheTexture* cacheTexture) { void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyph, uint32_t* retOriginX, uint32_t* retOriginY) { + checkInit(); cachedGlyph->mIsValid = false; // If the glyph is too tall, don't cache it - if (mCacheLines.size() == 0 || - glyph.fHeight + TEXTURE_BORDER_SIZE * 2 > mCacheLines[mCacheLines.size() - 1]->mMaxHeight) { - if (mCacheLines.size() != 0) { - ALOGE("Font size too large to fit in cache. width, height = %i, %i", - (int) glyph.fWidth, (int) glyph.fHeight); - } + if (glyph.fHeight + TEXTURE_BORDER_SIZE * 2 > mCacheLines[mCacheLines.size() - 1]->mMaxHeight) { + ALOGE("Font size too large to fit in cache. width, height = %i, %i", + (int) glyph.fWidth, (int) glyph.fHeight); return; }