summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsitem.cpp
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-03-02 15:22:20 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-06 11:49:38 (GMT)
commitab130a0019fadeff4622778ca9f8b3e630da14da (patch)
tree00b62727d1bcd965317ce0cd1dbbdaa43af3d05b /src/gui/graphicsview/qgraphicsitem.cpp
parentfac3c7b73ba2c6b39332445ae00b2fe26a578913 (diff)
downloadQt-ab130a0019fadeff4622778ca9f8b3e630da14da.zip
Qt-ab130a0019fadeff4622778ca9f8b3e630da14da.tar.gz
Qt-ab130a0019fadeff4622778ca9f8b3e630da14da.tar.bz2
Fixes: Speed up QGrahicsItemPrivate::effectiveOpacity().
RevBy: Andreas AutoTest: tst_QGraphicsItem::opacity still passes
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index bb95543..cda1bd1 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1862,6 +1862,9 @@ qreal QGraphicsItem::opacity() const
*/
qreal QGraphicsItem::effectiveOpacity() const
{
+ if (!d_ptr->hasEffectiveOpacity)
+ return qreal(1.0);
+
QVariant effectiveOpacity = d_ptr->extra(QGraphicsItemPrivate::ExtraEffectiveOpacity);
return effectiveOpacity.isNull() ? qreal(1.0) : qreal(effectiveOpacity.toDouble());
}
@@ -3680,7 +3683,14 @@ void QGraphicsItemPrivate::resolveEffectiveOpacity(qreal parentEffectiveOpacity)
}
// Set this item's resolved opacity.
- setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ if (qFuzzyCompare(myEffectiveOpacity, qreal(1.0))) {
+ // Opaque, unset effective opacity.
+ hasEffectiveOpacity = 0;
+ unsetExtra(ExtraEffectiveOpacity);
+ } else {
+ hasEffectiveOpacity = 1;
+ setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ }
// Resolve children always.
for (int i = 0; i < children.size(); ++i)