History log of /frameworks/base/core/java/android/text/MeasuredParagraph.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
fb0abe1feb2cadcee2a3edb2028e1da04bb8a8d5 03-Apr-2018 Seigo Nonaka <nona@google.com> 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
/frameworks/base/core/java/android/text/MeasuredParagraph.java
0903665f97435d27a893d45927e4a019008cadd6 30-Mar-2018 Seigo Nonaka <nona@google.com> Fills font metrics before passing to ReplacementSpan

Bug: 74518333
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest
Change-Id: Ifbc8625882919e6498a2758433e80f059a797fd4

Change-Id: I6181fd712aae38e0bba702374e01a40ee3b522dd
/frameworks/base/core/java/android/text/MeasuredParagraph.java
a553477ddf55d170a66410ed325ae5e5d3005965 15-Mar-2018 Seigo Nonaka <nona@google.com> Make PrecomputedText Spannable for supporting selection

This is 2nd attempt of I072dfd70b9a687d9c47e310d8cdb34f988fbb32e

The root cause of crashing is unexpected copying of NoCopySpan by
SpannableString constructor. To prevent crashing, stop copying
NoCopySpan by passing ignoreNoCopySpan=true to SpannableString
copy constructor.

The original commit message is following:

To support selectable TextView, make PrecomputedText spannable.
By this change, TextView start using DynamicLayout instead of
StaticLayout. DynamicLayout requires boundary rectangle of the
text, so this CL also adds getBounds method to PrecomputedText
which retrieves measured boundary box from native.

By this change, the selectable TextView performance for the
precomputed text 10x faster. On the other hand, the performacne
for the non-selectable text gets 2.5x slower. However, we concluded
that we accept this performance regression since it still 10 times
faster than non precomputed text.

Here is a precomputed text performance result of TextView.
android.widget.TextViewPrecomputedTextPerfTest:
newLayout_PrecomputedText : 736,130 -> 1,648,694: (+124.0%)
newLayout_PrecomputedText_Selectable: 17,379,765 -> 1,700,146: (-90.2%)
onDraw_PrecomputedText : 1,274,921 -> 1,848,076: (+45.0%)
onDraw_PrecomputedText_Selectable : 17,367,238 -> 1,399,169: (-91.9%)
onMeasure_PrecomputedText : 752,875 -> 1,766,606: (+134.6%)
onMeasure_PrecomputedText_Selectable: 17,647,842 -> 1,810,704: (-89.7%)
setText_PrecomputedText : 92,894 -> 135,471: (+45.8%)
setText_PrecomputedText_Selectable : 145,134 -> 215,757: (+48.7%)

Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: Ie98c75d8b4ba962eaf0a544357b2ff1ade891118
/frameworks/base/core/java/android/text/MeasuredParagraph.java
c3328d648e827c8a65f46ed3a8b0ec96076b5ebe 20-Mar-2018 Seigo Nonaka <nona@google.com> Stop creating PrecomputedText in StaticLayout

No performance regressions are expected

android.text.PrecomputedTextPerfTest:
create NoStyled Hyphenation : 17,849,966 -> 17,858,570: (+0.0%)
create NoStyled Hyphenation WidthOnly : 17,814,338 -> 17,801,205: (-0.1%)
create NoStyled NoHyphenation : 7,123,449 -> 7,068,308: (-0.8%)
create NoStyled NoHyphenation WidthOnly : 7,108,169 -> 7,074,908: (-0.5%)
create Styled Hyphenation : 12,179,203 -> 12,131,020: (-0.4%)
create Styled Hyphenation WidthOnly : 12,112,347 -> 12,241,311: (+1.1%)
create Styled NoHyphenation : 11,870,126 -> 11,880,442: (+0.1%)
create Styled NoHyphenation WidthOnly : 11,836,742 -> 11,860,292: (+0.2%)

android.text.StaticLayoutPerfTest:
create PrecomputedText Balanced Hyphenation : 697,713 -> 691,148: (-0.9%)
create PrecomputedText Balanced NoHyphenation: 517,113 -> 498,106: (-3.7%)
create PrecomputedText Greedy Hyphenation : 468,243 -> 455,015: (-2.8%)
create PrecomputedText Greedy NoHyphenation : 479,514 -> 461,617: (-3.7%)
create RandomText Balanced Hyphenation : 17,183,044 -> 17,049,811: (-0.8%)
create RandomText Balanced NoHyphenation : 7,183,745 -> 7,025,070: (-2.2%)
create RandomText Greedy Hyphenation : 7,130,841 -> 6,995,785: (-1.9%)
create RandomText Greedy NoHyphenation : 7,122,398 -> 7,037,074: (-1.2%)

draw PrecomputedText NoStyled : 520,306 -> 551,465: (+6.0%)
draw PrecomputedText NoStyled WithoutCache : 545,773 -> 566,956: (+3.9%)
draw PrecomputedText Styled : 826,044 -> 838,979: (+1.6%)
draw PrecomputedText Styled WithoutCache : 829,958 -> 841,749: (+1.4%)
draw RandomText NoStyled : 537,079 -> 545,428: (+1.6%)
draw RandomText NoStyled WithoutCache : 6,473,166 -> 6,445,194: (-0.4%)
draw RandomText Styled : 995,033 -> 1,015,913: (+2.1%)
draw RandomText Styled WithoutCache : 2,725,313 -> 2,770,604: (+1.7%)

android.widget.TextViewPrecomputedTextPerfTest:
newLayout PrecomputedText : 754,311 -> 718,130: (-4.8%)
newLayout PrecomputedText Selectable : 17,716,239 -> 17,484,046: (-1.3%)
newLayout RandomText : 16,657,952 -> 16,511,625: (-0.9%)
newLayout RandomText Selectable : 17,675,222 -> 17,520,653: (-0.9%)
onDraw PrecomputedText : 1,307,123 -> 1,280,009: (-2.1%)
onDraw PrecomputedText Selectable : 17,613,031 -> 17,404,379: (-1.2%)
onDraw RandomText : 17,369,256 -> 17,295,363: (-0.4%)
onDraw RandomText Selectable : 18,207,392 -> 18,077,660: (-0.7%)
onMeasure PrecomputedText : 748,537 -> 739,128: (-1.3%)
onMeasure PrecomputedText Selectable : 17,842,953 -> 17,784,459: (-0.3%)
onMeasure RandomText : 16,633,454 -> 16,549,182: (-0.5%)
onMeasure RandomText Selectable : 18,022,286 -> 17,873,919: (-0.8%)
setText PrecomputedText : 120,769 -> 119,496: (-1.1%)
setText PrecomputedText Selectable : 162,411 -> 150,809: (-7.1%)
setText RandomText : 11,096 -> 10,956: (-1.3%)
setText RandomText Selectable : 48,852 -> 48,593: (-0.5%)

Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I3af758ecc5a15975c4e59c6378faf7c14c3bd65b
/frameworks/base/core/java/android/text/MeasuredParagraph.java
e887f4d2c18040276ee230fdd3dadaa6610a188e 19-Mar-2018 Seigo Nonaka <nona@google.com> Revert "Make PrecomputedText Spannable for supporting selection"

Crash on Sheets APp
This reverts commit 80ed5a35a90b62b8070d861b9755e230bd679951.

Bug: 75652829
Change-Id: I40ddd1b9754e74fbd90d7a029cce9c6a7ede0777
Test: Manual
/frameworks/base/core/java/android/text/MeasuredParagraph.java
80ed5a35a90b62b8070d861b9755e230bd679951 15-Mar-2018 Seigo Nonaka <nona@google.com> Make PrecomputedText Spannable for supporting selection

To support selectable TextView, make PrecomputedText spannable.
By this change, TextView start using DynamicLayout instead of
StaticLayout. DynamicLayout requires boundary rectangle of the
text, so this CL also adds getBounds method to PrecomputedText
which retrieves measured boundary box from native.

By this change, the selectable TextView performance for the
precomputed text 10x faster. On the other hand, the performacne
for the non-selectable text gets 2.5x slower. However, we concluded
that we accept this performance regression since it still 10 times
faster than non precomputed text.

Here is a precomputed text performance result of TextView.
android.widget.TextViewPrecomputedTextPerfTest:
newLayout_PrecomputedText : 736,130 -> 1,648,694: (+124.0%)
newLayout_PrecomputedText_Selectable : 17,379,765 -> 1,700,146: (-90.2%)
onDraw_PrecomputedText : 1,274,921 -> 1,848,076: (+45.0%)
onDraw_PrecomputedText_Selectable : 17,367,238 -> 1,399,169: (-91.9%)
onMeasure_PrecomputedText : 752,875 -> 1,766,606: (+134.6%)
onMeasure_PrecomputedText_Selectable : 17,647,842 -> 1,810,704: (-89.7%)
setText_PrecomputedText : 92,894 -> 135,471: (+45.8%)
setText_PrecomputedText_Selectable : 145,134 -> 215,757: (+48.7%)

Verified no effects for other performance metrics:
android.widget.TextViewPrecomputedTextPerfTest:
newLayout_RandomText : 16,495,200 -> 16,450,483: (-0.3%)
newLayout_RandomText_Selectable : 17,482,439 -> 17,534,207: (+0.3%)
onDraw_RandomText : 17,224,949 -> 17,228,072: (+0.0%)
onDraw_RandomText_Selectable : 18,067,397 -> 17,958,235: (-0.6%)
onMeasure_RandomText : 16,435,649 -> 16,516,352: (+0.5%)
onMeasure_RandomText_Selectable : 17,724,819 -> 17,879,508: (+0.9%)
setText_RandomText : 11,130 -> 11,259: (+1.2%)
setText_RandomText_Selectable : 48,900 -> 48,607: (-0.6%)

android.text.PrecomputedTextPerfTest:
create_NoStyled_Hyphenation : 17,695,377 -> 17,660,233: (-0.2%)
create_NoStyled_Hyphenation_WidthOnly : 17,677,423 -> 17,541,823: (-0.8%)
create_NoStyled_NoHyphenation : 7,021,486 -> 7,030,069: (+0.1%)
create_NoStyled_NoHyphenation_WidthOnly : 7,045,453 -> 7,067,021: (+0.3%)
create_Styled_Hyphenation : 12,090,933 -> 12,267,730: (+1.5%)
create_Styled_Hyphenation_WidthOnly : 12,105,491 -> 12,277,272: (+1.4%)
create_Styled_NoHyphenation : 11,835,249 -> 11,960,278: (+1.1%)
create_Styled_NoHyphenation_WidthOnly : 11,871,765 -> 11,912,444: (+0.3%)

android.text.StaticLayoutPerfTest:
create_PrecomputedText_NoStyled_Balanced_Hyphenation : 709,839 -> 697,134: (-1.8%)
create_PrecomputedText_NoStyled_Balanced_NoHyphenation: 527,671 -> 528,928: (+0.2%)
create_PrecomputedText_NoStyled_Greedy_Hyphenation : 477,259 -> 481,966: (+1.0%)
create_PrecomputedText_NoStyled_Greedy_NoHyphenation : 479,772 -> 482,278: (+0.5%)
create_PrecomputedText_Styled_Greedy_NoHyphenation : 639,322 -> 637,790: (-0.2%)
create_RandomText_NoStyled_Balanced_Hyphenation : 17,123,681 -> 16,989,227: (-0.8%)
create_RandomText_NoStyled_Balanced_NoHyphenation : 7,040,572 -> 7,064,175: (+0.3%)
create_RandomText_NoStyled_Greedy_Hyphenation : 7,000,681 -> 7,002,322: (+0.0%)
create_RandomText_NoStyled_Greedy_NoHyphenation : 6,997,115 -> 6,996,953: (-0.0%)
create_RandomText_Styled_Greedy_NoHyphenation : 11,948,744 -> 12,052,791: (+0.9%)
draw_PrecomputedText_NoStyled : 543,623 -> 513,741: (-5.5%)
draw_PrecomputedText_NoStyled_WithoutCache : 564,742 -> 541,795: (-4.1%)
draw_PrecomputedText_Styled : 838,581 -> 837,438: (-0.1%)
draw_PrecomputedText_Styled_WithoutCache : 826,775 -> 850,586: (+2.9%)
draw_RandomText_NoStyled : 538,162 -> 533,603: (-0.8%)
draw_RandomText_NoStyled_WithoutCache : 6,401,486 -> 6,424,604: (+0.4%)
draw_RandomText_Styled : 1,024,683 -> 1,011,575: (-1.3%)
draw_RandomText_Styled_WithoutCache : 2,733,204 -> 2,722,828: (-0.4%)

Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I072dfd70b9a687d9c47e310d8cdb34f988fbb32e
/frameworks/base/core/java/android/text/MeasuredParagraph.java
49ca0244c9fa01dd667755cde6eb2342b8e2e05d 25-Jan-2018 Seigo Nonaka <nona@google.com> Introduce MeasuredText related perf tests

This CL adds two perf test for MeasuredText: the memory usage and
construction time of MeasuredText.

Here is an example output on walleye-userdebug:

Memory Usage (in bytes)
Hyphenation : 28,448
Hyphenation WidthOnly : 8,856
NoHyphenation : 27,592
NoHyphenation WidthOnly: 8,000

MeasuredText creation time
NoStyled Hyphenation : 18,977,877
NoStyled Hyphenation WidthOnly : 18,510,041
NoStyled NoHyphenation : 7,771,936
NoStyled NoHyphenation WidthOnly: 7,332,537
Styled Hyphenation : 13,514,428
Styled Hyphenation WidthOnly : 12,446,143
Styled NoHyphenation : 13,370,358
Styled NoHyphenation WidthOnly : 13,582,435

Bug: 72461923
Bug: 72462192
Test: See above

Change-Id: I7d326a9e70a29c38c940e0085da2bc4edf2a098a
/frameworks/base/core/java/android/text/MeasuredParagraph.java
783f961d2fa6f916009844dafeaa08ffaf96a4d3 20-Jan-2018 Seigo Nonaka <nona@google.com> Compute full text layout in MeasuredText and use it for drawing

The full layout is required for drawing text on UI thread.
To save this work, store the full layout result in MeasuredText and
compose the final layout from stored full layout if possible.

Currently justification/hyphenation is not supported but works normally
as before. Nothing changes on existing non measured text.

StaticLayout creation time for no style text (w/o patch -> w/ patch, N=30)
MeasuredText Balanced Hyphenation : 721,297 -> 720,657: (-0.1%)
MeasuredText Balanced NoHyphenation: 550,588 -> 546,069: (-0.8%)
MeasuredText Greedy Hyphenation : 503,582 -> 498,009: (-1.1%)
MeasuredText Greedy NoHyphenation : 502,344 -> 498,507: (-0.8%)
RandomText Balanced Hyphenation : 19,351,802 -> 19,176,024: (-0.9%)
RandomText Balanced NoHyphenation : 8,033,830 -> 7,973,336: (-0.8%)
RandomText Greedy Hyphenation : 7,957,335 -> 7,927,316: (-0.4%)
RandomText Greedy NoHyphenation : 7,988,884 -> 7,929,717: (-0.7%)

StaticLayout.draw time for no style text (w/o patch -> w/ patch, N=30)
MeasuredText NoStyled : 644,453 -> 660,684: (+2.5%)
MeasuredText NoStyled WithoutCache : 9,251,919 -> 648,992: (-93.0%)
MeasuredText Styled : 3,092,353 -> 870,702: (-71.8%)
MeasuredText Styled WithoutCache : 12,544,014 -> 1,114,557: (-91.1%)
RandomText NoStyled : 582,167 -> 572,092: (-1.7%)
RandomText NoStyled WithoutCache : 9,167,670 -> 9,056,447: (-1.2%)
RandomText Styled : 3,064,490 -> 3,029,028: (-1.2%)
RandomText Styled WithoutCache : 12,314,863 -> 12,283,026: (-0.3%)

Test: minikin_test
Test: bit CtsTextTestCases:*
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.text.MeasuredParagraphTest
Bug: 63897135

Change-Id: I7e6ec5c953d7d0f767aba4f61f94e62b6f3a3a2b
/frameworks/base/core/java/android/text/MeasuredParagraph.java
87b1547c929190c77b6b2d779f1d992691f04d17 12-Jan-2018 Seigo Nonaka <nona@google.com> Compute hyphenated word pieces in MeasuredText

Bug: 67504091
Test: bit CtsTextTestCases:*
Change-Id: Id1ff5abbf6d433a2d8baad364133fca98d1fe450
/frameworks/base/core/java/android/text/MeasuredParagraph.java
9d3bd08ebab564ed9231c8ee112e8085cda74ce8 11-Jan-2018 Seigo Nonaka <nona@google.com> Rename PremeasuredText to MeasuredText

There is already MeasuredText, so renamed existing MeasuredText to
MeasuredParagraph, then renamed PremeasuredText to MeasuredText.

Bug: 67504091
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit CtsTextTestCases:*
Change-Id: Ie20bea9501b18fabb36f64d388a7851c4643d4c3
/frameworks/base/core/java/android/text/MeasuredParagraph.java