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>
This commit is contained in:
parent
090124eab6
commit
0edb21df15
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user