Update JNI interface of GetBounds in PrecomputedText
Bug: 77495049
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest
Change-Id: I54a70a91f6fba90720b702b52ed6ad430e17c87d
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user