diff options
| author | 2013-03-20 16:31:12 -0700 | |
|---|---|---|
| committer | 2013-03-20 16:35:05 -0700 | |
| commit | 257ae3502cfad43df681b1783528d645bdabc63f (patch) | |
| tree | e257e21ddf04c544b0dbb6467d2d10a7c659ac1d /libs/hwui/FontRenderer.cpp | |
| parent | 10c4d99f04a399c78529d0ae66c1785b26a125c3 (diff) | |
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
Diffstat (limited to 'libs/hwui/FontRenderer.cpp')
| -rw-r--r-- | libs/hwui/FontRenderer.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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 <cutils/properties.h> +#include <utils/Functor.h> #include <utils/Log.h> #include <RenderScript.h> @@ -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(); |