From 32c00c1d30eb275f44ba9d0bff4d6b6b05e9a5ba Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 4 Jun 2009 16:49:10 +0200 Subject: Fix rendering of items that ignore parent opacity. Test if the children ignore the parent's opacity if the current item's opacity is 0.0. If any of the children do ignore the parent then we must continue. Further optimizations are possible: if the item itself is transparent, then don't visit children that don't ignore parent opacity. Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsscene.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index bb26bb6..c46ed68 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5101,6 +5101,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * { // Calculate opacity. qreal opacity; + bool invisibleButChildIgnoresParentOpacity = false; if (item) { if (!item->d_ptr->visible) return; @@ -5112,8 +5113,11 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * } else { opacity = item->d_ptr->opacity; } - if (opacity == 0.0 && !(item->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)) - return; + if (opacity == 0.0 && !(item->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)) { + invisibleButChildIgnoresParentOpacity = !item->d_ptr->childrenCombineOpacity(); + if (!invisibleButChildIgnoresParentOpacity) + return; + } } else { opacity = parentOpacity; } @@ -5176,7 +5180,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * bool dontDrawItem = !item || viewBoundingRect.isEmpty(); bool dontDrawChildren = item && dontDrawItem && childClip; childClip &= !dontDrawChildren & !children->isEmpty(); - if (item && item->d_ptr->flags & QGraphicsItem::ItemHasNoContents) + if (item && (item->d_ptr->flags & QGraphicsItem::ItemHasNoContents) || invisibleButChildIgnoresParentOpacity) dontDrawItem = true; // Clip children. @@ -5201,6 +5205,8 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * // Draw children behind int i = 0; if (!dontDrawChildren) { + // ### Don't visit children that don't ignore parent opacity if this + // item is invisible. for (i = 0; i < children->size(); ++i) { QGraphicsItem *child = children->at(i); if (wasDirtyParentSceneTransform) @@ -5233,6 +5239,8 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * // Draw children in front if (!dontDrawChildren) { + // ### Don't visit children that don't ignore parent opacity if this + // item is invisible. for (; i < children->size(); ++i) { QGraphicsItem *child = children->at(i); if (wasDirtyParentSceneTransform) -- cgit v0.12