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/declarative/graphicsitems | |
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/declarative/graphicsitems')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem.cpp | 24 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem_p.h | 6 |
2 files changed, 25 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; |