summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpainter
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2010-08-09 12:03:45 (GMT)
committerGunnar Sletta <gunnar.sletta@nokia.com>2010-08-09 12:04:54 (GMT)
commitcfc1658c68ee3b7227277a4549b60de545ec5f6f (patch)
treea633469d3c29868818e16b3e2fe63231eef1709f /tests/auto/qpainter
parent8bf7fbcc4f4e2cc5d9d9f0dc38a6e336d2fcc143 (diff)
downloadQt-cfc1658c68ee3b7227277a4549b60de545ec5f6f.zip
Qt-cfc1658c68ee3b7227277a4549b60de545ec5f6f.tar.gz
Qt-cfc1658c68ee3b7227277a4549b60de545ec5f6f.tar.bz2
Added QPainter::clipBoundingRect() which is significantly faster
than QPainter::clipRegion().boundingRect(). Task: http://bugreports.qt.nokia.com/browse/QTBUG-12618 Reviewed-by: Kim
Diffstat (limited to 'tests/auto/qpainter')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index f358681..9ed212f 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -168,6 +168,8 @@ private slots:
void clippedText();
+ void clipBoundingRect();
+
void setOpacity_data();
void setOpacity();
@@ -4522,6 +4524,41 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate()
QCOMPARE(widget->deviceTransform, proxy->deviceTransform);
}
+void tst_QPainter::clipBoundingRect()
+{
+ QPixmap pix(500, 500);
+
+ QPainter p(&pix);
+
+ // Test a basic rectangle
+ p.setClipRect(100, 100, 200, 100);
+ QVERIFY(p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(50, 50, 300, 200)));
+ p.setClipRect(120, 120, 20, 20, Qt::IntersectClip);
+ QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+
+ // Test a basic path + region
+ QPainterPath path;
+ path.addRect(100, 100, 200, 100);
+ p.setClipPath(path);
+ QVERIFY(p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(50, 50, 300, 200)));
+ p.setClipRegion(QRegion(120, 120, 20, 20), Qt::IntersectClip);
+ QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+
+ p.setClipRect(0, 0, 500, 500);
+ p.translate(250, 250);
+ for (int i=0; i<360; ++i) {
+ p.rotate(1);
+ p.setClipRect(-100, -100, 200, 200, Qt::IntersectClip);
+ }
+ QVERIFY(p.clipBoundingRect().contains(QRectF(-100, -100, 200, 200)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(-250, -250, 500, 500)));
+
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"