Fixed cosmetic line drawing where begin and end points are equal.
This case has typically required specific work-arounds in other rendering paths as well. Task-number: QTBUG-25153 Change-Id: I217e710a30222792ebca3bf297e438d944c32992 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
47b99599e8
commit
dfb55f8a6c
@ -356,6 +356,11 @@ bool QCosmeticStroker::clipLine(qreal &x1, qreal &y1, qreal &x2, qreal &y2)
|
|||||||
|
|
||||||
void QCosmeticStroker::drawLine(const QPointF &p1, const QPointF &p2)
|
void QCosmeticStroker::drawLine(const QPointF &p1, const QPointF &p2)
|
||||||
{
|
{
|
||||||
|
if (p1 == p2) {
|
||||||
|
drawPoints(&p1, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QPointF start = p1 * state->matrix;
|
QPointF start = p1 * state->matrix;
|
||||||
QPointF end = p2 * state->matrix;
|
QPointF end = p2 * state->matrix;
|
||||||
|
|
||||||
|
@ -279,6 +279,7 @@ private slots:
|
|||||||
|
|
||||||
void drawTextWithComplexBrush();
|
void drawTextWithComplexBrush();
|
||||||
void QTBUG26013_squareCapStroke();
|
void QTBUG26013_squareCapStroke();
|
||||||
|
void QTBUG25153_drawLine();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillData();
|
void fillData();
|
||||||
@ -4388,6 +4389,26 @@ void tst_QPainter::QTBUG26013_squareCapStroke()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QPainter::QTBUG25153_drawLine()
|
||||||
|
{
|
||||||
|
QImage image(2, 2, QImage::Format_RGB32);
|
||||||
|
|
||||||
|
QVector<Qt::PenCapStyle> styles;
|
||||||
|
styles << Qt::FlatCap << Qt::SquareCap << Qt::RoundCap;
|
||||||
|
|
||||||
|
foreach (Qt::PenCapStyle style, styles) {
|
||||||
|
image.fill(0xffffffff);
|
||||||
|
QPainter p(&image);
|
||||||
|
p.setPen(QPen(Qt::black, 0, Qt::SolidLine, style));
|
||||||
|
p.drawLine(QLineF(0, 0, 0, 0));
|
||||||
|
p.end();
|
||||||
|
|
||||||
|
QCOMPARE(image.pixel(0, 0), 0xff000000);
|
||||||
|
QCOMPARE(image.pixel(0, 1), 0xffffffff);
|
||||||
|
QCOMPARE(image.pixel(1, 0), 0xffffffff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QPainter)
|
QTEST_MAIN(tst_QPainter)
|
||||||
|
|
||||||
#include "tst_qpainter.moc"
|
#include "tst_qpainter.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user