From 1ba46c9b632731d7d7e791de2b203d0d933245b9 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 3 Feb 2020 16:18:20 +0100 Subject: Get rid of QMatrix Task-number: QTBUG-81628 Change-Id: Iad66bfdf49b9ee65558a451108c086fc40dc3884 Reviewed-by: Lars Knoll --- src/gui/painting/qpainterpath.cpp | 101 ++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 36 deletions(-) (limited to 'src/gui/painting/qpainterpath.cpp') diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index ab60afd9cd..11623c78f0 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -1603,6 +1602,25 @@ QPainterPath QPainterPath::toReversed() const return rev; } +/*! + \overload + + Converts the path into a list of polygons without any transformation, + and returns the list. + + This function creates one polygon for each subpath regardless of + intersecting subpaths (i.e. overlapping bounding rectangles). To + make sure that such overlapping subpaths are filled correctly, use + the toFillPolygons() function instead. + + \sa toFillPolygons(), toFillPolygon(), {QPainterPath#QPainterPath + Conversion}{QPainterPath Conversion} +*/ +QList QPainterPath::toSubpathPolygons() const +{ + return toSubpathPolygons(QTransform()); +} + /*! Converts the path into a list of polygons using the QTransform \a matrix, and returns the list. @@ -1660,18 +1678,34 @@ QList QPainterPath::toSubpathPolygons(const QTransform &matrix) const return flatCurves; } -#if QT_DEPRECATED_SINCE(5, 15) /*! - \overload - \obsolete + \overload - Use toSubpathPolygons(const QTransform &matrix) instead. - */ -QList QPainterPath::toSubpathPolygons(const QMatrix &matrix) const + Converts the path into a list of polygons without any transformation, + and returns the list. + + The function differs from the toFillPolygon() function in that it + creates several polygons. It is provided because it is usually + faster to draw several small polygons than to draw one large + polygon, even though the total number of points drawn is the same. + + The toFillPolygons() function differs from the toSubpathPolygons() + function in that it create only polygon for subpaths that have + overlapping bounding rectangles. + + Like the toFillPolygon() function, this function uses a rewinding + technique to make sure that overlapping subpaths can be filled + using the correct fill rule. Note that rewinding inserts addition + lines in the polygons so the outline of the fill polygon does not + match the outline of the path. + + \sa toSubpathPolygons(), toFillPolygon(), + {QPainterPath#QPainterPath Conversion}{QPainterPath Conversion} +*/ +QList QPainterPath::toFillPolygons() const { - return toSubpathPolygons(QTransform(matrix)); + return toFillPolygons(QTransform()); } -#endif // QT_DEPRECATED_SINCE(5, 15) /*! Converts the path into a list of polygons using the @@ -1792,19 +1826,6 @@ QList QPainterPath::toFillPolygons(const QTransform &matrix) const return polys; } -#if QT_DEPRECATED_SINCE(5, 15) -/*! - \overload - \obsolete - - Use toFillPolygons(const QTransform &matrix) instead. - */ -QList QPainterPath::toFillPolygons(const QMatrix &matrix) const -{ - return toFillPolygons(QTransform(matrix)); -} -#endif // QT_DEPRECATED_SINCE(5, 15) - //same as qt_polygon_isect_line in qpolygon.cpp static void qt_painterpath_isect_line(const QPointF &p1, const QPointF &p2, @@ -2881,6 +2902,28 @@ void QPainterPathStroker::setDashOffset(qreal offset) d_func()->dashOffset = offset; } +/*! + \overload + + Converts the path into a polygon without any transformation, + and returns the polygon. + + The polygon is created by first converting all subpaths to + polygons, then using a rewinding technique to make sure that + overlapping subpaths can be filled using the correct fill rule. + + Note that rewinding inserts addition lines in the polygon so + the outline of the fill polygon does not match the outline of + the path. + + \sa toSubpathPolygons(), toFillPolygons(), + {QPainterPath#QPainterPath Conversion}{QPainterPath Conversion} +*/ +QPolygonF QPainterPath::toFillPolygon() const +{ + return toFillPolygon(QTransform()); +} + /*! Converts the path into a polygon using the QTransform \a matrix, and returns the polygon. @@ -2898,7 +2941,6 @@ void QPainterPathStroker::setDashOffset(qreal offset) */ QPolygonF QPainterPath::toFillPolygon(const QTransform &matrix) const { - const QList flats = toSubpathPolygons(matrix); QPolygonF polygon; if (flats.isEmpty()) @@ -2914,19 +2956,6 @@ QPolygonF QPainterPath::toFillPolygon(const QTransform &matrix) const return polygon; } -#if QT_DEPRECATED_SINCE(5, 15) -/*! - \overload - \obsolete - - Use toFillPolygon(const QTransform &matrix) instead. -*/ -QPolygonF QPainterPath::toFillPolygon(const QMatrix &matrix) const -{ - return toFillPolygon(QTransform(matrix)); -} -#endif // QT_DEPRECATED_SINCE(5, 15) - //derivative of the equation static inline qreal slopeAt(qreal t, qreal a, qreal b, qreal c, qreal d) { -- cgit v1.2.3