Loading core/java/android/text/GraphicsOperations.java +2 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ extends CharSequence * Just like {@link Paint#getTextRunAdvances}. * @hide */ float getTextRunAdvancesICU(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, Paint paint); float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, Paint paint, int reserved); /** * Just like {@link Paint#getTextRunCursor}. Loading core/java/android/text/SpannableStringBuilder.java +8 −8 Original line number Diff line number Diff line Loading @@ -1173,8 +1173,8 @@ implements CharSequence, GetChars, Spannable, Editable, Appendable, * Don't call this yourself -- exists for Paint to use internally. * {@hide} */ public float getTextRunAdvancesICU(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesPos, Paint p) { public float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesPos, Paint p, int reserved) { float ret; Loading @@ -1182,16 +1182,16 @@ implements CharSequence, GetChars, Spannable, Editable, Appendable, int len = end - start; if (end <= mGapStart) { ret = p.getTextRunAdvancesICU(mText, start, len, contextStart, contextLen, flags, advances, advancesPos); ret = p.getTextRunAdvances(mText, start, len, contextStart, contextLen, flags, advances, advancesPos, reserved); } else if (start >= mGapStart) { ret = p.getTextRunAdvancesICU(mText, start + mGapLength, len, contextStart + mGapLength, contextLen, flags, advances, advancesPos); ret = p.getTextRunAdvances(mText, start + mGapLength, len, contextStart + mGapLength, contextLen, flags, advances, advancesPos, reserved); } else { char[] buf = TextUtils.obtain(contextLen); getChars(contextStart, contextEnd, buf, 0); ret = p.getTextRunAdvancesICU(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesPos); ret = p.getTextRunAdvances(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesPos, reserved); TextUtils.recycle(buf); } Loading core/java/android/widget/TextView.java +4 −4 Original line number Diff line number Diff line Loading @@ -2967,14 +2967,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener advancesIndex); } public float getTextRunAdvancesICU(int start, int end, int contextStart, public float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, Paint p) { Paint p, int reserved) { int count = end - start; int contextCount = contextEnd - contextStart; return p.getTextRunAdvancesICU(mChars, start + mStart, count, return p.getTextRunAdvances(mChars, start + mStart, count, contextStart + mStart, contextCount, flags, advances, advancesIndex); advancesIndex, reserved); } public int getTextRunCursor(int contextStart, int contextEnd, int flags, Loading core/jni/android/graphics/Paint.cpp +20 −38 Original line number Diff line number Diff line Loading @@ -482,44 +482,28 @@ public: return totalAdvance; } static float getTextRunAdvances___CIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, static float getTextRunAdvances___CIIIII_FII(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, jint index, jint count, jint contextIndex, jint contextCount, jint flags, jfloatArray advances, jint advancesIndex) { jint flags, jfloatArray advances, jint advancesIndex, jint reserved) { jchar* textArray = env->GetCharArrayElements(text, NULL); jfloat result = doTextRunAdvances(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex); jfloat result = (reserved == 0) ? doTextRunAdvances(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex) : doTextRunAdvancesICU(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex); env->ReleaseCharArrayElements(text, textArray, JNI_ABORT); return result; } static float getTextRunAdvances__StringIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, static float getTextRunAdvances__StringIIIII_FII(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags, jfloatArray advances, jint advancesIndex) { const jchar* textArray = env->GetStringChars(text, NULL); jfloat result = doTextRunAdvances(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex); env->ReleaseStringChars(text, textArray); return result; } static float getTextRunAdvancesICU___CIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, jint index, jint count, jint contextIndex, jint contextCount, jint flags, jfloatArray advances, jint advancesIndex) { jchar* textArray = env->GetCharArrayElements(text, NULL); jfloat result = doTextRunAdvancesICU(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex); env->ReleaseCharArrayElements(text, textArray, JNI_ABORT); return result; } static float getTextRunAdvancesICU__StringIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags, jfloatArray advances, jint advancesIndex) { jfloatArray advances, jint advancesIndex, jint reserved) { const jchar* textArray = env->GetStringChars(text, NULL); jfloat result = doTextRunAdvancesICU(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex); jfloat result = (reserved == 0) ? doTextRunAdvances(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex) : doTextRunAdvancesICU(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex); env->ReleaseStringChars(text, textArray); return result; } Loading Loading @@ -816,14 +800,12 @@ static JNINativeMethod methods[] = { {"native_breakText","(Ljava/lang/String;ZF[F)I", (void*) SkPaintGlue::breakTextS}, {"native_getTextWidths","(I[CII[F)I", (void*) SkPaintGlue::getTextWidths___CII_F}, {"native_getTextWidths","(ILjava/lang/String;II[F)I", (void*) SkPaintGlue::getTextWidths__StringII_F}, {"native_getTextRunAdvances","(I[CIIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvances___CIIIII_FI}, {"native_getTextRunAdvances","(ILjava/lang/String;IIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvances__StringIIIII_FI}, {"native_getTextRunAdvancesICU","(I[CIIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvancesICU___CIIIII_FI}, {"native_getTextRunAdvancesICU","(ILjava/lang/String;IIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvancesICU__StringIIIII_FI}, {"native_getTextRunAdvances","(I[CIIIII[FII)F", (void*) SkPaintGlue::getTextRunAdvances___CIIIII_FII}, {"native_getTextRunAdvances","(ILjava/lang/String;IIIII[FII)F", (void*) SkPaintGlue::getTextRunAdvances__StringIIIII_FII}, {"native_getTextGlyphs","(ILjava/lang/String;IIIII[C)I", (void*) SkPaintGlue::getTextGlyphs__StringIIIII_C}, {"native_getTextRunCursor", "(I[CIIIII)I", (void*) SkPaintGlue::getTextRunCursor___C}, Loading graphics/java/android/graphics/Paint.java +68 −113 Original line number Diff line number Diff line Loading @@ -1501,48 +1501,20 @@ public class Paint { public float getTextRunAdvances(char[] chars, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { if ((index | count | contextIndex | contextCount | advancesIndex | (index - contextIndex) | ((contextIndex + contextCount) - (index + count)) | (chars.length - (contextIndex + contextCount)) | (advances == null ? 0 : (advances.length - (advancesIndex + count)))) < 0) { throw new IndexOutOfBoundsException(); } if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) { throw new IllegalArgumentException("unknown flags value: " + flags); } if (!mHasCompatScaling) { return native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float res = native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); setTextSize(oldSize); if (advances != null) { for (int i = advancesIndex, e = i + count; i < e; i++) { advances[i] *= mInvCompatScaling; } } return res * mInvCompatScaling; // assume errors are not significant return getTextRunAdvances(chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex, 0 /* use Harfbuzz*/); } /** * Convenience overload that takes a char array instead of a * String. * * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int) * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int, int) * @hide */ public float getTextRunAdvancesICU(char[] chars, int index, int count, public float getTextRunAdvances(char[] chars, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { int advancesIndex, int reserved) { if ((index | count | contextIndex | contextCount | advancesIndex | (index - contextIndex) Loading @@ -1557,14 +1529,14 @@ public class Paint { } if (!mHasCompatScaling) { return native_getTextRunAdvancesICU(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); return native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex, reserved); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float res = native_getTextRunAdvancesICU(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); float res = native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex, reserved); setTextSize(oldSize); if (advances != null) { Loading @@ -1585,29 +1557,8 @@ public class Paint { public float getTextRunAdvances(CharSequence text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { if (text instanceof String) { return getTextRunAdvances((String) text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); } if (text instanceof SpannedString || text instanceof SpannableString) { return getTextRunAdvances(text.toString(), start, end, contextStart, contextEnd, flags, advances, advancesIndex); } if (text instanceof GraphicsOperations) { return ((GraphicsOperations) text).getTextRunAdvances(start, end, contextStart, contextEnd, flags, advances, advancesIndex, this); } int contextLen = contextEnd - contextStart; int len = end - start; char[] buf = TemporaryBuffer.obtain(contextLen); TextUtils.getChars(text, start, end, buf, 0); float result = getTextRunAdvances(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesIndex); TemporaryBuffer.recycle(buf); return result; return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, 0 /* use Harfbuzz */); } /** Loading @@ -1617,21 +1568,21 @@ public class Paint { * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int) * @hide */ public float getTextRunAdvancesICU(CharSequence text, int start, int end, public float getTextRunAdvances(CharSequence text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { int advancesIndex, int reserved) { if (text instanceof String) { return getTextRunAdvancesICU((String) text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); return getTextRunAdvances((String) text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, reserved); } if (text instanceof SpannedString || text instanceof SpannableString) { return getTextRunAdvancesICU(text.toString(), start, end, contextStart, contextEnd, flags, advances, advancesIndex); return getTextRunAdvances(text.toString(), start, end, contextStart, contextEnd, flags, advances, advancesIndex, reserved); } if (text instanceof GraphicsOperations) { return ((GraphicsOperations) text).getTextRunAdvancesICU(start, end, return ((GraphicsOperations) text).getTextRunAdvances(start, end, contextStart, contextEnd, flags, advances, advancesIndex, this); } Loading @@ -1639,8 +1590,8 @@ public class Paint { int len = end - start; char[] buf = TemporaryBuffer.obtain(contextLen); TextUtils.getChars(text, start, end, buf, 0); float result = getTextRunAdvancesICU(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesIndex); float result = getTextRunAdvances(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesIndex, reserved); TemporaryBuffer.recycle(buf); return result; } Loading Loading @@ -1689,44 +1640,55 @@ public class Paint { */ public float getTextRunAdvances(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { if ((start | end | contextStart | contextEnd | advancesIndex | (end - start) | (start - contextStart) | (contextEnd - end) | (text.length() - contextEnd) | (advances == null ? 0 : (advances.length - advancesIndex - (end - start)))) < 0) { throw new IndexOutOfBoundsException(); } if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) { throw new IllegalArgumentException("unknown flags value: " + flags); } if (!mHasCompatScaling) { return native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float totalAdvance = native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); setTextSize(oldSize); if (advances != null) { for (int i = advancesIndex, e = i + (end - start); i < e; i++) { advances[i] *= mInvCompatScaling; } } return totalAdvance * mInvCompatScaling; // assume errors are insignificant return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, 0 /* use Harfbuzz*/); } /** * Temporary - DO NOT USE * Returns the total advance width for the characters in the run * between start and end, and if advances is not null, the advance * assigned to each of these characters (java chars). * * <p>The trailing surrogate in a valid surrogate pair is assigned * an advance of 0. Thus the number of returned advances is * always equal to count, not to the number of unicode codepoints * represented by the run. * * <p>In the case of conjuncts or combining marks, the total * advance is assigned to the first logical character, and the * following characters are assigned an advance of 0. * * <p>This generates the sum of the advances of glyphs for * characters in a reordered cluster as the width of the first * logical character in the cluster, and 0 for the widths of all * other characters in the cluster. In effect, such clusters are * treated like conjuncts. * * <p>The shaping bounds limit the amount of context available * outside start and end that can be used for shaping analysis. * These bounds typically reflect changes in bidi level or font * metrics across which shaping does not occur. * * @param text the text to measure * @param start the index of the first character to measure * @param end the index past the last character to measure * @param contextStart the index of the first character to use for shaping context, * must be <= start * @param contextEnd the index past the last character to use for shaping context, * must be >= end * @param flags the flags to control the advances, either {@link #DIRECTION_LTR} * or {@link #DIRECTION_RTL} * @param advances array to receive the advances, must have room for all advances, * can be null if only total advance is needed * @param advancesIndex the position in advances at which to put the * advance corresponding to the character at start * @param reserved int reserved value * @return the total advance * * @hide */ public float getTextRunAdvancesICU(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { public float getTextRunAdvances(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, int reserved) { if ((start | end | contextStart | contextEnd | advancesIndex | (end - start) | (start - contextStart) | (contextEnd - end) Loading @@ -1740,14 +1702,14 @@ public class Paint { } if (!mHasCompatScaling) { return native_getTextRunAdvancesICU(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); return native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, reserved); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float totalAdvance = native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); contextStart, contextEnd, flags, advances, advancesIndex, reserved); setTextSize(oldSize); if (advances != null) { Loading Loading @@ -2017,17 +1979,10 @@ public class Paint { private static native float native_getTextRunAdvances(int native_object, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex); int flags, float[] advances, int advancesIndex, int reserved); private static native float native_getTextRunAdvances(int native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex); private static native float native_getTextRunAdvancesICU(int native_object, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex); private static native float native_getTextRunAdvancesICU(int native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex); int flags, float[] advances, int advancesIndex, int reserved); private native int native_getTextRunCursor(int native_object, char[] text, int contextStart, int contextLength, int flags, int offset, int cursorOpt); Loading Loading
core/java/android/text/GraphicsOperations.java +2 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ extends CharSequence * Just like {@link Paint#getTextRunAdvances}. * @hide */ float getTextRunAdvancesICU(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, Paint paint); float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, Paint paint, int reserved); /** * Just like {@link Paint#getTextRunCursor}. Loading
core/java/android/text/SpannableStringBuilder.java +8 −8 Original line number Diff line number Diff line Loading @@ -1173,8 +1173,8 @@ implements CharSequence, GetChars, Spannable, Editable, Appendable, * Don't call this yourself -- exists for Paint to use internally. * {@hide} */ public float getTextRunAdvancesICU(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesPos, Paint p) { public float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesPos, Paint p, int reserved) { float ret; Loading @@ -1182,16 +1182,16 @@ implements CharSequence, GetChars, Spannable, Editable, Appendable, int len = end - start; if (end <= mGapStart) { ret = p.getTextRunAdvancesICU(mText, start, len, contextStart, contextLen, flags, advances, advancesPos); ret = p.getTextRunAdvances(mText, start, len, contextStart, contextLen, flags, advances, advancesPos, reserved); } else if (start >= mGapStart) { ret = p.getTextRunAdvancesICU(mText, start + mGapLength, len, contextStart + mGapLength, contextLen, flags, advances, advancesPos); ret = p.getTextRunAdvances(mText, start + mGapLength, len, contextStart + mGapLength, contextLen, flags, advances, advancesPos, reserved); } else { char[] buf = TextUtils.obtain(contextLen); getChars(contextStart, contextEnd, buf, 0); ret = p.getTextRunAdvancesICU(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesPos); ret = p.getTextRunAdvances(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesPos, reserved); TextUtils.recycle(buf); } Loading
core/java/android/widget/TextView.java +4 −4 Original line number Diff line number Diff line Loading @@ -2967,14 +2967,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener advancesIndex); } public float getTextRunAdvancesICU(int start, int end, int contextStart, public float getTextRunAdvances(int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, Paint p) { Paint p, int reserved) { int count = end - start; int contextCount = contextEnd - contextStart; return p.getTextRunAdvancesICU(mChars, start + mStart, count, return p.getTextRunAdvances(mChars, start + mStart, count, contextStart + mStart, contextCount, flags, advances, advancesIndex); advancesIndex, reserved); } public int getTextRunCursor(int contextStart, int contextEnd, int flags, Loading
core/jni/android/graphics/Paint.cpp +20 −38 Original line number Diff line number Diff line Loading @@ -482,44 +482,28 @@ public: return totalAdvance; } static float getTextRunAdvances___CIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, static float getTextRunAdvances___CIIIII_FII(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, jint index, jint count, jint contextIndex, jint contextCount, jint flags, jfloatArray advances, jint advancesIndex) { jint flags, jfloatArray advances, jint advancesIndex, jint reserved) { jchar* textArray = env->GetCharArrayElements(text, NULL); jfloat result = doTextRunAdvances(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex); jfloat result = (reserved == 0) ? doTextRunAdvances(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex) : doTextRunAdvancesICU(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex); env->ReleaseCharArrayElements(text, textArray, JNI_ABORT); return result; } static float getTextRunAdvances__StringIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, static float getTextRunAdvances__StringIIIII_FII(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags, jfloatArray advances, jint advancesIndex) { const jchar* textArray = env->GetStringChars(text, NULL); jfloat result = doTextRunAdvances(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex); env->ReleaseStringChars(text, textArray); return result; } static float getTextRunAdvancesICU___CIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, jint index, jint count, jint contextIndex, jint contextCount, jint flags, jfloatArray advances, jint advancesIndex) { jchar* textArray = env->GetCharArrayElements(text, NULL); jfloat result = doTextRunAdvancesICU(env, paint, textArray + contextIndex, index - contextIndex, count, contextCount, flags, advances, advancesIndex); env->ReleaseCharArrayElements(text, textArray, JNI_ABORT); return result; } static float getTextRunAdvancesICU__StringIIIII_FI(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, jint start, jint end, jint contextStart, jint contextEnd, jint flags, jfloatArray advances, jint advancesIndex) { jfloatArray advances, jint advancesIndex, jint reserved) { const jchar* textArray = env->GetStringChars(text, NULL); jfloat result = doTextRunAdvancesICU(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex); jfloat result = (reserved == 0) ? doTextRunAdvances(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex) : doTextRunAdvancesICU(env, paint, textArray + contextStart, start - contextStart, end - start, contextEnd - contextStart, flags, advances, advancesIndex); env->ReleaseStringChars(text, textArray); return result; } Loading Loading @@ -816,14 +800,12 @@ static JNINativeMethod methods[] = { {"native_breakText","(Ljava/lang/String;ZF[F)I", (void*) SkPaintGlue::breakTextS}, {"native_getTextWidths","(I[CII[F)I", (void*) SkPaintGlue::getTextWidths___CII_F}, {"native_getTextWidths","(ILjava/lang/String;II[F)I", (void*) SkPaintGlue::getTextWidths__StringII_F}, {"native_getTextRunAdvances","(I[CIIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvances___CIIIII_FI}, {"native_getTextRunAdvances","(ILjava/lang/String;IIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvances__StringIIIII_FI}, {"native_getTextRunAdvancesICU","(I[CIIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvancesICU___CIIIII_FI}, {"native_getTextRunAdvancesICU","(ILjava/lang/String;IIIII[FI)F", (void*) SkPaintGlue::getTextRunAdvancesICU__StringIIIII_FI}, {"native_getTextRunAdvances","(I[CIIIII[FII)F", (void*) SkPaintGlue::getTextRunAdvances___CIIIII_FII}, {"native_getTextRunAdvances","(ILjava/lang/String;IIIII[FII)F", (void*) SkPaintGlue::getTextRunAdvances__StringIIIII_FII}, {"native_getTextGlyphs","(ILjava/lang/String;IIIII[C)I", (void*) SkPaintGlue::getTextGlyphs__StringIIIII_C}, {"native_getTextRunCursor", "(I[CIIIII)I", (void*) SkPaintGlue::getTextRunCursor___C}, Loading
graphics/java/android/graphics/Paint.java +68 −113 Original line number Diff line number Diff line Loading @@ -1501,48 +1501,20 @@ public class Paint { public float getTextRunAdvances(char[] chars, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { if ((index | count | contextIndex | contextCount | advancesIndex | (index - contextIndex) | ((contextIndex + contextCount) - (index + count)) | (chars.length - (contextIndex + contextCount)) | (advances == null ? 0 : (advances.length - (advancesIndex + count)))) < 0) { throw new IndexOutOfBoundsException(); } if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) { throw new IllegalArgumentException("unknown flags value: " + flags); } if (!mHasCompatScaling) { return native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float res = native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); setTextSize(oldSize); if (advances != null) { for (int i = advancesIndex, e = i + count; i < e; i++) { advances[i] *= mInvCompatScaling; } } return res * mInvCompatScaling; // assume errors are not significant return getTextRunAdvances(chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex, 0 /* use Harfbuzz*/); } /** * Convenience overload that takes a char array instead of a * String. * * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int) * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int, int) * @hide */ public float getTextRunAdvancesICU(char[] chars, int index, int count, public float getTextRunAdvances(char[] chars, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex) { int advancesIndex, int reserved) { if ((index | count | contextIndex | contextCount | advancesIndex | (index - contextIndex) Loading @@ -1557,14 +1529,14 @@ public class Paint { } if (!mHasCompatScaling) { return native_getTextRunAdvancesICU(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); return native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex, reserved); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float res = native_getTextRunAdvancesICU(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex); float res = native_getTextRunAdvances(mNativePaint, chars, index, count, contextIndex, contextCount, flags, advances, advancesIndex, reserved); setTextSize(oldSize); if (advances != null) { Loading @@ -1585,29 +1557,8 @@ public class Paint { public float getTextRunAdvances(CharSequence text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { if (text instanceof String) { return getTextRunAdvances((String) text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); } if (text instanceof SpannedString || text instanceof SpannableString) { return getTextRunAdvances(text.toString(), start, end, contextStart, contextEnd, flags, advances, advancesIndex); } if (text instanceof GraphicsOperations) { return ((GraphicsOperations) text).getTextRunAdvances(start, end, contextStart, contextEnd, flags, advances, advancesIndex, this); } int contextLen = contextEnd - contextStart; int len = end - start; char[] buf = TemporaryBuffer.obtain(contextLen); TextUtils.getChars(text, start, end, buf, 0); float result = getTextRunAdvances(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesIndex); TemporaryBuffer.recycle(buf); return result; return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, 0 /* use Harfbuzz */); } /** Loading @@ -1617,21 +1568,21 @@ public class Paint { * @see #getTextRunAdvances(String, int, int, int, int, int, float[], int) * @hide */ public float getTextRunAdvancesICU(CharSequence text, int start, int end, public float getTextRunAdvances(CharSequence text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { int advancesIndex, int reserved) { if (text instanceof String) { return getTextRunAdvancesICU((String) text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); return getTextRunAdvances((String) text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, reserved); } if (text instanceof SpannedString || text instanceof SpannableString) { return getTextRunAdvancesICU(text.toString(), start, end, contextStart, contextEnd, flags, advances, advancesIndex); return getTextRunAdvances(text.toString(), start, end, contextStart, contextEnd, flags, advances, advancesIndex, reserved); } if (text instanceof GraphicsOperations) { return ((GraphicsOperations) text).getTextRunAdvancesICU(start, end, return ((GraphicsOperations) text).getTextRunAdvances(start, end, contextStart, contextEnd, flags, advances, advancesIndex, this); } Loading @@ -1639,8 +1590,8 @@ public class Paint { int len = end - start; char[] buf = TemporaryBuffer.obtain(contextLen); TextUtils.getChars(text, start, end, buf, 0); float result = getTextRunAdvancesICU(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesIndex); float result = getTextRunAdvances(buf, start - contextStart, len, 0, contextLen, flags, advances, advancesIndex, reserved); TemporaryBuffer.recycle(buf); return result; } Loading Loading @@ -1689,44 +1640,55 @@ public class Paint { */ public float getTextRunAdvances(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { if ((start | end | contextStart | contextEnd | advancesIndex | (end - start) | (start - contextStart) | (contextEnd - end) | (text.length() - contextEnd) | (advances == null ? 0 : (advances.length - advancesIndex - (end - start)))) < 0) { throw new IndexOutOfBoundsException(); } if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) { throw new IllegalArgumentException("unknown flags value: " + flags); } if (!mHasCompatScaling) { return native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float totalAdvance = native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); setTextSize(oldSize); if (advances != null) { for (int i = advancesIndex, e = i + (end - start); i < e; i++) { advances[i] *= mInvCompatScaling; } } return totalAdvance * mInvCompatScaling; // assume errors are insignificant return getTextRunAdvances(text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, 0 /* use Harfbuzz*/); } /** * Temporary - DO NOT USE * Returns the total advance width for the characters in the run * between start and end, and if advances is not null, the advance * assigned to each of these characters (java chars). * * <p>The trailing surrogate in a valid surrogate pair is assigned * an advance of 0. Thus the number of returned advances is * always equal to count, not to the number of unicode codepoints * represented by the run. * * <p>In the case of conjuncts or combining marks, the total * advance is assigned to the first logical character, and the * following characters are assigned an advance of 0. * * <p>This generates the sum of the advances of glyphs for * characters in a reordered cluster as the width of the first * logical character in the cluster, and 0 for the widths of all * other characters in the cluster. In effect, such clusters are * treated like conjuncts. * * <p>The shaping bounds limit the amount of context available * outside start and end that can be used for shaping analysis. * These bounds typically reflect changes in bidi level or font * metrics across which shaping does not occur. * * @param text the text to measure * @param start the index of the first character to measure * @param end the index past the last character to measure * @param contextStart the index of the first character to use for shaping context, * must be <= start * @param contextEnd the index past the last character to use for shaping context, * must be >= end * @param flags the flags to control the advances, either {@link #DIRECTION_LTR} * or {@link #DIRECTION_RTL} * @param advances array to receive the advances, must have room for all advances, * can be null if only total advance is needed * @param advancesIndex the position in advances at which to put the * advance corresponding to the character at start * @param reserved int reserved value * @return the total advance * * @hide */ public float getTextRunAdvancesICU(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex) { public float getTextRunAdvances(String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex, int reserved) { if ((start | end | contextStart | contextEnd | advancesIndex | (end - start) | (start - contextStart) | (contextEnd - end) Loading @@ -1740,14 +1702,14 @@ public class Paint { } if (!mHasCompatScaling) { return native_getTextRunAdvancesICU(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); return native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex, reserved); } final float oldSize = getTextSize(); setTextSize(oldSize * mCompatScaling); float totalAdvance = native_getTextRunAdvances(mNativePaint, text, start, end, contextStart, contextEnd, flags, advances, advancesIndex); contextStart, contextEnd, flags, advances, advancesIndex, reserved); setTextSize(oldSize); if (advances != null) { Loading Loading @@ -2017,17 +1979,10 @@ public class Paint { private static native float native_getTextRunAdvances(int native_object, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex); int flags, float[] advances, int advancesIndex, int reserved); private static native float native_getTextRunAdvances(int native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex); private static native float native_getTextRunAdvancesICU(int native_object, char[] text, int index, int count, int contextIndex, int contextCount, int flags, float[] advances, int advancesIndex); private static native float native_getTextRunAdvancesICU(int native_object, String text, int start, int end, int contextStart, int contextEnd, int flags, float[] advances, int advancesIndex); int flags, float[] advances, int advancesIndex, int reserved); private native int native_getTextRunCursor(int native_object, char[] text, int contextStart, int contextLength, int flags, int offset, int cursorOpt); Loading