diff options
author | Romain Guy <romainguy@google.com> | 2012-01-17 17:39:26 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-01-17 17:39:26 -0800 |
commit | eb9a5367e8f0e970db8509ffb2584f5376bc62ed (patch) | |
tree | b1edb8a663363a150fa25545f035372defbe7b70 /libs | |
parent | d1d4bb70704e8f37d0823837eacdae21ebe0ed05 (diff) | |
download | frameworks_base-eb9a5367e8f0e970db8509ffb2584f5376bc62ed.zip frameworks_base-eb9a5367e8f0e970db8509ffb2584f5376bc62ed.tar.gz frameworks_base-eb9a5367e8f0e970db8509ffb2584f5376bc62ed.tar.bz2 |
First pass at implementing Canvas.drawPosText() in GL
Change-Id: Ia3ac347e95d57eb86c63045156c8dbc0572b03cb
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 32 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 3 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 14 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 2 |
4 files changed, 50 insertions, 1 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 656a384..824ab4f 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -60,6 +60,7 @@ const char* DisplayList::OP_NAMES[] = { "DrawLines", "DrawPoints", "DrawText", + "DrawPosText", "ResetShader", "SetupShader", "ResetColorFilter", @@ -482,6 +483,15 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) { text.text(), text.length(), count, x, y, paint, length); } break; + case DrawPosText: { + getText(&text); + int count = getInt(); + int positionsCount = 0; + float* positions = getFloats(positionsCount); + SkPaint* paint = getPaint(); + ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op], + text.text(), text.length(), count, paint); + } case ResetShader: { ALOGD("%s%s", (char*) indent, OP_NAMES[op]); } @@ -844,6 +854,17 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level) renderer.drawText(text.text(), text.length(), count, x, y, paint, length); } break; + case DrawPosText: { + getText(&text); + int count = getInt(); + int positionsCount = 0; + float* positions = getFloats(positionsCount); + SkPaint* paint = getPaint(); + DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent, + OP_NAMES[op], text.text(), text.length(), count, paint); + renderer.drawPosText(text.text(), text.length(), count, positions, paint); + } + break; case ResetShader: { DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]); renderer.resetShader(); @@ -1216,6 +1237,17 @@ void DisplayListRenderer::drawText(const char* text, int bytesCount, int count, addFloat(length < 0.0f ? paint->measureText(text, bytesCount) : length); } +void DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count, + const float* positions, SkPaint* paint) { + if (count <= 0) return; + addOp(DisplayList::DrawPosText); + addText(text, bytesCount); + addInt(count); + addFloats(positions, count * 2); + paint->setAntiAlias(true); + addPaint(paint); +} + void DisplayListRenderer::resetShader() { addOp(DisplayList::ResetShader); } diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index 5d922db..dd7ec4f 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -96,6 +96,7 @@ public: DrawLines, DrawPoints, DrawText, + DrawPosText, ResetShader, SetupShader, ResetColorFilter, @@ -291,6 +292,8 @@ public: virtual void drawPoints(float* points, int count, SkPaint* paint); virtual void drawText(const char* text, int bytesCount, int count, float x, float y, SkPaint* paint, float length = 1.0f); + virtual void drawPosText(const char* text, int bytesCount, int count, const float* positions, + SkPaint* paint); virtual void resetShader(); virtual void setupShader(SkiaShader* shader); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 12ed205..6ec87f3 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2082,6 +2082,17 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, } } +void OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count, + const float* positions, SkPaint* paint) { + if (text == NULL || count == 0) { + return; + } + if (mSnapshot->isIgnored()) return; + + // TODO: implement properly + drawText(text, bytesCount, count, 0, 0, paint); +} + void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, float x, float y, SkPaint* paint, float length) { if (text == NULL || count == 0) { @@ -2120,10 +2131,11 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, y = (int) floorf(y + mSnapshot->transform->getTranslateY() + 0.5f); } - FontRenderer& fontRenderer = mCaches.fontRenderer.getFontRenderer(paint); #if DEBUG_GLYPHS ALOGD("OpenGLRenderer drawText() with FontID=%d", SkTypeface::UniqueID(paint->getTypeface())); #endif + + FontRenderer& fontRenderer = mCaches.fontRenderer.getFontRenderer(paint); fontRenderer.setFont(paint, SkTypeface::UniqueID(paint->getTypeface()), paint->getTextSize()); diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 019e9b2..a9cda47 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -124,6 +124,8 @@ public: virtual void drawPoints(float* points, int count, SkPaint* paint); virtual void drawText(const char* text, int bytesCount, int count, float x, float y, SkPaint* paint, float length = -1.0f); + virtual void drawPosText(const char* text, int bytesCount, int count, const float* positions, + SkPaint* paint); virtual void resetShader(); virtual void setupShader(SkiaShader* shader); |