summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2013-03-05 14:43:50 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-14 06:33:33 (GMT)
commit82b2df405962aae03f8a4ea1cf3028fbac0eff57 (patch)
treef8d4c0ef1daf757a3481d4eea05da7b0620bf8fd /tests
parent74cdd38caeb6b8df7375d507ef4364e937d1edf7 (diff)
downloadQt-82b2df405962aae03f8a4ea1cf3028fbac0eff57.zip
Qt-82b2df405962aae03f8a4ea1cf3028fbac0eff57.tar.gz
Qt-82b2df405962aae03f8a4ea1cf3028fbac0eff57.tar.bz2
Fixed dashes being rendered differently depending on system clip.
We need to clip lines to the unclipped device rect in the case of dashing, since otherwise the dashes will be shifted and rendered differently when partial repaints are done. Task-number: QTBUG-24762 Change-Id: I3599b54baa552acc20bf8cc2e12f846b45f6019e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> (cherry picked from commit a12f6ba302e54c1570c54aa4c722f2dafbf794af)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 3e8bf1c..c6bf2ec 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -272,6 +272,7 @@ private slots:
void QTBUG26013_squareCapStroke();
void QTBUG25153_drawLine();
+ void dashing_systemClip();
private:
void fillData();
@@ -4866,6 +4867,44 @@ void tst_QPainter::QTBUG25153_drawLine()
}
}
+static void dashing_systemClip_paint(QPainter *p)
+{
+ 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);
+}
+
+void tst_QPainter::dashing_systemClip()
+{
+ QImage image(50, 50, QImage::Format_RGB32);
+ image.fill(Qt::white);
+
+ QPainter p(&image);
+ dashing_systemClip_paint(&p);
+ p.end();
+
+ QImage old = image.copy();
+
+ image.paintEngine()->setSystemClip(QRect(10, 0, image.width() - 10, image.height()));
+
+ p.begin(&image);
+ dashing_systemClip_paint(&p);
+
+ // doing same paint operation again with different system clip should not change the image
+ QCOMPARE(old, image);
+
+ old = image;
+
+ p.setClipRect(QRect(20, 20, 30, 30));
+ dashing_systemClip_paint(&p);
+
+ // ditto for regular clips
+ QCOMPARE(old, image);
+}
+
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"