4#ifndef QPAINTERPATH_P_H
5#define QPAINTERPATH_P_H
18#include <QtGui/private/qtguiglobal_p.h>
19#include "QtGui/qpainterpath.h"
20#include "QtGui/qregion.h"
21#include "QtCore/qlist.h"
22#include "QtCore/qvarlengtharray.h"
24#include <private/qvectorpath_p.h>
25#include <private/qstroker_p.h>
26#include <private/qbezier_p.h>
49 QVectorPathData(
const QList<QPainterPath::Element> &path,
bool hasWindingFill,
bool convex)
54 for (
int i=0; i<path.size(); ++i) {
55 const QPainterPath::Element &e = path.at(i);
57 points[ptsPos++] = e.x;
58 points[ptsPos++] = e.y;
59 if (e.type == QPainterPath::CurveToElement)
60 flags |= QVectorPath::CurvedShapeMask;
65 isLines = isLines && e.type == (QPainterPath::ElementType) (i%2);
69 flags |= QVectorPath::WindingFill;
71 flags |= QVectorPath::OddEvenFill;
74 flags |= QVectorPath::LinesShapeMask;
76 flags |= QVectorPath::AreaShapeMask;
78 flags |= QVectorPath::NonConvexShapeMask;
97 friend class QPainterPath;
98 friend class QPainterPathStroker;
100 friend class QTransform;
101 friend class QVectorPath;
102#ifndef QT_NO_DATASTREAM
108 : require_moveTo(
false),
110 dirtyControlBounds(
false),
112 hasWindingFill(
false),
121 require_moveTo(
false),
123 dirtyControlBounds(
false),
125 hasWindingFill(
false),
135 cStart(other.cStart),
136 require_moveTo(
false),
137 dirtyBounds(other.dirtyBounds),
138 dirtyControlBounds(other.dirtyControlBounds),
139 dirtyRunLengths(other.dirtyRunLengths),
140 convex(other.convex),
141 hasWindingFill(other.hasWindingFill),
142 cacheEnabled(other.cacheEnabled)
158 qreal *bezierLength)
const;
163 void appendTrimmedElement(QPainterPath *to,
int elemIdx,
int trimFlags, qreal startLen, qreal endLen);
166 appendTrimmedElement(to, elemIdx, TrimEnd, 0, len);
170 appendTrimmedElement(to, elemIdx, TrimStart, len, 0);
174 appendTrimmedElement(to, elemIdx, TrimStart | TrimEnd, fromLen, toLen);
180 pathConverter.reset(
new QVectorPathConverter(elements, hasWindingFill, convex));
181 return pathConverter->path;
185 QList<QPainterPath::Element> elements;
186 std::unique_ptr<QVectorPathConverter> pathConverter;
187 QList<qreal> m_runLengths;
189 QRectF controlBounds;
193 bool require_moveTo : 1;
194 bool dirtyBounds : 1;
195 bool dirtyControlBounds : 1;
196 bool dirtyRunLengths : 1;
198 bool hasWindingFill : 1;
199 bool cacheEnabled : 1;
212inline const QPainterPath QVectorPath::convertToPainterPath()
const
216 QPainterPathPrivate *data = path.d_func();
217 data->elements.reserve(m_count);
219 data->elements[0].x = m_points[index++];
220 data->elements[0].y = m_points[index++];
223 data->elements[0].type = m_elements[0];
224 for (
int i=1; i<m_count; ++i) {
225 QPainterPath::Element element;
226 element.x = m_points[index++];
227 element.y = m_points[index++];
228 element.type = m_elements[i];
229 data->elements << element;
232 data->elements[0].type = QPainterPath::MoveToElement;
233 for (
int i=1; i<m_count; ++i) {
234 QPainterPath::Element element;
235 element.x = m_points[index++];
236 element.y = m_points[index++];
237 element.type = QPainterPath::LineToElement;
238 data->elements << element;
242 data->hasWindingFill = !(m_hints & OddEvenFill);
246void Q_GUI_EXPORT qt_find_ellipse_coords(
const QRectF &r, qreal angle, qreal length,
247 QPointF* startPoint, QPointF *endPoint);
251 const QPainterPath::Element &first = elements.at(cStart);
252 const QPainterPath::Element &last = elements.last();
253 return first.x == last.x && first.y == last.y;
258 require_moveTo =
true;
259 const QPainterPath::Element &first = elements.at(cStart);
260 QPainterPath::Element &last = elements.last();
261 if (first.x != last.x || first.y != last.y) {
262 if (qFuzzyCompare(first.x, last.x) && qFuzzyCompare(first.y, last.y)) {
266 QPainterPath::Element e = { first.x, first.y, QPainterPath::LineToElement };
274 if (require_moveTo) {
275 QPainterPath::Element e = elements.last();
276 e.type = QPainterPath::MoveToElement;
278 require_moveTo =
false;
285 m_runLengths.clear();
291 require_moveTo =
false;
293 dirtyControlBounds =
false;
294 dirtyRunLengths =
false;
297 pathConverter.reset();
302 const QPainterPath::Element &e = elements.at(elemIdx);
304 return elements.at(elemIdx + 2);
311 Q_ASSERT(cacheEnabled);
312 Q_ASSERT(!dirtyRunLengths);
313 const auto it = std::lower_bound(m_runLengths.constBegin(), m_runLengths.constEnd(), len);
314 return (it == m_runLengths.constEnd()) ? m_runLengths.size() - 1 :
int(it - m_runLengths.constBegin());
319 Q_ASSERT(cacheEnabled);
322 qreal len = t * m_runLengths.constLast();
323 return elementAtLength(len);
326#define KAPPA qreal(0.5522847498
)
QT_FT_Outline * outline()
void clipElements(const QPointF *points, const QPainterPath::ElementType *types, int count)
QDataBuffer< QT_FT_Vector > m_points
void convertElements(const QPointF *points, const QPainterPath::ElementType *types, int count)
void setMatrix(const QTransform &m)
Sets up the matrix to be used for conversion.
void moveTo(const QPointF &pt)
void curveTo(const QPointF &cp1, const QPointF &cp2, const QPointF &ep)
void setClipRect(QRect clipRect)
QDataBuffer< QPointF > m_elements
QPainterPath::ElementType * elementTypes() const
QDataBuffer< char > m_tags
QDataBuffer< int > m_contours
QDataBuffer< QPainterPath::ElementType > m_element_types
QRectF m_clip_trigger_rect
QT_FT_Outline * convertPath(const QPainterPath &path)
void beginOutline(Qt::FillRule fillRule)
void lineTo(const QPointF &pt)
QPainterPathPrivate(QPointF startPoint)
void appendStartOfElement(QPainterPath *to, int elemIdx, qreal len)
int elementAtLength(qreal len)
void appendEndOfElement(QPainterPath *to, int elemIdx, qreal len)
QPainterPathPrivate(const QPainterPathPrivate &other) noexcept
void appendTrimmedElement(QPainterPath *to, int elemIdx, int trimFlags, qreal startLen, qreal endLen)
void appendSliceOfElement(QPainterPath *to, int elemIdx, qreal fromLen, qreal toLen)
QPainterPathPrivate & operator=(const QPainterPathPrivate &)=delete
const QVectorPath & vectorPath()
void appendElementRange(QPainterPath *to, int first, int last)
QBezier bezierAtT(const QPainterPath &path, qreal t, qreal *startingLength, qreal *bezierLength) const
QPointF endPointOfElement(int elemIdx) const
~QPainterPathPrivate()=default
QPainterPathPrivate() noexcept
QPainterPathStrokerPrivate()
QList< qfixed > dashPattern
friend class QPaintEngineExPrivate
QVectorPathConverter(const QList< QPainterPath::Element > &path, bool hasWindingFill, bool convex)
const QVectorPath & vectorPath()
#define qreal_to_fixed_26_6(f)
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
QT_BEGIN_NAMESPACE constexpr int QT_RASTER_COORD_LIMIT
QDebug Q_GUI_EXPORT & operator<<(QDebug &s, const QVectorPath &path)
QVectorPathData(const QList< QPainterPath::Element > &path, bool hasWindingFill, bool convex)
QVarLengthArray< QPainterPath::ElementType > elements
QVarLengthArray< qreal > points