Direct2D QPA: Match raster engine line output
For whatever reason direct2d and the raster engine disagree by one pixel about the positioning of positively sloping aliased lines. To get the same output, we shift such lines by one pixel. Change-Id: I4b20319770c02e3fdd212b3535ccae3c27ca9f2f Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
1b19f66037
commit
8701c20f0d
@ -1160,6 +1160,25 @@ void QWindowsDirect2DPaintEngine::drawRects(const QRectF *rects, int rectCount)
|
||||
}
|
||||
}
|
||||
|
||||
static bool isLinePositivelySloped(const QPointF &p1, const QPointF &p2)
|
||||
{
|
||||
if (p2.x() > p1.x())
|
||||
return p2.y() < p1.y();
|
||||
|
||||
if (p1.x() > p2.x())
|
||||
return p1.y() < p2.y();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void adjustLine(QPointF *p1, QPointF *p2)
|
||||
{
|
||||
if (isLinePositivelySloped(*p1, *p2)) {
|
||||
p1->ry() -= qreal(1.0);
|
||||
p2->ry() -= qreal(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
void QWindowsDirect2DPaintEngine::drawLines(const QLine *lines, int lineCount)
|
||||
{
|
||||
Q_D(QWindowsDirect2DPaintEngine);
|
||||
@ -1181,6 +1200,10 @@ void QWindowsDirect2DPaintEngine::drawLines(const QLine *lines, int lineCount)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Match raster engine output
|
||||
if (!antiAliasingEnabled())
|
||||
adjustLine(&p1, &p2);
|
||||
|
||||
adjustForAliasing(&p1);
|
||||
adjustForAliasing(&p2);
|
||||
|
||||
@ -1213,6 +1236,10 @@ void QWindowsDirect2DPaintEngine::drawLines(const QLineF *lines, int lineCount)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Match raster engine output
|
||||
if (!antiAliasingEnabled())
|
||||
adjustLine(&p1, &p2);
|
||||
|
||||
adjustForAliasing(&p1);
|
||||
adjustForAliasing(&p2);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user