Bug 1325743: Cache Moz2D ClearType usage information in a way similar to Thebes. r=mchang

This patch makes sure content processes update their cleartype settings, as well as making sure Moz2D's idea of the ClearType settings are in sync with those of Thebes. If the two differ this can cause graphical glitches.

MozReview-Commit-ID: 94arUnBWoUy

--HG--
extra : rebase_source : d74b702fc63c019ce1c30bdc741ea3ed6da457cd
This commit is contained in:
Bas Schouten 2017-01-04 20:26:17 +01:00
Родитель cbb2838ade
Коммит 47b62ee88c
6 изменённых файлов: 42 добавлений и 9 удалений

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

@ -1559,6 +1559,8 @@ public:
bool aUseEmbeddedBitmap,
bool aForceGDIMode);
static void UpdateSystemTextQuality();
private:
static ID2D1Device *mD2D1Device;
static ID3D11Device *mD3D11Device;

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

@ -41,6 +41,7 @@
#include "NativeFontResourceDWrite.h"
#include <d3d10_1.h>
#include "HelpersD2D.h"
#include "HelpersWinFonts.h"
#endif
#include "DrawTargetDual.h"
@ -709,6 +710,15 @@ Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
return MakeAndAddRef<GlyphRenderingOptionsDWrite>(aParams);
}
BYTE sSystemTextQuality = CLEARTYPE_QUALITY;
void
Factory::UpdateSystemTextQuality()
{
#ifdef WIN32
gfx::UpdateSystemTextQuality();
#endif
}
uint64_t
Factory::GetD2DVRAMUsageDrawTarget()
{

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

@ -6,32 +6,45 @@
namespace mozilla {
namespace gfx {
// Cleartype can be dynamically enabled/disabled, so we have to check it
// everytime we want to render some text.
extern BYTE sSystemTextQuality;
static BYTE
GetSystemTextQuality()
{
return sSystemTextQuality;
}
// Cleartype can be dynamically enabled/disabled, so we have to allow for dynamically
// updating it.
static void
UpdateSystemTextQuality()
{
BOOL font_smoothing;
UINT smoothing_type;
if (!SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &font_smoothing, 0)) {
return DEFAULT_QUALITY;
sSystemTextQuality = DEFAULT_QUALITY;
return;
}
if (font_smoothing) {
if (!SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE,
0, &smoothing_type, 0)) {
return DEFAULT_QUALITY;
sSystemTextQuality = DEFAULT_QUALITY;
return;
}
if (smoothing_type == FE_FONTSMOOTHINGCLEARTYPE) {
return CLEARTYPE_QUALITY;
sSystemTextQuality = CLEARTYPE_QUALITY;
return;
}
return ANTIALIASED_QUALITY;
sSystemTextQuality = ANTIALIASED_QUALITY;
return;
}
return DEFAULT_QUALITY;
sSystemTextQuality = DEFAULT_QUALITY;
}
static AntialiasMode

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

@ -35,6 +35,7 @@
#endif
#ifdef XP_WIN
#include "mozilla/gfx/DeviceManagerDx.h"
#include "gfxDWriteFonts.h"
#endif
namespace mozilla {
@ -289,6 +290,14 @@ ClientLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback,
{
PaintTelemetry::AutoRecord record(PaintTelemetry::Metric::Rasterization);
#ifdef WIN32
if (aCallbackData) {
// Content processes don't get OnPaint called. So update here whenever we
// may do Thebes drawing.
gfxDWriteFont::UpdateClearTypeUsage();
}
#endif
PROFILER_LABEL("ClientLayerManager", "EndTransactionInternal",
js::ProfileEntry::Category::GRAPHICS);

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

@ -123,6 +123,7 @@ gfxDWriteFont::~gfxDWriteFont()
void
gfxDWriteFont::UpdateClearTypeUsage()
{
Factory::UpdateSystemTextQuality();
mUseClearType = UsingClearType();
}

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

@ -188,8 +188,6 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel)
return false;
}
gfxDWriteFont::UpdateClearTypeUsage();
// After we CallUpdateWindow to the child, occasionally a WM_PAINT message
// is posted to the parent event loop with an empty update rect. Do a
// dummy paint so that Windows stops dispatching WM_PAINT in an inifinite