History log of /frameworks/minikin/include/minikin/U16StringPiece.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
43a52c5ee653e75ce3ccf2477a9dcdec6f8d7fa3 14-Mar-2018 Seigo Nonaka <nona@google.com> 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
/frameworks/minikin/include/minikin/U16StringPiece.h
437f86f9e3508cec3259cfa293ef028fd0c41afc 13-Dec-2017 Seigo Nonaka <nona@google.com> Remove unused code

Greedy implementation and overhang computation can be removed from
LineBreakerImpl.
To be able to see the diff easily, rename to LineBreakerImpl to
OptimalLineBreaker in subsequence change.

Bug: 65024629
Test: minikin_test
Change-Id: I2d6f11edd96b59a6b43bc629ac9408d9e583d2ee
/frameworks/minikin/include/minikin/U16StringPiece.h
524d294be051584e5506e5a4ad6ec70471bf4c08 12-Dec-2017 Seigo Nonaka <nona@google.com> Stop creating local vector for storing temporary hyphenation result

No temporary vector is necessary during hypheanation.
At the same time, this reveals Range name confliction. Remove internal
Range struct and use public one in CmapCoverage.cpp

Bug: 65024629
Test: minikin_tests
Change-Id: I31fb3472bb6a88e4e15d851723f34adc25e1d993
/frameworks/minikin/include/minikin/U16StringPiece.h
d565f7d88018f09a740ff6cf26cb2b068139c784 10-Nov-2017 Seigo Nonaka <nona@google.com> Rewrite LineBreaker with U16StringPiece and Range

There are lots of primitive types which represents the ranges of
text. It is good to replace them with Range class and utility
methods to be more readable.

Locally verified this doesn't regresses the performance.
Here is a raw perf test result on marlin. (w/o patch -> w/ patch)

StaticLayoutPerfTest (median):
createRandom: 6,696,561 -> 6,639,608 (+0.85%)
createRandom Balanced: 6,625,276 -> 6,563,600 (+0.93%)

TextViewOnMeasurePerfTest (median):
measure_AtMost: 59,128,766 -> 59,975,584 (-1.43%)
measure_Exactly: 57,584,917 -> 58,287,526 (-1.22%)
measure_Unspecified: 99,198,124 -> 98,851,486 (+0.35%)

Test: bit CtsTextTestCases:*
Test: bit CtsWidgetTestCases:*
Bug: 65024629
Change-Id: I3690e635a27d8e200ce25679d5bbbe95f6f3bd03
/frameworks/minikin/include/minikin/U16StringPiece.h