summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-03-27 08:30:47 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-27 12:33:42 +0200
commit4f92f9b7251addef556b25e8ab88e00acfaf61b0 (patch)
treecadb3a0fe7e4c2564e609c3d27d2bc47be516029 /src/gui/kernel
parent8d28f263aa14cc450085c9df3623a483b6021c56 (diff)
Introduce FontSmoothingGamma as a platform style hint.
- 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 <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp15
-rw-r--r--src/gui/kernel/qguiapplication_p.h4
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h3
-rw-r--r--src/gui/kernel/qstylehints.cpp5
-rw-r--r--src/gui/kernel/qstylehints.h1
6 files changed, 29 insertions, 1 deletions
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 <qpalette.h>
#include <qscreen.h>
#include <private/qscreen_p.h>
+#include <private/qdrawhelper_p.h>
#include <QtGui/QPlatformIntegration>
#include <QtGui/QGenericPluginFactory>
@@ -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<QWindow *, SynthesizedMouseData> 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<QDrawHelperGammaTables> 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;