Another fix of cosmetic QPainter::drawPolyline()
At the edge of the view, a line segment could end up as not producing any pixels even if not clipped by the floating-point clip routine. Make sure the starting point for the next line is still updated correctly for any significant segment lengths. Change-Id: I381a4efb81ce6006f3da4c67abf279aea79e4663 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>bb10
parent
17aaaad653
commit
fee16baca1
|
|
@ -719,10 +719,11 @@ static inline void capAdjust(int caps, int &x1, int &x2, int &y, int yinc)
|
|||
template<DrawPixel drawPixel, class Dasher>
|
||||
static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qreal ry2, int caps)
|
||||
{
|
||||
bool didDraw = qAbs(rx2 - rx1) + qAbs(ry2 - ry1) >= 1.0;
|
||||
|
||||
if (stroker->clipLine(rx1, ry1, rx2, ry2))
|
||||
return true;
|
||||
|
||||
bool didDraw = false;
|
||||
const int half = stroker->legacyRounding ? 31 : 0;
|
||||
int x1 = toF26Dot6(rx1) + half;
|
||||
int y1 = toF26Dot6(ry1) + half;
|
||||
|
|
|
|||
|
|
@ -4885,6 +4885,7 @@ void tst_QPainter::drawPolyline_data()
|
|||
QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20) << QPointF(10, 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));
|
||||
}
|
||||
|
||||
void tst_QPainter::drawPolyline()
|
||||
|
|
@ -4894,7 +4895,7 @@ void tst_QPainter::drawPolyline()
|
|||
|
||||
for (int r = 0; r < 2; r++) {
|
||||
images[r] = QImage(150, 150, QImage::Format_ARGB32);
|
||||
images[r].fill(Qt::transparent);
|
||||
images[r].fill(Qt::white);
|
||||
QPainter p(images + r);
|
||||
QPen pen(Qt::red, 0, Qt::SolidLine, Qt::FlatCap);
|
||||
p.setPen(pen);
|
||||
|
|
|
|||
Loading…
Reference in New Issue