Use Harfbuzz for Canvas drawText APIs

Change-Id: I661d5e9e0bbe9a859e7a000cb161994d29add099
This commit is contained in:
Fabrice Di Meglio
2011-04-18 18:33:48 -07:00
parent 4af51a14fe
commit b39d89735b

View File

@@ -743,7 +743,11 @@ public:
jcharArray text, int index, int count,
jfloat x, jfloat y, int flags, SkPaint* paint) {
jchar* textArray = env->GetCharArrayElements(text, NULL);
#if RTL_USE_HARFBUZZ
drawTextWithGlyphs(canvas, textArray + index, 0, count, x, y, flags, paint);
#else
TextLayout::drawText(paint, textArray + index, count, flags, x, y, canvas);
#endif
env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
}
@@ -752,7 +756,11 @@ public:
int start, int end,
jfloat x, jfloat y, int flags, SkPaint* paint) {
const jchar* textArray = env->GetStringChars(text, NULL);
#if RTL_USE_HARFBUZZ
drawTextWithGlyphs(canvas, textArray, start, end, x, y, flags, paint);
#else
TextLayout::drawText(paint, textArray + start, end - start, flags, x, y, canvas);
#endif
env->ReleaseStringChars(text, textArray);
}
@@ -781,6 +789,23 @@ public:
x, y, flags, paint);
}
static void drawTextWithGlyphs(SkCanvas* canvas, const jchar* textArray,
int start, int count, int contextCount,
jfloat x, jfloat y, int flags, SkPaint* paint) {
sp<TextLayoutCacheValue> value = gTextLayoutCache.getValue(
paint, textArray, start, count, contextCount, flags);
if (value == NULL) {
LOGE("drawTextWithGlyphs -- cannot get Cache value");
return ;
}
#if DEBUG_GLYPHS
logGlyphs(value);
#endif
doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(),
x, y, flags, paint);
}
static void drawTextWithGlyphs___CIIFFIPaint(JNIEnv* env, jobject, SkCanvas* canvas,
jcharArray text, int index, int count,
jfloat x, jfloat y, int flags, SkPaint* paint) {
@@ -831,8 +856,13 @@ public:
jfloat x, jfloat y, int dirFlags, SkPaint* paint) {
jchar* chars = env->GetCharArrayElements(text, NULL);
#if RTL_USE_HARFBUZZ
drawTextWithGlyphs(canvas, chars + contextIndex, index - contextIndex,
count, contextCount, x, y, dirFlags, paint);
#else
TextLayout::drawTextRun(paint, chars + contextIndex, index - contextIndex,
count, contextCount, dirFlags, x, y, canvas);
count, contextCount, dirFlags, x, y, canvas);
#endif
env->ReleaseCharArrayElements(text, chars, JNI_ABORT);
}
@@ -844,8 +874,13 @@ public:
jint count = end - start;
jint contextCount = contextEnd - contextStart;
const jchar* chars = env->GetStringChars(text, NULL);
#if RTL_USE_HARFBUZZ
drawTextWithGlyphs(canvas, chars + contextStart, start - contextStart,
count, contextCount, x, y, dirFlags, paint);
#else
TextLayout::drawTextRun(paint, chars + contextStart, start - contextStart,
count, contextCount, dirFlags, x, y, canvas);
count, contextCount, dirFlags, x, y, canvas);
#endif
env->ReleaseStringChars(text, chars);
}