path: root/src/plugins
diff options
authorLouai Al-Khanji <>2014-04-29 16:14:19 +0300
committerThe Qt Project <>2014-04-30 08:23:39 +0200
commit0edb21df154cd2469ba91ea95c8c6464d1140c8d (patch)
tree154d2b72273e9773d8ff3ca2cf35346aaf8387f9 /src/plugins
parent090124eab6f184abbe9be04f4bc1a9eee5285207 (diff)
Direct2D QPA: Pixel-align aliased drawing
Aliased drawing has so far not been perfectly pixel aligned, resulting in less than stellar output in some instances. Although a little hacky, adding 0.5 to all coordinates when in aliased mode fixes things up nicely. There doesn't appear to be a better way to get d2d to cooperate as we would like it to. Change-Id: I10ee494d2f576bfd0eca6d4429095a3726c0bf14 Reviewed-by: Risto Avila <> Reviewed-by: Andrew Knight <>
Diffstat (limited to 'src/plugins')
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
index 8d775e5a9d..0c3618132d 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
@@ -89,6 +89,11 @@ enum ClipType {
+// Since d2d is a float-based system we need to be able to snap our drawing to whole pixels.
+// Applying the magical aliasing offset to coordinates will do so, just make sure that
+// aliased painting is turned on on the d2d device context.
+static const qreal MAGICAL_ALIASING_OFFSET = 0.5;
#define D2D_TAG(tag) d->dc()->SetTags(tag, tag)
Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert);
@@ -184,8 +189,11 @@ public:
D2D1_POINT_2F adjusted(const QPointF &point)
+ static const QPointF adjustment(MAGICAL_ALIASING_OFFSET,
if (m_roundCoordinates)
- return to_d2d_point_2f(point.toPoint());
+ return to_d2d_point_2f(point + adjustment);
return to_d2d_point_2f(point);