diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-16 03:25:35 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-16 03:25:35 (GMT) |
commit | 575f0064bd91e26daa75805c142c10a04a32c2fd (patch) | |
tree | 0f54233b31901dfbcbc3f3ebcc60b82bf1ad2b0a /src | |
parent | 7b0d764f37fa4009dc1556666eb8a141164fb0e0 (diff) | |
download | Qt-575f0064bd91e26daa75805c142c10a04a32c2fd.zip Qt-575f0064bd91e26daa75805c142c10a04a32c2fd.tar.gz Qt-575f0064bd91e26daa75805c142c10a04a32c2fd.tar.bz2 |
Avoid calling QGraphicsItem::setTransformOriginPoint() until needed
Task-number: QTBUG-9772
Reviewed-by: Alexis
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem.cpp | 24 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem_p.h | 6 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 10 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem_p.h | 1 |
4 files changed, 36 insertions, 5 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 86dbaf0..0e4e327 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1794,9 +1794,13 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry, if (transformOrigin() != QDeclarativeItem::TopLeft && (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height())) { - QPointF origin = d->computeTransformOrigin(); - if (transformOriginPoint() != origin) - setTransformOriginPoint(origin); + if (d->transformData) { + QPointF origin = d->computeTransformOrigin(); + if (transformOriginPoint() != origin) + setTransformOriginPoint(origin); + } else { + d->transformOriginDirty = true; + } } if (newGeometry.x() != oldGeometry.x()) @@ -2656,11 +2660,23 @@ void QDeclarativeItem::setTransformOrigin(TransformOrigin origin) Q_D(QDeclarativeItem); if (origin != d->origin) { d->origin = origin; - QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); + if (d->transformData) + QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); + else + d->transformOriginDirty = true; emit transformOriginChanged(d->origin); } } +void QDeclarativeItemPrivate::transformChanged() +{ + Q_Q(QDeclarativeItem); + if (transformOriginDirty) { + q->QGraphicsItem::setTransformOriginPoint(computeTransformOrigin()); + transformOriginDirty = false; + } +} + /*! \property QDeclarativeItem::smooth \brief whether the item is smoothly transformed. diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index cf138c3..3f5bf1a 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -116,7 +116,7 @@ public: _stateGroup(0), origin(QDeclarativeItem::Center), widthValid(false), heightValid(false), _componentComplete(true), _keepMouse(false), - smooth(false), keyHandler(0), + smooth(false), transformOriginDirty(true), keyHandler(0), mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0) { QGraphicsItemPrivate::acceptedMouseButtons = 0; @@ -233,6 +233,7 @@ public: bool _componentComplete:1; bool _keepMouse:1; bool smooth:1; + bool transformOriginDirty : 1; QDeclarativeItemKeyFilter *keyHandler; @@ -269,6 +270,9 @@ public: } } + // Reimplemented from QGraphicsItemPrivate + virtual void transformChanged(); + virtual void focusChanged(bool); static int consistentTime; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9759b39..e290c7e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1237,6 +1237,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } dirtySceneTransform = 1; + if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData))) + transformChanged(); // Restore the sub focus chain. if (subFocusItem) { @@ -3622,6 +3624,7 @@ void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform) q_ptr->prepareGeometryChange(); transformData->transform = transform; dirtySceneTransform = 1; + transformChanged(); } /*! @@ -3812,6 +3815,8 @@ void QGraphicsItem::setRotation(qreal angle) if (d_ptr->isObject) emit static_cast<QGraphicsObject *>(this)->rotationChanged(); + + d_ptr->transformChanged(); } /*! @@ -3876,6 +3881,8 @@ void QGraphicsItem::setScale(qreal factor) if (d_ptr->isObject) emit static_cast<QGraphicsObject *>(this)->scaleChanged(); + + d_ptr->transformChanged(); } @@ -3931,6 +3938,7 @@ void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transf transformations.at(i)->d_func()->setItem(this); d_ptr->transformData->onlyTransform = false; d_ptr->dirtySceneTransform = 1; + d_ptr->transformChanged(); } /*! @@ -3947,6 +3955,7 @@ void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t) t->d_func()->setItem(q); transformData->onlyTransform = false; dirtySceneTransform = 1; + transformChanged(); } /*! @@ -3963,6 +3972,7 @@ void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t) t->d_func()->setItem(q); transformData->onlyTransform = false; dirtySceneTransform = 1; + transformChanged(); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index f922842..8c7fbb4 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -284,6 +284,7 @@ public: void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); bool discardUpdateRequest(bool ignoreVisibleBit = false, bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; + virtual void transformChanged() {} int depth() const; #ifndef QT_NO_GRAPHICSEFFECT enum InvalidateReason { |