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

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

Merge "Clean test APIs for Harfbuzz support"

parents 054d5c57 796cc962
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -799,24 +799,6 @@ public:
                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) {
        jchar* textArray = env->GetCharArrayElements(text, NULL);
        drawTextWithGlyphs(canvas, textArray + index, 0, count, x, y, flags, paint);
        env->ReleaseCharArrayElements(text, textArray, JNI_ABORT);
    }

    static void drawTextWithGlyphs__StringIIFFIPaint(JNIEnv* env, jobject,
                                          SkCanvas* canvas, jstring text,
                                          int start, int end,
                                          jfloat x, jfloat y, int flags, SkPaint* paint) {

        const jchar* textArray = env->GetStringChars(text, NULL);
        drawTextWithGlyphs(canvas, textArray, start, end, x, y, flags, paint);
        env->ReleaseStringChars(text, textArray);
    }

    static void doDrawGlyphs(SkCanvas* canvas, const jchar* glyphArray, int index, int count,
            jfloat x, jfloat y, int flags, SkPaint* paint) {
        // TODO: need to suppress this code after the GL renderer is modified for not
@@ -833,16 +815,6 @@ public:
        paint->setTextEncoding(oldEncoding);
    }

    static void drawGlyphs___CIIFFIPaint(JNIEnv* env, jobject, SkCanvas* canvas,
                                         jcharArray glyphs, int index, int count,
                                         jfloat x, jfloat y, int flags, SkPaint* paint) {
        jchar* glyphArray = env->GetCharArrayElements(glyphs, NULL);

        doDrawGlyphs(canvas, glyphArray, index, count, x, y, flags, paint);

        env->ReleaseCharArrayElements(glyphs, glyphArray, JNI_ABORT);
    }

    static void drawTextRun___CIIIIFFIPaint(
        JNIEnv* env, jobject, SkCanvas* canvas, jcharArray text, int index,
        int count, int contextIndex, int contextCount,
@@ -1044,12 +1016,6 @@ static JNINativeMethod gCanvasMethods[] = {
        (void*) SkCanvasGlue::drawText___CIIFFIPaint},
    {"native_drawText","(ILjava/lang/String;IIFFII)V",
        (void*) SkCanvasGlue::drawText__StringIIFFIPaint},
    {"native_drawTextWithGlyphs","(I[CIIFFII)V",
        (void*) SkCanvasGlue::drawTextWithGlyphs___CIIFFIPaint},
    {"native_drawTextWithGlyphs","(ILjava/lang/String;IIFFII)V",
        (void*) SkCanvasGlue::drawTextWithGlyphs__StringIIFFIPaint},
    {"native_drawGlyphs","(I[CIIFFII)V",
        (void*) SkCanvasGlue::drawGlyphs___CIIFFIPaint},
    {"native_drawTextRun","(I[CIIIIFFII)V",
        (void*) SkCanvasGlue::drawTextRun___CIIIIFFIPaint},
    {"native_drawTextRun","(ILjava/lang/String;IIIIFFII)V",
+1 −75
Original line number Diff line number Diff line
@@ -1420,70 +1420,6 @@ public class Canvas {
        }
    }

    /**
     * Draw the text, with origin at (x,y), using the specified paint. The
     * origin is interpreted based on the Align setting in the paint.
     *
     * @param text  The text to be drawn
     * @param x     The x-coordinate of the origin of the text being drawn
     * @param y     The y-coordinate of the origin of the text being drawn
     * @param paint The paint used for the text (e.g. color, size, style)
     *
     * @hide
     *
     * Used only for BiDi / RTL Tests
     */
    public void drawTextWithGlyphs(char[] text, int index, int count, float x, float y,
                         Paint paint) {
        if ((index | count | (index + count) |
            (text.length - index - count)) < 0) {
            throw new IndexOutOfBoundsException();
        }
        native_drawTextWithGlyphs(mNativeCanvas, text, index, count, x, y, paint.mBidiFlags,
                paint.mNativePaint);
    }

    /**
     * Draw the text, with origin at (x,y), using the specified paint. The
     * origin is interpreted based on the Align setting in the paint.
     *
     * @param text  The text to be drawn
     * @param x     The x-coordinate of the origin of the text being drawn
     * @param y     The y-coordinate of the origin of the text being drawn
     * @param paint The paint used for the text (e.g. color, size, style)
     *
     * @hide
     *
     * Used only for BiDi / RTL Tests
     */
    public void drawTextWithGlyphs(String text, float x, float y, Paint paint) {
        native_drawTextWithGlyphs(mNativeCanvas, text, 0, text.length(), x, y, paint.mBidiFlags,
                paint.mNativePaint);
    }

    /**
     * Draw the glyphs, with origin at (x,y), using the specified paint. The
     * origin is interpreted based on the Align setting in the paint.
     *
     * @param glyphs The glyphs to be drawn
     * @param x      The x-coordinate of the origin of the text being drawn
     * @param y      The y-coordinate of the origin of the text being drawn
     * @param paint  The paint used for the text (e.g. color, size, style)
     *
     * @hide
     *
     * Used only for BiDi / RTL Tests
     */
    public void drawGlyphs(char[] glyphs, int index, int count, float x, float y,
                         Paint paint) {
        if ((index | count | (index + count) |
            (glyphs.length - index - count)) < 0) {
            throw new IndexOutOfBoundsException();
        }
        native_drawGlyphs(mNativeCanvas, glyphs, index, count, x, y, paint.mBidiFlags,
                paint.mNativePaint);
    }

    /**
     * Render a run of all LTR or all RTL text, with shaping. This does not run
     * bidi on the provided text, but renders it as a uniform right-to-left or
@@ -1813,16 +1749,6 @@ public class Canvas {
                                               int start, int end, float x,
                                               float y, int flags, int paint);

    private static native void native_drawTextWithGlyphs(int nativeCanvas, char[] text,
                                               int index, int count, float x,
                                               float y, int flags, int paint);
    private static native void native_drawTextWithGlyphs(int nativeCanvas, String text,
                                               int start, int end, float x,
                                               float y, int flags, int paint);
    private static native void native_drawGlyphs(int nativeCanvas, char[] glyphs,
                                               int index, int count, float x,
                                               float y, int flags, int paint);

    private static native void native_drawTextRun(int nativeCanvas, String text,
            int start, int end, int contextStart, int contextEnd,
            float x, float y, int flags, int paint);
+4 −28
Original line number Diff line number Diff line
@@ -168,15 +168,11 @@ public class BiDiTestView extends View {
        drawMetricsAroundText(canvas, x, y, textWidthHB, textWidthICU, textSize, Color.RED, Color.GREEN);

        paint.setColor(Color.WHITE);
//        char[] glyphs = new char[2*length];
//        int count = getGlyphs(text, glyphs, dir);
//
//        logGlypths(glyphs, count);
//        drawTextWithDrawGlyph(canvas, glyphs, count, x, y + currentTextSize);

        Log.v(TAG, "START -- drawTextWithGlyphs");
        drawTextWithGlyphs(canvas, text, x, y + currentTextSize, dir);
        Log.v(TAG, "END   -- drawTextWithGlyphs");
        Log.v(TAG, "START -- drawText");
        setPaintDir(paint, dir);
        canvas.drawText(text, x, y + currentTextSize, this.paint);
        Log.v(TAG, "END   -- drawText");

        // Restore old paint properties
        paint.setFakeBoldText(oldFakeBold);
@@ -190,26 +186,6 @@ public class BiDiTestView extends View {
        paint.setBidiFlags(dir);
    }

    private void drawTextWithDrawGlyph(Canvas canvas, char[] glyphs, int count, int x, int y) {
        canvas.drawGlyphs(glyphs, 0, count, x, y, paint);
    }

    private void drawTextWithGlyphs(Canvas canvas, String text, int x, int y, int dir) {
        setPaintDir(paint, dir);
        canvas.drawTextWithGlyphs(text, x, y, paint);
    }

    private void logGlypths(char[] glyphs, int count) {
        Log.v(TAG, "GlyphIds - count=" + count);
        for (int n = 0; n < count; n++) {
            Log.v(TAG, "GlyphIds - Id[" + n + "]="+ (int)glyphs[n]);
        }
    }

    private int getGlyphs(String text, char[] glyphs, int dir) {
        return paint.getTextGlypths(text, 0, text.length(), 0, text.length(), dir, glyphs);
    }

    private void drawInsideRect(Canvas canvas, int color) {
        paint.setColor(color);
        int width = getWidth();