summaryrefslogtreecommitdiffstats
path: root/core/jni/android_view_GLES20Canvas.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-02-24 16:48:34 -0800
committerRomain Guy <romainguy@google.com>2012-02-24 16:48:34 -0800
commit325740fb444af8fc7fb0119b2e30ce322c2ae134 (patch)
tree7739e7e56c5835f8f161e8cbed17346083390176 /core/jni/android_view_GLES20Canvas.cpp
parent34c55d30858cba1e58c38e7d8e175d25cf0b33c4 (diff)
downloadframeworks_base-325740fb444af8fc7fb0119b2e30ce322c2ae134.zip
frameworks_base-325740fb444af8fc7fb0119b2e30ce322c2ae134.tar.gz
frameworks_base-325740fb444af8fc7fb0119b2e30ce322c2ae134.tar.bz2
Add hooks to implement Canvas.drawTextOnPath() in GL
Change-Id: I165c9e05facf5365aa6850605688e538640c7fcc
Diffstat (limited to 'core/jni/android_view_GLES20Canvas.cpp')
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index cdce4f9..f0560c1 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -521,6 +521,20 @@ static void renderText(OpenGLRenderer* renderer, const jchar* text, int count,
renderer->drawText((const char*) glyphs, bytesCount, glyphsCount, x, y, paint);
}
+static void renderTextOnPath(OpenGLRenderer* renderer, const jchar* text, int count,
+ SkPath* path, jfloat hOffset, jfloat vOffset, int flags, SkPaint* paint) {
+ sp<TextLayoutValue> value = TextLayoutEngine::getInstance().getValue(paint,
+ text, 0, count, count, flags);
+ if (value == NULL) {
+ return;
+ }
+ const jchar* glyphs = value->getGlyphs();
+ size_t glyphsCount = value->getGlyphsCount();
+ int bytesCount = glyphsCount * sizeof(jchar);
+ renderer->drawTextOnPath((const char*) glyphs, bytesCount, glyphsCount, path,
+ hOffset, vOffset, paint);
+}
+
static void renderTextRun(OpenGLRenderer* renderer, const jchar* text,
jint start, jint count, jint contextCount, jfloat x, jfloat y,
int flags, SkPaint* paint) {
@@ -551,6 +565,24 @@ static void android_view_GLES20Canvas_drawText(JNIEnv* env, jobject clazz,
env->ReleaseStringChars(text, textArray);
}
+static void android_view_GLES20Canvas_drawTextArrayOnPath(JNIEnv* env, jobject clazz,
+ OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
+ SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) {
+ jchar* textArray = env->GetCharArrayElements(text, NULL);
+ renderTextOnPath(renderer, textArray + index, count, path,
+ hOffset, vOffset, flags, paint);
+ env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
+}
+
+static void android_view_GLES20Canvas_drawTextOnPath(JNIEnv* env, jobject clazz,
+ OpenGLRenderer* renderer, jstring text, jint start, jint end,
+ SkPath* path, jfloat hOffset, jfloat vOffset, jint flags, SkPaint* paint) {
+ const jchar* textArray = env->GetStringChars(text, NULL);
+ renderTextOnPath(renderer, textArray + start, end - start, path,
+ hOffset, vOffset, flags, paint);
+ env->ReleaseStringChars(text, textArray);
+}
+
static void android_view_GLES20Canvas_drawTextRunArray(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, jcharArray text, jint index, jint count,
jint contextIndex, jint contextCount, jfloat x, jfloat y, jint dirFlags,
@@ -885,6 +917,10 @@ static JNINativeMethod gMethods[] = {
{ "nDrawText", "(ILjava/lang/String;IIFFII)V",
(void*) android_view_GLES20Canvas_drawText },
+ { "nDrawTextOnPath", "(I[CIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextArrayOnPath },
+ { "nDrawTextOnPath", "(ILjava/lang/String;IIIFFII)V",
+ (void*) android_view_GLES20Canvas_drawTextOnPath },
+
{ "nDrawTextRun", "(I[CIIIIFFII)V", (void*) android_view_GLES20Canvas_drawTextRunArray },
{ "nDrawTextRun", "(ILjava/lang/String;IIIIFFII)V",
(void*) android_view_GLES20Canvas_drawTextRun },