Make PrecomputedText Spannable for supporting selection
This is 2nd attempt of I072dfd70b9a687d9c47e310d8cdb34f988fbb32e The root cause of crashing is unexpected copying of NoCopySpan by SpannableString constructor. To prevent crashing, stop copying NoCopySpan by passing ignoreNoCopySpan=true to SpannableString copy constructor. The original commit message is following: To support selectable TextView, make PrecomputedText spannable. By this change, TextView start using DynamicLayout instead of StaticLayout. DynamicLayout requires boundary rectangle of the text, so this CL also adds getBounds method to PrecomputedText which retrieves measured boundary box from native. By this change, the selectable TextView performance for the precomputed text 10x faster. On the other hand, the performacne for the non-selectable text gets 2.5x slower. However, we concluded that we accept this performance regression since it still 10 times faster than non precomputed text. Here is a precomputed text performance result of TextView. android.widget.TextViewPrecomputedTextPerfTest: newLayout_PrecomputedText : 736,130 -> 1,648,694: (+124.0%) newLayout_PrecomputedText_Selectable: 17,379,765 -> 1,700,146: (-90.2%) onDraw_PrecomputedText : 1,274,921 -> 1,848,076: (+45.0%) onDraw_PrecomputedText_Selectable : 17,367,238 -> 1,399,169: (-91.9%) onMeasure_PrecomputedText : 752,875 -> 1,766,606: (+134.6%) onMeasure_PrecomputedText_Selectable: 17,647,842 -> 1,810,704: (-89.7%) setText_PrecomputedText : 92,894 -> 135,471: (+45.8%) setText_PrecomputedText_Selectable : 145,134 -> 215,757: (+48.7%) 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: Ie98c75d8b4ba962eaf0a544357b2ff1ade891118
Loading
Please register or sign in to comment