summaryrefslogtreecommitdiff
path: root/core/java/android/text/StaticLayout.java
Commit message (Collapse)AuthorAgeFilesLines
* Update the text wrapping API.James.cf Lin2022-03-101-2/+4
| | | | | | | | | | | 1) Update the LineBreakConfig class to be immutable. 2) Do not return null in the PrecomputedText.Params#getLineBreaiConfig API Bug: 216638444 Test: atest TextViewTest; atest MeasuredTextTest; atest PrecomputedTextTest; atest TextViewPrecomputedTextTest; atest StaticLayoutLineBreakingVariantsTest Merged-In: I93bcb6ebc35344e34e9bb8a24df375aa7b3a8d81 Merged-In: I07766137ff6639c7d4acaad07dbcf11a2841cdb0 Change-Id: I07766137ff6639c7d4acaad07dbcf11a2841cdb0
* Add setLineBreakConfig APISeigo Nonaka2022-01-151-3/+21
| | | | | | | | Add new API to allow applications to specify the line break word style. The line break style is one of the locale extension. When the line break style is set, it will be brought to ICU for calculation. Bug: 183780874 Test: atest minikin_tests; atest TextViewTest; atest MeasuredTextTest; atest PrecomputedTextTest Change-Id: Ia9cdb5b83e346f96ae22abbb1bcce05c43207bba
* Implement fallback line spacing for BoringLayoutSeigo Nonaka2022-01-121-4/+10
| | | | | | | | | | | | | | | | | | | | | | The fallback line spacing is a feature of extending the line height when the fallback font has taller glyph. This was implemented to StaticLayout in Android P but not yet implemented in BoringLayout. This CL enables this feature to the BoringLayout as well. Not to break existing apps, change this behavior only if the targetSdk version is T or later. This is a 2nd attempt of Ia6d6f9f44e73ddaf5e8fe9a8aead7a53efbddd44 The root cause of SystemUI crash was wrong API usage. (start, end) was passed instead of (start, count). Bug: 210923482 Test: atest FallbackLineSpacingTest BoringLayoutFallbackLineSpacingTest Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Test: atest SystemUITests Change-Id: I9137607b0120934f7ad2a12c0f0b8aaa52915831
* Revert "Implement fallback line spacing for BoringLayout"Shubham Dubey2022-01-101-10/+4
| | | | | | | | | | | | | | | | | | | | | Revert "Add font extent calculation" Revert "Add test case for fallback line spacing" Revert submission 16486662-fallback_line_spacing Reason for revert: Investigate test failures on master BUGID: b/213826416 BUGID: b/213829920 Reverted Changes: I06cd7ab71:Add font extent calculation I6214d52cd:Implement fallback line spacing for BoringLayout Ia5825c474:Add test case for fallback line spacing Change-Id: Ia6d6f9f44e73ddaf5e8fe9a8aead7a53efbddd44
* Implement fallback line spacing for BoringLayoutSeigo Nonaka2022-01-061-4/+10
| | | | | | | | | | | | | | | | | The fallback line spacing is a feature of extending the line height when the fallback font has taller glyph. This was implemented to StaticLayout in Android P but not yet implemented in BoringLayout. This CL enables this feature to the BoringLayout as well. Not to break existing apps, change this behavior only if the targetSdk version is T or later. Bug: 210923482 Test: atest FallbackLineSpacingTest BoringLayoutFallbackLineSpacingTest Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Change-Id: I6214d52cde25a044bc6e246d2118e35d3a243c9d
* Fix top/bottom to adjust fallback ascent/descent.Seigo Nonaka2021-12-101-0/+12
| | | | | | | | | | The fallback ascent/descent can be larger than default font top/bottom height. Not to clip the bottom of the view, adjust the top/bottom with fallback ascent/descent. Bug: 210163467 Test: atest StaticLayoutFallbackLineSpacingTest Change-Id: Ifbf64f6d281d3324a926a6f0b45941824d499179
* Implement fast hyphenation algorithmSeigo Nonaka2021-11-101-1/+15
| | | | | | | | | | | | | | | | | | | | | RandomText Balanced Hyphenation ON min: 2,312,291 mean: 2,320,574 median: 2,320,112 RandomText Balanced Hyphenation ON(Fast) min: 985,850 mean: 990,922 median: 986,586 RandomText Balanced Hyphenation OFF min: 909,060 median: 923,585 mean: 930,052 Bug: 201096525 Test: TreeHugger and minikin_tests Change-Id: Ide2d73acb3de85e91018e524c89df2c949235a4e
* Fix ellipsis reinitialization for static cached StaticLayout.Ahaan Ugale2021-02-051-0/+3
| | | | | | | | | | | | | | | DynamicLayout uses a static StaticLayout instance internally to avoid allocations. For the specific case of multiline, TruncateAt.START, and no ellipsization needed (may also be triggered by slightly different params), the ellipsis results for a reused static instance are not modified. If the instance was previously ellipsized, the new result keeps that ellipsization result even though it shouldn't be ellipsized (at least for some lines). Bug: 179524847 Test: atest DynamicLayoutBlocksTest DynamicLayoutTest TextLayoutTest \ TextViewTest Change-Id: I1b4142648ec1b6b3fc2ece0ec55aac9539497134
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-5/+5
| | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-5/+5
| | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-5/+5
| | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-071-1/+1
| | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I288969b0c22fa3a63bc2e71bb5009fe4a927e154
* Merge "Change TabStop type from int to float"TreeHugger Robot2019-03-131-4/+4
|\
| * Change TabStop type from int to floatSeigo Nonaka2019-03-121-4/+4
| | | | | | | | | | | | | | | | | | This is from API council feedback. Bug: 124794899 Test: atest CtsTextTestCases Test: atest CtsGraphicsTestCases Change-Id: Ifa95f87067239cca9c0791bf079045e4f645c3ad
* | Hide packing structure from public APISeigo Nonaka2019-03-111-8/+34
|/ | | | | | | | | | | | | | | | | | | The hyphen edit is packed into 8bit integer in native library, but this should not be exposed to public API as API council suggested. This CL includes: - Removing packing structure from HyphenEdit and move constants from Hyphenator to Paint. - Replace LineBreaker's getLineHyphenEdit with two separate start/end function. - Replace Paint's getHyphenEdit with two separate start/end function. - StaticLayout still relies on this packing mechanism but no longer need to be the same packing structure as in Minikin. Bug: 124794844 Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Change-Id: I8206061f554cf6e119b2b565162f54317eac630a
* Address API review from the councilSeigo Nonaka2019-03-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here are the list this CL includes: - Adding missing @NonNull, @Nullable, @IntRange annotations - Added @Px annotation to Paint.set/getWordSpacing - Change Builder classes to final. - Change FileDescriptor to ParcelFileDescriptor as described in guideline. - With this change, additional error handling is required in old Typeface.Builder but we can keep the same behavior (silently fallback to system fallback in error case). - Fix comment in getLineHyphenEdit in LineBreaker.Result - Rename setJustified to setJustificationMode in LineBreaker.Builder Fix: 126702154 Fix: 126701272 Fix: 126701569 Fix: 126701953 Fix: 126701507 Fix: 126701667 Fix: 126700866 Fix: 126701009 Fix: 126700795 Fix: 126700292 Fix: 126699209 Fix: 124795407 Fix: 124795470 Bug: 124794844 Bug: 124794899 Test: m update-api Test: TreeHugger Change-Id: If6e8566b0eef9151d35d75b7f258128d7d3df358
* Fix that TextLine overwrites wordSpcing on paintHaoyu Zhang2019-01-081-0/+4
| | | | | | | | | | | TextLine is using wordSpcing for justification. And previously, TextLine will overwrite wordSpcing even justification is not on. This CL make sure that TextLine only changes wordSpcing when justification is on. Bug: 122471618 Test: atest TextLineTest Change-Id: I6f1e2f6c17b65f92d7a5bb064fdafbf5df9ef8f7
* Recompute PcT with existing PcT for different directionSeigo Nonaka2018-12-101-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The text direction can not be fully determined in detached state. To improve even in that case, compute PrecomputedText from existing PrecomputedText with new direction. Here is the performance difference. According to the perf test result, up to 80% of computation can be recycled from existing PrecomputedText. android.text.StaticLayoutPerfTest (u sec): PrecomputedText Greedy NoHyphenation : 371 -> 371: ( +0, +0.0%) PrecomputedText Greedy NoHyphenation DirDifferent: 6,923 -> 1,437: (-5486, -79.2%) RandomText Greedy NoHyphenation : 6,633 -> 6,627: ( -6, -0.1%) On the other hand, this CL increase the memory usage of the PrecomputedText up to 10%. Here is an reference memory usage. android.text.PrecomputedTextMemoryUsageTest (bytes): MemoryUsage Arabic Hyphenation : 17,135 -> 18,116: ( +981, +5.7%) Arabic NoHyphenation : 17,135 -> 18,116: ( +981, +5.7%) CJK Hyphenation : 29,000 -> 31,584: (+2584, +8.9%) CJK NoHyphenation : 29,000 -> 31,584: (+2584, +8.9%) Latin Hyphenation : 16,526 -> 17,185: ( +659, +4.0%) Latin NoHyphenation : 14,200 -> 14,784: ( +584, +4.1%) Bug: 119312268 Test: atest CtsWidgetTestCases Test: atest CtsTextTestCases Test: atest CtsGraphicsTestCases Test: minikin_tests Change-Id: Ia02c201afac5d7d1c086a45f15696f39a6b2a76c
* Add StaticLayout constructor to dark-grey listSiyamed Sinir2018-11-271-1/+1
| | | | | | Test: None Bug: 117521430 Change-Id: I304214b7749e5dd87e77b8dfe405aae12e68cbb9
* Fix invalid character accessSeigo Nonaka2018-10-151-1/+1
| | | | | | | | | The invalid access has introduced by I976df4db63be241af395dd30dd94182f76bdae53 Bug: 114454225 Test: atest StaticLayoutLineBreakingTest Change-Id: I8ad3d7761c98eb8ace97af3a4794d4bfe04c05e0
* Make LineBreaker publicSeigo Nonaka2018-10-091-6/+7
| | | | | | | | | | | | | | | This CL includes: - Move NativeLineBreaker/NativeMeasuredParagraph to android.graphics.text package since these two uses the shaping result of the text which is a part of graphics responsibility. At the same time, by this moving, minikin is only used by android.graphics package. - Rename NativeLineBreaker/NativeMeasuredParagraph to LineBreaker/MeasuredText. - Updated comments of the break strategy and hyphenation frequency. Bug: 112327179 Test: atest CtsTextTestCases CtsGraphicsTestCases CtsWidgetTestCases Change-Id: Id69c328e7c9097b9fc11b5c0bd04d1c2e0939c6a
* Prepare NativeLineBreaker.LineBreaks to be public APISeigo Nonaka2018-09-261-18/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a ground work of making NativeLineBreaker/MeasuredParagraph public. This CL rename NativeLineBreaker.LineBreaks to NativeLineBreaker.Result. This CL also moving array re-allocation logic from native code to Java in StaticLayout. Ideally, we can remove array but this CL keeps array since that introduces additional complexity. Here is a raw perf test result: android.text.StaticLayoutPerfTest: create PrecomputedText Balanced Hyphenation : 667 -> 810: (+143, +21.4%) PrecomputedText Balanced NoHyphenation: 510 -> 594: ( +84, +16.5%) PrecomputedText Greedy Hyphenation : 446 -> 530: ( +84, +18.8%) PrecomputedText Greedy NoHyphenation : 448 -> 533: ( +85, +19.0%) RandomText Balanced Hyphenation : 17,982 -> 18,176: (+194, +1.1%) RandomText Balanced NoHyphenation : 7,348 -> 7,461: (+113, +1.5%) RandomText Greedy Hyphenation : 7,293 -> 7,330: ( +37, +0.5%) RandomText Greedy NoHyphenation : 7,289 -> 7,352: ( +63, +0.9%) draw PrecomputedText NoStyle : 645 -> 645: ( +0, +0.0%) PrecomputedText Style : 941 -> 947: ( +6, +0.6%) RandomText NoStyle : 541 -> 543: ( +2, +0.4%) RandomText Style : 751 -> 753: ( +2, +0.3%) android.widget.TextViewPrecomputedTextPerfTest: newLayout PrecomputedText : 839 -> 983: (+144, +17.2%) PrecomputedText Selectable : 883 -> 1,053: (+170, +19.3%) RandomText : 17,594 -> 17,761: (+167, +0.9%) RandomText Selectable : 18,331 -> 18,695: (+364, +2.0%) onDraw PrecomputedText : 1,233 -> 1,385: (+152, +12.3%) PrecomputedText Selectable : 1,164 -> 1,207: ( +43, +3.7%) RandomText : 18,836 -> 19,042: (+206, +1.1%) RandomText Selectable : 19,025 -> 19,092: ( +67, +0.4%) onMeasure PrecomputedText : 853 -> 991: (+138, +16.2%) PrecomputedText Selectable : 1,077 -> 1,234: (+157, +14.6%) RandomText : 17,613 -> 17,913: (+300, +1.7%) RandomText Selectable : 18,696 -> 18,922: (+226, +1.2%) setText PrecomputedText : 133 -> 136: ( +3, +2.3%) PrecomputedText Selectable : 190 -> 192: ( +2, +1.1%) RandomText : 10 -> 11: ( +1, +10.0%) RandomText Selectable : 49 -> 50: ( +1, +2.0%) Bug: 112327179 Test: atest FrameworksCoreTests CtsGraphicsTestCases CtsWidgetTestCases CtsTextTestCases Change-Id: I25f41dacf73e00a859f43331bc53f8d123116192
* Move some members to the "Q blacklist".Mathew Inwood2018-09-141-1/+2
| | | | | | | | | | | | | | Based on some analysis, these fields/methods are likely false positives. Set maxTargetSdk=P so that any apps using them are required to migrate off them in future. See the bug for more details. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
* Unhide HyphenEdit related methodsSeigo Nonaka2018-09-101-2/+10
| | | | | | | | These APIs are necessary to implement hyphenation by third party developers. Bug: 112327179 Test: atest android.graphics.cts.PaintTest#testSetGetHyphenEdit Change-Id: I692a56d3d1b15100503eb6d8e0f59d6c5c8af81b
* Introduce NativeLineBreaker.Builder and ParagraphConstraintSeigo Nonaka2018-08-171-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To make NativeLineBreaker public API, introduce NativeLineBreaker.Builder and ParagraphConstraint. Here is a performance differences: android.text.StaticLayoutPerfTest: PrecomputedText Balanced Hyphenation : 635 -> 684: ( +49, +7.7%) PrecomputedText Balanced NoHyphenation: 477 -> 523: ( +46, +9.6%) PrecomputedText Greedy Hyphenation : 413 -> 463: ( +50, +12.1%) PrecomputedText Greedy NoHyphenation : 413 -> 463: ( +50, +12.1%) RandomText Balanced Hyphenation : 18,030 -> 18,157: (+127, +0.7%) RandomText Balanced NoHyphenation : 7,390 -> 7,388: ( -2, -0.0%) RandomText Greedy Hyphenation : 7,319 -> 7,331: ( +12, +0.2%) RandomText Greedy NoHyphenation : 7,316 -> 7,375: ( +59, +0.8%) draw PrecomputedText NoStyle : 631 -> 627: ( -4, -0.6%) PrecomputedText Style : 842 -> 847: ( +5, +0.6%) RandomText NoStyle : 531 -> 547: ( +16, +3.0%) RandomText Style : 754 -> 758: ( +4, +0.5%) Bug: 112327179 Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases FrameworksCoreTests:android.text CtsWidgetTestCases:TextViewPrecomputedTextTest CtsGraphicsTestCases:android.graphics.fonts Change-Id: I5b817bbc9f00e5806efa98f239ee20ff3d688c50
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-151-0/+14
| | | | | | | | | | | | | | | | | | | | For packages: android.text.util android.text.style android.text.method android.text.format android.text This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I9afbd4ca8826c37cb70db43252e39b9a674e5ae0
* Merge "Disable hyphenation by in default theme"Siyamed Sinir2018-08-071-0/+14
|\
| * Disable hyphenation by in default themeSiyamed Sinir2018-07-231-0/+14
| | | | | | | | | | | | | | | | | | Test: Added cts tests for default values Test: atest CtsWidgetTestCases:EditTextTest Test: atest CtsWidgetTestCases:TextViewTest Test: atest FrameworksCoreTests:TextViewTest Bug: 111096709 Change-Id: Ia4d13574557970432fdcd27581ee3fff4ec36c64
* | Extract native methods into isolated classesSeigo Nonaka2018-07-271-268/+200
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | StaticLayout/MeasuredParagraph uses native methods which is a pain point of porting TextView to JetPack. To make minimize the dependency to the native methods, extract native methods and put them into a thin wrapper class. The performance impact is limited: android.text.StaticLayoutPerfTest: PrecomputedText Balanced Hyphenation : 602 -> 644: ( +42, +7.0%) PrecomputedText Balanced NoHyphenation: 457 -> 476: ( +19, +4.2%) PrecomputedText Greedy Hyphenation : 397 -> 412: ( +15, +3.8%) PrecomputedText Greedy NoHyphenation : 397 -> 411: ( +14, +3.5%) RandomText Balanced Hyphenation : 17,594 -> 17,715: (+121, +0.7%) RandomText Balanced NoHyphenation : 7,146 -> 7,236: ( +90, +1.3%) RandomText Greedy Hyphenation : 7,125 -> 7,196: ( +71, +1.0%) RandomText Greedy NoHyphenation : 7,099 -> 7,187: ( +88, +1.2%) draw PrecomputedText NoStyle : 614 -> 628: ( +14, +2.3%) PrecomputedText Style : 778 -> 826: ( +48, +6.2%) RandomText NoStyle : 537 -> 540: ( +3, +0.6%) RandomText Style : 786 -> 759: ( -27, -3.4%) Bug: N/A Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases FrameworksCoreTests:android.text CtsWidgetTestCases:TextViewPrecomputedTextTest Change-Id: I976df4db63be241af395dd30dd94182f76bdae53
* Cleanup: Remove unused padding argumentsSeigo Nonaka2018-06-051-36/+2
| | | | | | Bug: N/A Test: N/A Change-Id: I05f5a7d45fcbdc5aacee3e2e915b62017b9cd178
* Merge "Stop creating PrecomputedText in StaticLayout" into pi-dev am: be8b90b966Seigo Nonaka2018-03-211-16/+14
|\ | | | | | | | | | | am: ccaf61ff44 Change-Id: I450b62679599144eb202344d464a3167a3fb2611
| * Stop creating PrecomputedText in StaticLayoutSeigo Nonaka2018-03-201-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix StaticLayout maxLineHeight warningSiyamed Sinir2018-03-081-4/+4
|/ | | | | | | | | Test: atest cts/tests/tests/widget/src/android/widget/cts/TextViewTest.java Test: atest cts/tests/tests/text/src/android/text/cts/StaticLayoutTest.java Test: atest frameworks/base/core/tests/coretests/src/android/text/StaticLayoutTest.java Test: Visual inspection on apk’s provided in b/28988744#3 Bug: 67678695 Change-Id: Ia2de14bc06022fd963b6cc677404906efbe8b70a
* Reorganize MeasuredText API (2nd)Seigo Nonaka2018-02-161-28/+11
| | | | | | | | | | | | | | | | | | | | | | | | This is 2nd attempt of I7db9e2ca4db68a16648cfb8fcf63555f501304c2 This CL changes the MeasuredText API: - Rename MeasuredText to PrecomputedText. - Introduce PrecomputedText.Param which holds all text layout parameters. - Add API to get PrecomputedText.Param from TextView. - Remove MeasuredText.Builder and add PrecomputedText.create method instead. - Remove setRange from MeasuredText since it is not for normal use case. (It can not be used for TextView) Bug: 67504091 Bug: 72861572 Test: bit FrameworksCoreTests:android.text. Test: atest CtsWidgetTestCases:EditTextTest \ CtsWidgetTestCases:TextViewFadingEdgeTest \ FrameworksCoreTests:TextViewFallbackLineSpacingTest \ FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \ CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \ CtsTextTestCases Change-Id: Ie73bce52c6c673cda58973ddad04627a7cf2e5e9
* Revert "Reorganize MeasuredText API"Seigo Nonaka2018-02-141-48/+36
| | | | | | | | | | The last change needs more discussion and found some edge cases. Revert and make small step-by-step changes. Bug: 73091756 This reverts commit 7fd36d19e309ea515b4048cfaabb8035ceab7baf. Change-Id: I89ff52a70cf6a5d6c553afa20f83719e1f9eb726
* Reorganize MeasuredText APISeigo Nonaka2018-02-121-36/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL changes the MeasuredText API: - Rename MeasuredText to PrecomputedText. - PrecomputedText is no longer a Spanned. - Introduce PrecomputedText.Param which holds all text layout parameters. - Add API to get PrecomputedText.Param from TextView. - Remove MeasuredText.Builder and add PrecomputedText.create method instead. - Remove setRange from MeasuredText since it is not for normal use case. (It can not be used for TextView) Here is a performance scores: (median, walleye-userdebug, N=20) StaticLayout creation time (w/o patch -> w/ patch) PrecomputedText Balanced Hyphenation : 743,615 -> 737,145: (-0.9%) PrecomputedText Balanced NoHyphenation: 551,544 -> 542,715: (-1.6%) PrecomputedText Greedy Hyphenation : 500,343 -> 499,601: (-0.1%) PrecomputedText Greedy NoHyphenation : 497,987 -> 492,587: (-1.1%) RandomText Balanced Hyphenation : 19,100,592 -> 19,135,289: (+0.2%) RandomText Balanced NoHyphenation : 8,015,088 -> 7,954,260: (-0.8%) RandomText Greedy Hyphenation : 7,950,915 -> 7,877,424: (-0.9%) RandomText Greedy NoHyphenation : 7,939,337 -> 7,863,471: (-1.0%) PrecomputedText creation time (w/o patch -> w/ patch) NoStyled Hyphenation : 18,935,638 -> 18,925,422: (-0.1%) NoStyled Hyphenation WidthOnly : 18,469,726 -> 18,978,413: (+2.8%) NoStyled NoHyphenation : 7,940,792 -> 7,919,127: (-0.3%) NoStyled NoHyphenation WidthOnly : 7,463,230 -> 7,922,643: (+6.2%) Styled Hyphenation : 14,822,501 -> 14,809,017: (-0.1%) Styled Hyphenation WidthOnly : 13,891,770 -> 14,656,617: (+5.5%) Styled NoHyphenation : 14,511,134 -> 14,301,503: (-1.4%) Styled NoHyphenation WidthOnly : 13,495,345 -> 14,264,314: (+5.7%) StaticLayout draw time (w/o patch -> w/ patch) PrecomputedText NoStyled : 663,974 -> 661,610: (-0.4%) PrecomputedText NoStyled WithoutCache : 648,294 -> 648,766: (+0.1%) PrecomputedText Styled : 879,322 -> 852,770: (-3.0%) PrecomputedText Styled WithoutCache : 1,084,570 -> 1,110,147: (+2.4%) RandomText NoStyled : 565,682 -> 555,435: (-1.8%) RandomText NoStyled WithoutCache : 9,070,533 -> 9,064,825: (-0.1%) RandomText Styled : 2,955,202 -> 2,962,008: (+0.2%) RandomText Styled WithoutCache : 12,242,325 -> 12,228,573: (-0.1%) Bug: 67504091 Bug: 73091756 Test: bit FrameworksCoreTests:android.text. Test: atest CtsWidgetTestCases:EditTextTest \ CtsWidgetTestCases:TextViewFadingEdgeTest \ FrameworksCoreTests:TextViewFallbackLineSpacingTest \ FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \ CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \ CtsTextTestCases Change-Id: I7db9e2ca4db68a16648cfb8fcf63555f501304c2
* Merge "Compute full text layout in MeasuredText and use it for drawing"TreeHugger Robot2018-01-241-1/+1
|\
| * Compute full text layout in MeasuredText and use it for drawingSeigo Nonaka2018-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Revert "Make ellipsize retry if text doesn't fit"Siyamed Sinir2018-01-231-155/+62
|/ | | | | | | | | | | | | | | | This reverts commit e88b5df5b7aaf5a5f654805eb5e5e4c2f09afaa8. Test: bit FrameworksCoreTests:android.text.StaticLayoutTest Test: bit FrameworksCoreTests:android.text.DynamicLayoutTest Test: bit FrameworksCoreTests:android.text.TextUtilsTest Test: bit CtsTextTestCases:* Test: atest FilesActivityUiTest Bug: 71599479 Bug: 31537595 Bug: 64156587 Change-Id: I1afa77a4b90b9b822b409a3f4721c45d0c0a6664
* Compute hyphenated word pieces in MeasuredTextSeigo Nonaka2018-01-181-10/+24
| | | | | | Bug: 67504091 Test: bit CtsTextTestCases:* Change-Id: Id1ff5abbf6d433a2d8baad364133fca98d1fe450
* Rename PremeasuredText to MeasuredTextSeigo Nonaka2018-01-111-25/+26
| | | | | | | | | | 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
* Deprecate StaticLayout and DynamicLayout constructorsClara Bayarri2017-12-191-19/+13
| | | | | | | | | | The Builders should be used instead. Also remove a StaticLayout constructor only used in tests in favor of the Builder. Bug: 64985428 Test: adb shell am instrument -w -e class android.text.StaticLayoutTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner Change-Id: Ief6839d2c6bb0969bdeb30359eae00d38a2bdb09
* Introduce PremeasuredTextSeigo Nonaka2017-12-111-21/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By measuring the character widths beforehand, we can save at least 40% of the StaticLayout construction time which typically happens on UI thread. Also verified this doesn't cause performance regression for not premeasured text. Raw performance score (Not premeasured -> premeasured, median, N=100) No Style, Greedy, Hyphenation OFF: 7,812,975 -> 503,245 (-93.6%) No Style, Balanced, Hyphenation OFF: 7,843,254 -> 396,892 (-95.0%) No Style, Greedy, Hyphenation ON : 19,134,214 -> 11,658,928 (-39.1%) No Style, Balanced, Hyphenation ON : 19,348,062 -> 11,634,942 (-39.9%) Styled, Greedy, Hyphenation OFF: 14,353,673 -> 572,840 (-96.0%) Raw performance score (w/o patch -> w/ patch, median, N=100): No Style, Greedy, Hyphenation OFF: 7,732,894 -> 7,812,975 (+1.04%) No Style, Balanced, Hyphenation OFF: 7,884,510 -> 7,843,254 (-0.52%) No Style, Greedy, Hyphenation ON : 18,986,958 -> 19,134,214 (+0.78%) No Style, Balanced, Hyphenation ON : 19,232,791 -> 19,348,062 (+0.60%) Styled, Greedy, Hyphenation OFF: 14,319,690 -> 14,353,673 (+0.24%) Bug: 67504091 Test: bit CtsTextTestCases:* Test: bit CtsGraphicsTestCases:* Test: bit CtsWidgetTestCases:* Test: FrameworksCoreTests:android.text.MeasuredTextTest Change-Id: I0b46f04b42cc012606a9c722eca0d51147a0dcc7
* Fix testCursorIsOnRight test caseSeigo Nonaka2017-12-111-8/+5
| | | | | | | | | | | | | This is partial revert of Ie932903845645e50cfa0cb428babb31a44babc47 The root cause is MeasuredText.getParagraphDir respect requsted text direction even if it is an empty text. Ideally we don't need to create MeasuredText object for empty string but for safety, reverted to the original code. Bug: 70384435 Test: bit FrameworksCoreTests:android.widget.EditorCursorTest Change-Id: Id24405f476c50fa27743589a640281d96de1c9ce
* Associate native MeasuredText with Java one.Seigo Nonaka2017-12-051-47/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | To measure text beforehand, remove static layout dependency from MeasuredText. Now MeasuredText can compute native measured text by itself and StaticLayout use it for line breaking. This CL introduce one additional JNI method call per paragraph during line breaking but looks negligible cost. Here is a raw performance test result on walleye-userdebug. StaticLayoutPerfTest (median, N=100): createRandom: 7,879,440 -> 7,964,789 (+1.08%) createRandom Balanced: 7,835,192 -> 7,848,151 (+0.17%) TextViewOnMeasurePerfTest (median, N=100): measure_AtMost: 92,599,175 -> 93,027,121 (+0.47%) measure_Exactly: 89,949,922 -> 90,439,886 (+0.54%) measure_Unspecified: 148,645,916 -> 150,047,694 (+0.94%) Bug: 67504091 Test: bit CtsTextTestCases:* Test: bit CtsWidgetTestCases:* Test: bit CtsGraphicsTestCases:* Test: bit FrameworksCoreTests:android.text.StaticLayoutTest Change-Id: Ie932903845645e50cfa0cb428babb31a44babc47
* Refactor MeasuredTextSeigo Nonaka2017-12-051-84/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is 2nd attempt of I58d3020a3fa560d05576e18888fbfe46e2975e8f The root cause of the crash is passing end offset instead of passing length. This CL contains that fix and also has a test case for that. This refactoring contains: - Add lots of comments. - Mark private the internal fields and introduce accessors and helper methods. - Factor out the auto grow array implementation to another class. - Use SynchronizedPool for pool implementation. - Introduce three build methods for each use case. - Hide addStyleRun and compute all necessary informations in build method. Locally verified that this doesn't cause performance regressions. Here is a raw performance test result on walleye-userdebug. StaticLayoutPerfTest (median, N=100): createRandom: 7,846,449 -> 8,003,903 (+2.01%) createRandom Balanced: 7,810,436 -> 7,919,200 (+1.40%) TextViewOnMeasurePerfTest (median, N=100): measure_AtMost: 94,276,376 -> 94,124,658 (-0.16%) measure_Exactly: 91,629,352 -> 91,617,639 (-0.01%) measure_Unspecified: 151,006,181 -> 150,957,598 (-0.03%) Test: bit CtsTextTestCases:* Test: bit CtsGraphicsTestCases:* Test: bit CtsWidgetTestCases:* Test: bit FrameworksCoreTests:android.text.StaticLayoutTest Bug: 65024629 Bug: 70146381 Change-Id: I772f60444d0fe87f59609977af5ef712cab3eb37
* Revert "Refactor MeasuredText"Seigo Nonaka2017-12-041-26/+84
| | | | | | | | This reverts commit 75492afb1b6566c889025e9ca0a15a0d0fe422aa. Reason for revert: 70146381 Change-Id: Ibb6433b5e02608326ef51cc16d8d5d8efa86beec
* Refactor MeasuredTextSeigo Nonaka2017-11-301-84/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This refactoring contains: - Add lots of comments. - Mark private the internal fields and introduce accessors and helper methods. - Factor out the auto grow array implementation to another class. - Use SynchronizedPool for pool implementation. - Introduce three build methods for each use case. - Hide addStyleRun and compute all necessary informations in build method. Locally verified that this doesn't cause performance regressions. Here is a raw performance test result on walleye-userdebug. StaticLayoutPerfTest (median, N=100): createRandom: 7,846,449 -> 8,003,903 (+2.01%) createRandom Balanced: 7,810,436 -> 7,919,200 (+1.40%) TextViewOnMeasurePerfTest (median, N=100): measure_AtMost: 94,276,376 -> 94,124,658 (-0.16%) measure_Exactly: 91,629,352 -> 91,617,639 (-0.01%) measure_Unspecified: 151,006,181 -> 150,957,598 (-0.03%) Test: bit CtsTextTestCases:* Test: bit CtsGraphicsTestCases:* Test: bit CtsWidgetTestCases:* Test: bit FrameworksCoreTests:android.text.StaticLayoutTest Bug: 65024629 Change-Id: I58d3020a3fa560d05576e18888fbfe46e2975e8f
* Reorganize JNI in StaticLayoutSeigo Nonaka2017-10-241-292/+321
| | | | | | | | | | | | | | | | | | | | | | | | This CL reorganize the JNI strategy as follows: - Remove nNewBuilder/nFreeBuilder. - Make addStyleRun/addReplacementRun CriticalNative. - Remove nSetupParagraph and pass necessary arguments to nComputeLineBreaks instead. Here is a performance scores: (w/o patch -> w/ patch) StaticLayoutPerfTest (median): createRandom: 3,755,090 -> 3,781,394 (+0.70%) createRandom Balanced: 3,702,837 -> 3,730,435 (+0.74%) TextViewOnMeasurePerfTest (median): measure_AtMost: 39,172,360 -> 35,883,014 (-8.4%) measure_Exactly: 38,005,066 -> 34,585,052 (-9.0%) measure_Unspecified: 67,191,780 -> 63,100,545 (-6.1%) Bug: 65024629 Test: bit CtsTextTestCases:* Test: bit CtsWidgetTestCases:* Change-Id: If9db1fdd2b03a1cf240f87322c1e852cf8085fff
* Move hyphenator mapping to native code.Seigo Nonaka2017-10-131-43/+8
| | | | | | | | | | | | | | This CL contains the following changes: - Replace Hyphenator mapping in Java with minikin::HyphenatorMap. - Remove locale tracking code from StaticLayout.java - Stop creating Hyphenator pointer array in StaticLayout. Bug: 65024629 Bug: 67319341 Test: bit CtsTextTestCases:* Test: bit FrameworksCoreTests:android.text. Test: bit FrameworksCoreTests:android.widget.TextViewTest Change-Id: Ib88c8e816c70959057abe296cc434ddb70bc397a