summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-06-12 11:27:57 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-06-12 11:45:20 (GMT)
commit8134541fc3229177ec7545fa0d3ea49eadc8f00c (patch)
treeade0cee9514adb21579f73f755095b56e477e806 /tests
parentd86ec1c4bec373090d85835f1bec44b025fa2fbc (diff)
downloadQt-8134541fc3229177ec7545fa0d3ea49eadc8f00c.zip
Qt-8134541fc3229177ec7545fa0d3ea49eadc8f00c.tar.gz
Qt-8134541fc3229177ec7545fa0d3ea49eadc8f00c.tar.bz2
QGraphicsItems are repainted when outside the view's exposed region.
The problem was that we used QRect::isEmpty() on the item's bounding rect intersected with the exposed region's bounding rect as a criteria for whether the item should be drawn or not. This does not work as expected with partial updates, where the boundingRect() of the exposed region easily can cover the entire viewport area. The item should *only* be drawn if its bounding rect intersects with the exposed region (and not the exposed region's bounding rect). Auto-test included.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 06b4a78..78d09ba 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -194,6 +194,7 @@ private slots:
void mouseTracking();
void mouseTracking2();
void render();
+ void exposeRegion();
// task specific tests below me
void task172231_untransformableItems();
@@ -3323,6 +3324,39 @@ void tst_QGraphicsView::render()
QCOMPARE(r4->paints, 2);
}
+void tst_QGraphicsView::exposeRegion()
+{
+ RenderTester *item = new RenderTester(QRectF(0, 0, 20, 20));
+ QGraphicsScene scene;
+ scene.addItem(item);
+
+ CustomView view;
+ view.setScene(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(125);
+
+ item->paints = 0;
+ view.lastUpdateRegions.clear();
+
+ // Update a small area in the viewport's topLeft() and bottomRight().
+ // (the boundingRect() of this area covers the entire viewport).
+ QWidget *viewport = view.viewport();
+ QRegion expectedExposeRegion = QRect(0, 0, 5, 5);
+ expectedExposeRegion += QRect(viewport->rect().bottomRight() - QPoint(5, 5), QSize(5, 5));
+ viewport->update(expectedExposeRegion);
+ qApp->processEvents();
+
+ // Make sure it triggers correct repaint on the view.
+ QCOMPARE(view.lastUpdateRegions.size(), 1);
+ QCOMPARE(view.lastUpdateRegions.at(0), expectedExposeRegion);
+
+ // Make sure the item didn't get any repaints.
+ QCOMPARE(item->paints, 0);
+}
+
void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
{
QGraphicsView view;