From 4f92f9b7251addef556b25e8ab88e00acfaf61b0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Mar 2012 08:30:47 +0200 Subject: Introduce FontSmoothingGamma as a platform style hint. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Allocate gamma tables on the heap in a thread-safe way, use font smoothing returned by the style hints of the platform to calculate them. - Improve font rendering on Windows. Change-Id: I8cd39b51cf03cbd642474c02b9076814baecd597 Reviewed-by: Samuel Rødal --- src/gui/kernel/qguiapplication.cpp | 15 +++++++++++++++ src/gui/kernel/qguiapplication_p.h | 4 ++++ src/gui/kernel/qplatformintegration_qpa.cpp | 2 ++ src/gui/kernel/qplatformintegration_qpa.h | 3 ++- src/gui/kernel/qstylehints.cpp | 5 +++++ src/gui/kernel/qstylehints.h | 1 + 6 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 5a95ebe848..4cd02c3d5b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include @@ -764,6 +765,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() delete platform_theme; delete platform_integration; platform_integration = 0; + delete m_gammaTables.load(); } #if 0 @@ -2170,4 +2172,17 @@ void QGuiApplicationPrivate::notifyThemeChanged() } } +const QDrawHelperGammaTables *QGuiApplicationPrivate::gammaTables() +{ + QDrawHelperGammaTables *result = m_gammaTables.load(); + if (!result){ + const qreal smoothing = qApp->styleHints()->fontSmoothingGamma(); + QDrawHelperGammaTables *tables = new QDrawHelperGammaTables(smoothing); + if (!m_gammaTables.testAndSetRelease(0, tables)) + delete tables; + result = m_gammaTables.load(); + } + return result; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index f30a2bb5a0..4d8ef6fadd 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE class QPlatformIntegration; class QPlatformTheme; +struct QDrawHelperGammaTables; class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate { @@ -203,6 +204,8 @@ public: }; QHash synthesizedMousePoints; + const QDrawHelperGammaTables *gammaTables(); + protected: virtual void notifyThemeChanged(); @@ -212,6 +215,7 @@ private: static QGuiApplicationPrivate *self; static QTouchDevice *m_fakeTouchDevice; static int m_fakeMouseSourcePointId; + QAtomicPointer m_gammaTables; }; Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k); diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp index 6879f0517e..4efd2d896f 100644 --- a/src/gui/kernel/qplatformintegration_qpa.cpp +++ b/src/gui/kernel/qplatformintegration_qpa.cpp @@ -293,6 +293,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return false; case PasswordMaskDelay: return 0; + case FontSmoothingGamma: + return qreal(1.7); } return 0; diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 68dfc21833..fe40fd3dad 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -122,7 +122,8 @@ public: StartDragTime, KeyboardAutoRepeatRate, ShowIsFullScreen, - PasswordMaskDelay + PasswordMaskDelay, + FontSmoothingGamma }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 4970f6a26b..9384d34097 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -101,4 +101,9 @@ int QStyleHints::passwordMaskDelay() const return hint(QPlatformIntegration::PasswordMaskDelay).toInt(); } +qreal QStyleHints::fontSmoothingGamma() const +{ + return hint(QPlatformIntegration::FontSmoothingGamma).toReal(); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index ae51ebc052..301b51868f 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -63,6 +63,7 @@ public: int cursorFlashTime() const; bool showIsFullScreen() const; int passwordMaskDelay() const; + qreal fontSmoothingGamma() const; private: friend class QGuiApplication; -- cgit v1.2.3