diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-15 15:49:06 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-15 15:50:03 (GMT) |
commit | a7362cdfa071e2987e403245f0c58936485d1fba (patch) | |
tree | 0c00960bde98c2e70f2de3644d922801276b1df6 /src/gui | |
parent | 9d6069f32962128f737b83a4bf7d7e7309983023 (diff) | |
download | Qt-a7362cdfa071e2987e403245f0c58936485d1fba.zip Qt-a7362cdfa071e2987e403245f0c58936485d1fba.tar.gz Qt-a7362cdfa071e2987e403245f0c58936485d1fba.tar.bz2 |
Optimization: Don't determine the expose if the item is invisible.
If the item either sets the ItemHasNoContents flag, or if it's invisible
but has child items that are not (and ignore parent opacity), then don't
bother calculating the item's exposed view rect as the item will not get
drawn anyway.
This carves down the number of QTransform::mapRect operations by 25%
when running the Declarative UI calculator transition. We'll proceed
to removing such operations from the markDirty step as well.
Reviewed-by: bnilsen
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 673fd23..38a1abe 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5073,6 +5073,9 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * opacity = parentOpacity; } + // Item is invisible. + bool invisible = !item || ((item->d_ptr->flags & QGraphicsItem::ItemHasNoContents) || invisibleButChildIgnoresParentOpacity); + // Calculate the full transform for this item. bool wasDirtyParentSceneTransform = false; bool dontDrawItem = true; @@ -5092,16 +5095,18 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * transform *= viewTransform; } - QRectF brect = item->boundingRect(); - // ### This does not take the clip into account. - _q_adjustRect(&brect); - QRect viewBoundingRect = transform.mapRect(brect).toRect(); - item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect); - viewBoundingRect.adjust(-1, -1, 1, 1); - if (exposedRegion) - dontDrawItem = !exposedRegion->intersects(viewBoundingRect); - else - dontDrawItem = viewBoundingRect.isEmpty(); + if (!invisible) { + QRectF brect = item->boundingRect(); + // ### This does not take the clip into account. + _q_adjustRect(&brect); + QRect viewBoundingRect = transform.mapRect(brect).toRect(); + item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect); + viewBoundingRect.adjust(-1, -1, 1, 1); + if (exposedRegion) + dontDrawItem = !exposedRegion->intersects(viewBoundingRect); + else + dontDrawItem = viewBoundingRect.isEmpty(); + } } // Find and sort children. @@ -5158,7 +5163,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * bool childClip = (item && (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)); bool dontDrawChildren = item && dontDrawItem && childClip; childClip &= !dontDrawChildren && !children->isEmpty(); - if (item && ((item->d_ptr->flags & QGraphicsItem::ItemHasNoContents) || invisibleButChildIgnoresParentOpacity)) + if (item && invisible) dontDrawItem = true; // Clip children. |