diff options
author | Balazs Domjan <domjan@gmail.com> | 2013-08-22 15:37:17 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 09:44:33 +0200 |
commit | fdd843d5a76f2bba5c4ebdd5813c97f5105c5765 (patch) | |
tree | 361d49a73535e27e2d0f7e70e4a023e57949c820 /src/gui | |
parent | 31db8728cf038f0a38c42d64c375403fde8598c9 (diff) |
Fix transform (rotation matrix) uniform scale testing.
The rotation matrix is different according to the order of scale and rotate operations. The fix takes into account this.
Task-number: QTBUG-31822
Change-Id: Ia1c9068e54966ec083af9c165af29caa87c510f6
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qtransform.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 5088e9cdc8..a07b5def5d 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -2293,13 +2293,30 @@ bool qt_scaleForTransform(const QTransform &transform, qreal *scale) return qFuzzyCompare(xScale, yScale); } - const qreal xScale = transform.m11() * transform.m11() + // rotate then scale: compare columns + const qreal xScale1 = transform.m11() * transform.m11() + transform.m21() * transform.m21(); - const qreal yScale = transform.m12() * transform.m12() + const qreal yScale1 = transform.m12() * transform.m12() + transform.m22() * transform.m22(); - if (scale) - *scale = qSqrt(qMax(xScale, yScale)); - return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale); + + // scale then rotate: compare rows + const qreal xScale2 = transform.m11() * transform.m11() + + transform.m12() * transform.m12(); + const qreal yScale2 = transform.m21() * transform.m21() + + transform.m22() * transform.m22(); + + // decide the order of rotate and scale operations + if (qAbs(xScale1 - yScale1) > qAbs(xScale2 - yScale2)) { + if (scale) + *scale = qSqrt(qMax(xScale1, yScale1)); + + return type == QTransform::TxRotate && qFuzzyCompare(xScale1, yScale1); + } else { + if (scale) + *scale = qSqrt(qMax(xScale2, yScale2)); + + return type == QTransform::TxRotate && qFuzzyCompare(xScale2, yScale2); + } } QT_END_NAMESPACE |