summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qtransform.cpp27
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