Bug 1726744: Don't force GDI classic when cleartype rendering mode pref is set. r=jfkthame

This also sets the cairo dwrite params in the parent where they might still be
needed for printing.

Differential Revision: https://phabricator.services.mozilla.com/D123731
This commit is contained in:
Bob Owen 2021-08-26 11:55:17 +00:00
Родитель cf3257fdfd
Коммит 0ba10eefad
3 изменённых файлов: 30 добавлений и 9 удалений

Просмотреть файл

@ -135,9 +135,22 @@ void gfxDWriteFont::SystemTextQualityChanged() {
gfxPlatform::ForceGlobalReflow();
}
mozilla::Atomic<bool> gfxDWriteFont::sForceGDIClassicEnabled{true};
/* static */
void gfxDWriteFont::UpdateClearTypeVars() {
MOZ_ASSERT(XRE_IsParentProcess());
// We don't force GDI classic if the cleartype rendering mode pref is set to
// something valid.
int32_t renderingModePref =
Preferences::GetInt(GFX_CLEARTYPE_PARAMS_MODE, -1);
if (renderingModePref < 0 || renderingModePref > 5) {
renderingModePref = -1;
}
sForceGDIClassicEnabled = (renderingModePref == -1);
if (!XRE_IsParentProcess()) {
return;
}
if (!Factory::GetDWriteFactory()) {
return;
@ -207,9 +220,9 @@ void gfxDWriteFont::UpdateClearTypeVars() {
pixelGeometry = prefInt;
}
prefInt = Preferences::GetInt(GFX_CLEARTYPE_PARAMS_MODE, -1);
if (prefInt >= 0 && prefInt <= 5) {
renderingMode = prefInt;
// renderingModePref is retrieved and validated above.
if (renderingModePref != -1) {
renderingMode = renderingModePref;
}
}
@ -232,6 +245,13 @@ void gfxDWriteFont::UpdateClearTypeVars() {
if (gfxVars::SystemTextRenderingMode() != renderingMode) {
gfxVars::SetSystemTextRenderingMode(renderingMode);
}
// Set cairo dwrite params in the parent process where it might still be
// needed for printing. We use the validated pref int directly for rendering
// mode, because a negative (i.e. not set) rendering mode is also used for
// deciding on forcing GDI in cairo.
cairo_dwrite_set_cleartype_params(gamma, enhancedContrast, clearTypeLevel,
pixelGeometry, renderingModePref);
}
UniquePtr<gfxFont> gfxDWriteFont::CopyWithAntialiasOption(
@ -626,9 +646,9 @@ int32_t gfxDWriteFont::GetGlyphWidth(uint16_t aGID) {
}
bool gfxDWriteFont::GetForceGDIClassic() const {
return static_cast<gfxDWriteFontEntry*>(mFontEntry.get())
return sForceGDIClassicEnabled &&
static_cast<gfxDWriteFontEntry*>(mFontEntry.get())
->GetForceGDIClassic() &&
cairo_dwrite_get_cleartype_rendering_mode() < 0 &&
GetAdjustedSize() <= gfxDWriteFontList::PlatformFontList()
->GetForceGDIClassicMaxFontSize();
}

Просмотреть файл

@ -6,6 +6,7 @@
#ifndef GFX_WINDOWSDWRITEFONTS_H
#define GFX_WINDOWSDWRITEFONTS_H
#include "mozilla/Atomics.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/UniquePtr.h"
#include <dwrite_1.h>
@ -84,6 +85,8 @@ class gfxDWriteFont final : public gfxFont {
gfxFloat MeasureGlyphWidth(uint16_t aGlyph);
DWRITE_MEASURING_MODE GetMeasuringMode() const;
static mozilla::Atomic<bool> sForceGDIClassicEnabled;
bool GetForceGDIClassic() const;
RefPtr<IDWriteFontFace> mFontFace;

Просмотреть файл

@ -1056,9 +1056,7 @@ void gfxWindowsPlatform::FontsPrefsChanged(const char* aPref) {
if (aPref &&
!strncmp(GFX_CLEARTYPE_PARAMS, aPref, strlen(GFX_CLEARTYPE_PARAMS))) {
if (XRE_IsParentProcess()) {
gfxDWriteFont::UpdateClearTypeVars();
}
gfxDWriteFont::UpdateClearTypeVars();
} else {
clearTextFontCaches = false;
}