diff options
| author | 2024-08-26 01:41:23 +0000 | |
|---|---|---|
| committer | 2024-08-26 01:41:23 +0000 | |
| commit | 03a6f8bf1c2034c455e5f0c2ccb712535d2aec55 (patch) | |
| tree | 40adf6cff23cf502a56f3668b414c7eb58131c47 | |
| parent | 4cc6b39fa5fe44f5b4c71b1447b49b84d745ec6d (diff) | |
| parent | 3c07e21b71fd3b41827531d425b5787652542fb9 (diff) | |
Merge "Use run based APIs for iterating fonts" into main
| -rw-r--r-- | libs/hwui/FeatureFlags.h | 9 | ||||
| -rw-r--r-- | libs/hwui/hwui/MinikinUtils.h | 49 |
2 files changed, 42 insertions, 16 deletions
diff --git a/libs/hwui/FeatureFlags.h b/libs/hwui/FeatureFlags.h index ac75c077b58f..c1c30f5379ab 100644 --- a/libs/hwui/FeatureFlags.h +++ b/libs/hwui/FeatureFlags.h @@ -49,6 +49,15 @@ inline bool letter_spacing_justification() { #endif // __ANDROID__ } +inline bool typeface_redesign() { +#ifdef __ANDROID__ + static bool flag = com_android_text_flags_typeface_redesign(); + return flag; +#else + return true; +#endif // __ANDROID__ +} + } // namespace text_feature } // namespace android diff --git a/libs/hwui/hwui/MinikinUtils.h b/libs/hwui/hwui/MinikinUtils.h index f8574ee50525..1510ce1378d8 100644 --- a/libs/hwui/hwui/MinikinUtils.h +++ b/libs/hwui/hwui/MinikinUtils.h @@ -27,6 +27,8 @@ #include <cutils/compiler.h> #include <log/log.h> #include <minikin/Layout.h> + +#include "FeatureFlags.h" #include "MinikinSkia.h" #include "Paint.h" #include "Typeface.h" @@ -71,27 +73,42 @@ public: static void forFontRun(const minikin::Layout& layout, Paint* paint, F& f) { float saveSkewX = paint->getSkFont().getSkewX(); bool savefakeBold = paint->getSkFont().isEmbolden(); - const minikin::MinikinFont* curFont = nullptr; - size_t start = 0; - size_t nGlyphs = layout.nGlyphs(); - for (size_t i = 0; i < nGlyphs; i++) { - const minikin::MinikinFont* nextFont = layout.typeface(i).get(); - if (i > 0 && nextFont != curFont) { + if (text_feature::typeface_redesign()) { + for (uint32_t runIdx = 0; runIdx < layout.getFontRunCount(); ++runIdx) { + uint32_t start = layout.getFontRunStart(runIdx); + uint32_t end = layout.getFontRunEnd(runIdx); + const minikin::FakedFont& fakedFont = layout.getFontRunFont(runIdx); + + std::shared_ptr<minikin::MinikinFont> font = fakedFont.typeface(); + SkFont* skfont = &paint->getSkFont(); + MinikinFontSkia::populateSkFont(skfont, font.get(), fakedFont.fakery); + f(start, end); + skfont->setSkewX(saveSkewX); + skfont->setEmbolden(savefakeBold); + } + } else { + const minikin::MinikinFont* curFont = nullptr; + size_t start = 0; + size_t nGlyphs = layout.nGlyphs(); + for (size_t i = 0; i < nGlyphs; i++) { + const minikin::MinikinFont* nextFont = layout.typeface(i).get(); + if (i > 0 && nextFont != curFont) { + SkFont* skfont = &paint->getSkFont(); + MinikinFontSkia::populateSkFont(skfont, curFont, layout.getFakery(start)); + f(start, i); + skfont->setSkewX(saveSkewX); + skfont->setEmbolden(savefakeBold); + start = i; + } + curFont = nextFont; + } + if (nGlyphs > start) { SkFont* skfont = &paint->getSkFont(); MinikinFontSkia::populateSkFont(skfont, curFont, layout.getFakery(start)); - f(start, i); + f(start, nGlyphs); skfont->setSkewX(saveSkewX); skfont->setEmbolden(savefakeBold); - start = i; } - curFont = nextFont; - } - if (nGlyphs > start) { - SkFont* skfont = &paint->getSkFont(); - MinikinFontSkia::populateSkFont(skfont, curFont, layout.getFakery(start)); - f(start, nGlyphs); - skfont->setSkewX(saveSkewX); - skfont->setEmbolden(savefakeBold); } } }; |