From 06153cadcc6c253491879af29f9843765f519354 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 3 Sep 2009 13:44:33 +0200 Subject: 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 --- src/gui/graphicsview/qgraphicsitem_p.h | 30 ++++++++++-------------------- 1 file 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; } }; -- cgit v0.12