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>
bb10
Balazs Domjan 2013-08-22 15:37:17 +02:00 committed by The Qt Project
parent 31db8728cf
commit fdd843d5a7
1 changed files with 22 additions and 5 deletions

View File

@ -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