assume scale argument is not null in qt_scaleForTransform()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-08-23 02:29:39 +03:00
parent e5cbe2e47e
commit 16c05a6d9a

View file

@ -1531,15 +1531,14 @@ static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transfor
Q_GUI_EXPORT Q_GUI_EXPORT
bool qt_scaleForTransform(const QTransform &transform, qreal *scale) bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
{ {
Q_ASSERT(scale);
const QTransform::TransformationType type = transform.type(); const QTransform::TransformationType type = transform.type();
if (type <= QTransform::TxTranslate) { if (type <= QTransform::TxTranslate) {
if (scale)
*scale = 1; *scale = 1;
return true; return true;
} else if (type == QTransform::TxScale) { } else if (type == QTransform::TxScale) {
const qreal xScale = qAbs(transform.m11()); const qreal xScale = qAbs(transform.m11());
const qreal yScale = qAbs(transform.m22()); const qreal yScale = qAbs(transform.m22());
if (scale)
*scale = qMax(xScale, yScale); *scale = qMax(xScale, yScale);
return qFuzzyCompare(xScale, yScale); return qFuzzyCompare(xScale, yScale);
} }
@ -1548,7 +1547,6 @@ bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
+ transform.m21() * transform.m21(); + transform.m21() * transform.m21();
const qreal yScale = transform.m12() * transform.m12() const qreal yScale = transform.m12() * transform.m12()
+ transform.m22() * transform.m22(); + transform.m22() * transform.m22();
if (scale)
*scale = qSqrt(qMax(xScale, yScale)); *scale = qSqrt(qMax(xScale, yScale));
return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale); return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale);
} }