backed out changesets 5607cca3f7bf, 1ccc676a3a2c, 3eb99af46b93, 63c8f645cc1c (bug 661471 parts 6-7) to avoid merge conflicts, as they also landed on mozilla-central but with slight differences.

This commit is contained in:
Jonathan Kew 2011-06-09 12:27:48 +01:00
Родитель 497dde54d2
Коммит 626a30de52
11 изменённых файлов: 52 добавлений и 122 удалений

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

@ -130,7 +130,6 @@ struct _cairo_d2d_surface {
/** Indicates if text rendering is initialized */
enum TextRenderingState {
TEXT_RENDERING_UNINITIALIZED,
TEXT_RENDERING_NO_CLEARTYPE,
TEXT_RENDERING_NORMAL,
TEXT_RENDERING_GDI_CLASSIC
};

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

@ -4105,23 +4105,26 @@ _cairo_d2d_show_glyphs (void *surface,
cairo_clip_t *clip,
int *remaining_glyphs)
{
if (((cairo_surface_t*)surface)->type != CAIRO_SURFACE_TYPE_D2D ||
scaled_font->backend->type != CAIRO_FONT_TYPE_DWRITE)
{
if (((cairo_surface_t*)surface)->type != CAIRO_SURFACE_TYPE_D2D) {
return CAIRO_INT_STATUS_UNSUPPORTED;
}
cairo_d2d_surface_t *d2dsurf = static_cast<cairo_d2d_surface_t*>(surface);
cairo_bool_t forceGDIClassic =
scaled_font->backend->type == CAIRO_FONT_TYPE_DWRITE &&
reinterpret_cast<cairo_dwrite_scaled_font_t*>(scaled_font)->force_GDI_classic;
cairo_d2d_surface_t::TextRenderingState textRenderingState =
reinterpret_cast<cairo_dwrite_scaled_font_t*>(scaled_font)->rendering_mode;
(forceGDIClassic ? cairo_d2d_surface_t::TEXT_RENDERING_GDI_CLASSIC : cairo_d2d_surface_t::TEXT_RENDERING_NORMAL);
if (d2dsurf->textRenderingState != textRenderingState) {
RefPtr<IDWriteRenderingParams> params =
DWriteFactory::RenderingParams(textRenderingState);
DWriteFactory::RenderingParams(forceGDIClassic);
d2dsurf->rt->SetTextRenderingParams(params);
d2dsurf->textRenderingState = textRenderingState;
}
cairo_int_status_t status = (cairo_int_status_t)
_cairo_dwrite_show_glyphs_on_d2d_surface(surface, op, source, glyphs, num_glyphs, scaled_font, clip);
cairo_int_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
if (scaled_font->backend->type == CAIRO_FONT_TYPE_DWRITE) {
status = (cairo_int_status_t)
_cairo_dwrite_show_glyphs_on_d2d_surface(surface, op, source, glyphs, num_glyphs, scaled_font, clip);
}
return status;
}

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

@ -119,8 +119,7 @@ private:
IDWriteFactory *DWriteFactory::mFactoryInstance = NULL;
IDWriteFontCollection *DWriteFactory::mSystemCollection = NULL;
IDWriteRenderingParams *DWriteFactory::mDefaultRenderingParams = NULL;
IDWriteRenderingParams *DWriteFactory::mCustomClearTypeRenderingParams = NULL;
IDWriteRenderingParams *DWriteFactory::mRenderingParams = NULL;
IDWriteRenderingParams *DWriteFactory::mForceGDIClassicRenderingParams = NULL;
FLOAT DWriteFactory::mGamma = -1.0;
FLOAT DWriteFactory::mEnhancedContrast = -1.0;
@ -469,7 +468,7 @@ _cairo_dwrite_font_face_scaled_font_create (void *abstract_face,
// this means that if cleartype settings are changed but the scaled_fonts
// are re-used, they might not adhere to the new system setting until re-
// creation.
switch (cairo_win32_get_system_text_quality()) {
switch (_cairo_win32_get_system_text_quality()) {
case CLEARTYPE_QUALITY:
default_quality = CAIRO_ANTIALIAS_SUBPIXEL;
break;
@ -497,9 +496,7 @@ _cairo_dwrite_font_face_scaled_font_create (void *abstract_face,
}
dwriteFont->manual_show_glyphs_allowed = TRUE;
dwriteFont->rendering_mode =
default_quality == CAIRO_ANTIALIAS_SUBPIXEL ?
cairo_d2d_surface_t::TEXT_RENDERING_NORMAL : cairo_d2d_surface_t::TEXT_RENDERING_NO_CLEARTYPE;
dwriteFont->force_GDI_classic = FALSE;
return _cairo_scaled_font_set_metrics (*font, &extents);
}
@ -1086,18 +1083,14 @@ void
cairo_dwrite_scaled_font_set_force_GDI_classic(cairo_scaled_font_t *dwrite_scaled_font, cairo_bool_t force)
{
cairo_dwrite_scaled_font_t *font = reinterpret_cast<cairo_dwrite_scaled_font_t*>(dwrite_scaled_font);
if (force && font->rendering_mode == cairo_d2d_surface_t::TEXT_RENDERING_NORMAL) {
font->rendering_mode = cairo_d2d_surface_t::TEXT_RENDERING_GDI_CLASSIC;
} else if (!force && font->rendering_mode == cairo_d2d_surface_t::TEXT_RENDERING_GDI_CLASSIC) {
font->rendering_mode = cairo_d2d_surface_t::TEXT_RENDERING_NORMAL;
}
font->force_GDI_classic = force;
}
cairo_bool_t
cairo_dwrite_scaled_font_get_force_GDI_classic(cairo_scaled_font_t *dwrite_scaled_font)
{
cairo_dwrite_scaled_font_t *font = reinterpret_cast<cairo_dwrite_scaled_font_t*>(dwrite_scaled_font);
return font->rendering_mode == cairo_d2d_surface_t::TEXT_RENDERING_GDI_CLASSIC;
return font->force_GDI_classic;
}
void
@ -1107,12 +1100,6 @@ cairo_dwrite_set_cleartype_params(FLOAT gamma, FLOAT contrast, FLOAT level,
DWriteFactory::SetRenderingParams(gamma, contrast, level, geometry, mode);
}
int
cairo_dwrite_get_cleartype_rendering_mode()
{
return DWriteFactory::GetClearTypeRenderingMode();
}
cairo_int_status_t
_dwrite_draw_glyphs_to_gdi_surface_gdi(cairo_win32_surface_t *surface,
DWRITE_MATRIX *transform,
@ -1126,7 +1113,7 @@ _dwrite_draw_glyphs_to_gdi_surface_gdi(cairo_win32_surface_t *surface,
IDWriteBitmapRenderTarget *rt;
IDWriteRenderingParams *params =
DWriteFactory::RenderingParams(scaled_font->rendering_mode);
DWriteFactory::RenderingParams(scaled_font->force_GDI_classic);
gdiInterop->CreateBitmapRenderTarget(surface->dc,
area.right - area.left,
@ -1427,7 +1414,8 @@ DWriteFactory::CreateRenderingParams()
return;
}
Instance()->CreateRenderingParams(&mDefaultRenderingParams);
RefPtr<IDWriteRenderingParams> defaultParams;
Instance()->CreateRenderingParams(&defaultParams);
// For EnhancedContrast, we override the default if the user has not set it
// in the registry (by using the ClearType Tuner).
@ -1439,7 +1427,7 @@ DWriteFactory::CreateRenderingParams()
if (RegOpenKeyExA(ENHANCED_CONTRAST_REGISTRY_KEY,
0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
contrast = mDefaultRenderingParams->GetEnhancedContrast();
contrast = defaultParams->GetEnhancedContrast();
RegCloseKey(hKey);
} else {
contrast = 1.0;
@ -1449,20 +1437,18 @@ DWriteFactory::CreateRenderingParams()
// For parameters that have not been explicitly set via the SetRenderingParams API,
// we copy values from default params (or our overridden value for contrast)
FLOAT gamma =
mGamma >= 1.0 && mGamma <= 2.2 ?
mGamma : mDefaultRenderingParams->GetGamma();
mGamma >= 1.0 && mGamma <= 2.2 ? mGamma : defaultParams->GetGamma();
FLOAT clearTypeLevel =
mClearTypeLevel >= 0.0 && mClearTypeLevel <= 1.0 ?
mClearTypeLevel : mDefaultRenderingParams->GetClearTypeLevel();
mClearTypeLevel >= 0.0 && mClearTypeLevel <= 1.0 ? mClearTypeLevel : defaultParams->GetClearTypeLevel();
DWRITE_PIXEL_GEOMETRY pixelGeometry =
mPixelGeometry >= DWRITE_PIXEL_GEOMETRY_FLAT && mPixelGeometry <= DWRITE_PIXEL_GEOMETRY_BGR ?
(DWRITE_PIXEL_GEOMETRY)mPixelGeometry : mDefaultRenderingParams->GetPixelGeometry();
(DWRITE_PIXEL_GEOMETRY)mPixelGeometry : defaultParams->GetPixelGeometry();
DWRITE_RENDERING_MODE renderingMode =
mRenderingMode >= DWRITE_RENDERING_MODE_DEFAULT && mRenderingMode <= DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC ?
(DWRITE_RENDERING_MODE)mRenderingMode : mDefaultRenderingParams->GetRenderingMode();
(DWRITE_RENDERING_MODE)mRenderingMode : defaultParams->GetRenderingMode();
Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel,
pixelGeometry, renderingMode,
&mCustomClearTypeRenderingParams);
&mRenderingParams);
Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel,
pixelGeometry, DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC,
&mForceGDIClassicRenderingParams);

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

@ -36,6 +36,7 @@
#include <dwrite.h>
#include <D2d1.h>
// DirectWrite is not available on all platforms.
typedef HRESULT (WINAPI*DWriteCreateFactoryFunc)(
__in DWRITE_FACTORY_TYPE factoryType,
@ -51,7 +52,7 @@ struct _cairo_dwrite_scaled_font {
cairo_antialias_t antialias_mode;
DWRITE_MEASURING_MODE measuring_mode;
cairo_bool_t manual_show_glyphs_allowed;
cairo_d2d_surface_t::TextRenderingState rendering_mode;
cairo_bool_t force_GDI_classic;
};
typedef struct _cairo_dwrite_scaled_font cairo_dwrite_scaled_font_t;
@ -102,22 +103,13 @@ public:
return family;
}
static IDWriteRenderingParams *RenderingParams(cairo_d2d_surface_t::TextRenderingState mode)
static IDWriteRenderingParams *RenderingParams(cairo_bool_t forceGDIClassic)
{
if (!mDefaultRenderingParams ||
!mForceGDIClassicRenderingParams ||
!mCustomClearTypeRenderingParams)
{
if (!mRenderingParams || !mForceGDIClassicRenderingParams) {
CreateRenderingParams();
}
IDWriteRenderingParams *params;
if (mode == cairo_d2d_surface_t::TEXT_RENDERING_NO_CLEARTYPE) {
params = mDefaultRenderingParams;
} else if (mode == cairo_d2d_surface_t::TEXT_RENDERING_GDI_CLASSIC && mRenderingMode < 0) {
params = mForceGDIClassicRenderingParams;
} else {
params = mCustomClearTypeRenderingParams;
}
IDWriteRenderingParams *params =
forceGDIClassic ? mForceGDIClassicRenderingParams : mRenderingParams;
if (params) {
params->AddRef();
}
@ -135,23 +127,15 @@ public:
mClearTypeLevel = aClearTypeLevel;
mPixelGeometry = aPixelGeometry;
mRenderingMode = aRenderingMode;
// discard any current RenderingParams objects
if (mCustomClearTypeRenderingParams) {
mCustomClearTypeRenderingParams->Release();
mCustomClearTypeRenderingParams = NULL;
// discard any current RenderingParams object
if (mRenderingParams) {
mRenderingParams->Release();
mRenderingParams = NULL;
}
if (mForceGDIClassicRenderingParams) {
mForceGDIClassicRenderingParams->Release();
mForceGDIClassicRenderingParams = NULL;
}
if (mDefaultRenderingParams) {
mDefaultRenderingParams->Release();
mDefaultRenderingParams = NULL;
}
}
static int GetClearTypeRenderingMode() {
return mRenderingMode;
}
private:
@ -159,8 +143,7 @@ private:
static IDWriteFactory *mFactoryInstance;
static IDWriteFontCollection *mSystemCollection;
static IDWriteRenderingParams *mDefaultRenderingParams;
static IDWriteRenderingParams *mCustomClearTypeRenderingParams;
static IDWriteRenderingParams *mRenderingParams;
static IDWriteRenderingParams *mForceGDIClassicRenderingParams;
static FLOAT mGamma;
static FLOAT mEnhancedContrast;

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

@ -258,7 +258,7 @@ _have_cleartype_quality (void)
}
BYTE
cairo_win32_get_system_text_quality (void)
_cairo_win32_get_system_text_quality (void)
{
BOOL font_smoothing;
UINT smoothing_type;
@ -325,7 +325,7 @@ _win32_scaled_font_create (LOGFONTW *logfont,
* here is the hint_metrics options.
*/
if (options->antialias == CAIRO_ANTIALIAS_DEFAULT)
f->quality = cairo_win32_get_system_text_quality ();
f->quality = _cairo_win32_get_system_text_quality ();
else {
switch (options->antialias) {
case CAIRO_ANTIALIAS_NONE:

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

@ -216,6 +216,9 @@ _cairo_win32_scaled_font_is_type1 (cairo_scaled_font_t *scaled_font);
cairo_bool_t
_cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font);
BYTE
_cairo_win32_get_system_text_quality (void);
#ifdef WINCE
// These are the required stubs for windows mobile

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

@ -80,8 +80,6 @@ cairo_win32_surface_set_can_convert_to_dib (cairo_surface_t *surface, cairo_bool
cairo_public cairo_status_t
cairo_win32_surface_get_can_convert_to_dib (cairo_surface_t *surface, cairo_bool_t *can_convert);
BYTE cairo_win32_get_system_text_quality (void);
#if CAIRO_HAS_WIN32_FONT
/*
@ -137,9 +135,6 @@ cairo_dwrite_scaled_font_get_force_GDI_classic(cairo_scaled_font_t *dwrite_scale
void
cairo_dwrite_set_cleartype_params(FLOAT gamma, FLOAT contrast, FLOAT level, int geometry, int mode);
int
cairo_dwrite_get_cleartype_rendering_mode();
#endif /* CAIRO_HAS_DWRITE_FONT */
#if CAIRO_HAS_D2D_SURFACE

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

@ -694,8 +694,7 @@ bool
gfxDWriteFont::GetForceGDIClassic()
{
return static_cast<gfxDWriteFontEntry*>(mFontEntry.get())->GetForceGDIClassic() &&
cairo_dwrite_get_cleartype_rendering_mode() < 0 &&
GetAdjustedSize() <=
GetAdjustedSize() <=
gfxDWriteFontList::PlatformFontList()->GetForceGDIClassicMaxFontSize();
}

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

@ -772,10 +772,8 @@ nsPresContext::GetUserPreferences()
}
void
nsPresContext::InvalidateThebesLayers()
nsPresContext::AppUnitsPerDevPixelChanged()
{
if (!mShell)
return;
nsIFrame* rootFrame = mShell->FrameManager()->GetRootFrame();
if (rootFrame) {
// FrameLayerBuilder caches invalidation-related values that depend on the
@ -783,12 +781,6 @@ nsPresContext::InvalidateThebesLayers()
// is completely flushed.
FrameLayerBuilder::InvalidateThebesLayersInSubtree(rootFrame);
}
}
void
nsPresContext::AppUnitsPerDevPixelChanged()
{
InvalidateThebesLayers();
mDeviceContext->FlushFontCache();
@ -876,7 +868,6 @@ nsPresContext::UpdateAfterPreferencesChanged()
mShell->SetPreferenceStyleRules(PR_TRUE);
}
InvalidateThebesLayers();
mDeviceContext->FlushFontCache();
nsChangeHint hint = nsChangeHint(0);

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

@ -1049,7 +1049,6 @@ protected:
NS_HIDDEN_(void) UpdateCharSet(const nsAFlatCString& aCharSet);
void InvalidateThebesLayers();
void AppUnitsPerDevPixelChanged();
PRBool MayHavePaintEventListener();

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

@ -4458,35 +4458,6 @@ nsWindow::ProcessMessageForPlugin(const MSG &aMsg,
return PR_TRUE;
}
static void ForceFontUpdate()
{
// update device context font cache
// Dirty but easiest way:
// Changing nsIPrefBranch entry which triggers callbacks
// and flows into calling mDeviceContext->FlushFontCache()
// to update the font cache in all the instance of Browsers
static const char kPrefName[] = "font.internaluseonly.changed";
PRBool fontInternalChange =
Preferences::GetBool(kPrefName, PR_FALSE);
Preferences::SetBool(kPrefName, !fontInternalChange);
}
static PRBool ClearTypeSettingChanged()
{
static int currentQuality = -1;
BYTE quality = cairo_win32_get_system_text_quality();
if (currentQuality == quality)
return PR_FALSE;
if (currentQuality < 0) {
currentQuality = quality;
return PR_FALSE;
}
currentQuality = quality;
return PR_TRUE;
}
// The main windows message processing method.
PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
LRESULT *aRetValue)
@ -4649,7 +4620,15 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
fontEnum->UpdateFontList(&didChange);
//didChange is TRUE only if new font langGroup is added to the list.
if (didChange) {
ForceFontUpdate();
// update device context font cache
// Dirty but easiest way:
// Changing nsIPrefBranch entry which triggers callbacks
// and flows into calling mDeviceContext->FlushFontCache()
// to update the font cache in all the instance of Browsers
const char* kPrefName = "font.internaluseonly.changed";
PRBool fontInternalChange =
Preferences::GetBool(kPrefName, PR_FALSE);
Preferences::SetBool(kPrefName, !fontInternalChange);
}
} //if (NS_SUCCEEDED(rv))
}
@ -4832,13 +4811,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
break;
case WM_PAINT:
if (ClearTypeSettingChanged()) {
ForceFontUpdate();
gfxFontCache *fc = gfxFontCache::GetCache();
if (fc) {
fc->Flush();
}
}
*aRetValue = (int) OnPaint(NULL, 0);
result = PR_TRUE;
break;