diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-03 10:28:08 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-03 10:30:06 (GMT) |
commit | 464ee98eee5ce160b497aec6a1163422980dd797 (patch) | |
tree | 883172815821752a51bff8c2ccb4128a42f0122e /src/gui/graphicsview | |
parent | 75078d7b20155ba192b88ec54008e07d1ee44676 (diff) | |
download | Qt-464ee98eee5ce160b497aec6a1163422980dd797.zip Qt-464ee98eee5ce160b497aec6a1163422980dd797.tar.gz Qt-464ee98eee5ce160b497aec6a1163422980dd797.tar.bz2 |
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
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem_p.h | 13 |
1 files changed, 13 insertions, 0 deletions
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); |