Revert "Reorganize MeasuredText API"

The last change needs more discussion and found some edge cases. Revert and make small step-by-step changes.

Bug: 73091756

This reverts commit 7fd36d19e3.

Change-Id: I89ff52a70cf6a5d6c553afa20f83719e1f9eb726
This commit is contained in:
Seigo Nonaka
2018-02-13 21:40:01 +00:00
parent acc788a952
commit 4e90fa262d
16 changed files with 639 additions and 816 deletions

View File

@@ -22,7 +22,7 @@ import android.annotation.Nullable;
import android.annotation.Size;
import android.graphics.Canvas.VertexMode;
import android.text.GraphicsOperations;
import android.text.PrecomputedText;
import android.text.MeasuredText;
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 PrecomputedText) {
PrecomputedText mt = (PrecomputedText) text;
if (text instanceof MeasuredText) {
MeasuredText mt = (MeasuredText) 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 nativePrecomputedText, int measuredTextOffset);
long nativeMeasuredText, 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);

View File

@@ -2835,16 +2835,6 @@ 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();
@@ -3012,6 +3002,4 @@ 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);
}