Bug 1334761 - Update ClearType usage at startup, and flush caches and reflow everything if it changes during the session. r=bas

This commit is contained in:
Jonathan Kew 2017-09-14 17:26:53 +01:00
parent c6a1bbca85
commit 5f318d222b
6 changed files with 34 additions and 16 deletions

View File

@ -44,7 +44,7 @@ GetCairoAntialiasOption(gfxFont::AntialiasOption anAntialiasOption)
#define FE_FONTSMOOTHINGCLEARTYPE 2
#endif
bool gfxDWriteFont::mUseClearType = true;
bool gfxDWriteFont::sUseClearType = true;
// This function is expensive so we only want to call it when we have to.
static bool
@ -114,8 +114,15 @@ gfxDWriteFont::~gfxDWriteFont()
void
gfxDWriteFont::UpdateClearTypeUsage()
{
Factory::UpdateSystemTextQuality();
mUseClearType = UsingClearType();
Factory::UpdateSystemTextQuality();
// Check if ClearType status has changed; if so, toggle our flag,
// flush cached stuff that depended on the old setting, and force
// reflow everywhere to ensure we are using correct glyph metrics.
if (sUseClearType != UsingClearType()) {
sUseClearType = !sUseClearType;
gfxPlatform::FlushFontAndWordCaches();
gfxPlatform::ForceGlobalReflow();
}
}
UniquePtr<gfxFont>
@ -175,7 +182,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
// Note that GetMeasuringMode depends on mAdjustedSize
if ((anAAOption == gfxFont::kAntialiasDefault &&
mUseClearType &&
sUseClearType &&
GetMeasuringMode() == DWRITE_MEASURING_MODE_NATURAL) ||
anAAOption == gfxFont::kAntialiasSubpixel)
{
@ -688,7 +695,7 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
bool forceGDI = GetForceGDIClassic();
IDWriteRenderingParams* params = gfxWindowsPlatform::GetPlatform()->GetRenderingParams(
mUseClearType ?
sUseClearType ?
(forceGDI ?
gfxWindowsPlatform::TEXT_RENDERING_GDI_CLASSIC :
gfxWindowsPlatform::TEXT_RENDERING_NORMAL) :

View File

@ -105,7 +105,8 @@ protected:
bool mNeedsBold;
bool mUseSubpixelPositions;
bool mAllowManualShowGlyphs;
static bool mUseClearType;
static bool sUseClearType;
};
#endif

View File

@ -2167,6 +2167,15 @@ gfxPlatform::FlushFontAndWordCaches()
gfxPlatform::PurgeSkiaFontCache();
}
/* static */ void
gfxPlatform::ForceGlobalReflow()
{
// modify a preference that will trigger reflow everywhere
static const char kPrefName[] = "font.internaluseonly.changed";
bool fontInternalChange = Preferences::GetBool(kPrefName, false);
Preferences::SetBool(kPrefName, !fontInternalChange);
}
void
gfxPlatform::FontsPrefsChanged(const char *aPref)
{

View File

@ -557,6 +557,14 @@ public:
int32_t GetBidiNumeralOption();
/**
* This is a bit ugly, but useful... force all presContexts to reflow,
* by toggling a preference that they observe. This is used when
* something about platform settings changes that might have an effect
* on layout, such as font rendering settings that influence metrics.
*/
static void ForceGlobalReflow();
static void
FlushFontAndWordCaches();

View File

@ -1583,15 +1583,6 @@ gfxPlatformFontList::GetPrefsAndStartLoader()
StartLoader(delay, interval);
}
void
gfxPlatformFontList::ForceGlobalReflow()
{
// modify a preference that will trigger reflow everywhere
static const char kPrefName[] = "font.internaluseonly.changed";
bool fontInternalChange = Preferences::GetBool(kPrefName, false);
Preferences::SetBool(kPrefName, !fontInternalChange);
}
void
gfxPlatformFontList::RebuildLocalFonts()
{

View File

@ -485,7 +485,9 @@ protected:
void GetPrefsAndStartLoader();
// for font list changes that affect all documents
void ForceGlobalReflow();
void ForceGlobalReflow() {
gfxPlatform::ForceGlobalReflow();
}
void RebuildLocalFonts();