summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-04 14:49:10 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-09 07:33:39 (GMT)
commit32c00c1d30eb275f44ba9d0bff4d6b6b05e9a5ba (patch)
tree8708678789f3514e29701272be5dc0904d122b5f /src
parentba48a3fdf39a3db7a3d13ac15031c810454c6e25 (diff)
downloadQt-32c00c1d30eb275f44ba9d0bff4d6b6b05e9a5ba.zip
Qt-32c00c1d30eb275f44ba9d0bff4d6b6b05e9a5ba.tar.gz
Qt-32c00c1d30eb275f44ba9d0bff4d6b6b05e9a5ba.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp14
1 files 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)