From 33739ccb95b5341bbf8173350a66a766277e9bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Fri, 28 Nov 2014 15:18:12 +0000 Subject: [PATCH] Windows: Bring FreeType rendering up to par with other platforms The text was very washed out, almost white on small font sizes. This ifdef was introduced to cater for GDI differences between Vista and Pre-Vista, it's GDI specific, nothing to do with FreeType. Text now looks good, and md5sum of the rendering is the same as on Linux. Task-number: QTBUG-42564 Change-Id: I2e06b83b80df093331454fe1b780d26462db597d Reviewed-by: Konstantin Ritt Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qdrawhelper.cpp | 7 +++++-- src/plugins/platforms/windows/qwindowsfontdatabase.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 6482cc50f7..9c1b2e707d 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6219,6 +6219,8 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int } #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +Q_GUI_EXPORT bool qt_needs_a8_gamma_correction = false; + static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb, const uint *gamma, const uchar *invgamma) { // Do a gammacorrected gray alphablend... @@ -6266,6 +6268,7 @@ static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer, int sb = gamma[qBlue(color)]; bool opaque_src = (qAlpha(color) == 255); + bool doGrayBlendPixel = opaque_src && qt_needs_a8_gamma_correction; #endif if (!clip) { @@ -6280,7 +6283,7 @@ static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer, dest[i] = c; } else { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && opaque_src + if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel && qAlpha(dest[i]) == 255) { grayBlendPixel(dest+i, coverage, sr, sg, sb, gamma, invgamma); } else @@ -6321,7 +6324,7 @@ static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer, dest[xp] = c; } else { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && opaque_src + if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel && qAlpha(dest[xp]) == 255) { grayBlendPixel(dest+xp, coverage, sr, sg, sb, gamma, invgamma); } else diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 449453cf28..f15783490e 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -1062,6 +1062,9 @@ QWindowsFontEngineDataPtr sharedFontData() } #endif // QT_NO_THREAD +#ifndef Q_OS_WINCE +extern Q_GUI_EXPORT bool qt_needs_a8_gamma_correction; +#endif QWindowsFontDatabase::QWindowsFontDatabase() { // Properties accessed by QWin32PrintEngine (Qt Print Support) @@ -1075,6 +1078,9 @@ QWindowsFontDatabase::QWindowsFontDatabase() qCDebug(lcQpaFonts) << __FUNCTION__ << "Clear type: " << data->clearTypeEnabled << "gamma: " << data->fontSmoothingGamma; } +#ifndef Q_OS_WINCE + qt_needs_a8_gamma_correction = true; +#endif } QWindowsFontDatabase::~QWindowsFontDatabase()