18#include <QtGui/private/qtguiglobal_p.h>
19#include "QtGui/qpainterpath.h"
20#include "private/qdatabuffer_p.h"
21#include "private/qnumeric_p.h"
27#if defined QFIXED_IS_26_6
29#define qt_real_to_fixed(real) qfixed(real * 64
)
30#define qt_int_to_fixed(real) qfixed(int(real) << 6
)
31#define qt_fixed_to_real(fixed) qreal(fixed / qreal(64
))
32#define qt_fixed_to_int(fixed) int(fixed >> 6
)
38 bool operator==(
const qfixed2d &other)
const {
return x == other.x && y == other.y; }
40#elif defined QFIXED_IS_32_32
42#define qt_real_to_fixed(real) qfixed(real * double(qint64(1
) << 32
))
43#define qt_fixed_to_real(fixed) qreal(fixed / double(qint64(1
) << 32
))
49 bool operator==(
const qfixed2d &other)
const {
return x == other.x && y == other.y; }
51#elif defined QFIXED_IS_16_16
53#define qt_real_to_fixed(real) qfixed(real * qreal(1
<< 16
))
54#define qt_fixed_to_real(fixed) qreal(fixed / qreal(1
<< 16
))
60 bool operator==(
const qfixed2d &other)
const {
return x == other.x && y == other.y; }
64#define qt_real_to_fixed(real) qfixed(real)
65#define qt_fixed_to_real(fixed) fixed
73 && qFuzzyCompare(
y, other
.y); }
77#define QT_PATH_KAPPA 0.5522847498
80 QPointF *controlPoints,
int *point_count);
98 QPainterPath::ElementType type;
102 inline bool isMoveTo()
const {
return type == QPainterPath::MoveToElement; }
103 inline bool isLineTo()
const {
return type == QPainterPath::LineToElement; }
104 inline bool isCurveTo()
const {
return type == QPainterPath::CurveToElement; }
106 operator qfixed2d () { qfixed2d pt = { x, y };
return pt; }
110 virtual ~QStrokerOps();
112 void setMoveToHook(qStrokerMoveToHook moveToHook) { m_moveTo = moveToHook; }
113 void setLineToHook(qStrokerLineToHook lineToHook) { m_lineTo = lineToHook; }
114 void setCubicToHook(qStrokerCubicToHook cubicToHook) { m_cubicTo = cubicToHook; }
116 virtual void begin(
void *customData);
119 inline void moveTo(qfixed x, qfixed y);
120 inline void lineTo(qfixed x, qfixed y);
121 inline void cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey);
123 void strokePath(
const QPainterPath &path,
void *data,
const QTransform &matrix);
124 void strokePolygon(
const QPointF *points,
int pointCount,
bool implicit_close,
125 void *data,
const QTransform &matrix);
126 void strokeEllipse(
const QRectF &ellipse,
void *data,
const QTransform &matrix);
128 QRectF clipRect()
const {
return m_clip_rect; }
129 void setClipRect(
const QRectF &clip) { m_clip_rect = clip; }
131 void setCurveThresholdFromTransform(
const QTransform &transform)
134 qt_scaleForTransform(transform, &scale);
135 m_dashThreshold = scale == 0 ? qreal(0.5) : (qreal(0.5) / scale);
138 void setCurveThreshold(qfixed threshold) { m_curveThreshold = threshold; }
139 qfixed curveThreshold()
const {
return m_curveThreshold; }
142 inline void emitMoveTo(qfixed x, qfixed y);
143 inline void emitLineTo(qfixed x, qfixed y);
144 inline void emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey);
146 virtual void processCurrentSubpath() = 0;
147 QDataBuffer<Element> m_elements;
150 qfixed m_curveThreshold;
151 qfixed m_dashThreshold;
154 qStrokerMoveToHook m_moveTo;
155 qStrokerLineToHook m_lineTo;
156 qStrokerCubicToHook m_cubicTo;
176 void setStrokeWidth(qfixed width)
178 m_strokeWidth = width;
181 qfixed strokeWidth()
const {
return m_strokeWidth; }
183 void setCapStyle(Qt::PenCapStyle capStyle) { m_capStyle = joinModeForCap(capStyle); }
184 Qt::PenCapStyle capStyle()
const {
return capForJoinMode(m_capStyle); }
185 LineJoinMode capStyleMode()
const {
return m_capStyle; }
187 void setJoinStyle(Qt::PenJoinStyle style) { m_joinStyle = joinModeForJoin(style); }
188 Qt::PenJoinStyle joinStyle()
const {
return joinForJoinMode(m_joinStyle); }
189 LineJoinMode joinStyleMode()
const {
return m_joinStyle; }
191 void setMiterLimit(qfixed length) { m_miterLimit = length; }
192 qfixed miterLimit()
const {
return m_miterLimit; }
194 void setForceOpen(
bool state) { m_forceOpen = state; }
195 bool forceOpen()
const {
return m_forceOpen; }
197 void joinPoints(qfixed x, qfixed y,
const QLineF &nextLine, LineJoinMode join);
198 inline void emitMoveTo(qfixed x, qfixed y);
199 inline void emitLineTo(qfixed x, qfixed y);
200 inline void emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey);
203 static Qt::PenCapStyle capForJoinMode(LineJoinMode mode);
204 static LineJoinMode joinModeForCap(Qt::PenCapStyle);
206 static Qt::PenJoinStyle joinForJoinMode(LineJoinMode mode);
207 static LineJoinMode joinModeForJoin(Qt::PenJoinStyle joinStyle);
209 void processCurrentSubpath() override;
211 qfixed m_strokeWidth;
214 LineJoinMode m_capStyle;
215 LineJoinMode m_joinStyle;
229 QDashStroker(QStroker *stroker);
232 QStroker *stroker()
const {
return m_stroker; }
234 static QList<qfixed> patternForStyle(Qt::PenStyle style);
235 static int repetitionLimit() {
return 10000; }
237 void setDashPattern(
const QList<qfixed> &dashPattern) { m_dashPattern = dashPattern; }
238 QList<qfixed> dashPattern()
const {
return m_dashPattern; }
240 void setDashOffset(qreal offset) { m_dashOffset = offset; }
241 qreal dashOffset()
const {
return m_dashOffset; }
243 void begin(
void *data) override;
246 inline void setStrokeWidth(qreal width) { m_stroke_width = width; }
247 inline void setMiterLimit(qreal limit) { m_miter_limit = limit; }
250 void processCurrentSubpath() override;
253 QList<qfixed> m_dashPattern;
256 qreal m_stroke_width;
262
263
265inline void QStrokerOps::emitMoveTo(qfixed x, qfixed y)
268 m_moveTo(x, y, m_customData);
271inline void QStrokerOps::emitLineTo(qfixed x, qfixed y)
274 m_lineTo(x, y, m_customData);
277inline void QStrokerOps::emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey)
280 m_cubicTo(c1x, c1y, c2x, c2y, ex, ey, m_customData);
283inline void QStrokerOps::moveTo(qfixed x, qfixed y)
285 if (m_elements.size()>1)
286 processCurrentSubpath();
288 Element e = { QPainterPath::MoveToElement, x, y };
292inline void QStrokerOps::lineTo(qfixed x, qfixed y)
294 Element e = { QPainterPath::LineToElement, x, y };
298inline void QStrokerOps::cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey)
300 Element c1 = { QPainterPath::CurveToElement, x1, y1 };
301 Element c2 = { QPainterPath::CurveToDataElement, x2, y2 };
302 Element e = { QPainterPath::CurveToDataElement, ex, ey };
309
310
311inline void QStroker::emitMoveTo(qfixed x, qfixed y)
317 QStrokerOps::emitMoveTo(x, y);
320inline void QStroker::emitLineTo(qfixed x, qfixed y)
326 QStrokerOps::emitLineTo(x, y);
329inline void QStroker::emitCubicTo(qfixed c1x, qfixed c1y,
330 qfixed c2x, qfixed c2y,
331 qfixed ex, qfixed ey)
333 if (c2x == ex && c2y == ey) {
334 if (c1x == ex && c1y == ey) {
347 QStrokerOps::emitCubicTo(c1x, c1y, c2x, c2y, ex, ey);
351
352
353inline void QDashStroker::begin(
void *data)
356 m_stroker->begin(data);
357 QStrokerOps::begin(data);
360inline void QDashStroker::end()
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)
#define QT_MAX_CACHED_GLYPH_SIZE
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