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

Commit 0b860336 authored by Seigo Nonaka's avatar Seigo Nonaka Committed by android-build-merger
Browse files

Merge "Update JNI interface of GetBounds in PrecomputedText" into pi-dev

am: 42c68686

Change-Id: I734f1715092ec932f8fc5569c4ecadfc45d9ad66
parents cef38b38 42c68686
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -303,10 +303,9 @@ public class MeasuredParagraph {
     *
     * This is available only if the MeasuredParagraph is computed with buildForStaticLayout.
     */
    public void getBounds(@NonNull Paint paint, @IntRange(from = 0) int start,
            @IntRange(from = 0) int end, @NonNull Rect bounds) {
        nGetBounds(mNativePtr, mCopiedBuffer, paint.getNativeInstance(), start, end,
                paint.getBidiFlags(), bounds);
    public void getBounds(@IntRange(from = 0) int start, @IntRange(from = 0) int end,
            @NonNull Rect bounds) {
        nGetBounds(mNativePtr, mCopiedBuffer, start, end, bounds);
    }

    /**
@@ -743,6 +742,6 @@ public class MeasuredParagraph {
    @CriticalNative
    private static native int nGetMemoryUsage(/* Non Zero */ long nativePtr);

    private static native void nGetBounds(long nativePtr, char[] buf, long paintPtr, int start,
            int end, int bidiFlag, Rect rect);
    private static native void nGetBounds(long nativePtr, char[] buf, int start, int end,
            Rect rect);
}
+1 −2
Original line number Diff line number Diff line
@@ -515,8 +515,7 @@ public class PrecomputedText implements Spannable {
                + "para: (" + paraStart + ", " + paraEnd + "), "
                + "request: (" + start + ", " + end + ")");
        }
        getMeasuredParagraph(paraIndex).getBounds(mParams.mPaint,
                start - paraStart, end - paraStart, bounds);
        getMeasuredParagraph(paraIndex).getBounds(start - paraStart, end - paraStart, bounds);
    }

    /**
+5 −12
Original line number Diff line number Diff line
@@ -111,20 +111,13 @@ static jfloat nGetWidth(jlong ptr, jint start, jint end) {
}

// Regular JNI
static void nGetBounds(JNIEnv* env, jobject, jlong ptr, jcharArray javaText, jlong paintPtr,
                           jint start, jint end, jint bidiFlags, jobject bounds) {
static void nGetBounds(JNIEnv* env, jobject, jlong ptr, jcharArray javaText, jint start, jint end,
                       jobject bounds) {
    ScopedCharArrayRO text(env, javaText);
    const minikin::U16StringPiece textBuffer(text.get(), text.size());
    const minikin::Range range(start, end);

    minikin::MeasuredText* mt = toMeasuredParagraph(ptr);
    Paint* paint = toPaint(paintPtr);
    const Typeface* typeface = Typeface::resolveDefault(paint->getAndroidTypeface());
    minikin::Layout layout = MinikinUtils::doLayout(paint,
            static_cast<minikin::Bidi>(bidiFlags), typeface, textBuffer.data(), start, end - start,
            textBuffer.size(), mt);

    minikin::MinikinRect rect;
    layout.getBounds(&rect);
    minikin::MinikinRect rect = toMeasuredParagraph(ptr)->getBounds(textBuffer, range);

    SkRect r;
    r.fLeft = rect.mLeft;
@@ -156,7 +149,7 @@ static const JNINativeMethod gMethods[] = {

    // MeasuredParagraph native functions.
    {"nGetWidth", "(JII)F", (void*) nGetWidth},  // Critical Natives
    {"nGetBounds", "(J[CJIIILandroid/graphics/Rect;)V", (void*) nGetBounds},  // Regular JNI
    {"nGetBounds", "(J[CIILandroid/graphics/Rect;)V", (void*) nGetBounds},  // Regular JNI
    {"nGetReleaseFunc", "()J", (void*) nGetReleaseFunc},  // Critical Natives
    {"nGetMemoryUsage", "(J)I", (void*) nGetMemoryUsage},  // Critical Native
};