Precompute full hyphenation layout
The previous offset based computation doesn't work well for some cases,
e.g. the final text for drawing may be a substring of the original
string. The offset based matching doesn't work well for such case.
This CL changes
- Store the layout results during measuring hyphenation pieces.
- Change the LayoutPiece key from offset to string.
- This CL increases the heap usage about 23kb for 500 characters text.
This changes the performance behaviors.
android.text.PrecomputedTextMemoryUsageTest:
MemoryUsage_Hyphenation : 28,448 -> 51,836: (+82.2%)
MemoryUsage_Hyphenation_WidthOnly : 8,856 -> 8,856: (+0.0%)
MemoryUsage_NoHyphenation : 27,592 -> 26,386: (-4.4%)
MemoryUsage_NoHyphenation_WidthOnly : 8,000 -> 8,000: (+0.0%)
android.text.PrecomputedTextPerfTest:
create_NoStyled_Hyphenation : 17,162,475 -> 17,695,377: (+3.1%)
create_NoStyled_Hyphenation_WidthOnly : 17,044,784 -> 17,677,423: (+3.7%)
create_NoStyled_NoHyphenation : 7,108,911 -> 7,021,486: (-1.2%)
create_NoStyled_NoHyphenation_WidthOnly : 7,102,481 -> 7,045,453: (-0.8%)
create_Styled_Hyphenation : 12,394,607 -> 12,090,933: (-2.5%)
create_Styled_Hyphenation_WidthOnly : 12,297,095 -> 12,105,491: (-1.6%)
create_Styled_NoHyphenation : 11,886,364 -> 11,835,249: (-0.4%)
create_Styled_NoHyphenation_WidthOnly : 12,018,548 -> 11,871,765: (-1.2%)
android.text.StaticLayoutMultithreadPerfTest:
create_RandomText_Thread_1 : 7,051,921 -> 6,998,143: (-0.8%)
create_RandomText_Thread_2 : 7,112,819 -> 7,032,146: (-1.1%)
create_RandomText_Thread_4 : 7,843,295 -> 7,860,874: (+0.2%)
android.text.StaticLayoutPerfTest:
create_PrecomputedText_Balanced_Hyphenation : 703,563 -> 709,839: (+0.9%)
create_PrecomputedText_Balanced_NoHyphenation: 523,437 -> 527,671: (+0.8%)
create_PrecomputedText_Greedy_Hyphenation : 470,881 -> 477,259: (+1.4%)
create_PrecomputedText_Greedy_NoHyphenation : 471,487 -> 479,772: (+1.8%)
create_RandomText_Balanced_Hyphenation : 17,166,857 -> 17,123,681: (-0.3%)
create_RandomText_Balanced_NoHyphenation : 7,107,289 -> 7,040,572: (-0.9%)
create_RandomText_Greedy_Hyphenation : 7,055,902 -> 7,000,681: (-0.8%)
create_RandomText_Greedy_NoHyphenation : 7,032,325 -> 6,997,115: (-0.5%)
draw_PrecomputedText_NoStyled : 527,505 -> 543,623: (+3.1%)
draw_PrecomputedText_NoStyled_WithoutCache : 526,084 -> 564,742: (+7.3%)
draw_PrecomputedText_Styled : 880,951 -> 838,581: (-4.8%)
draw_PrecomputedText_Styled_WithoutCache : 874,259 -> 826,775: (-5.4%)
draw_RandomText_NoStyled : 549,637 -> 538,162: (-2.1%)
draw_RandomText_NoStyled_WithoutCache : 6,449,481 -> 6,401,486: (-0.7%)
draw_RandomText_Styled : 1,001,350 -> 1,024,683: (+2.3%)
draw_RandomText_Styled_WithoutCache : 2,759,161 -> 2,733,204: (-0.9%)
android.widget.TextViewPrecomputedTextPerfTest:
newLayout_PrecomputedText : 738,105 -> 736,130: (-0.3%)
newLayout_PrecomputedText_Selectable : 17,410,426 -> 17,379,765: (-0.2%)
newLayout_RandomText : 16,565,334 -> 16,495,200: (-0.4%)
newLayout_RandomText_Selectable : 17,607,671 -> 17,482,439: (-0.7%)
onDraw_PrecomputedText : 2,371,858 -> 1,274,921: (-46.2%)
onDraw_PrecomputedText_Selectable : 17,493,221 -> 17,367,238: (-0.7%)
onDraw_RandomText : 17,349,102 -> 17,224,949: (-0.7%)
onDraw_RandomText_Selectable : 18,107,851 -> 18,067,397: (-0.2%)
onMeasure_PrecomputedText : 756,229 -> 752,875: (-0.4%)
onMeasure_PrecomputedText_Selectable : 17,725,005 -> 17,647,842: (-0.4%)
onMeasure_RandomText : 16,636,892 -> 16,435,649: (-1.2%)
onMeasure_RandomText_Selectable : 17,866,544 -> 17,724,819: (-0.8%)
setText_PrecomputedText : 90,499 -> 92,894: (+2.6%)
setText_PrecomputedText_Selectable : 146,906 -> 145,134: (-1.2%)
setText_RandomText : 11,251 -> 11,130: (-1.1%)
setText_RandomText_Selectable : 48,745 -> 48,900: (+0.3%)
Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest
Test: minikin_tests
Change-Id: I2290d7e06d9e2f4bc13f60246ce66ba1c1785cdd
10 files changed