Bug 1894424 - Optimize gfxFont::AlwaysNeedsMaskForShadow check by caching the answer in the font entry. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D209104
This commit is contained in:
Jonathan Kew 2024-05-01 14:28:56 +00:00
parent 71c786152a
commit 3655e633e9
3 changed files with 15 additions and 4 deletions

View file

@ -1527,9 +1527,7 @@ class gfxFont {
// and therefore needs us to use a mask for text-shadow even when
// we're not actually blurring.
bool AlwaysNeedsMaskForShadow() const {
return mFontEntry->TryGetColorGlyphs() || mFontEntry->TryGetSVGData(this) ||
mFontEntry->HasFontTable(TRUETYPE_TAG('C', 'B', 'D', 'T')) ||
mFontEntry->HasFontTable(TRUETYPE_TAG('s', 'b', 'i', 'x'));
return mFontEntry->AlwaysNeedsMaskForShadow();
}
// whether a feature is supported by the font (limited to a small set

View file

@ -355,7 +355,7 @@ bool gfxFontEntry::TryGetSVGData(const gfxFont* aFont) {
mSVGInitialized = true;
}
if (GetSVGGlyphs()) {
if (GetSVGGlyphs() && aFont) {
AutoWriteLock lock(mLock);
if (!mFontsUsingSVGGlyphs.Contains(aFont)) {
mFontsUsingSVGGlyphs.AppendElement(aFont);

View file

@ -273,6 +273,18 @@ class gfxFontEntry {
return flag == LazyFlag::Yes;
}
inline bool AlwaysNeedsMaskForShadow() {
LazyFlag flag = mNeedsMaskForShadow;
if (flag == LazyFlag::Uninitialized) {
flag =
TryGetColorGlyphs() || TryGetSVGData(nullptr) || HasColorBitmapTable()
? LazyFlag::Yes
: LazyFlag::No;
mNeedsMaskForShadow = flag;
}
return flag == LazyFlag::Yes;
}
inline bool HasCmapTable() {
if (!mCharacterMap && !mShmemCharacterMap) {
ReadCMAP();
@ -670,6 +682,7 @@ class gfxFontEntry {
std::atomic<LazyFlag> mHasGraphiteTables;
std::atomic<LazyFlag> mHasGraphiteSpaceContextuals;
std::atomic<LazyFlag> mHasColorBitmapTable;
std::atomic<LazyFlag> mNeedsMaskForShadow;
enum class SpaceFeatures : uint8_t {
Uninitialized = 0xff,