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/GreedyLineBreaker.cpp
|
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/GreedyLineBreaker.cpp
|
a22996e31226e3dcbfb0c57d03ca9ac54028fc28 |
|
01-Feb-2018 |
Seigo Nonaka <nona@google.com> |
Remove HbFontCache This is 2nd attempt of the If86840fcf9. HbFontCache was introduced for saving hb_font_t creation cost, but it turned out that creating hb_font_t from another hb_font_t is cheap. Instead of computing hb_font_t from buffer, compute hb_font_t in Zygote process and store it in Font class. By this change, mutex lock is no longer necessary for all HarfBuzz related function calls. StaticLayout creation time (w/o -> w/ patch, N=10, walleye-userdebug): MeasuredText Balanced Hyphenation : 712,896 -> 705,864: (-1.0%) MeasuredText Balanced NoHyphenation: 548,745 -> 535,891: (-2.3%) MeasuredText Greedy Hyphenation : 486,093 -> 479,541: (-1.3%) MeasuredText Greedy NoHyphenation : 491,053 -> 480,571: (-2.1%) RandomText Balanced Hyphenation : 17,749,025 -> 17,426,362: (-1.8%) RandomText Balanced NoHyphenation : 7,433,576 -> 7,401,203: (-0.4%) RandomText Greedy Hyphenation : 7,388,658 -> 7,327,291: (-0.8%) RandomText Greedy NoHyphenation : 7,375,390 -> 7,381,066: (+0.1%) MeasuredText creation time (w/o -> w/ patch, N=10, walleye-userdebug) Styled Hyphenation : 14,364,510 -> 14,430,830: (+0.5%) Styled Hyphenation WidthOnly : 13,629,489 -> 13,446,345: (-1.3%) Styled NoHyphenation : 14,104,669 -> 13,873,049: (-1.6%) Styled NoHyphenation WidthOnly : 13,304,362 -> 13,091,473: (-1.6%) NoStyled Hyphenation : 17,512,424 -> 17,368,559: (-0.8%) NoStyled Hyphenation WidthOnly : 17,095,872 -> 16,985,377: (-0.6%) NoStyled NoHyphenation : 7,371,994 -> 7,344,223: (-0.4%) NoStyled NoHyphenation WidthOnly : 6,932,519 -> 6,950,149: (+0.3%) StaticLayout draw time (w/o -> w/ patch, N=10, walleye-userdebug) MeasuredText NoStyled : 661,017 -> 657,547: (-0.5%) MeasuredText NoStyled WithoutCache : 660,506 -> 651,035: (-1.4%) MeasuredText Styled : 868,116 -> 854,418: (-1.6%) MeasuredText Styled WithoutCache : 916,078 -> 880,388: (-3.9%) RandomText NoStyled : 561,192 -> 547,528: (-2.4%) RandomText NoStyled WithoutCache : 6,758,025 -> 6,695,065: (-0.9%) RandomText Styled : 2,886,462 -> 2,843,580: (-1.5%) RandomText Styled WithoutCache : 3,319,513 -> 3,276,261: (-1.3%) Bug: 37567215 Test: minikin_tests Test: hwui_unit_tests Test: atest CtsTextTestCases \ CtsWidgetTestCases:EditTextTest \ CtsWidgetTestCases:TextViewFadingEdgeTest \ FrameworksCoreTests:TextViewFallbackLineSpacingTest \ FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \ CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest Test: bit FrameworksCoreTests:android.text. Change-Id: If523fce5ce3747b03a1d3bad8c5938a4e2901792
/frameworks/minikin/libs/minikin/GreedyLineBreaker.cpp
|
4de86391218f9fa2d1ba15d78cd80514fb5ce43d |
|
07-Feb-2018 |
Seigo Nonaka <nona@google.com> |
Revert "Remove HbFontCache" This causes a regression for some characters. This reverts commit 6c6954b40f7a6bd6dcf8a3d01c78600437c2e011. Bug: 73054061 Change-Id: I010754474eebd55e43666893c4f7af9de12b22f3
/frameworks/minikin/libs/minikin/GreedyLineBreaker.cpp
|
6c6954b40f7a6bd6dcf8a3d01c78600437c2e011 |
|
01-Feb-2018 |
Seigo Nonaka <nona@google.com> |
Remove HbFontCache HbFontCache was introduced for saving hb_font_t creation cost, but it turned out that creating hb_font_t from another hb_font_t is cheap. Instead of computing hb_font_t from buffer, compute hb_font_t in Zygote process and store it in Font class. By this change, mutex lock is no longer necessary for all HarfBuzz related function calls. StaticLayout creation time (w/o -> w/ patch, N=10, walleye-userdebug): MeasuredText Balanced Hyphenation : 712,896 -> 705,864: (-1.0%) MeasuredText Balanced NoHyphenation: 548,745 -> 535,891: (-2.3%) MeasuredText Greedy Hyphenation : 486,093 -> 479,541: (-1.3%) MeasuredText Greedy NoHyphenation : 491,053 -> 480,571: (-2.1%) RandomText Balanced Hyphenation : 17,749,025 -> 17,426,362: (-1.8%) RandomText Balanced NoHyphenation : 7,433,576 -> 7,401,203: (-0.4%) RandomText Greedy Hyphenation : 7,388,658 -> 7,327,291: (-0.8%) RandomText Greedy NoHyphenation : 7,375,390 -> 7,381,066: (+0.1%) MeasuredText creation time (w/o -> w/ patch, N=10, walleye-userdebug) Styled Hyphenation : 14,364,510 -> 14,430,830: (+0.5%) Styled Hyphenation WidthOnly : 13,629,489 -> 13,446,345: (-1.3%) Styled NoHyphenation : 14,104,669 -> 13,873,049: (-1.6%) Styled NoHyphenation WidthOnly : 13,304,362 -> 13,091,473: (-1.6%) NoStyled Hyphenation : 17,512,424 -> 17,368,559: (-0.8%) NoStyled Hyphenation WidthOnly : 17,095,872 -> 16,985,377: (-0.6%) NoStyled NoHyphenation : 7,371,994 -> 7,344,223: (-0.4%) NoStyled NoHyphenation WidthOnly : 6,932,519 -> 6,950,149: (+0.3%) StaticLayout draw time (w/o -> w/ patch, N=10, walleye-userdebug) MeasuredText NoStyled : 661,017 -> 657,547: (-0.5%) MeasuredText NoStyled WithoutCache : 660,506 -> 651,035: (-1.4%) MeasuredText Styled : 868,116 -> 854,418: (-1.6%) MeasuredText Styled WithoutCache : 916,078 -> 880,388: (-3.9%) RandomText NoStyled : 561,192 -> 547,528: (-2.4%) RandomText NoStyled WithoutCache : 6,758,025 -> 6,695,065: (-0.9%) RandomText Styled : 2,886,462 -> 2,843,580: (-1.5%) RandomText Styled WithoutCache : 3,319,513 -> 3,276,261: (-1.3%) Bug: 37567215 Test: minikin_tests Test: hwui_unit_tests Test: atest CtsTextTestCases \ CtsWidgetTestCases:EditTextTest \ CtsWidgetTestCases:TextViewFadingEdgeTest \ FrameworksCoreTests:TextViewFallbackLineSpacingTest \ FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \ CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest Test: bit FrameworksCoreTests:android.text. Change-Id: If86840fcf957ca16e3a821204b79156fc23f1596
/frameworks/minikin/libs/minikin/GreedyLineBreaker.cpp
|
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/GreedyLineBreaker.cpp
|
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/GreedyLineBreaker.cpp
|
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/GreedyLineBreaker.cpp
|