From 464ee98eee5ce160b497aec6a1163422980dd797 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 3 Sep 2009 12:28:08 +0200 Subject: Fix test failure & optimize matrix operations in QGraphicsItem. This fixes failures in tst_QGraphicsItem::setTransformProperties(). Change 9e8ff32d introduced QMatrix4x4 as an internal matrix for QGraphicsItem. Problem is, QMatrix4x4 is float-based whereas QTransform is double-based. This change readds the use of QTransform in the case where there are no QGraphicsTransforms in the list. This by itself also makes this common case a bit faster. The workaround is moot if somebody adds any QGraphicsTransform, including one that doesn't do anything (like rotate by 0 degrees). So we might have to find a better fix. Reviewed-by: Olivier --- src/gui/graphicsview/qgraphicsitem_p.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 49361cf..55ed62e 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -517,6 +517,19 @@ 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; + } + QMatrix4x4 x(transform); for (int i = 0; i < graphicsTransforms.size(); ++i) graphicsTransforms.at(i)->applyTo(&x); -- cgit v0.12