/src/qtsvg/src/svg/qsvgnode_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 | | |
6 | | #ifndef QSVGNODE_P_H |
7 | | #define QSVGNODE_P_H |
8 | | |
9 | | // |
10 | | // W A R N I N G |
11 | | // ------------- |
12 | | // |
13 | | // This file is not part of the Qt API. It exists purely as an |
14 | | // implementation detail. This header file may change from version to |
15 | | // version without notice, or even be removed. |
16 | | // |
17 | | // We mean it. |
18 | | // |
19 | | |
20 | | #include "qsvgstyle_p.h" |
21 | | #include <QtCore/qstring.h> |
22 | | |
23 | | QT_BEGIN_NAMESPACE |
24 | | |
25 | | class QPainter; |
26 | | class QSvgDocument; |
27 | | |
28 | | class Q_SVG_EXPORT QSvgNode |
29 | | { |
30 | | public: |
31 | | enum Type |
32 | | { |
33 | | Doc, |
34 | | Group, |
35 | | Defs, |
36 | | Switch, |
37 | | AnimateColor, |
38 | | AnimateTransform, |
39 | | Circle, |
40 | | Ellipse, |
41 | | Image, |
42 | | Line, |
43 | | Path, |
44 | | Polygon, |
45 | | Polyline, |
46 | | Rect, |
47 | | Text, |
48 | | Textarea, |
49 | | Tspan, |
50 | | Use, |
51 | | Video, |
52 | | Mask, |
53 | | Symbol, |
54 | | Marker, |
55 | | Pattern, |
56 | | Filter, |
57 | | FeMerge, |
58 | | FeMergenode, |
59 | | FeColormatrix, |
60 | | FeGaussianblur, |
61 | | FeOffset, |
62 | | FeComposite, |
63 | | FeFlood, |
64 | | FeBlend, |
65 | | FeUnsupported, |
66 | | Font, |
67 | | }; |
68 | | enum DisplayMode { |
69 | | InlineMode, |
70 | | BlockMode, |
71 | | ListItemMode, |
72 | | RunInMode, |
73 | | CompactMode, |
74 | | MarkerMode, |
75 | | TableMode, |
76 | | InlineTableMode, |
77 | | TableRowGroupMode, |
78 | | TableHeaderGroupMode, |
79 | | TableFooterGroupMode, |
80 | | TableRowMode, |
81 | | TableColumnGroupMode, |
82 | | TableColumnMode, |
83 | | TableCellMode, |
84 | | TableCaptionMode, |
85 | | NoneMode, |
86 | | InheritMode |
87 | | }; |
88 | | |
89 | | public: |
90 | | QSvgNode(QSvgNode *parent=0); |
91 | | virtual ~QSvgNode(); |
92 | | void draw(QPainter *p, QSvgExtraStates &states); |
93 | 1.03k | virtual bool separateFillStroke(const QPainter *, const QSvgExtraStates &) const {return false;} |
94 | | virtual void drawCommand(QPainter *p, QSvgExtraStates &states) = 0; |
95 | | void fillThenStroke(QPainter *p, QSvgExtraStates &states); |
96 | | QImage drawIntoBuffer(QPainter *p, QSvgExtraStates &states, const QRect &boundsRect); |
97 | | void applyMaskToBuffer(QImage *proxy, const QImage &mask) const; |
98 | | void drawWithMask(QPainter *p, QSvgExtraStates &states, const QImage &mask, const QRect &boundsRect); |
99 | | void applyBufferToCanvas(QPainter *p, const QImage &proxy) const; |
100 | | |
101 | | QSvgNode *parent() const; |
102 | | bool isDescendantOf(const QSvgNode *parent) const; |
103 | | |
104 | | void appendStyleProperty(QSvgStylePropertyPtr prop); |
105 | | void applyStyle(QPainter *p, QSvgExtraStates &states) const; |
106 | | void applyStyleRecursive(QPainter *p, QSvgExtraStates &states) const; |
107 | | void revertStyle(QPainter *p, QSvgExtraStates &states) const; |
108 | | void revertStyleRecursive(QPainter *p, QSvgExtraStates &states) const; |
109 | | void applyAnimatedStyle(QPainter *p, QSvgExtraStates &states) const; |
110 | | void revertAnimatedStyle(QPainter *p, QSvgExtraStates &states) const; |
111 | | QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const; |
112 | | |
113 | | virtual Type type() const = 0; |
114 | | QLatin1StringView typeName() const; |
115 | | virtual QRectF internalFastBounds(QPainter *p, QSvgExtraStates &states) const; |
116 | | virtual QRectF internalBounds(QPainter *p, QSvgExtraStates &states) const; |
117 | | QRectF bounds(QPainter *p, QSvgExtraStates &states) const; |
118 | | QRectF bounds(const QSvgDocument *doc) const; |
119 | | virtual QRectF decoratedInternalBounds(QPainter *p, QSvgExtraStates &states) const; |
120 | | virtual QRectF decoratedBounds(QPainter *p, QSvgExtraStates &states) const; |
121 | | |
122 | | void setRequiredFeatures(const QStringList &lst); |
123 | | const QStringList & requiredFeatures() const; |
124 | | |
125 | | void setRequiredExtensions(const QStringList &lst); |
126 | | const QStringList & requiredExtensions() const; |
127 | | |
128 | | void setRequiredLanguages(const QStringList &lst); |
129 | | const QStringList & requiredLanguages() const; |
130 | | |
131 | | void setRequiredFormats(const QStringList &lst); |
132 | | const QStringList & requiredFormats() const; |
133 | | |
134 | | void setRequiredFonts(const QStringList &lst); |
135 | | const QStringList & requiredFonts() const; |
136 | | |
137 | | void setVisible(bool visible); |
138 | | bool isVisible() const; |
139 | | |
140 | | void setDisplayMode(DisplayMode display); |
141 | | DisplayMode displayMode() const; |
142 | | |
143 | | QString nodeId() const; |
144 | | void setNodeId(const QString &i); |
145 | | |
146 | | QString xmlClass() const; |
147 | | void setXmlClass(const QString &str); |
148 | | |
149 | | QString maskId() const; |
150 | | void setMaskId(const QString &str); |
151 | | bool hasMask() const; |
152 | | |
153 | | QString filterId() const; |
154 | | void setFilterId(const QString &str); |
155 | | bool hasFilter() const; |
156 | | |
157 | | QString markerStartId() const; |
158 | | void setMarkerStartId(const QString &str); |
159 | | bool hasMarkerStart() const; |
160 | | |
161 | | QString markerMidId() const; |
162 | | void setMarkerMidId(const QString &str); |
163 | | bool hasMarkerMid() const; |
164 | | |
165 | | QString markerEndId() const; |
166 | | void setMarkerEndId(const QString &str); |
167 | | bool hasMarkerEnd() const; |
168 | | |
169 | | bool hasAnyMarker() const; |
170 | | |
171 | | virtual bool requiresGroupRendering() const; |
172 | | |
173 | | virtual bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const; |
174 | 0 | const QSvgStaticStyle &style() const { return m_style; } |
175 | | protected: |
176 | | mutable QSvgStaticStyle m_style; |
177 | | mutable QSvgAnimatedStyle m_animatedStyle; |
178 | | |
179 | | QRectF filterRegion(const QSvgDocument *doc, QRectF bounds) const; |
180 | | |
181 | | static qreal strokeWidth(QPainter *p); |
182 | | static void initPainter(QPainter *p); |
183 | | |
184 | | enum BoundsMode { |
185 | | Simplistic, |
186 | | IncludeMiterLimit |
187 | | }; |
188 | | static QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, |
189 | | qreal width, BoundsMode mode); |
190 | | |
191 | | private: |
192 | | QSvgNode *m_parent; |
193 | | |
194 | | QStringList m_requiredFeatures; |
195 | | QStringList m_requiredExtensions; |
196 | | QStringList m_requiredLanguages; |
197 | | QStringList m_requiredFormats; |
198 | | QStringList m_requiredFonts; |
199 | | |
200 | | QString m_id; |
201 | | QString m_class; |
202 | | QString m_maskId; |
203 | | QString m_filterId; |
204 | | QString m_markerStartId; |
205 | | QString m_markerMidId; |
206 | | QString m_markerEndId; |
207 | | |
208 | | mutable QRectF m_cachedBounds; |
209 | | DisplayMode m_displayMode{DisplayMode::BlockMode}; |
210 | | bool m_visible{true}; |
211 | | |
212 | | friend class QSvgDocument; |
213 | | |
214 | | private: |
215 | | Q_DISABLE_COPY_X(QSvgNode, "Classes inheriting from this class may contain" |
216 | | "a vector of unique pointers as a member variable") |
217 | | }; |
218 | | |
219 | | inline QSvgNode *QSvgNode::parent() const |
220 | 3.23M | { |
221 | 3.23M | return m_parent; |
222 | 3.23M | } |
223 | | |
224 | | inline bool QSvgNode::isVisible() const |
225 | 1.57M | { |
226 | 1.57M | return m_visible; |
227 | 1.57M | } |
228 | | |
229 | | inline QString QSvgNode::nodeId() const |
230 | 205k | { |
231 | 205k | return m_id; |
232 | 205k | } |
233 | | |
234 | | inline QString QSvgNode::xmlClass() const |
235 | 194k | { |
236 | 194k | return m_class; |
237 | 194k | } |
238 | | |
239 | | QT_END_NAMESPACE |
240 | | |
241 | | #endif // QSVGNODE_P_H |