/src/qtbase/src/gui/painting/qcosmeticstroker_p.h
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QCOSMETICSTROKER_P_H |
6 | | #define QCOSMETICSTROKER_P_H |
7 | | |
8 | | // |
9 | | // W A R N I N G |
10 | | // ------------- |
11 | | // |
12 | | // This file is not part of the Qt API. It exists purely as an |
13 | | // implementation detail. This header file may change from version to |
14 | | // version without notice, or even be removed. |
15 | | // |
16 | | // We mean it. |
17 | | // |
18 | | |
19 | | #include <QtGui/private/qtguiglobal_p.h> |
20 | | #include <private/qdrawhelper_p.h> |
21 | | #include <private/qvectorpath_p.h> |
22 | | #include <private/qpaintengine_raster_p.h> |
23 | | #include <qpen.h> |
24 | | |
25 | | QT_BEGIN_NAMESPACE |
26 | | |
27 | | |
28 | | class QCosmeticStroker; |
29 | | |
30 | | |
31 | | typedef bool (*StrokeLine)(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); |
32 | | |
33 | | class QCosmeticStroker |
34 | | { |
35 | | public: |
36 | | struct Point { |
37 | | int x; |
38 | | int y; |
39 | | }; |
40 | | struct PointF { |
41 | | qreal x; |
42 | | qreal y; |
43 | | }; |
44 | | |
45 | | enum Caps { |
46 | | NoCaps = 0, |
47 | | CapBegin = 0x1, |
48 | | CapEnd = 0x2 |
49 | | }; |
50 | | |
51 | | // used to avoid drop outs or duplicated points |
52 | | enum Direction { |
53 | | NoDirection = 0, |
54 | | TopToBottom = 0x1, |
55 | | BottomToTop = 0x2, |
56 | | LeftToRight = 0x4, |
57 | | RightToLeft = 0x8, |
58 | | VerticalMask = 0x3, |
59 | | HorizontalMask = 0xc |
60 | | }; |
61 | | |
62 | | QCosmeticStroker(QRasterPaintEngineState *s, const QRect &dr, const QRect &dr_unclipped) |
63 | 0 | : state(s), |
64 | 0 | deviceRect(dr_unclipped), |
65 | 0 | clip(dr), |
66 | 0 | pattern(nullptr), |
67 | 0 | reversePattern(nullptr), |
68 | 0 | patternSize(0), |
69 | 0 | patternLength(0), |
70 | 0 | patternOffset(0), |
71 | 0 | current_span(0), |
72 | 0 | lastDir(NoDirection), |
73 | 0 | lastAxisAligned(false) |
74 | 0 | { setup(); } |
75 | | |
76 | 0 | ~QCosmeticStroker() { free(pattern); free(reversePattern); } |
77 | | |
78 | | void drawLine(const QPointF &p1, const QPointF &p2); |
79 | | void drawPath(const QVectorPath &path); |
80 | | void drawPoints(const QPoint *points, int num); |
81 | | void drawPoints(const QPointF *points, int num); |
82 | | |
83 | | |
84 | | QRasterPaintEngineState *state; |
85 | | QRect deviceRect; |
86 | | QRect clip; |
87 | | // clip bounds in real |
88 | | qreal xmin, xmax; |
89 | | qreal ymin, ymax; |
90 | | |
91 | | StrokeLine stroke; |
92 | | bool drawCaps; |
93 | | |
94 | | int *pattern; |
95 | | int *reversePattern; |
96 | | int patternSize; |
97 | | int patternLength; |
98 | | int patternOffset; |
99 | | |
100 | | enum { NSPANS = 255 }; |
101 | | QT_FT_Span spans[NSPANS]; |
102 | | int current_span; |
103 | | ProcessSpans blend; |
104 | | |
105 | | int opacity; |
106 | | |
107 | | uint color; |
108 | | uint *pixels; |
109 | | int ppl; |
110 | | |
111 | | Direction lastDir; |
112 | | Point lastPixel; |
113 | | bool lastAxisAligned; |
114 | | |
115 | | private: |
116 | | void setup(); |
117 | | |
118 | | void renderCubic(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4, int caps); |
119 | | void renderCubicSubdivision(PointF *points, int level, int caps); |
120 | | // used for closed subpaths |
121 | | void calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal ry2); |
122 | | |
123 | | public: |
124 | | bool clipLine(qreal &x1, qreal &y1, qreal &x2, qreal &y2); |
125 | | }; |
126 | | |
127 | | QT_END_NAMESPACE |
128 | | |
129 | | #endif // QCOSMETICLINE_H |