19#include <QtGui/private/qtguiglobal_p.h>
20#include "QtGui/qpainterpath.h"
21#include "private/qdatabuffer_p.h"
22#include "private/qnumeric_p.h"
28#if defined QFIXED_IS_26_6
30#define qt_real_to_fixed(real) qfixed(real * 64
)
31#define qt_int_to_fixed(real) qfixed(int(real) << 6
)
32#define qt_fixed_to_real(fixed) qreal(fixed / qreal(64
))
33#define qt_fixed_to_int(fixed) int(fixed >> 6
)
39 bool operator==(
const qfixed2d &other)
const {
return x == other.x && y == other.y; }
41#elif defined QFIXED_IS_32_32
43#define qt_real_to_fixed(real) qfixed(real * double(qint64(1
) << 32
))
44#define qt_fixed_to_real(fixed) qreal(fixed / double(qint64(1
) << 32
))
50 bool operator==(
const qfixed2d &other)
const {
return x == other.x && y == other.y; }
52#elif defined QFIXED_IS_16_16
54#define qt_real_to_fixed(real) qfixed(real * qreal(1
<< 16
))
55#define qt_fixed_to_real(fixed) qreal(fixed / qreal(1
<< 16
))
61 bool operator==(
const qfixed2d &other)
const {
return x == other.x && y == other.y; }
65#define qt_real_to_fixed(real) qfixed(real)
66#define qt_fixed_to_real(fixed) fixed
74 && qFuzzyCompare(
y, other
.y); }
78#define QT_PATH_KAPPA 0.5522847498
81 QPointF *controlPoints,
int *point_count);
99 QPainterPath::ElementType type;
103 inline bool isMoveTo()
const {
return type == QPainterPath::MoveToElement; }
104 inline bool isLineTo()
const {
return type == QPainterPath::LineToElement; }
105 inline bool isCurveTo()
const {
return type == QPainterPath::CurveToElement; }
107 operator qfixed2d () { qfixed2d pt = { x, y };
return pt; }
111 virtual ~QStrokerOps();
113 void setMoveToHook(qStrokerMoveToHook moveToHook) { m_moveTo = moveToHook; }
114 void setLineToHook(qStrokerLineToHook lineToHook) { m_lineTo = lineToHook; }
115 void setCubicToHook(qStrokerCubicToHook cubicToHook) { m_cubicTo = cubicToHook; }
117 virtual void begin(
void *customData);
120 inline void moveTo(qfixed x, qfixed y);
121 inline void lineTo(qfixed x, qfixed y);
122 inline void cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey);
124 void strokePath(
const QPainterPath &path,
void *data,
const QTransform &matrix);
125 void strokePolygon(
const QPointF *points,
int pointCount,
bool implicit_close,
126 void *data,
const QTransform &matrix);
127 void strokeEllipse(
const QRectF &ellipse,
void *data,
const QTransform &matrix);
129 QRectF clipRect()
const {
return m_clip_rect; }
130 void setClipRect(
const QRectF &clip) { m_clip_rect = clip; }
132 void setCurveThresholdFromTransform(
const QTransform &transform)
135 qt_scaleForTransform(transform, &scale);
136 const qreal threshold = scale == 0 ? qreal(0.5) : (qreal(0.5) / scale);
140 m_curveThresholdExplicitlySet ? qMin(threshold, m_curveThreshold) : threshold;
143 void setCurveThreshold(qfixed threshold)
145 m_curveThreshold = threshold;
146 m_curveThresholdExplicitlySet =
true;
148 qfixed curveThreshold()
const {
return m_curveThreshold; }
149 bool curveThresholdExplicitlySet()
const {
return m_curveThresholdExplicitlySet; }
152 inline void emitMoveTo(qfixed x, qfixed y);
153 inline void emitLineTo(qfixed x, qfixed y);
154 inline void emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey);
156 virtual void processCurrentSubpath() = 0;
157 QDataBuffer<Element> m_elements;
160 qfixed m_curveThreshold;
161 qfixed m_dashThreshold;
162 bool m_curveThresholdExplicitlySet;
165 qStrokerMoveToHook m_moveTo;
166 qStrokerLineToHook m_lineTo;
167 qStrokerCubicToHook m_cubicTo;
187 void setStrokeWidth(qfixed width)
189 m_strokeWidth = width;
192 qfixed strokeWidth()
const {
return m_strokeWidth; }
194 void setCapStyle(Qt::PenCapStyle capStyle) { m_capStyle = joinModeForCap(capStyle); }
195 Qt::PenCapStyle capStyle()
const {
return capForJoinMode(m_capStyle); }
196 LineJoinMode capStyleMode()
const {
return m_capStyle; }
198 void setJoinStyle(Qt::PenJoinStyle style) { m_joinStyle = joinModeForJoin(style); }
199 Qt::PenJoinStyle joinStyle()
const {
return joinForJoinMode(m_joinStyle); }
200 LineJoinMode joinStyleMode()
const {
return m_joinStyle; }
202 void setMiterLimit(qfixed length) { m_miterLimit = length; }
203 qfixed miterLimit()
const {
return m_miterLimit; }
205 void setForceOpen(
bool state) { m_forceOpen = state; }
206 bool forceOpen()
const {
return m_forceOpen; }
208 void joinPoints(qfixed x, qfixed y,
const QLineF &nextLine, LineJoinMode join);
209 inline void emitMoveTo(qfixed x, qfixed y);
210 inline void emitLineTo(qfixed x, qfixed y);
211 inline void emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey);
214 static Qt::PenCapStyle capForJoinMode(LineJoinMode mode);
215 static LineJoinMode joinModeForCap(Qt::PenCapStyle);
217 static Qt::PenJoinStyle joinForJoinMode(LineJoinMode mode);
218 static LineJoinMode joinModeForJoin(Qt::PenJoinStyle joinStyle);
220 void processCurrentSubpath() override;
222 qfixed m_strokeWidth;
225 LineJoinMode m_capStyle;
226 LineJoinMode m_joinStyle;
240 QDashStroker(QStroker *stroker);
243 QStroker *stroker()
const {
return m_stroker; }
245 static QList<qfixed> patternForStyle(Qt::PenStyle style);
246 static int repetitionLimit() {
return 10000; }
248 void setDashPattern(
const QList<qfixed> &dashPattern) { m_dashPattern = dashPattern; }
249 QList<qfixed> dashPattern()
const {
return m_dashPattern; }
251 void setDashOffset(qreal offset) { m_dashOffset = offset; }
252 qreal dashOffset()
const {
return m_dashOffset; }
254 void begin(
void *data) override;
257 inline void setStrokeWidth(qreal width) { m_stroke_width = width; }
258 inline void setMiterLimit(qreal limit) { m_miter_limit = limit; }
261 void processCurrentSubpath() override;
264 QList<qfixed> m_dashPattern;
267 qreal m_stroke_width;
273
274
276inline void QStrokerOps::emitMoveTo(qfixed x, qfixed y)
279 m_moveTo(x, y, m_customData);
282inline void QStrokerOps::emitLineTo(qfixed x, qfixed y)
285 m_lineTo(x, y, m_customData);
288inline void QStrokerOps::emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey)
291 m_cubicTo(c1x, c1y, c2x, c2y, ex, ey, m_customData);
294inline void QStrokerOps::moveTo(qfixed x, qfixed y)
296 if (m_elements.size()>1)
297 processCurrentSubpath();
299 Element e = { QPainterPath::MoveToElement, x, y };
303inline void QStrokerOps::lineTo(qfixed x, qfixed y)
305 Element e = { QPainterPath::LineToElement, x, y };
309inline void QStrokerOps::cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey)
311 Element c1 = { QPainterPath::CurveToElement, x1, y1 };
312 Element c2 = { QPainterPath::CurveToDataElement, x2, y2 };
313 Element e = { QPainterPath::CurveToDataElement, ex, ey };
320
321
322inline void QStroker::emitMoveTo(qfixed x, qfixed y)
328 QStrokerOps::emitMoveTo(x, y);
331inline void QStroker::emitLineTo(qfixed x, qfixed y)
337 QStrokerOps::emitLineTo(x, y);
340inline void QStroker::emitCubicTo(qfixed c1x, qfixed c1y,
341 qfixed c2x, qfixed c2y,
342 qfixed ex, qfixed ey)
344 if (c2x == ex && c2y == ey) {
345 if (c1x == ex && c1y == ey) {
358 QStrokerOps::emitCubicTo(c1x, c1y, c2x, c2y, ex, ey);
362
363
364inline void QDashStroker::begin(
void *data)
367 m_stroker->begin(data);
368 QStrokerOps::begin(data);
371inline void QDashStroker::end()
Combined button and popup list for selecting options.
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
static void qpaintengineex_cubicTo(qreal c1x, qreal c1y, qreal c2x, qreal c2y, qreal ex, qreal ey, void *data)
static const QPainterPath::ElementType qpaintengineex_ellipse_types[]
static const QPainterPath::ElementType qpaintengineex_rect4_types_32[]
QDebug Q_GUI_EXPORT & operator<<(QDebug &s, const QVectorPath &path)
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
static void qpaintengineex_lineTo(qreal x, qreal y, void *data)
static const QPainterPath::ElementType qpaintengineex_roundedrect_types[]
static const QPainterPath::ElementType qpaintengineex_line_types_16[]
static void qpaintengineex_moveTo(qreal x, qreal y, void *data)
void(* qStrokerCubicToHook)(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey, void *data)
void(* qStrokerLineToHook)(qfixed x, qfixed y, void *data)
QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, QPointF *controlPoints, int *point_count)
void(* qStrokerMoveToHook)(qfixed x, qfixed y, void *data)
qreal qt_t_for_arc_angle(qreal angle)
#define qt_fixed_to_real(fixed)
#define qt_real_to_fixed(real)
QT_BEGIN_NAMESPACE typedef qreal qfixed
StrokeHandler(int reserve)
QDataBuffer< QPainterPath::ElementType > types
bool operator==(const qfixed2d &other) const