summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainterpath.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-02-03 16:18:20 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-02-28 08:57:57 +0100
commit1ba46c9b632731d7d7e791de2b203d0d933245b9 (patch)
treea7933031bde57f582181c2e9c185989ebdbb9470 /src/gui/painting/qpainterpath.cpp
parentd2068b24e4b2e96832af154d02e19b5333880c21 (diff)
Get rid of QMatrix
Task-number: QTBUG-81628 Change-Id: Iad66bfdf49b9ee65558a451108c086fc40dc3884 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/painting/qpainterpath.cpp')
-rw-r--r--src/gui/painting/qpainterpath.cpp101
1 files changed, 65 insertions, 36 deletions
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 <qdebug.h>
#include <qiodevice.h>
#include <qlist.h>
-#include <qmatrix.h>
#include <qpen.h>
#include <qpolygon.h>
#include <qtextlayout.h>
@@ -1604,6 +1603,25 @@ QPainterPath QPainterPath::toReversed() const
}
/*!
+ \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<QPolygonF> 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<QPolygonF> QPainterPath::toSubpathPolygons(const QTransform &matrix) const
return flatCurves;
}
-#if QT_DEPRECATED_SINCE(5, 15)
/*!
- \overload
- \obsolete
+ \overload
- Use toSubpathPolygons(const QTransform &matrix) instead.
- */
-QList<QPolygonF> 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<QPolygonF> 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<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const
return polys;
}
-#if QT_DEPRECATED_SINCE(5, 15)
-/*!
- \overload
- \obsolete
-
- Use toFillPolygons(const QTransform &matrix) instead.
- */
-QList<QPolygonF> 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,
@@ -2882,6 +2903,28 @@ void QPainterPathStroker::setDashOffset(qreal 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<QPolygonF> 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)
{