summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainterpath_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qpainterpath_p.h')
-rw-r--r--src/gui/painting/qpainterpath_p.h181
1 files changed, 70 insertions, 111 deletions
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index 57668190db..a07b6cca37 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPAINTERPATH_P_H
#define QPAINTERPATH_P_H
@@ -55,6 +19,7 @@
#include "QtGui/qpainterpath.h"
#include "QtGui/qregion.h"
#include "QtCore/qlist.h"
+#include "QtCore/qshareddata.h"
#include "QtCore/qvarlengtharray.h"
#include <qdebug.h>
@@ -66,51 +31,6 @@
QT_BEGIN_NAMESPACE
-// ### Qt 6: merge with QPainterPathData
-class QPainterPathPrivate
-{
-public:
- friend class QPainterPath;
- friend class QPainterPathData;
- friend class QPainterPathStroker;
- friend class QPainterPathStrokerPrivate;
- friend class QTransform;
- friend class QVectorPath;
- friend struct QPainterPathPrivateDeleter;
-#ifndef QT_NO_DATASTREAM
- friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
- friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
-#endif
-
- QPainterPathPrivate() noexcept
- : ref(1)
- {
- }
-
- QPainterPathPrivate(const QPainterPathPrivate &other) noexcept
- : ref(1),
- elements(other.elements)
- {
- }
-
- QPainterPathPrivate &operator=(const QPainterPathPrivate &) = delete;
- ~QPainterPathPrivate() = default;
-
-private:
- QAtomicInt ref;
- QList<QPainterPath::Element> elements;
-};
-
-class QPainterPathStrokerPrivate
-{
-public:
- QPainterPathStrokerPrivate();
-
- QStroker stroker;
- QList<qfixed> dashPattern;
- qreal dashOffset;
-};
-
class QPolygonF;
class QVectorPathConverter;
@@ -173,36 +93,64 @@ private:
Q_DISABLE_COPY_MOVE(QVectorPathConverter)
};
-class QPainterPathData : public QPainterPathPrivate
+class QPainterPathPrivate : public QSharedData
{
public:
- QPainterPathData() :
- cStart(0),
- fillRule(Qt::OddEvenFill),
- require_moveTo(false),
- dirtyBounds(false),
- dirtyControlBounds(false),
- convex(false),
- pathConverter(nullptr)
+ friend class QPainterPath;
+ friend class QPainterPathStroker;
+ friend class QPainterPathStrokerPrivate;
+ friend class QTransform;
+ friend class QVectorPath;
+ friend struct QPainterPathPrivateDeleter;
+#ifndef QT_NO_DATASTREAM
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
+#endif
+
+ QPainterPathPrivate() noexcept
+ : QSharedData(),
+ cStart(0),
+ fillRule(Qt::OddEvenFill),
+ require_moveTo(false),
+ dirtyBounds(false),
+ dirtyControlBounds(false),
+ convex(false),
+ pathConverter(nullptr)
+ {
+ }
+
+ QPainterPathPrivate(QPointF startPoint)
+ : QSharedData(),
+ elements{ { startPoint.x(), startPoint.y(), QPainterPath::MoveToElement } },
+ cStart(0),
+ fillRule(Qt::OddEvenFill),
+ bounds(startPoint, QSizeF(0, 0)),
+ controlBounds(startPoint, QSizeF(0, 0)),
+ require_moveTo(false),
+ dirtyBounds(false),
+ dirtyControlBounds(false),
+ convex(false),
+ pathConverter(nullptr)
{
}
- QPainterPathData(const QPainterPathData &other) :
- QPainterPathPrivate(other),
- cStart(other.cStart),
- fillRule(other.fillRule),
- bounds(other.bounds),
- controlBounds(other.controlBounds),
- require_moveTo(false),
- dirtyBounds(other.dirtyBounds),
- dirtyControlBounds(other.dirtyControlBounds),
- convex(other.convex),
- pathConverter(nullptr)
+ QPainterPathPrivate(const QPainterPathPrivate &other) noexcept
+ : QSharedData(other),
+ elements(other.elements),
+ cStart(other.cStart),
+ fillRule(other.fillRule),
+ bounds(other.bounds),
+ controlBounds(other.controlBounds),
+ require_moveTo(false),
+ dirtyBounds(other.dirtyBounds),
+ dirtyControlBounds(other.dirtyControlBounds),
+ convex(other.convex),
+ pathConverter(nullptr)
{
}
- QPainterPathData &operator=(const QPainterPathData &) = delete;
- ~QPainterPathData() = default;
+ QPainterPathPrivate &operator=(const QPainterPathPrivate &) = delete;
+ ~QPainterPathPrivate() = default;
inline bool isClosed() const;
inline void close();
@@ -215,6 +163,9 @@ public:
return pathConverter->path;
}
+private:
+ QList<QPainterPath::Element> elements;
+
int cStart;
Qt::FillRule fillRule;
@@ -229,12 +180,21 @@ public:
std::unique_ptr<QVectorPathConverter> pathConverter;
};
+class QPainterPathStrokerPrivate
+{
+public:
+ QPainterPathStrokerPrivate();
+
+ QStroker stroker;
+ QList<qfixed> dashPattern;
+ qreal dashOffset;
+};
inline const QPainterPath QVectorPath::convertToPainterPath() const
{
QPainterPath path;
path.ensureData();
- QPainterPathData *data = path.d_func();
+ QPainterPathPrivate *data = path.d_func();
data->elements.reserve(m_count);
int index = 0;
data->elements[0].x = m_points[index++];
@@ -270,14 +230,14 @@ inline const QPainterPath QVectorPath::convertToPainterPath() const
void Q_GUI_EXPORT qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length,
QPointF* startPoint, QPointF *endPoint);
-inline bool QPainterPathData::isClosed() const
+inline bool QPainterPathPrivate::isClosed() const
{
const QPainterPath::Element &first = elements.at(cStart);
const QPainterPath::Element &last = elements.last();
return first.x == last.x && first.y == last.y;
}
-inline void QPainterPathData::close()
+inline void QPainterPathPrivate::close()
{
Q_ASSERT(ref.loadRelaxed() == 1);
require_moveTo = true;
@@ -294,7 +254,7 @@ inline void QPainterPathData::close()
}
}
-inline void QPainterPathData::maybeMoveTo()
+inline void QPainterPathPrivate::maybeMoveTo()
{
if (require_moveTo) {
QPainterPath::Element e = elements.last();
@@ -304,14 +264,13 @@ inline void QPainterPathData::maybeMoveTo()
}
}
-inline void QPainterPathData::clear()
+inline void QPainterPathPrivate::clear()
{
Q_ASSERT(ref.loadRelaxed() == 1);
elements.clear();
cStart = 0;
- fillRule = Qt::OddEvenFill;
bounds = {};
controlBounds = {};