summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-03-25 11:38:35 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-06 11:49:47 (GMT)
commit9ed299a3edba92791e1c5af64b8fd9c9fe74c0ea (patch)
tree6371f7619e8e227389cea04d7f167e66a502a6fb /src/gui/graphicsview
parent0d959a6c402ea3a3a55d7076d453d4bdbf8dce8e (diff)
downloadQt-9ed299a3edba92791e1c5af64b8fd9c9fe74c0ea.zip
Qt-9ed299a3edba92791e1c5af64b8fd9c9fe74c0ea.tar.gz
Qt-9ed299a3edba92791e1c5af64b8fd9c9fe74c0ea.tar.bz2
Fixes: Optimize QGraphicsViewPrivate::itemUpdated.
AutoTest: Still pass Details: Get rid of QTransform::inverted()/operator*= and do nothing if the item clips all its children and the update rect is outside the bounding rect.
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 43263da..4db2257 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -801,38 +801,36 @@ void QGraphicsViewPrivate::itemUpdated(QGraphicsItem *item, const QRectF &rect)
updateLater();
QRectF updateRect = rect;
- if (item->isClipped()) {
+ if ((item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) || item->d_ptr->children.isEmpty()) {
+ updateRect &= item->boundingRect();
+ if (updateRect.isEmpty())
+ return;
+ }
+
+ QGraphicsItem *clipItem = item;
+ if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
// Minimize unnecessary redraw.
- QGraphicsItem *p = item;
- QTransform xform;
- QGraphicsItem *lastTransformItem = 0;
- while ((p = p->d_ptr->parent)) {
- if (p->flags() & QGraphicsItem::ItemClipsChildrenToShape) {
- if (!lastTransformItem)
- xform = item->itemTransform(p);
- else
- xform *= lastTransformItem->itemTransform(p);
- lastTransformItem = p;
- updateRect &= xform.inverted().mapRect(p->boundingRect());
+ QGraphicsItem *parent = item;
+ while ((parent = parent->d_ptr->parent)) {
+ if (parent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) {
+ // Map update rect to the current parent and itersect with its bounding rect.
+ updateRect = clipItem->itemTransform(parent).mapRect(updateRect) & parent->boundingRect();
if (updateRect.isEmpty())
return;
+ clipItem = parent;
}
- if (!(p->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
break;
}
-
- if (updateRect.isEmpty())
- return;
}
- // Map the rect to view coordinates.
- QRect vr = viewport->rect();
-
+ // Map update rect from clipItem coordinates to view coordinates.
+ Q_ASSERT(clipItem);
if (!item->d_ptr->hasBoundingRegionGranularity)
- this->updateRect(mapToViewRect(item, updateRect) & vr);
+ this->updateRect(mapToViewRect(clipItem, updateRect) & viewport->rect());
else
- updateRegion(mapToViewRegion(item, updateRect) & vr);
+ updateRegion(mapToViewRegion(clipItem, updateRect) & viewport->rect());
}
void QGraphicsViewPrivate::updateLater()