Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f048419 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android (Google) Code Review
Browse files

Merge "Use Harfbuzz for Canvas drawText APIs"

parents 9bf2d9e1 b39d8973
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -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);
#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);
#endif
        env->ReleaseStringChars(text, chars);
    }