Commit Graph

1493 Commits

Author SHA1 Message Date
Seigo Nonaka
291ef0536d Recompute PcT with existing PcT for different direction
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
2018-12-10 16:18:02 -08:00
qqd
3cdaa2488f Make getUnderlineColor public.
Bug: 117521361
Test: atest CtsTextTestCases:android.text.style.cts.SuggestionSpanTest
Change-Id: Iafc7fa65b495e5cc5e69809c94c15c947ceab9ca
2018-12-03 14:12:42 -08:00
Neil Fuller
f148c8d7d4 Merge "Track move of timezone classes to libcore.timezone" am: d48dbc9a34 am: f79ecf7c82
am: 402dc485d0

Change-Id: If9c8cfdce9bd0b3bcd460216edca369fd75abdde
2018-11-28 08:24:57 -08:00
Neil Fuller
402dc485d0 Merge "Track move of timezone classes to libcore.timezone" am: d48dbc9a34
am: f79ecf7c82

Change-Id: I1551e5d4330ea290ba3e3054349f79ee28f919c6
2018-11-28 08:10:04 -08:00
TreeHugger Robot
36491d6cc1 Merge "Add StaticLayout constructor to dark-grey list" 2018-11-28 00:36:40 +00:00
Siyamed Sinir
00589be8f9 Add StaticLayout constructor to dark-grey list
Test: None
Bug: 117521430
Change-Id: I304214b7749e5dd87e77b8dfe405aae12e68cbb9
2018-11-27 22:43:09 +00:00
Haoyu Zhang
19b3c371d3 Merge "Make LineHeightSpan.Standard a ParcelableSpan" 2018-11-27 21:02:25 +00:00
Abodunrinwa Toki
adc194032b Do not linkify text with RLO/LRO characters.
Also don't show smart actions for selections in text with unsupported
characters.

Bug: 116321860
Test: atest android.view.textclassifier.TextClassifierTest \
            android.text.util.cts.LinkifyTest \
	    android.text.util.LinkifyTest \
	    android.widget.TextViewActivityTest

Change-Id: Id271cab8aef6b9b13ef17f1a8654c7616f75cf13
2018-11-27 15:11:41 +00:00
Neil Fuller
b8383a10b9 Track move of timezone classes to libcore.timezone
Some time zone related libcore classes are moving from
libcore.util to libcore.timezone.

Bug: 119026403
Test: build only
Change-Id: Ic807977a85276b888362295d1d305effe33076fc
2018-11-27 14:44:59 +00:00
Haoyu Zhang
63a5efb46b Make LineHeightSpan.Standard a ParcelableSpan
Implement ParcelableSpan interface for LineHeightSpan.

Bug: 112621694
Test: atest LineHeightSpan_StandardTest
Change-Id: I452a2b12310b525555e908e4d04dda7101693319
2018-11-26 16:54:46 -08:00
TreeHugger Robot
e4e4432545 Merge "Revert "Revert "Refactor TextLine class""" 2018-11-17 01:46:12 +00:00
TreeHugger Robot
5b36e2ba38 Merge "Revert "Revert "Enable PrecomputedText for BiDi text""" 2018-11-17 01:46:12 +00:00
Siyamed Sinir
956213398d Revert "Revert "Enable PrecomputedText for BiDi text""
This reverts commit 321140ad84.

Reason for revert: we thought this CL caused b/119659731 but apparently it is not.

Change-Id: I5b52cc1facec77d6a0d844bcaac53e90c7ecd132
2018-11-16 23:38:23 +00:00
Siyamed Sinir
bf92c2f4f4 Revert "Revert "Refactor TextLine class""
This reverts commit 3c097aa45e.

Reason for revert: we thought this CL caused b/119659731 but apparently it is not.

Change-Id: Id375c4c8f2bffb7c42dc36bc053d536c6ea57a8d
2018-11-16 23:38:12 +00:00
TreeHugger Robot
2dd6939473 Merge "Revert "Refactor TextLine class"" 2018-11-16 21:37:12 +00:00
TreeHugger Robot
5eee684bd4 Merge "Revert "Enable PrecomputedText for BiDi text"" 2018-11-16 21:37:12 +00:00
Siyamed Sinir
321140ad84 Revert "Enable PrecomputedText for BiDi text"
This reverts commit 6224e238d6.

Reason for revert: b/119659731

Change-Id: I33ea82d69d09f113d594446f8979f0df21200662
2018-11-16 20:03:01 +00:00
Siyamed Sinir
3c097aa45e Revert "Refactor TextLine class"
This reverts commit 888dbca2f7.

Reason for revert: <INSERT REASONING HERE>

Change-Id: I259327a6ca507e2614cacdcdabdeca7df48b8ed2
2018-11-16 19:46:28 +00:00
Haoyu Zhang
c826047f85 Merge "Fix getLineLeft crashes when alignment is null" 2018-11-16 00:19:07 +00:00
Seigo Nonaka
6224e238d6 Enable PrecomputedText for BiDi text
Bug: 119312268
Test: atest CtsTextTestCases
Test: atest CtsWidgetTestCases
Test: atest CtsGraphicsTestCases
Change-Id: Ifddf5a35642a22cbb1665fce65c467e6b21bfea6
2018-11-14 17:13:03 -08:00
Haoyu Zhang
d1e6d2e3c6 Fix getLineLeft crashes when alignment is null
Bug: 119221721
Test: atest StaticLayoutGetLineLeftRightTest
Change-Id: If83ac95f47d76052cf088b7d977ee5cded9a8fee
2018-11-14 13:19:14 -08:00
Seigo Nonaka
888dbca2f7 Refactor TextLine class
Did following refactoring:
- The surrogate composition is not necessary since this method is only
  interested in TAB character.
- Move BiDi information interpretation logic to Layout.Directions.
- The short circuit for DIRS_ALL_LEFT_TO_RIGHT/DIRS_ALL_RIGHT_TO_LEFT
  is not necessary.
- Renamed the variables.

Bug: 119312268
Test: atest TextLineTest
Test: TreeHugger
Test: Verified locally this doesn't cause performance regression
Change-Id: If987387673ec5a22f703952dfbe45b084664ee59
2018-11-14 13:18:38 -08:00
Haoyu Zhang
9b74c07517 Merge "Fix getLineRight()/getLineLeft() may compute leadingMargin twice" 2018-10-30 18:16:44 +00:00
Branden Archer
ea3bcb762d fix spelling typo in comment
Test: typo in comment, no test necessary

Change-Id: I5a56c289e1e29a8eca33d55a77c52e87efa446a2
2018-10-29 08:49:55 -07:00
Nathan Harold
41e2d7494f Merge "Move some members to the "Q blacklist"." am: f5cf9f24ed
am: 13c9e7e2f3

Change-Id: Ia2419cce28d26d9464da2a5172cb332b629e943e
2018-10-24 16:14:06 -07:00
Bill Yi
8b634e9191 Merge pie-platform-release to aosp-master - DO NOT MERGE
Change-Id: I695db52f5e22509401258e8b083e7650d401d993
2018-10-24 14:48:44 -07:00
Mathew Inwood
45d2c252b1 Move some members to the "Q blacklist".
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
Merged-In: I719b5c94e5b1f4fa562dd5d655953422958ad37e
Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
(cherry picked from commit 8c854f86a4)
2018-10-22 17:28:24 -07:00
Qingqing Deng
b3e9481f78 Merge "Disable double cursor for BiDi in Layout." 2018-10-22 20:24:52 +00:00
Haoyu Zhang
7425d982f1 Fix getLineRight()/getLineLeft() may compute leadingMargin twice
Bug: 74129926
Test: atest StaticLayoutGetLineLeftRightTest LayoutTest
Change-Id: I5f05d55eb4115d920ac8e5ecb52fbd16fdf60790
2018-10-19 20:53:28 -07:00
qqd
19799c44c4 Disable double cursor for BiDi in Layout.
-- Disabled double cursor for BiDi in Layout.getCursorPath.
-- Add tests in LayoutTest.

Bug: 112875662
Test: Manual (no more double cursors, bidi editing feels OK)
Test: bit FrameworksCoreTests:android.text.LayoutTest
Change-Id: I3d201734d12f59724fa627b06ba9ca8c307c27fb
2018-10-19 19:09:22 -07:00
Seigo Nonaka
9958c4ab21 Introduce FontStyle for future extensibility
This is a ground work for b/114479228
FontStyle is an argument of the font itemization. Currently Android
system uses weight and italic info for itemizing but maybe we will
use width and oblique style in future.
To be extensible in future, introduce FontStyle.

This CL includes:
- new class FontStyle which holds width and italic at this moment. In
  future, we may add width and oblique. (or grdual italic slant)
- Font class still returns weight/slant since they need to be immutable.
- Moved font weight constants from Font to FontStyle

Bug: 114479228
Test: atest CtsGraphicsTestCases
Change-Id: I0ba717fbf9f90ee6f760c1a0f6eda17b4bef6f43
2018-10-19 14:51:59 -07:00
Haoyu Zhang
0a04650e51 Merge "Add textLocale attributes to TextView and TextAppearanceSpan" 2018-10-19 20:30:02 +00:00
Haoyu Zhang
1137512f7c Add textLocale attributes to TextView and TextAppearanceSpan
Bug: 112390716
Test: atest TextAppearanceSpanTest TextViewTest
Change-Id: I812f76cc3acec14b9839436cc7c5cc1ef827998e
2018-10-18 15:38:30 -07:00
Seigo Nonaka
7b86fe573c Change add{StyleRun, ReplacementRun} to append{StyleRun, ReplacementRun}
Giving any range to the Builder is too much freedum and hard to tell
errors. Changes to accept length instead of ranges. By this change, we
can prevent and tell errors about
- The gap in the text that no Paint is assigned.
- The given range is overlapped.
- The given range exceeds the text length.

Bug: 112327179
Test: TreeHugger

Change-Id: Iefc078b1f7be2d006a65b46e0b4ea1018ecb29e7
2018-10-18 14:58:18 -07:00
TreeHugger Robot
e9944aa1dc Merge "Make loadSafeLabel a generic facility as makeSafeForPresentation" 2018-10-16 16:21:10 +00:00
TreeHugger Robot
13635f0ec0 Merge "Fix invalid character access" 2018-10-16 09:08:01 +00:00
Seigo Nonaka
5783c13806 Fix invalid character access
The invalid access has introduced by
I976df4db63be241af395dd30dd94182f76bdae53

Bug: 114454225
Test: atest StaticLayoutLineBreakingTest
Change-Id: I8ad3d7761c98eb8ace97af3a4794d4bfe04c05e0
2018-10-15 18:03:44 -07:00
Haoyu Zhang
36252bf2bf Merge "Add default implementation for LineBackgroundSpan" 2018-10-16 00:31:40 +00:00
Seigo Nonaka
aa35899430 Merge "Make LineBreaker public" 2018-10-15 21:56:12 +00:00
Philip P. Moltmann
c1fda744f0 Make loadSafeLabel a generic facility as makeSafeForPresentation
Any app loading untrusted strings should make the strings face. Hence make
the method publicly available.

Test: atest CtsTextTestCases:MakeSafeForPresentationTest GtsContentTestCases:PackageItemInfoTests
Change-Id: Ib0679fe892181535339dac77583c427e0d64dd05
Fixes: 113856697
2018-10-15 09:11:52 -07:00
Haoyu Zhang
3ad5850818 Update docs for TextAppearanceSpan
Bug: 78873447
Test: atest TextAppearanceSpanTest
Change-Id: If9e4f00a7b023d952f0e091f96765d6234523628
2018-10-12 21:32:00 +00:00
Seigo Nonaka
70200b0f56 Make LineBreaker public
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
2018-10-09 12:16:52 -07:00
Haoyu Zhang
003f737163 Add default implementation for LineBackgroundSpan
Bug: 1526775
Test: atest LineBackgroundSpan_StandardTest
Change-Id: Id97981857a90804387d93e89a1b93c1a74498f47
2018-10-04 12:24:34 -07:00
Seigo Nonaka
a75543820d Merge "Prepare NativeLineBreaker.LineBreaks to be public API" 2018-09-28 18:51:44 +00:00
Haoyu Zhang
88f0f6c9b1 Merge "Synchronize attributes in TextView with TextAppearanceSpan" 2018-09-27 19:15:31 +00:00
Haoyu Zhang
445326d93d Merge "Fix equals not working correctly in SpannableString and SpannableStringBuilder" 2018-09-27 19:14:53 +00:00
Seigo Nonaka
ab9b479d4f Prepare NativeLineBreaker.LineBreaks to be public API
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
2018-09-26 16:25:32 -07:00
Seigo Nonaka
47e79a1626 Merge "Move hasEqualAttribute from Paint with adding some accessors" 2018-09-25 18:34:26 +00:00
Haoyu Zhang
6b4380ea5f Fix equals not working correctly in SpannableString and SpannableStringBuilder
Bug: 73359036
Test: atest SpannableStringTest SpannableStringBuilderTest
Change-Id: Idfaf71cde914d5c5325a6c6a3bfcda20ebee62f2
2018-09-20 16:21:52 -07:00
Haoyu Zhang
87682ba293 Synchronize attributes in TextView with TextAppearanceSpan
Bug: 78873447
Test: atest TextAppearanceSpanTest
Change-Id: I1c71e815389716ac9580f8f76690f6a423632015
2018-09-19 18:21:25 -07:00