summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-03 11:44:33 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-03 11:46:13 (GMT)
commit06153cadcc6c253491879af29f9843765f519354 (patch)
tree0f97bff89de8407290fc18e75e58d85b8bcbd878 /src
parente3c62dc1def9270761ca63c73ae76fdca9d61582 (diff)
downloadQt-06153cadcc6c253491879af29f9843765f519354.zip
Qt-06153cadcc6c253491879af29f9843765f519354.tar.gz
Qt-06153cadcc6c253491879af29f9843765f519354.tar.bz2
Improvements to usage of QMatrix4x4 in QGraphicsItem.
This could have been amended to 464ee98eee5ce160b497aec6a1163422980dd797, the idea is that we use QMatrix4x4 only for the QGraphicsTransform instances and QTransform for the rest. The problem with the last submit was that adding any (unrelated) QGraphicsTransform would cause the QGraphicsItem::rotation properties (and friends) to lose precision. Reviewed-by: Olivier Reviewed-by: gabi
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 55ed62e..1bf8993 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -517,30 +517,20 @@ struct QGraphicsItemPrivate::TransformData
return transform * *postmultiplyTransform;
}
- if (graphicsTransforms.isEmpty()) {
- // Faster, and higher precision if there are no graphics
- // transforms.
- QTransform x(transform);
- x.translate(xOrigin, yOrigin);
- x.rotate(rotation);
- x.scale(scale, scale);
- x.translate(-xOrigin, -yOrigin);
- if (postmultiplyTransform)
- x *= *postmultiplyTransform;
- return x;
+ QTransform x(transform);
+ if (!graphicsTransforms.isEmpty()) {
+ QMatrix4x4 m;
+ for (int i = 0; i < graphicsTransforms.size(); ++i)
+ graphicsTransforms.at(i)->applyTo(&m);
+ x *= m.toTransform();
}
-
- QMatrix4x4 x(transform);
- for (int i = 0; i < graphicsTransforms.size(); ++i)
- graphicsTransforms.at(i)->applyTo(&x);
x.translate(xOrigin, yOrigin);
- x.rotate(rotation, 0, 0, 1);
- x.scale(scale);
+ x.rotate(rotation);
+ x.scale(scale, scale);
x.translate(-xOrigin, -yOrigin);
- QTransform t = x.toTransform(); // project the 3D matrix back to 2D.
if (postmultiplyTransform)
- t *= *postmultiplyTransform;
- return t;
+ x *= *postmultiplyTransform;
+ return x;
}
};