From e816baea651476aca4407200d4a5e629b9ab8dfa Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Thu, 9 Aug 2012 13:39:02 -0700 Subject: Optimize interactions with glyph cache There are two fixes here: - precaching: instead of caching-then-drawing whenever there is a new glyph, we cache at DisplayList record time. Then when we finally draw that DisplayList, we just upload the affected texture(s) once, instead of once per change. This is a huge savings in upload time, especially when there are larger glyphs being used by the app. - packing: Previously, glyphs would line up horizontally on each cache line, leaving potentially tons of space vertically, especially when smaller glyphs got put into cache lines intended for large glyphs (which can happen when an app uses lots of unique glyphs, a common case with, for example, chinese/japanese/korean languages). The new approach packs glyphs vertically as well as horizontally to use the space more efficiently and provide space for more glyphs in these situations. Change-Id: I84338aa25db208c7bf13f3f92b4d05ed40c33527 --- libs/hwui/DisplayListRenderer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'libs/hwui/DisplayListRenderer.cpp') diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 95fc2c5..2de70d4 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -1699,7 +1699,9 @@ status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, i addFloat(hOffset); addFloat(vOffset); paint->setAntiAlias(true); - addPaint(paint); + SkPaint* addedPaint = addPaint(paint); + FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint); + fontRenderer.precache(addedPaint, text, count); return DrawGlInfo::kStatusDone; } @@ -1711,7 +1713,9 @@ status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int addInt(count); addFloats(positions, count * 2); paint->setAntiAlias(true); - addPaint(paint); + SkPaint* addedPaint = addPaint(paint); + FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint); + fontRenderer.precache(addedPaint, text, count); return DrawGlInfo::kStatusDone; } @@ -1742,7 +1746,11 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou addFloat(x); addFloat(y); addFloats(positions, count * 2); - addPaint(paint); + SkPaint* addedPaint = addPaint(paint); + if (!reject) { + FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint); + fontRenderer.precache(addedPaint, text, count); + } addFloat(length); addSkip(location); return DrawGlInfo::kStatusDone; -- cgit v1.1