diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-04-22 12:49:24 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-04-22 14:03:59 (GMT) |
commit | cf9db492ac60568bd159c3749dfa11e2347b9927 (patch) | |
tree | f52c740d74180974fbb3a040d375b9d4bc9cc887 | |
parent | 3696886a327fc4894518c5570b02d5238dcede8a (diff) | |
download | Qt-cf9db492ac60568bd159c3749dfa11e2347b9927.zip Qt-cf9db492ac60568bd159c3749dfa11e2347b9927.tar.gz Qt-cf9db492ac60568bd159c3749dfa11e2347b9927.tar.bz2 |
Prevent QTransform::type() from returning TxScale instead of TxProject.
We have code that assumes that m33 = 1 if the type is TxScale. Instead
of changing all that code it's better to just return TxProject as type
when m33 is different from 1.
Reviewed-by: Simon Hausmann
-rw-r--r-- | src/gui/painting/qtransform.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qtransform/tst_qtransform.cpp | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 39e429d..af27fd5 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1880,7 +1880,7 @@ const QMatrix &QTransform::toAffine() const QTransform::TransformationType QTransform::type() const { if (m_dirty >= m_type) { - if (m_dirty > TxShear && (!qFuzzyCompare(m_13 + 1, 1) || !qFuzzyCompare(m_23 + 1, 1))) + if (m_dirty > TxShear && (!qFuzzyCompare(m_13 + 1, 1) || !qFuzzyCompare(m_23 + 1, 1) || !qFuzzyCompare(m_33, 1))) m_type = TxProject; else if (m_dirty > TxScale && (!qFuzzyCompare(affine._m12 + 1, 1) || !qFuzzyCompare(affine._m21 + 1, 1))) { const qreal dot = affine._m11 * affine._m12 + affine._m21 * affine._m22; @@ -1888,7 +1888,7 @@ QTransform::TransformationType QTransform::type() const m_type = TxRotate; else m_type = TxShear; - } else if (m_dirty > TxTranslate && (!qFuzzyCompare(affine._m11, 1) || !qFuzzyCompare(affine._m22, 1) || !qFuzzyCompare(m_33, 1))) + } else if (m_dirty > TxTranslate && (!qFuzzyCompare(affine._m11, 1) || !qFuzzyCompare(affine._m22, 1))) m_type = TxScale; else if (m_dirty > TxNone && (!qFuzzyCompare(affine._dx + 1, 1) || !qFuzzyCompare(affine._dy + 1, 1))) m_type = TxTranslate; diff --git a/tests/auto/qtransform/tst_qtransform.cpp b/tests/auto/qtransform/tst_qtransform.cpp index 8516ddb..74c405e 100644 --- a/tests/auto/qtransform/tst_qtransform.cpp +++ b/tests/auto/qtransform/tst_qtransform.cpp @@ -593,6 +593,16 @@ void tst_QTransform::types() m3.translate(5.0f, 5.0f); QCOMPARE(m3.type(), QTransform::TxScale); QCOMPARE(m3.inverted().type(), QTransform::TxScale); + + m3.setMatrix(1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 2.0f); + QCOMPARE(m3.type(), QTransform::TxProject); + + m3.setMatrix(0.0f, 2.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 2.0f); + QCOMPARE(m3.type(), QTransform::TxProject); } |