diff options
author | Samuel Rødal <samuel.rodal@digia.com> | 2012-09-20 15:30:24 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-20 23:08:44 +0200 |
commit | 72aaba336c7afe6d79d59995bfb31a8effca4e9e (patch) | |
tree | e6f38c0330f1229bec0f4db6e4a612e6d2f8b46d /tests/auto | |
parent | 562d6ff90f693e43086b286b6e4b2bf2e581e111 (diff) | |
download | qtbase-72aaba336c7afe6d79d59995bfb31a8effca4e9e.tar.gz |
Fixed inconsistent rounding of square cap pens.
A horizontal line should round up at the same time as a vertical line
with square cap, when rendering at subpixel coordinates. Thus, the
special casing in the cosmetic stroker of offsetting by half a pixel
should be for flat caps instead of for square caps.
Task-number: QTBUG-26013
Change-Id: Ic09249337f814c7de95a17976ec9e651561a744b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 14e83adfd0..029bbb8df3 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -278,6 +278,7 @@ private slots: void drawTextOutsideGuiThread(); void drawTextWithComplexBrush(); + void QTBUG26013_squareCapStroke(); private: void fillData(); @@ -4361,6 +4362,34 @@ void tst_QPainter::drawTextWithComplexBrush() QVERIFY(paintedPixels > 0); } +void tst_QPainter::QTBUG26013_squareCapStroke() +{ + QImage image(4, 4, QImage::Format_RGB32); + + QPainter p(&image); + p.setPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)); + + for (int i = 0; i < 3; ++i) { + qreal d = i / 3.0; + + image.fill(0xffffffff); + + p.drawLine(QLineF(0, d, 0, d + 2)); + p.drawLine(QLineF(1, d, 3, d)); + + // ensure that a horizontal line and a vertical line with square cap round up (downwards) at the same time + QCOMPARE(image.pixel(0, 0), image.pixel(1, 0)); + + image.fill(0xffffffff); + + p.drawLine(QLineF(d, 0, d + 2, 0)); + p.drawLine(QLineF(d, 1, d, 3)); + + // ensure that a vertical line and a horizontal line with square cap round up (to the right) at the same time + QCOMPARE(image.pixel(0, 0), image.pixel(0, 1)); + } +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |