diff options
| author | 2012-07-23 15:22:52 -0700 | |
|---|---|---|
| committer | 2012-07-23 16:52:20 -0700 | |
| commit | 996e57c84368058be793897ebc355b917a59abc2 (patch) | |
| tree | 11d598d07a5153872cd496fd3ca7d4a1a3bdecb8 /libs/hwui/OpenGLRenderer.cpp | |
| parent | 219dfa4d392851c1ffd7147cb78d4236658a79d8 (diff) | |
Hardware implementation of glyph positioning (bug 5443796)
This implementation adds a drawGeneralText() method to the OpenGL
Renderer, which supports both a global x, y position, an array of
individual glyph positions, and also a length parameter (which enables
drawing of underline and strikethrough. It also adds the method to the
display list (with marshalling and unmarshalling).
With this change, the existing drawText() method is removed entirely, as
it's subsumed by the new method. It's easy enough to revert to the old
functionality if needed by passing in a NULL positions array.
Change-Id: I8c9e6ce4309fd51cc5511db85df99f6de8f4f6f5
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 6d781c77fa7a..07281ccf19c9 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2421,8 +2421,8 @@ status_t OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count return DrawGlInfo::kStatusDrew; } -status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, - float x, float y, SkPaint* paint, float length) { +status_t OpenGLRenderer::drawGeneralText(const char* text, int bytesCount, int count, + float x, float y, const float* positions, SkPaint* paint, float length) { if (text == NULL || count == 0 || mSnapshot->isIgnored() || (paint->getAlpha() * mSnapshot->alpha == 0 && paint->getXfermode() == NULL)) { return DrawGlInfo::kStatusDone; @@ -2455,7 +2455,8 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, } #if DEBUG_GLYPHS - ALOGD("OpenGLRenderer drawText() with FontID=%d", SkTypeface::UniqueID(paint->getTypeface())); + ALOGD("OpenGLRenderer drawGeneralText() with FontID=%d", + SkTypeface::UniqueID(paint->getTypeface())); #endif FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint); @@ -2467,7 +2468,8 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, getAlphaAndMode(paint, &alpha, &mode); if (CC_UNLIKELY(mHasShadow)) { - drawTextShadow(paint, text, bytesCount, count, NULL, fontRenderer, alpha, mode, oldX, oldY); + drawTextShadow(paint, text, bytesCount, count, positions, fontRenderer, alpha, mode, + oldX, oldY); } // Pick the appropriate texture filtering @@ -2505,8 +2507,16 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, const bool hasActiveLayer = false; #endif - if (fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y, - hasActiveLayer ? &bounds : NULL)) { + bool status; + if (positions != NULL) { + status = fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y, + positions, hasActiveLayer ? &bounds : NULL); + } else { + // TODO: would it be okay to call renderPosText with null positions? + status = fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y, + hasActiveLayer ? &bounds : NULL); + } + if (status) { #if RENDER_LAYERS_AS_REGIONS if (hasActiveLayer) { if (!pureTranslate) { |