Reorganize MeasuredText API (2nd)
This is 2nd attempt of I7db9e2ca4db68a16648cfb8fcf63555f501304c2
This CL changes the MeasuredText API:
- Rename MeasuredText to PrecomputedText.
- Introduce PrecomputedText.Param which holds all text layout parameters.
- Add API to get PrecomputedText.Param from TextView.
- Remove MeasuredText.Builder and add PrecomputedText.create method instead.
- Remove setRange from MeasuredText since it is not for normal use case.
(It can not be used for TextView)
Bug: 67504091
Bug: 72861572
Test: bit FrameworksCoreTests:android.text.
Test: atest CtsWidgetTestCases:EditTextTest \
CtsWidgetTestCases:TextViewFadingEdgeTest \
FrameworksCoreTests:TextViewFallbackLineSpacingTest \
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \
CtsTextTestCases
Change-Id: Ie73bce52c6c673cda58973ddad04627a7cf2e5e9
This commit is contained in:
@@ -22,7 +22,7 @@ import android.annotation.Nullable;
|
||||
import android.annotation.Size;
|
||||
import android.graphics.Canvas.VertexMode;
|
||||
import android.text.GraphicsOperations;
|
||||
import android.text.MeasuredText;
|
||||
import android.text.PrecomputedText;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannedString;
|
||||
import android.text.TextUtils;
|
||||
@@ -487,8 +487,8 @@ public abstract class BaseCanvas {
|
||||
TextUtils.getChars(text, contextStart, contextEnd, buf, 0);
|
||||
long measuredTextPtr = 0;
|
||||
int measuredTextOffset = 0;
|
||||
if (text instanceof MeasuredText) {
|
||||
MeasuredText mt = (MeasuredText) text;
|
||||
if (text instanceof PrecomputedText) {
|
||||
PrecomputedText mt = (PrecomputedText) text;
|
||||
int paraIndex = mt.findParaIndex(start);
|
||||
if (end <= mt.getParagraphEnd(paraIndex)) {
|
||||
// Only suppor the same paragraph.
|
||||
@@ -647,7 +647,7 @@ public abstract class BaseCanvas {
|
||||
|
||||
private static native void nDrawTextRun(long nativeCanvas, char[] text, int start, int count,
|
||||
int contextStart, int contextCount, float x, float y, boolean isRtl, long nativePaint,
|
||||
long nativeMeasuredText, int measuredTextOffset);
|
||||
long nativePrecomputedText, int measuredTextOffset);
|
||||
|
||||
private static native void nDrawTextOnPath(long nativeCanvas, char[] text, int index, int count,
|
||||
long nativePath, float hOffset, float vOffset, int bidiFlags, long nativePaint);
|
||||
|
||||
@@ -2835,6 +2835,16 @@ public class Paint {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true of the passed {@link Paint} will have the same effect on text measurement
|
||||
*
|
||||
* @param other A {@link Paint} object.
|
||||
* @return true if the other {@link Paint} has the same effect on text measurement.
|
||||
*/
|
||||
public boolean equalsForTextMeasurement(@NonNull Paint other) {
|
||||
return nEqualsForTextMeasurement(mNativePaint, other.mNativePaint);
|
||||
}
|
||||
|
||||
// regular JNI
|
||||
private static native long nGetNativeFinalizer();
|
||||
private static native long nInit();
|
||||
@@ -3002,4 +3012,6 @@ public class Paint {
|
||||
private static native float nGetStrikeThruThickness(long paintPtr);
|
||||
@CriticalNative
|
||||
private static native void nSetTextSize(long paintPtr, float textSize);
|
||||
@CriticalNative
|
||||
private static native boolean nEqualsForTextMeasurement(long leftPaintPtr, long rightPaintPtr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user