diff options
author | Louai Al-Khanji <louai.al-khanji@digia.com> | 2014-04-29 16:14:19 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-30 08:23:39 +0200 |
commit | 0edb21df154cd2469ba91ea95c8c6464d1140c8d (patch) | |
tree | 154d2b72273e9773d8ff3ca2cf35346aaf8387f9 /src/plugins/platforms | |
parent | 090124eab6f184abbe9be04f4bc1a9eee5285207 (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 <risto.avila@digia.com>
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp | 10 |
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 { LayerClip }; +// 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: private: D2D1_POINT_2F adjusted(const QPointF &point) { + static const QPointF adjustment(MAGICAL_ALIASING_OFFSET, + MAGICAL_ALIASING_OFFSET); + if (m_roundCoordinates) - return to_d2d_point_2f(point.toPoint()); + return to_d2d_point_2f(point + adjustment); else return to_d2d_point_2f(point); } |