Commit 255a2914 authored by mthiesse's avatar mthiesse Committed by Commit bot

VR: Get fallback fonts for set of characters rather than full string.

This shaves ~6ms off of our total skia render time for English. Similar numbers for other languages.

BUG=715591

Review-Url: https://codereview.chromium.org/2846023002
Cr-Commit-Position: refs/heads/master@{#468070}
parent eb02b0f8
......@@ -44,6 +44,10 @@ gfx::FontList UiTexture::GetFontList(int size, base::string16 text) {
gfx::Font default_font(kDefaultFontFamily, size);
std::vector<gfx::Font> fonts{default_font};
std::set<wchar_t> characters;
for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) {
characters.insert(it.get());
}
// TODO(acondor): Obtain fallback fonts with gfx::GetFallbackFonts
// (which is not implemented for android yet) in order to avoid
// querying per character.
......@@ -51,10 +55,10 @@ gfx::FontList UiTexture::GetFontList(int size, base::string16 text) {
sk_sp<SkFontMgr> font_mgr(SkFontMgr::RefDefault());
std::set<std::string> names;
// TODO(acondor): Query BrowserProcess to obtain the application locale.
for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) {
for (wchar_t character : characters) {
sk_sp<SkTypeface> tf(font_mgr->matchFamilyStyleCharacter(
default_font.GetFontName().c_str(), SkFontStyle(), nullptr, 0,
it.get()));
kDefaultFontFamily, SkFontStyle(), nullptr, 0, character));
// TODO(acondor): How should we handle no matching font?
if (!tf)
continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment