QPainter cosmetic stroker: Fix painting error for FlatCap lines
Initialize the lastDir properly, to avoid the stroking algorithm doing direction-change handling for a single line. That could cause a cap to be painted for a single FlatCap line. Also fixes a bug in tst_qpainter, revealed by the above fix. The result drawPolyline was erroneously compared to the result of drawing the lines individually, for a case where the former correctly paints the pixel of the join point in the corner, while the latter by coincidence used to paint the same pixel as a cap because of the bug above. Task-number: QTBUG-70101 Change-Id: Ie20eda33214cfe9e7627f17ef4c7a5b3835c9c24 Reviewed-by: Lars Knoll <lars.knoll@qt.io>bb10
parent
213cfc3fae
commit
b233ce66d3
|
|
@ -85,6 +85,7 @@ public:
|
|||
|
||||
// used to avoid drop outs or duplicated points
|
||||
enum Direction {
|
||||
NoDirection = 0,
|
||||
TopToBottom = 0x1,
|
||||
BottomToTop = 0x2,
|
||||
LeftToRight = 0x4,
|
||||
|
|
@ -104,7 +105,7 @@ public:
|
|||
patternOffset(0),
|
||||
legacyRounding(false),
|
||||
current_span(0),
|
||||
lastDir(LeftToRight),
|
||||
lastDir(NoDirection),
|
||||
lastAxisAligned(false)
|
||||
{ setup(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -5024,7 +5024,7 @@ void tst_QPainter::drawPolyline_data()
|
|||
{
|
||||
QTest::addColumn< QVector<QPointF> >("points");
|
||||
|
||||
QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20) << QPointF(10, 20));
|
||||
QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20));
|
||||
QTest::newRow("clipped") << (QVector<QPointF>() << QPoint(-10, 100) << QPoint(-1, 100) << QPoint(-1, -2) << QPoint(100, -2) << QPoint(100, 40)); // QTBUG-31579
|
||||
QTest::newRow("shortsegment") << (QVector<QPointF>() << QPoint(20, 100) << QPoint(20, 99) << QPoint(21, 99) << QPoint(21, 104)); // QTBUG-42398
|
||||
QTest::newRow("edge") << (QVector<QPointF>() << QPointF(4.5, 121.6) << QPointF(9.4, 150.9) << QPointF(14.2, 184.8) << QPointF(19.1, 130.4));
|
||||
|
|
|
|||
Loading…
Reference in New Issue