Refactor MeasuredText
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
8 files changed