From 257ae3502cfad43df681b1783528d645bdabc63f Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Wed, 20 Mar 2013 16:31:12 -0700 Subject: Optimize text GL setup Only performs the GL setup steps when at least one glyph is drawn. This change also skips various draw operations when the specified paint draws with alpha = 0. Change-Id: I9eda148b0503acffc552ee19196f5d52e958a1a2 --- libs/hwui/FontRenderer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libs/hwui/FontRenderer.cpp') diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 009dcb97aa0e..26c7e5d1ad6f 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -21,6 +21,7 @@ #include +#include #include #include @@ -416,6 +417,8 @@ void FontRenderer::issueDrawCommand() { CacheTexture* texture = mCacheTextures[i]; if (texture->canDraw()) { if (first) { + if (mFunctor) (*mFunctor)(0, NULL); + checkTextureUpdate(); caches.bindIndicesBuffer(mIndexBufferID); @@ -561,11 +564,12 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch return image; } -void FontRenderer::initRender(const Rect* clip, Rect* bounds) { +void FontRenderer::initRender(const Rect* clip, Rect* bounds, Functor* functor) { checkInit(); mDrawn = false; mBounds = bounds; + mFunctor = functor; mClip = clip; } @@ -583,13 +587,13 @@ void FontRenderer::precache(SkPaint* paint, const char* text, int numGlyphs, con bool FontRenderer::renderPosText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y, - const float* positions, Rect* bounds) { + const float* positions, Rect* bounds, Functor* functor) { if (!mCurrentFont) { ALOGE("No font set"); return false; } - initRender(clip, bounds); + initRender(clip, bounds, functor); mCurrentFont->render(paint, text, startIndex, len, numGlyphs, x, y, positions); finishRender(); @@ -604,7 +608,7 @@ bool FontRenderer::renderTextOnPath(SkPaint* paint, const Rect* clip, const char return false; } - initRender(clip, bounds); + initRender(clip, bounds, NULL); mCurrentFont->render(paint, text, startIndex, len, numGlyphs, path, hOffset, vOffset); finishRender(); -- cgit v1.2.3-59-g8ed1b