OSDN Git Service

Introduce early exit path for non resource path.
authorSeigo Nonaka <nona@google.com>
Mon, 15 May 2017 23:25:11 +0000 (16:25 -0700)
committerSeigo Nonaka <nona@google.com>
Tue, 16 May 2017 17:14:56 +0000 (10:14 -0700)
commit2ea169a2ecbb7e589fcef78cb1486d007a8fb867
treebc9958b4719c1d704157b8179c0751322ff18836
parent9289faa163b2c4ea449cf466cd29dac061647b3e
Introduce early exit path for non resource path.

Developer can specify android:fontFamily with three ways, pre-defined
font family name, e.g. "sans-serif", path to the font file in resource
directory, e.g. "res/fonts/Roboto-Regular.ttf", or path to the XML font
family file, e.g. "res/fonts/Roboto.xml".

Resources.getFont treats font files and XML files but pre-defined family
name is handled by TextView. Thus, we can early exit if the passed value
is not likely resource path.

This improves the inflation performance.
The score without this patch:
gfx-avg-frame-time-50: 6.9
gfx-avg-frame-time-90: 9.4
gfx-avg-frame-time-95: 10.4
gfx-avg-frame-time-99: 16.7

The score with this patch:
gfx-avg-frame-time-50: 7.0
gfx-avg-frame-time-90: 8.9
gfx-avg-frame-time-95: 9.7
gfx-avg-frame-time-99: 16.5

Measured on bullhead-userdebug.

The APCT perf test improves from
String FontFamily: 200,086 -> 132,561
File FontFamily  : 199,256 -> 161,843
XML FontFamily   : 203,681 -> 158,553

Measured on angler-userdebug.

Bug: 38232467
Test: UiBenchmark
Change-Id: Ia601ae7207ae8c60848c9efdbb9396267a57257c
apct-tests/perftests/core/res/font/samplefont.ttf [new file with mode: 0644]
apct-tests/perftests/core/res/font/samplefont_source.ttx [new file with mode: 0644]
apct-tests/perftests/core/res/font/samplexmlfont.xml [new file with mode: 0644]
apct-tests/perftests/core/res/layout/test_textview_font_family_file.xml [new file with mode: 0644]
apct-tests/perftests/core/res/layout/test_textview_font_family_string.xml [new file with mode: 0644]
apct-tests/perftests/core/res/layout/test_textview_font_family_xml.xml [new file with mode: 0644]
apct-tests/perftests/core/res/values/strings.xml
apct-tests/perftests/core/src/android/widget/TextViewFontFamilyLayoutPerfTest.java [new file with mode: 0644]
core/java/android/content/res/ResourcesImpl.java