summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-05-28 14:08:25 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-09 07:27:32 (GMT)
commitce5b4c468d98bb4ec64429fa362554b9b3614496 (patch)
tree11d38006f049c0ba6c3a2a3a8be387339e6e9d85
parent7c164da956c3b55b6b38df1c9e13dcd821b5062f (diff)
downloadQt-ce5b4c468d98bb4ec64429fa362554b9b3614496.zip
Qt-ce5b4c468d98bb4ec64429fa362554b9b3614496.tar.gz
Qt-ce5b4c468d98bb4ec64429fa362554b9b3614496.tar.bz2
smaller optimisation in setTransform
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 3f6b83c..486e0b5 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2860,28 +2860,25 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
*/
void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
{
- QTransform oldTransform = this->transform();
- QTransform newTransform(combine ? QTransform(matrix) * oldTransform : QTransform(matrix));
- if (oldTransform == newTransform)
+ if(!d_ptr->transform)
+ d_ptr->transform = new QTransform;
+
+ QTransform newTransform(combine ? QTransform(matrix) * *d_ptr->transform : QTransform(matrix));
+ if(*d_ptr->transform == newTransform)
return;
- // Notify the item that the matrix is changing.
- QVariant newTransformVariant(itemChange(ItemMatrixChange,
- qVariantFromValue<QMatrix>(newTransform.toAffine())));
- newTransform = QTransform(qVariantValue<QMatrix>(newTransformVariant));
- if (oldTransform == newTransform)
+ // Notify the item that the transformation matrix is changing.
+ const QVariant newTransformVariant(itemChange(ItemTransformChange,
+ qVariantFromValue<QTransform>(newTransform)));
+ newTransform = qVariantValue<QTransform>(newTransformVariant);
+ if (*d_ptr->transform == newTransform)
return;
// Update and set the new transformation.
prepareGeometryChange();
- if(!d_ptr->transform)
- d_ptr->transform = new QTransform(newTransform);
- else
- *d_ptr->transform = newTransform;
+ *d_ptr->transform = newTransform;
// Send post-notification.
- // NB! We have to change the value from QMatrix to QTransform.
- qVariantSetValue<QTransform>(newTransformVariant, newTransform);
itemChange(ItemTransformHasChanged, newTransformVariant);
}
@@ -2907,24 +2904,23 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
*/
void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
{
- QTransform oldTransform = this->transform();
- QTransform newTransform(combine ? matrix * oldTransform : matrix);
- if (oldTransform == newTransform)
+ if(!d_ptr->transform)
+ d_ptr->transform = new QTransform;
+
+ QTransform newTransform(combine ? matrix * *d_ptr->transform : matrix);
+ if(*d_ptr->transform == newTransform)
return;
// Notify the item that the transformation matrix is changing.
const QVariant newTransformVariant(itemChange(ItemTransformChange,
qVariantFromValue<QTransform>(newTransform)));
newTransform = qVariantValue<QTransform>(newTransformVariant);
- if (oldTransform == newTransform)
+ if (*d_ptr->transform == newTransform)
return;
// Update and set the new transformation.
prepareGeometryChange();
- if(!d_ptr->transform)
- d_ptr->transform = new QTransform(newTransform);
- else
- *d_ptr->transform = newTransform;
+ *d_ptr->transform = newTransform;
// Send post-notification.
itemChange(ItemTransformHasChanged, newTransformVariant);