From 30af0c25486fceda457fa7c23f01de0574f45da8 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Mon, 23 Sep 2019 15:17:04 +0000 Subject: [PATCH] Bug 1582749 - try to load only the advance width from FreeType when possible. r=jfkthame During metrics initialization we load a few uncached glyph widths which can occasionally show up in a profile. This should reduce the overhead of that somewhat. Differential Revision: https://phabricator.services.mozilla.com/D46786 --HG-- extra : moz-landing-system : lando --- gfx/thebes/gfxFT2FontBase.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/gfxFT2FontBase.cpp b/gfx/thebes/gfxFT2FontBase.cpp index 8bf1bf5fff69..0337e33ac592 100644 --- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -157,7 +157,8 @@ uint32_t gfxFT2FontBase::GetCharExtents(char aChar, gfxFloat* aWidth, FT_UInt gid = GetGlyph(aChar); int32_t width; IntRect bounds; - if (gid && GetFTGlyphExtents(gid, &width, &bounds)) { + if (gid && GetFTGlyphExtents(gid, aWidth ? &width : nullptr, + aBounds ? &bounds : nullptr)) { if (aWidth) { *aWidth = FLOAT_FROM_16_16(width); } @@ -529,7 +530,11 @@ bool gfxFT2FontBase::GetFTGlyphExtents(uint16_t aGID, int32_t* aAdvance, return false; } - if (Factory::LoadFTGlyph(face.get(), aGID, mFTLoadFlags) != FT_Err_Ok) { + FT_Int32 flags = mFTLoadFlags; + if (!aBounds) { + flags |= FT_LOAD_ADVANCE_ONLY; + } + if (Factory::LoadFTGlyph(face.get(), aGID, flags) != FT_Err_Ok) { // FT_Face was somehow broken/invalid? Don't try to access glyph slot. // This probably shouldn't happen, but does: see bug 1440938. NS_WARNING("failed to load glyph!");