5#ifndef QPAINTERPATH_P_H
6#define QPAINTERPATH_P_H
19#include <QtGui/private/qtguiglobal_p.h>
20#include "QtGui/qpainterpath.h"
21#include "QtGui/qregion.h"
22#include "QtCore/qlist.h"
23#include "QtCore/qvarlengtharray.h"
25#include <private/qvectorpath_p.h>
26#include <private/qstroker_p.h>
27#include <private/qbezier_p.h>
50 QVectorPathData(
const QList<QPainterPath::Element> &path,
bool hasWindingFill,
bool convex)
55 for (
int i=0; i<path.size(); ++i) {
56 const QPainterPath::Element &e = path.at(i);
58 points[ptsPos++] = e.x;
59 points[ptsPos++] = e.y;
60 if (e.type == QPainterPath::CurveToElement)
61 flags |= QVectorPath::CurvedShapeMask;
66 isLines = isLines && e.type == (QPainterPath::ElementType) (i%2);
70 flags |= QVectorPath::WindingFill;
72 flags |= QVectorPath::OddEvenFill;
75 flags |= QVectorPath::LinesShapeMask;
77 flags |= QVectorPath::AreaShapeMask;
79 flags |= QVectorPath::NonConvexShapeMask;
98 friend class QPainterPath;
99 friend class QPainterPathStroker;
101 friend class QTransform;
102 friend class QVectorPath;
103#ifndef QT_NO_DATASTREAM
109 : require_moveTo(
false),
111 dirtyControlBounds(
false),
113 hasWindingFill(
false),
122 require_moveTo(
false),
124 dirtyControlBounds(
false),
126 hasWindingFill(
false),
136 cStart(other.cStart),
137 require_moveTo(
false),
138 dirtyBounds(other.dirtyBounds),
139 dirtyControlBounds(other.dirtyControlBounds),
140 dirtyRunLengths(other.dirtyRunLengths),
141 convex(other.convex),
142 hasWindingFill(other.hasWindingFill),
143 cacheEnabled(other.cacheEnabled)
159 qreal *bezierLength)
const;
164 void appendTrimmedElement(QPainterPath *to,
int elemIdx,
int trimFlags, qreal startLen, qreal endLen);
167 appendTrimmedElement(to, elemIdx, TrimEnd, 0, len);
171 appendTrimmedElement(to, elemIdx, TrimStart, len, 0);
175 appendTrimmedElement(to, elemIdx, TrimStart | TrimEnd, fromLen, toLen);
181 pathConverter.reset(
new QVectorPathConverter(elements, hasWindingFill, convex));
182 return pathConverter->path;
186 QList<QPainterPath::Element> elements;
187 std::unique_ptr<QVectorPathConverter> pathConverter;
188 QList<qreal> m_runLengths;
190 QRectF controlBounds;
194 bool require_moveTo : 1;
195 bool dirtyBounds : 1;
196 bool dirtyControlBounds : 1;
197 bool dirtyRunLengths : 1;
199 bool hasWindingFill : 1;
200 bool cacheEnabled : 1;
213inline const QPainterPath QVectorPath::convertToPainterPath()
const
217 QPainterPathPrivate *data = path.d_func();
218 data->elements.reserve(m_count);
220 data->elements[0].x = m_points[index++];
221 data->elements[0].y = m_points[index++];
224 data->elements[0].type = m_elements[0];
225 for (
int i=1; i<m_count; ++i) {
226 QPainterPath::Element element;
227 element.x = m_points[index++];
228 element.y = m_points[index++];
229 element.type = m_elements[i];
230 data->elements << element;
233 data->elements[0].type = QPainterPath::MoveToElement;
234 for (
int i=1; i<m_count; ++i) {
235 QPainterPath::Element element;
236 element.x = m_points[index++];
237 element.y = m_points[index++];
238 element.type = QPainterPath::LineToElement;
239 data->elements << element;
243 data->hasWindingFill = !(m_hints & OddEvenFill);
247void Q_GUI_EXPORT qt_find_ellipse_coords(
const QRectF &r, qreal angle, qreal length,
248 QPointF* startPoint, QPointF *endPoint);
252 const QPainterPath::Element &first = elements.at(cStart);
253 const QPainterPath::Element &last = elements.last();
254 return first.x == last.x && first.y == last.y;
259 require_moveTo =
true;
260 const QPainterPath::Element &first = elements.at(cStart);
261 QPainterPath::Element &last = elements.last();
262 if (first.x != last.x || first.y != last.y) {
263 if (qFuzzyCompare(QPointF(first), QPointF(last))) {
267 QPainterPath::Element e = { first.x, first.y, QPainterPath::LineToElement };
275 if (require_moveTo) {
276 QPainterPath::Element e = elements.last();
277 e.type = QPainterPath::MoveToElement;
279 require_moveTo =
false;
286 m_runLengths.clear();
292 require_moveTo =
false;
294 dirtyControlBounds =
false;
295 dirtyRunLengths =
false;
298 pathConverter.reset();
303 const QPainterPath::Element &e = elements.at(elemIdx);
305 return elements.at(elemIdx + 2);
312 Q_ASSERT(cacheEnabled);
313 Q_ASSERT(!dirtyRunLengths);
314 const auto it =
std::lower_bound(m_runLengths.constBegin(), m_runLengths.constEnd(), len);
315 return (it == m_runLengths.constEnd()) ? m_runLengths.size() - 1 :
int(it - m_runLengths.constBegin());
320 Q_ASSERT(cacheEnabled);
323 qreal len = t * m_runLengths.constLast();
324 return elementAtLength(len);
327#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()
Combined button and popup list for selecting options.
#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