2adb04f8edb61857a2c53c16ced533df47be67c3 |
|
23-Mar-2018 |
Seigo Nonaka <nona@google.com> |
Discard hyphenation context During line breaking, the hyphenated pieces are computed with context. On the other hand, during drawing, the context is not available. This ends up with cache miss during drawing. To increase the cache hit and making line break correct, remove context during line breaking. Bug: 65024629 Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases FrameworksCoreTests:android.text CtsWidgetTestCases:TextViewPrecomputedTextTest Test: minikin_test Change-Id: I27efa55825aa5060d742020661f831c69697aaf5
/frameworks/minikin/libs/minikin/LineBreakerUtil.h
|
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/libs/minikin/LineBreakerUtil.h
|
8e60b6f3a6bed9ece5608847f7dab7c3359c9a67 |
|
24-Feb-2018 |
Seigo Nonaka <nona@google.com> |
Stop including CR, LF characters in the previous run Bug: 73625594 Test: bit FrameworksCoreTests:android.text. Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases Change-Id: I809296e7edd9fe54d5defd83c7ddc5bb40a1d0e4
/frameworks/minikin/libs/minikin/LineBreakerUtil.h
|
7d8c4ed5b7683e16e6205a6b52b1910f8ff6b51b |
|
09-Feb-2018 |
Seigo Nonaka <nona@google.com> |
Remove global mutex lock from minikin All modules are now free from gMinikinLock. This increases the performance of parallel text layout in background thread. Here is a raw performance score on walleye-userdebug StaticLayout creation time in parallel: RandomText Thread 1 : 7,348,118 -> 7,327,542: (-0.3%) RandomText Thread 2 : 13,872,214 -> 7,402,398: (-46.6%) RandomText Thread 4 : 24,999,986 -> 8,185,263: (-67.3%) StaticLayout creation time: MeasuredText Balanced Hyphenation : 774,245 -> 781,534: (+0.9%) MeasuredText Balanced NoHyphenation: 587,157 -> 574,882: (-2.1%) MeasuredText Greedy Hyphenation : 535,843 -> 523,630: (-2.3%) MeasuredText Greedy NoHyphenation : 534,965 -> 522,259: (-2.4%) RandomText Balanced Hyphenation : 17,886,651 -> 17,814,108: (-0.4%) RandomText Balanced NoHyphenation : 7,385,288 -> 7,410,588: (+0.3%) RandomText Greedy Hyphenation : 7,380,350 -> 7,296,407: (-1.1%) RandomText Greedy NoHyphenation : 7,358,680 -> 7,320,040: (-0.5%) MeasuredText creation time NoStyled Hyphenation : 17,587,451 -> 17,544,350: (-0.2%) NoStyled Hyphenation WidthOnly : 17,112,258 -> 17,092,507: (-0.1%) NoStyled NoHyphenation : 7,307,064 -> 7,296,519: (-0.1%) NoStyled NoHyphenation WidthOnly : 6,880,721 -> 6,848,543: (-0.5%) Styled Hyphenation : 14,753,919 -> 14,659,049: (-0.6%) Styled Hyphenation WidthOnly : 13,767,908 -> 13,755,623: (-0.1%) Styled NoHyphenation : 14,368,118 -> 14,337,125: (-0.2%) Styled NoHyphenation WidthOnly : 13,414,942 -> 13,375,858: (-0.3%) StaticLayout draw time: MeasuredText NoStyled : 676,438 -> 678,795: (+0.3%) MeasuredText NoStyled WithoutCache : 663,041 -> 654,687: (-1.3%) MeasuredText Styled : 885,574 -> 890,281: (+0.5%) MeasuredText Styled WithoutCache : 944,259 -> 928,675: (-1.7%) RandomText NoStyled : 562,361 -> 553,651: (-1.5%) RandomText NoStyled WithoutCache : 6,678,968 -> 6,696,637: (+0.3%) RandomText Styled : 2,970,369 -> 2,933,900: (-1.2%) RandomText Styled WithoutCache : 3,408,554 -> 3,387,260: (-0.6%) Bug: 37567215 Test: minikin_tests Test: minikin_stress_tests Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases CtsGraphicsTestCases:PaintTest Test: bit FrameworksCoreTests:android.text. Change-Id: I6aab090be6bfa65f1205b26b77c6c65823a3d94e
/frameworks/minikin/libs/minikin/LineBreakerUtil.h
|
5cc07b9fefb63956668a06926cc8a044f65f78dc |
|
20-Jan-2018 |
Seigo Nonaka <nona@google.com> |
Remove unused argument LayoutOverhang The overhang stuff is not used now. Let's remove them. Bug: 65024629 Test: minikin_tests Change-Id: I5b19341824308effe4e7c0920f808f05c357df57
/frameworks/minikin/libs/minikin/LineBreakerUtil.h
|
c9611626465f9e11817854f554e7b7d0c6cee905 |
|
12-Jan-2018 |
Seigo Nonaka <nona@google.com> |
Store hyphenated pieces in MeasuredText Do hyphenation calculation at the same time of measuring character widths. We can do the 93% of line break work beforehand. Here is a raw performance score: (walleye-userdebug, w/o patch -> w/ patch, N=30) Measured Balanced Hyphenation : 11,428,287 -> 703,417 (-93.8%) Measured Balanced NoHyphenation: 535,660 -> 536,210 (+0.1%) Random Balanced Hyphenation : 18,903,251 -> 19,046,535 (+0.8%) Random Balanced NoHyphenation : 7,973,160 -> 7,956,803 (-0.2%) Measured Greedy Hyphenation : 486,633 -> 486,381 (-0.1%) Measured Greedy NoHyphenation : 484,716 -> 490,018 (+1.1%) Random Greedy Hyphenation : 7,966,823 -> 7,921,520 (-0.6%) Random Greedy NoHyphenation : 7,918,480 -> 7,925,110 (+0.1%) This CL also removes overhang member variable from MeasuredText since this is no longer used in line breaker. Bug: 67504091 Test: bit CtsTextTestCases:* Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: minikin_tests Change-Id: I94c65980bf1190c9351d50dc0c811a377fb93ee6
/frameworks/minikin/libs/minikin/LineBreakerUtil.h
|
366f57fb4efd0ddf5d48cd232cd88d3777517ea2 |
|
09-Jan-2018 |
Seigo Nonaka <nona@google.com> |
Reorganize optimal line breaker This CL contains: - Rename LineBreakImpl.{h|cpp} with OptimalLineBreaker.{h|cpp} - Extract line break candidate enumeration code from LineBreakerImpl and rename LineBreakImpl with LineBreakOptimizer. - Fix unexpected hyphenation by ordering hyphenation break point and desperate break points. - Refactor line break candidate enumeration code. Compatibility: To check the compatibility from current implementation, manually compared the line break result for the UDHR text (http://unicode.org/udhr/). Then verified new implementation completely replicate the same output as the current implementation except for desperate breaks. Here is the combination verified: Langauge: ar, zh-CN, zh-TW, nl, fr, de, it, ja, ko, po, pl-PL, pl-BR, ru, es-ES, th, tr, bg, ca, hr, cs, da, el, he, hi, hu, id, lv, lt, no, ro, sr-Cyrl, sr-Latn, sk, sl, sv, uk, vi Font Size: 14px, 15px, 16px, 17px, 18px, 19px Line Width: 128px, 256px, 512px, 1024px Performance: Verified this doesn't cause performance regression. Here is raw performance score. StaticLayoutPerfTest(walleye-userdebug, w/o patch -> w/ patch, N=50): Random Text, No Hyphen : 7,782,872 -> 7,754,140 (-0.37%) Random Text, Hyphen : 19,028,618 -> 18,942,728 (-0.45%) measured Text, No Hyphen : 346,625 -> 349,809 (+0.92%) measured Text, Hyphen : 11,411,894 -> 11,379,360 (-0.29%) Bug: 71709070 Bug: 65024629 Test: minikin_tests Test: bit CtsTextTestCases:* Test: bit FrameworksCoreTests:android.text.StaticLayoutTest Change-Id: I1933335764405da6d7c82cf1d1af1692e6d10a04
/frameworks/minikin/libs/minikin/LineBreakerUtil.h
|
d57562ceb31842c7bcdb28c084c863631a844acd |
|
08-Dec-2017 |
Seigo Nonaka <nona@google.com> |
Implement new line breaker for greedy algorithm The new greedy line breaker is 2x faster than current line breaker. Current greedy line breaker does lots of unnecessary things. - Hyphenation is not necessary until the word is too long for the line. - Cost calculation and optimization for the cost is not necessary. Only if the break point is inside email or url. This can be done in O(1). The new line breaker is fully compatible with older line breaker except for - Overhang calculation is dropped since it is implemented partially but not consistent with other line break strategy. Also it is not exposed as Java API. - The priority of desperate line breaking and hyphenation is not consistent and current master implementation is broken. Sometimes the line breaker exceeds the line width. The new line breaker has explicit priority for the hyphenation and keep the line width under the limit. (See Issue 70415793) Compatibility: To check the compatibility from current implementation, manually compared the line break result for the UDHR text (http://unicode.org/udhr/). Then verified new implementation completely replicate the same output as the current implementaiton. Here is the combination verified: Langauge: ar, zh-CN, zh-TW, nl, fr, de, it, ja, ko, po, pl-PL, pl-BR, ru, es-ES, th, tr, bg, ca, hr, cs, da, el, he, hi, hu, id, lv, lt, no, ro, sr-Cyrl, sr-Latn, sk, sl, sv, uk, vi Font Size: 14px, 15px, 16px, 17px, 18px, 19px Line Width: 128px, 256px, 512px, 1024px Performance: Here is the performance score: (All greedy algorithm, w/o patch -> w/ patch, median, N=100) Random, No Style, Hyphenation OFF: 7,854,007 -> 7,780,766 (-0.93%) Random, No Style, Hyphenation ON : 19,274,298 -> 7,762,346 (-60.0%) Measured, No Style, Hyphenation OFF: 516,039 -> 424,173 (-18.0%) Measured, No Style, Hyphenation ON : 11,772,800 -> 482,506 (-96.0%) I'll remove old greedy line breaker once this is submitted. Test: CtsTextTestCases:* Test: CtsGraphicsTestCases:* Test: CtsWidgetTestCases:* Test: minikin_test Bug: 70415793 Bug: 65024629 Bug: 64389125 Change-Id: Iaff9afed4bb6eebecb010e468546239f10852903
/frameworks/minikin/libs/minikin/LineBreakerUtil.h
|