Fix QTransform::quadToQuad() to work with QRectF
A typical usage for mapping a 4-point polygon to a rectangle might be
QTransform transform;
bool ok = QTransform::quadToQuad(polygon, polygon->boundingRect(),
transform);
It works because the QPolygonF(QRectF) ctor is implicitly called on
the second argument; but that ctor turns it into a 5-point polygon.
So it should be legal for QTransform functions to work with 5-point
closed paths.
Fixes: QTBUG-21329
Change-Id: Iae249012e14b8a3e8d3b0dfa35da8f9759359832
Pick-to: 6.5 5.15
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 48b1af941c50ab28cc92f9ea65a8a74a32eaf2bc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 5ead2a3d63a905ed758390e1558dbac744756077)
bb10
parent
cc7dd33d00
commit
f5000beeb6
|
|
@ -1613,7 +1613,7 @@ QPolygon QTransform::mapToPolygon(const QRect &rect) const
|
|||
*/
|
||||
bool QTransform::squareToQuad(const QPolygonF &quad, QTransform &trans)
|
||||
{
|
||||
if (quad.size() != 4)
|
||||
if (quad.size() != (quad.isClosed() ? 5 : 4))
|
||||
return false;
|
||||
|
||||
qreal dx0 = quad[0].x();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ private slots:
|
|||
void mapInt();
|
||||
void mapPathWithPoint();
|
||||
void mapRectToPolygon(); // QTBUG-127723
|
||||
void quadToQuad(); // QTBUG-21329
|
||||
|
||||
private:
|
||||
void mapping_data();
|
||||
|
|
@ -714,6 +715,14 @@ void tst_QTransform::mapRectToPolygon()
|
|||
QCOMPARE(polygon1, polygon2);
|
||||
}
|
||||
|
||||
void tst_QTransform::quadToQuad() // QTBUG-21329
|
||||
{
|
||||
QTransform result;
|
||||
QVERIFY(QTransform::quadToQuad(QRectF(0, 0, 1, 1), QRectF(0, 0, 1, 1), result));
|
||||
QPolygonF trapezoid({{0, 0}, {10, 0}, {11, 11}, {0, 10}});
|
||||
QVERIFY(QTransform::quadToQuad(trapezoid, trapezoid.boundingRect(), result));
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QTransform)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue