summaryrefslogtreecommitdiff
path: root/core/java/android/text/StaticLayout.java
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2017-10-06 11:41:00 -0700
committerSeigo Nonaka <nona@google.com>2017-10-10 20:44:47 +0000
commit2dd1a55b41170c26434fe3eb72bdd4e5e610daf9 (patch)
tree10337f8cd2aaa7574075b4c65d549764dea6e8d0 /core/java/android/text/StaticLayout.java
parent34e83d28f03432f2447928241886c9c668299061 (diff)
Remove nGetWidths and pass the jfloat[] as nComputeLineBreaks argument.
nGetWidths was always called just before nComputeLineBreaks. It would be an improvement to pass the result array as the argument of nComputeLineBreaks. Bug: 65024629 Test: bit FrameworksCoreTests:android.text.StaticLayoutLineBreakingTest Test: bit CtsTextTestCase:* Test: Manually checked no regression in TextViewOnMeasurePerfTest Test: Manually checked no regression in StaticLayoutPerfTest result Change-Id: I566be66558a22b3a3ff79d502bebbbfec75dd065
Diffstat (limited to 'core/java/android/text/StaticLayout.java')
-rw-r--r--core/java/android/text/StaticLayout.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 961cd8eef530..335901759067 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -433,7 +433,6 @@ public class StaticLayout extends Layout {
* + addStyleRun (a text run, to be measured in native code)
* + addReplacementRun (a replacement run, width is given)
*
- * After measurement, nGetWidths() is valid if the widths are needed (eg for ellipsis).
* Run nComputeLineBreaks() to obtain line breaks for the paragraph.
*
* After all paragraphs, call finish() to release expensive buffers.
@@ -866,10 +865,9 @@ public class StaticLayout extends Layout {
spanEndCacheCount++;
}
- nGetWidths(b.mNativePtr, widths);
int breakCount = nComputeLineBreaks(b.mNativePtr, lineBreaks, lineBreaks.breaks,
lineBreaks.widths, lineBreaks.ascents, lineBreaks.descents, lineBreaks.flags,
- lineBreaks.breaks.length);
+ lineBreaks.breaks.length, widths);
final int[] breaks = lineBreaks.breaks;
final float[] lineWidths = lineBreaks.widths;
@@ -1551,16 +1549,17 @@ public class StaticLayout extends Layout {
@FloatRange(from = 0.0f) float width, @Nullable String languageTags,
@Nullable long[] hyphenators);
- private static native void nGetWidths(long nativePtr, float[] widths);
-
// populates LineBreaks and returns the number of breaks found
//
// the arrays inside the LineBreaks objects are passed in as well
// to reduce the number of JNI calls in the common case where the
// arrays do not have to be resized
+ // The individual character widths will be returned in charWidths. The length of charWidths must
+ // be at least the length of the text.
private static native int nComputeLineBreaks(long nativePtr, LineBreaks recycle,
int[] recycleBreaks, float[] recycleWidths, float[] recycleAscents,
- float[] recycleDescents, int[] recycleFlags, int recycleLength);
+ float[] recycleDescents, int[] recycleFlags, int recycleLength,
+ float[] charWidths);
private int mLineCount;
private int mTopPadding, mBottomPadding;