From 1090f49c5aada61b7ed6eb7743e34cd4ea937b46 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Mon, 4 Feb 2019 21:07:41 -0800 Subject: Implement batch horizontal advances callback The SkFont's overhead is not negligible if we performs glyph width computation one-by-one. HarfBuzz now supports batch width request, so let's use it for aoviding SkFont's overhead. Here is the raw performance scores: android.text.StaticLayoutPerfTest: create RandomText Balanced Hyphenation : 16,311 -> 15,253: (-1058, -6.5%) RandomText Balanced NoHyphenation : 6,679 -> 6,164: ( -515, -7.7%) RandomText Greedy Hyphenation : 6,614 -> 6,083: ( -531, -8.0%) RandomText Greedy NoHyphenation : 6,613 -> 6,090: ( -523, -7.9%) Bug: 123907498 Test: minikin_tests Test: hwui_unit_tests Test: atest CtsTextTestCases Test: atest CtsGraphicsTestCases Test: atest CtsWidgetTestCases Test: TreeHugger Change-Id: I5a33e24aa0b5d865f02518c5e80177d5a7706593 --- libs/hwui/hwui/MinikinSkia.cpp | 9 +++++++++ libs/hwui/hwui/MinikinSkia.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/libs/hwui/hwui/MinikinSkia.cpp b/libs/hwui/hwui/MinikinSkia.cpp index 375f5bc9df37..6a12a203b9f8 100644 --- a/libs/hwui/hwui/MinikinSkia.cpp +++ b/libs/hwui/hwui/MinikinSkia.cpp @@ -65,6 +65,15 @@ float MinikinFontSkia::GetHorizontalAdvance(uint32_t glyph_id, const minikin::Mi return skWidth; } +void MinikinFontSkia::GetHorizontalAdvances(uint16_t* glyph_ids, uint32_t count, + const minikin::MinikinPaint& paint, + const minikin::FontFakery& fakery, + float* outAdvances) const { + SkFont skFont; + MinikinFontSkia_SetSkiaFont(this, &skFont, paint, fakery); + skFont.getWidths(glyph_ids, count, outAdvances); +} + void MinikinFontSkia::GetBounds(minikin::MinikinRect* bounds, uint32_t glyph_id, const minikin::MinikinPaint& paint, const minikin::FontFakery& fakery) const { diff --git a/libs/hwui/hwui/MinikinSkia.h b/libs/hwui/hwui/MinikinSkia.h index ad46b2391cac..90f7d48a47ee 100644 --- a/libs/hwui/hwui/MinikinSkia.h +++ b/libs/hwui/hwui/MinikinSkia.h @@ -35,6 +35,11 @@ public: float GetHorizontalAdvance(uint32_t glyph_id, const minikin::MinikinPaint& paint, const minikin::FontFakery& fakery) const override; + void GetHorizontalAdvances(uint16_t* glyph_ids, uint32_t count, + const minikin::MinikinPaint& paint, + const minikin::FontFakery& fakery, + float* outAdvances) const override; + void GetBounds(minikin::MinikinRect* bounds, uint32_t glyph_id, const minikin::MinikinPaint& paint, const minikin::FontFakery& fakery) const override; -- cgit v1.2.3-59-g8ed1b