summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpainter
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2013-03-14 07:51:07 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-20 16:32:30 (GMT)
commita2d573ac8e72315e60d4b17903d3035adffb8b18 (patch)
treebb8dc44ad3383993c8081230393284cd41144267 /tests/auto/qpainter
parent0e1862cf317ae08ff80dc967491e69ea84599f13 (diff)
downloadQt-a2d573ac8e72315e60d4b17903d3035adffb8b18.zip
Qt-a2d573ac8e72315e60d4b17903d3035adffb8b18.tar.gz
Qt-a2d573ac8e72315e60d4b17903d3035adffb8b18.tar.bz2
Fixed artifacts when drawing same line with different clips.
Expanding on the change fixing QTBUG-24762 with the realization that any line needs to be drawn in a consistent way regardless of system or painter clip, not just dashed lines. Task-number: QTBUG-25036 Change-Id: Ief7ef19cc92c52e7d792500a581a072ba032767e Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> (cherry picked from commit c7191d3e214b9cdb17ec383b61f7e21e784f80d0)
Diffstat (limited to 'tests/auto/qpainter')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp58
1 files changed, 47 insertions, 11 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index c6bf2ec..e224522 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -272,7 +272,9 @@ private slots:
void QTBUG26013_squareCapStroke();
void QTBUG25153_drawLine();
- void dashing_systemClip();
+
+ void cosmeticStrokerClipping_data();
+ void cosmeticStrokerClipping();
private:
void fillData();
@@ -4867,22 +4869,54 @@ void tst_QPainter::QTBUG25153_drawLine()
}
}
-static void dashing_systemClip_paint(QPainter *p)
+enum CosmeticStrokerPaint
+{
+ Antialiasing,
+ Dashing
+};
+
+static void paint_func(QPainter *p, CosmeticStrokerPaint type)
+{
+ p->save();
+ switch (type) {
+ case Antialiasing:
+ p->setPen(Qt::black);
+ p->setRenderHint(QPainter::Antialiasing);
+ p->drawLine(4, 8, 42, 42);
+ break;
+ case Dashing:
+ p->setPen(QPen(Qt::black, 1, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin));
+ p->drawLine(8, 8, 42, 8);
+ p->drawLine(42, 8, 42, 42);
+ p->drawLine(42, 42, 8, 42);
+ p->drawLine(8, 42, 8, 8);
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+ p->restore();
+}
+
+Q_DECLARE_METATYPE(CosmeticStrokerPaint)
+
+void tst_QPainter::cosmeticStrokerClipping_data()
{
- p->setPen(QPen(Qt::black, 1, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin));
- p->drawLine(8, 8, 42, 8);
- p->drawLine(42, 8, 42, 42);
- p->drawLine(42, 42, 8, 42);
- p->drawLine(8, 42, 8, 8);
+ QTest::addColumn<CosmeticStrokerPaint>("paint");
+
+ QTest::newRow("antialiasing_paint") << Antialiasing;
+ QTest::newRow("dashing_paint") << Dashing;
}
-void tst_QPainter::dashing_systemClip()
+void tst_QPainter::cosmeticStrokerClipping()
{
+ QFETCH(CosmeticStrokerPaint, paint);
+
QImage image(50, 50, QImage::Format_RGB32);
image.fill(Qt::white);
QPainter p(&image);
- dashing_systemClip_paint(&p);
+ paint_func(&p, paint);
p.end();
QImage old = image.copy();
@@ -4890,7 +4924,8 @@ void tst_QPainter::dashing_systemClip()
image.paintEngine()->setSystemClip(QRect(10, 0, image.width() - 10, image.height()));
p.begin(&image);
- dashing_systemClip_paint(&p);
+ p.fillRect(image.rect(), Qt::white);
+ paint_func(&p, paint);
// doing same paint operation again with different system clip should not change the image
QCOMPARE(old, image);
@@ -4898,7 +4933,8 @@ void tst_QPainter::dashing_systemClip()
old = image;
p.setClipRect(QRect(20, 20, 30, 30));
- dashing_systemClip_paint(&p);
+ p.fillRect(image.rect(), Qt::white);
+ paint_func(&p, paint);
// ditto for regular clips
QCOMPARE(old, image);