Add hooks to implement Canvas.drawTextOnPath() in GL
Change-Id: I165c9e05facf5365aa6850605688e538640c7fcc
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index f9088ac..8153823 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -61,6 +61,7 @@
"DrawLines",
"DrawPoints",
"DrawText",
+ "DrawTextOnPath",
"DrawPosText",
"ResetShader",
"SetupShader",
@@ -483,7 +484,7 @@
break;
case DrawText: {
getText(&text);
- int count = getInt();
+ int32_t count = getInt();
float x = getFloat();
float y = getFloat();
SkPaint* paint = getPaint(renderer);
@@ -492,6 +493,17 @@
text.text(), text.length(), count, x, y, paint, length);
}
break;
+ case DrawTextOnPath: {
+ getText(&text);
+ int32_t count = getInt();
+ SkPath* path = getPath();
+ float hOffset = getFloat();
+ float vOffset = getFloat();
+ SkPaint* paint = getPaint(renderer);
+ ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
+ text.text(), text.length(), count, paint);
+ }
+ break;
case DrawPosText: {
getText(&text);
int count = getInt();
@@ -890,6 +902,19 @@
renderer.drawText(text.text(), text.length(), count, x, y, paint, length);
}
break;
+ case DrawTextOnPath: {
+ getText(&text);
+ int32_t count = getInt();
+ SkPath* path = getPath();
+ float hOffset = getFloat();
+ float vOffset = getFloat();
+ SkPaint* paint = getPaint(renderer);
+ DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
+ text.text(), text.length(), count, paint);
+ renderer.drawTextOnPath(text.text(), text.length(), count, path,
+ hOffset, vOffset, paint);
+ }
+ break;
case DrawPosText: {
getText(&text);
int32_t count = getInt();
@@ -1331,6 +1356,19 @@
addSkip(location);
}
+void DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
+ SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
+ if (!text || count <= 0) return;
+ addOp(DisplayList::DrawTextOnPath);
+ addText(text, bytesCount);
+ addInt(count);
+ addPath(path);
+ addFloat(hOffset);
+ addFloat(vOffset);
+ paint->setAntiAlias(true);
+ addPaint(paint);
+}
+
void DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
const float* positions, SkPaint* paint) {
if (!text || count <= 0) return;
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 4a299c6..5d1b460 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -99,6 +99,7 @@
DrawLines,
DrawPoints,
DrawText,
+ DrawTextOnPath,
DrawPosText,
ResetShader,
SetupShader,
@@ -310,6 +311,8 @@
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 drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
+ float hOffset, float vOffset, SkPaint* paint);
virtual void drawPosText(const char* text, int bytesCount, int count, const float* positions,
SkPaint* paint);
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 55e2ca5..6f0f836 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -2292,6 +2292,11 @@
drawTextDecorations(text, bytesCount, length, oldX, oldY, paint);
}
+void OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
+ float hOffset, float vOffset, SkPaint* paint) {
+ // TODO: Implement
+}
+
void OpenGLRenderer::drawPath(SkPath* path, SkPaint* paint) {
if (mSnapshot->isIgnored()) return;
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 3f63c3fe..4d7a491 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -124,8 +124,10 @@
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 drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
+ float hOffset, float vOffset, SkPaint* paint);
+ virtual void drawPosText(const char* text, int bytesCount, int count,
+ const float* positions, SkPaint* paint);
virtual void resetShader();
virtual void setupShader(SkiaShader* shader);