Include MinikinPaint into cache key
MeasruedText::buildLayout can not be used for acquiring bounding box since
the input range can across the style boundary. To make things correctly,
include MinikinPaint as the key of the LayoutPiece. This is totally same as the
LayoutCacheKey in LayoutCache, so reuses LayoutCacheKey instead of self defined
key class in LayoutPiece.
This increases the memory usage and ideally run index can be used for layout cache
key instead of full MinikinPaint, but let me make thing correct first.
Here is a raw performance result.
android.text.PrecomputedTextMemoryUsageTest:
MemoryUsage
Hyphenation : 50,873 -> 59,721: (+17.4%)
Hyphenation WidthOnly : 8,856 -> 8,856: (+0.0%)
NoHyphenation : 26,386 -> 29,242: (+10.8%)
NoHyphenation WidthOnly : 8,000 -> 8,000: (+0.0%)
android.text.PrecomputedTextPerfTest:
create
NoStyle Hyphenation : 18,378,988 -> 18,332,327: (-0.3%)
NoStyle Hyphenation WidthOnly : 18,332,392 -> 18,397,337: (+0.4%)
NoStyle NoHyphenation : 7,385,258 -> 7,390,699: (+0.1%)
NoStyle NoHyphenation WidthOnly : 7,403,445 -> 7,388,476: (-0.2%)
Style Hyphenation : 12,637,464 -> 12,624,799: (-0.1%)
Style Hyphenation WidthOnly : 12,667,559 -> 12,642,056: (-0.2%)
Style NoHyphenation : 12,348,519 -> 12,241,291: (-0.9%)
Style NoHyphenation WidthOnly : 12,325,515 -> 12,317,746: (-0.1%)
android.text.StaticLayoutPerfTest:
create
PrecomputedText
Balanced Hyphenation : 691,388 -> 680,137: (-1.6%)
Balanced NoHyphenation : 502,038 -> 495,980: (-1.2%)
Greedy Hyphenation : 451,619 -> 446,380: (-1.2%)
Greedy NoHyphenation : 449,011 -> 444,621: (-1.0%)
RandomText
Balanced Hyphenation : 17,639,029 -> 17,609,190: (-0.2%)
Balanced NoHyphenation : 7,295,497 -> 7,251,221: (-0.6%)
Greedy Hyphenation : 7,268,452 -> 7,201,506: (-0.9%)
Greedy NoHyphenation : 7,215,397 -> 7,225,217: (+0.1%)
draw
PrecomputedText
NoStyle : 588,349 -> 620,041: (+5.4%)
NoStyle WithoutCache : 613,312 -> 645,161: (+5.2%)
Style : 911,309 -> 938,200: (+3.0%)
Style WithoutCache : 920,240 -> 955,410: (+3.8%)
RandomText
NoStyle : 542,517 -> 555,951: (+2.5%)
NoStyle WithoutCache : 6,747,436 -> 6,723,770: (-0.4%)
Style : 1,022,591 -> 1,034,170: (+1.1%)
Style WithoutCache : 2,862,071 -> 2,835,226: (-0.9%)
android.widget.TextViewPrecomputedTextPerfTest:
newLayout
PrecomputedText : 791,018 -> 785,320: (-0.7%)
PrecomputedText Selectable : 1,569,428 -> 1,190,267: (-24.2%)
RandomText : 17,146,396 -> 17,064,908: (-0.5%)
RandomText Selectable : 18,239,348 -> 18,225,575: (-0.1%)
onDraw
PrecomputedText : 1,263,842 -> 1,286,294: (+1.8%)
PrecomputedText Selectable : 1,380,186 -> 1,303,995: (-5.5%)
RandomText : 17,734,725 -> 17,823,735: (+0.5%)
RandomText Selectable : 18,549,828 -> 18,610,101: (+0.3%)
onMeasure
PrecomputedText : 799,962 -> 809,164: (+1.2%)
PrecomputedText Selectable : 1,747,993 -> 1,358,504: (-22.3%)
RandomText : 17,155,624 -> 17,087,524: (-0.4%)
RandomText Selectable : 18,435,408 -> 18,515,944: (+0.4%)
setText
PrecomputedText : 136,250 -> 133,602: (-1.9%)
PrecomputedText Selectable : 213,980 -> 205,610: (-3.9%)
RandomText : 16,512 -> 16,599: (+0.5%)
RandomText Selectable : 56,143 -> 56,239: (+0.2%)
Bug: 77495049
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest
Change-Id: I20d7cdd2f11960e334a1f2cd816679bb8f84e6cb
10 files changed