summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-05-29 13:32:38 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-09 07:29:55 (GMT)
commit5d54c09085979431831297f0e63f39c73f884d20 (patch)
tree7eb04ac77a4f927ca4938def53dce143cbb588a6
parent2581606e0f86280546c498fec130d2625376dda7 (diff)
downloadQt-5d54c09085979431831297f0e63f39c73f884d20.zip
Qt-5d54c09085979431831297f0e63f39c73f884d20.tar.gz
Qt-5d54c09085979431831297f0e63f39c73f884d20.tar.bz2
Avoid calling QGraphicsItem::effectiveOpacity() when rendering - instead
just calculate it top-down. Reviewed-by: bnilsen
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp30
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h3
2 files changed, 26 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 52dc152..1d33361 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -5047,10 +5047,27 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform &parentTransform,
const QTransform &viewTransform,
const QRegion &exposedRegion, QWidget *widget,
- QGraphicsView::OptimizationFlags optimizationFlags)
+ QGraphicsView::OptimizationFlags optimizationFlags,
+ qreal parentOpacity)
{
- if (item && item->d_ptr->isInvisible())
- return;
+ // Calculate opacity.
+ qreal opacity;
+ if (item) {
+ if (!item->d_ptr->visible)
+ return;
+ QGraphicsItem *p = item->d_ptr->parent;
+ bool itemIgnoresParentOpacity = item->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity;
+ bool parentDoesntPropagateOpacity = (p && (p->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren));
+ if (!itemIgnoresParentOpacity && !parentDoesntPropagateOpacity) {
+ opacity = parentOpacity * item->opacity();
+ } else {
+ opacity = item->d_ptr->opacity;
+ }
+ if (opacity == 0.0 && !(item->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren))
+ return;
+ } else {
+ opacity = parentOpacity;
+ }
// Calculate the full transform for this item.
QTransform transform = parentTransform;
@@ -5113,7 +5130,8 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent))
break;
drawSubtreeRecursive(child, painter, transform, viewTransform,
- exposedRegion, widget, optimizationFlags);
+ exposedRegion, widget, optimizationFlags,
+ opacity);
}
}
@@ -5130,7 +5148,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
painter->setWorldTransform(transform);
if (clipsToShape)
painter->setClipPath(item->shape(), Qt::IntersectClip);
- painter->setOpacity(item->effectiveOpacity());
+ painter->setOpacity(opacity);
drawItemHelper(item, painter, &option, widget, false);
@@ -5142,7 +5160,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (!dontDrawChildren) {
for (; i < children.size(); ++i) {
drawSubtreeRecursive(children.at(i), painter, transform, viewTransform,
- exposedRegion, widget, optimizationFlags);
+ exposedRegion, widget, optimizationFlags, opacity);
}
}
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index e7e96f5..4facec3 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -256,7 +256,8 @@ public:
void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform &parentTransform,
const QTransform &viewTransform,
- const QRegion &exposedRegion, QWidget *widget, QGraphicsView::OptimizationFlags optimizationFlags);
+ const QRegion &exposedRegion, QWidget *widget, QGraphicsView::OptimizationFlags optimizationFlags,
+ qreal parentOpacity = qreal(1.0));
void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false,
bool maybeDirtyClipPath = false, bool force = false, bool ignoreOpacity = false);
void processDirtyItemsRecursive(QGraphicsItem *item, const QTransform &);