summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengineex.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-07-28 09:55:18 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-07-28 14:45:45 (GMT)
commit1d81d6c163bad6ffe2914ee7e7cc71bb25cb5181 (patch)
treed52a5833a666672a799b491b8f3a1e79af3ccdf5 /src/gui/painting/qpaintengineex.cpp
parente70af37dba3defc0f1b0a08cb5770d3662f3f0ec (diff)
downloadQt-1d81d6c163bad6ffe2914ee7e7cc71bb25cb5181.zip
Qt-1d81d6c163bad6ffe2914ee7e7cc71bb25cb5181.tar.gz
Qt-1d81d6c163bad6ffe2914ee7e7cc71bb25cb5181.tar.bz2
Added QVectorPath::convertToPainterPath() for future convenience
Diffstat (limited to 'src/gui/painting/qpaintengineex.cpp')
-rw-r--r--src/gui/painting/qpaintengineex.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 797a5ab..ce4f7fd 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -91,6 +91,40 @@ QRectF QVectorPath::controlPointRect() const
return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2));
}
+QPainterPath QVectorPath::convertToPainterPath() const
+{
+ QPainterPath path;
+
+ if (m_count == 0)
+ return path;
+
+ const QPointF *points = (const QPointF *) m_points;
+
+ if (m_elements) {
+ for (int i=0; i<m_count; ++i) {
+ switch (m_elements[i]) {
+ case QPainterPath::MoveToElement:
+ path.moveTo(points[i]);
+ break;
+ case QPainterPath::LineToElement:
+ path.lineTo(points[i]);
+ break;
+ case QPainterPath::CurveToElement:
+ path.cubicTo(points[i], points[i+1], points[i+2]);
+ break;
+ default:
+ break;
+ }
+ }
+ } else {
+ path.moveTo(points[0]);
+ for (int i=1; i<m_count; ++i)
+ path.lineTo(points[i]);
+ }
+
+ return path;
+}
+
const QVectorPath &qtVectorPathForPath(const QPainterPath &path)
{
Q_ASSERT(path.d_func());