forked from mirrors/gecko-dev
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:
parent
44f3e9c4c2
commit
f8e2122b2b
3 changed files with 16 additions and 4 deletions
|
|
@ -1527,9 +1527,7 @@ class gfxFont {
|
||||||
// and therefore needs us to use a mask for text-shadow even when
|
// and therefore needs us to use a mask for text-shadow even when
|
||||||
// we're not actually blurring.
|
// we're not actually blurring.
|
||||||
bool AlwaysNeedsMaskForShadow() const {
|
bool AlwaysNeedsMaskForShadow() const {
|
||||||
return mFontEntry->TryGetColorGlyphs() || mFontEntry->TryGetSVGData(this) ||
|
return mFontEntry->AlwaysNeedsMaskForShadow();
|
||||||
mFontEntry->HasFontTable(TRUETYPE_TAG('C', 'B', 'D', 'T')) ||
|
|
||||||
mFontEntry->HasFontTable(TRUETYPE_TAG('s', 'b', 'i', 'x'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// whether a feature is supported by the font (limited to a small set
|
// whether a feature is supported by the font (limited to a small set
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ gfxFontEntry::gfxFontEntry(const nsACString& aName, bool aIsStandardFace)
|
||||||
mHasGraphiteTables(LazyFlag::Uninitialized),
|
mHasGraphiteTables(LazyFlag::Uninitialized),
|
||||||
mHasGraphiteSpaceContextuals(LazyFlag::Uninitialized),
|
mHasGraphiteSpaceContextuals(LazyFlag::Uninitialized),
|
||||||
mHasColorBitmapTable(LazyFlag::Uninitialized),
|
mHasColorBitmapTable(LazyFlag::Uninitialized),
|
||||||
|
mNeedsMaskForShadow(LazyFlag::Uninitialized),
|
||||||
mHasSpaceFeatures(SpaceFeatures::Uninitialized) {
|
mHasSpaceFeatures(SpaceFeatures::Uninitialized) {
|
||||||
mTrakTable.exchange(kTrakTableUninitialized);
|
mTrakTable.exchange(kTrakTableUninitialized);
|
||||||
memset(&mDefaultSubSpaceFeatures, 0, sizeof(mDefaultSubSpaceFeatures));
|
memset(&mDefaultSubSpaceFeatures, 0, sizeof(mDefaultSubSpaceFeatures));
|
||||||
|
|
@ -355,7 +356,7 @@ bool gfxFontEntry::TryGetSVGData(const gfxFont* aFont) {
|
||||||
mSVGInitialized = true;
|
mSVGInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetSVGGlyphs()) {
|
if (GetSVGGlyphs() && aFont) {
|
||||||
AutoWriteLock lock(mLock);
|
AutoWriteLock lock(mLock);
|
||||||
if (!mFontsUsingSVGGlyphs.Contains(aFont)) {
|
if (!mFontsUsingSVGGlyphs.Contains(aFont)) {
|
||||||
mFontsUsingSVGGlyphs.AppendElement(aFont);
|
mFontsUsingSVGGlyphs.AppendElement(aFont);
|
||||||
|
|
|
||||||
|
|
@ -273,6 +273,18 @@ class gfxFontEntry {
|
||||||
return flag == LazyFlag::Yes;
|
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() {
|
inline bool HasCmapTable() {
|
||||||
if (!mCharacterMap && !mShmemCharacterMap) {
|
if (!mCharacterMap && !mShmemCharacterMap) {
|
||||||
ReadCMAP();
|
ReadCMAP();
|
||||||
|
|
@ -670,6 +682,7 @@ class gfxFontEntry {
|
||||||
std::atomic<LazyFlag> mHasGraphiteTables;
|
std::atomic<LazyFlag> mHasGraphiteTables;
|
||||||
std::atomic<LazyFlag> mHasGraphiteSpaceContextuals;
|
std::atomic<LazyFlag> mHasGraphiteSpaceContextuals;
|
||||||
std::atomic<LazyFlag> mHasColorBitmapTable;
|
std::atomic<LazyFlag> mHasColorBitmapTable;
|
||||||
|
std::atomic<LazyFlag> mNeedsMaskForShadow;
|
||||||
|
|
||||||
enum class SpaceFeatures : uint8_t {
|
enum class SpaceFeatures : uint8_t {
|
||||||
Uninitialized = 0xff,
|
Uninitialized = 0xff,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue