summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsscene
diff options
context:
space:
mode:
authorChris Meyer <cmeyer1969@gmail.com>2010-10-04 08:49:32 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-10-04 08:49:32 (GMT)
commit73fa0f87c26a3f5bf17746ec91d05264f0020093 (patch)
treec06e6f972cdae0c2f084d8bcd5b464b06134b52e /tests/auto/qgraphicsscene
parentea8dd9d2dbd3345fbf76625c441d9832f758bf70 (diff)
downloadQt-73fa0f87c26a3f5bf17746ec91d05264f0020093.zip
Qt-73fa0f87c26a3f5bf17746ec91d05264f0020093.tar.gz
Qt-73fa0f87c26a3f5bf17746ec91d05264f0020093.tar.bz2
Fix QTBUG-13730. QGraphicsScene::render clipping bug. Includes test case.
Merge-request: 2480 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r--tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.pngbin0 -> 1819 bytes
-rw-r--r--tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.pngbin0 -> 1255 bytes
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp65
3 files changed, 39 insertions, 26 deletions
diff --git a/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.png b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.png
new file mode 100644
index 0000000..9b401b4
--- /dev/null
+++ b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.png
Binary files differ
diff --git a/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.png b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.png
new file mode 100644
index 0000000..1c59698
--- /dev/null
+++ b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.png
Binary files differ
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index b8e729e..09cf4e2 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -2617,59 +2617,70 @@ void tst_QGraphicsScene::render_data()
QTest::addColumn<QRectF>("sourceRect");
QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode");
QTest::addColumn<QMatrix>("matrix");
+ QTest::addColumn<QPainterPath>("clip");
+
+ QPainterPath clip_rect;
+ clip_rect.addRect(50, 100, 200, 150);
+
+ QPainterPath clip_ellipse;
+ clip_ellipse.addEllipse(100,50,150,200);
QTest::newRow("all-all-untransformed") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-topleft-untransformed") << QRectF(0, 0, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-topright-untransformed") << QRectF(150, 0, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-bottomleft-untransformed") << QRectF(0, 150, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-bottomright-untransformed") << QRectF(150, 150, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topleft-all-untransformed") << QRectF() << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topright-all-untransformed") << QRectF() << QRectF(0, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomleft-all-untransformed") << QRectF() << QRectF(-10, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomright-all-untransformed") << QRectF() << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topleft-topleft-untransformed") << QRectF(0, 0, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topright-topleft-untransformed") << QRectF(150, 0, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomleft-topleft-untransformed") << QRectF(0, 150, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomright-topleft-untransformed") << QRectF(150, 150, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("top-topleft-untransformed") << QRectF(0, 0, 300, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottom-topleft-untransformed") << QRectF(0, 150, 300, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("left-topleft-untransformed") << QRectF(0, 0, 150, 300) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("right-topleft-untransformed") << QRectF(150, 0, 150, 300) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("top-bottomright-untransformed") << QRectF(0, 0, 300, 150) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottom-bottomright-untransformed") << QRectF(0, 150, 300, 150) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("left-bottomright-untransformed") << QRectF(0, 0, 150, 300) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("right-bottomright-untransformed") << QRectF(150, 0, 150, 300) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-all-45-deg-right") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().rotate(-45);
+ << Qt::IgnoreAspectRatio << QMatrix().rotate(-45) << QPainterPath();
QTest::newRow("all-all-45-deg-left") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().rotate(45);
+ << Qt::IgnoreAspectRatio << QMatrix().rotate(45) << QPainterPath();
QTest::newRow("all-all-scale-2x") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().scale(2, 2);
+ << Qt::IgnoreAspectRatio << QMatrix().scale(2, 2) << QPainterPath();
QTest::newRow("all-all-translate-50-0") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().translate(50, 0);
+ << Qt::IgnoreAspectRatio << QMatrix().translate(50, 0) << QPainterPath();
QTest::newRow("all-all-translate-0-50") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().translate(0, 50);
+ << Qt::IgnoreAspectRatio << QMatrix().translate(0, 50) << QPainterPath();
+ QTest::newRow("all-all-untransformed-clip-rect") << QRectF() << QRectF()
+ << Qt::IgnoreAspectRatio << QMatrix() << clip_rect;
+ QTest::newRow("all-all-untransformed-clip-ellipse") << QRectF() << QRectF()
+ << Qt::IgnoreAspectRatio << QMatrix() << clip_ellipse;
}
void tst_QGraphicsScene::render()
@@ -2678,6 +2689,7 @@ void tst_QGraphicsScene::render()
QFETCH(QRectF, sourceRect);
QFETCH(Qt::AspectRatioMode, aspectRatioMode);
QFETCH(QMatrix, matrix);
+ QFETCH(QPainterPath, clip);
QPixmap pix(30, 30);
pix.fill(Qt::blue);
@@ -2703,6 +2715,7 @@ void tst_QGraphicsScene::render()
painter.drawLine(0, 150, 300, 150);
painter.drawLine(150, 0, 150, 300);
painter.setMatrix(matrix);
+ if (!clip.isEmpty()) painter.setClipPath(clip);
scene.render(&painter, targetRect, sourceRect, aspectRatioMode);
painter.end();