summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
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 /src/gui/graphicsview
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 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 55d8a1d..673fd23 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -5074,8 +5074,8 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
}
// Calculate the full transform for this item.
- QRect viewBoundingRect;
bool wasDirtyParentSceneTransform = false;
+ bool dontDrawItem = true;
QTransform transform;
if (item) {
if (item->d_ptr->itemIsUntransformable()) {
@@ -5091,15 +5091,17 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
transform = item->d_ptr->sceneTransform;
transform *= viewTransform;
}
-
+
QRectF brect = item->boundingRect();
// ### This does not take the clip into account.
_q_adjustRect(&brect);
- viewBoundingRect = transform.mapRect(brect).toRect();
+ QRect viewBoundingRect = transform.mapRect(brect).toRect();
item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
viewBoundingRect.adjust(-1, -1, 1, 1);
if (exposedRegion)
- viewBoundingRect &= exposedRegion->boundingRect();
+ dontDrawItem = !exposedRegion->intersects(viewBoundingRect);
+ else
+ dontDrawItem = viewBoundingRect.isEmpty();
}
// Find and sort children.
@@ -5154,7 +5156,6 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
}
bool childClip = (item && (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape));
- bool dontDrawItem = !item || viewBoundingRect.isEmpty();
bool dontDrawChildren = item && dontDrawItem && childClip;
childClip &= !dontDrawChildren && !children->isEmpty();
if (item && ((item->d_ptr->flags & QGraphicsItem::ItemHasNoContents) || invisibleButChildIgnoresParentOpacity))