/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 | | }; |
67 | | enum DisplayMode { |
68 | | InlineMode, |
69 | | BlockMode, |
70 | | ListItemMode, |
71 | | RunInMode, |
72 | | CompactMode, |
73 | | MarkerMode, |
74 | | TableMode, |
75 | | InlineTableMode, |
76 | | TableRowGroupMode, |
77 | | TableHeaderGroupMode, |
78 | | TableFooterGroupMode, |
79 | | TableRowMode, |
80 | | TableColumnGroupMode, |
81 | | TableColumnMode, |
82 | | TableCellMode, |
83 | | TableCaptionMode, |
84 | | NoneMode, |
85 | | InheritMode |
86 | | }; |
87 | | |
88 | | public: |
89 | | QSvgNode(QSvgNode *parent=0); |
90 | | virtual ~QSvgNode(); |
91 | | void draw(QPainter *p, QSvgExtraStates &states); |
92 | 0 | virtual bool separateFillStroke(const QPainter *, const QSvgExtraStates &) const {return false;} |
93 | | virtual void drawCommand(QPainter *p, QSvgExtraStates &states) = 0; |
94 | | void fillThenStroke(QPainter *p, QSvgExtraStates &states); |
95 | | QImage drawIntoBuffer(QPainter *p, QSvgExtraStates &states, const QRect &boundsRect); |
96 | | void applyMaskToBuffer(QImage *proxy, QImage mask) const; |
97 | | void drawWithMask(QPainter *p, QSvgExtraStates &states, const QImage &mask, const QRect &boundsRect); |
98 | | void applyBufferToCanvas(QPainter *p, QImage proxy) const; |
99 | | |
100 | | QSvgNode *parent() const; |
101 | | bool isDescendantOf(const QSvgNode *parent) const; |
102 | | |
103 | | void appendStyleProperty(QSvgStyleProperty *prop, const QString &id); |
104 | | void applyStyle(QPainter *p, QSvgExtraStates &states) const; |
105 | | void applyStyleRecursive(QPainter *p, QSvgExtraStates &states) const; |
106 | | void revertStyle(QPainter *p, QSvgExtraStates &states) const; |
107 | | void revertStyleRecursive(QPainter *p, QSvgExtraStates &states) const; |
108 | | void applyAnimatedStyle(QPainter *p, QSvgExtraStates &states) const; |
109 | | void revertAnimatedStyle(QPainter *p, QSvgExtraStates &states) const; |
110 | | QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const; |
111 | | |
112 | | QSvgDocument *document() const; |
113 | | |
114 | | virtual Type type() const = 0; |
115 | | QString typeName() const; |
116 | | virtual QRectF internalFastBounds(QPainter *p, QSvgExtraStates &states) const; |
117 | | virtual QRectF internalBounds(QPainter *p, QSvgExtraStates &states) const; |
118 | | QRectF bounds(QPainter *p, QSvgExtraStates &states) const; |
119 | | QRectF bounds() const; |
120 | | virtual QRectF decoratedInternalBounds(QPainter *p, QSvgExtraStates &states) const; |
121 | | virtual QRectF decoratedBounds(QPainter *p, QSvgExtraStates &states) const; |
122 | | |
123 | | void setRequiredFeatures(const QStringList &lst); |
124 | | const QStringList & requiredFeatures() const; |
125 | | |
126 | | void setRequiredExtensions(const QStringList &lst); |
127 | | const QStringList & requiredExtensions() const; |
128 | | |
129 | | void setRequiredLanguages(const QStringList &lst); |
130 | | const QStringList & requiredLanguages() const; |
131 | | |
132 | | void setRequiredFormats(const QStringList &lst); |
133 | | const QStringList & requiredFormats() const; |
134 | | |
135 | | void setRequiredFonts(const QStringList &lst); |
136 | | const QStringList & requiredFonts() const; |
137 | | |
138 | | void setVisible(bool visible); |
139 | | bool isVisible() const; |
140 | | |
141 | | void setDisplayMode(DisplayMode display); |
142 | | DisplayMode displayMode() const; |
143 | | |
144 | | QString nodeId() const; |
145 | | void setNodeId(const QString &i); |
146 | | |
147 | | QString xmlClass() const; |
148 | | void setXmlClass(const QString &str); |
149 | | |
150 | | QString maskId() const; |
151 | | void setMaskId(const QString &str); |
152 | | bool hasMask() const; |
153 | | |
154 | | QString filterId() const; |
155 | | void setFilterId(const QString &str); |
156 | | bool hasFilter() const; |
157 | | |
158 | | QString markerStartId() const; |
159 | | void setMarkerStartId(const QString &str); |
160 | | bool hasMarkerStart() const; |
161 | | |
162 | | QString markerMidId() const; |
163 | | void setMarkerMidId(const QString &str); |
164 | | bool hasMarkerMid() const; |
165 | | |
166 | | QString markerEndId() const; |
167 | | void setMarkerEndId(const QString &str); |
168 | | bool hasMarkerEnd() const; |
169 | | |
170 | | bool hasAnyMarker() const; |
171 | | |
172 | | virtual bool requiresGroupRendering() const; |
173 | | |
174 | | virtual bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const; |
175 | 0 | const QSvgStaticStyle &style() const { return m_style; } |
176 | | protected: |
177 | | mutable QSvgStaticStyle m_style; |
178 | | mutable QSvgAnimatedStyle m_animatedStyle; |
179 | | |
180 | | QRectF filterRegion(QRectF bounds) const; |
181 | | |
182 | | static qreal strokeWidth(QPainter *p); |
183 | | static void initPainter(QPainter *p); |
184 | | |
185 | | enum BoundsMode { |
186 | | Simplistic, |
187 | | IncludeMiterLimit |
188 | | }; |
189 | | static QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, |
190 | | qreal width, BoundsMode mode); |
191 | | |
192 | | private: |
193 | | QSvgNode *m_parent; |
194 | | |
195 | | QStringList m_requiredFeatures; |
196 | | QStringList m_requiredExtensions; |
197 | | QStringList m_requiredLanguages; |
198 | | QStringList m_requiredFormats; |
199 | | QStringList m_requiredFonts; |
200 | | |
201 | | QString m_id; |
202 | | QString m_class; |
203 | | QString m_maskId; |
204 | | QString m_filterId; |
205 | | QString m_markerStartId; |
206 | | QString m_markerMidId; |
207 | | QString m_markerEndId; |
208 | | |
209 | | mutable QRectF m_cachedBounds; |
210 | | DisplayMode m_displayMode; |
211 | | bool m_visible; |
212 | | |
213 | | friend class QSvgDocument; |
214 | | |
215 | | private: |
216 | | Q_DISABLE_COPY_X(QSvgNode, "Classes inheriting from this class may contain" |
217 | | "a vector of unique pointers as a member variable") |
218 | | }; |
219 | | |
220 | | inline QSvgNode *QSvgNode::parent() const |
221 | 53.3M | { |
222 | 53.3M | return m_parent; |
223 | 53.3M | } |
224 | | |
225 | | inline bool QSvgNode::isVisible() const |
226 | 1.38M | { |
227 | 1.38M | return m_visible; |
228 | 1.38M | } |
229 | | |
230 | | inline QString QSvgNode::nodeId() const |
231 | 6.12M | { |
232 | 6.12M | return m_id; |
233 | 6.12M | } |
234 | | |
235 | | inline QString QSvgNode::xmlClass() const |
236 | 4.43M | { |
237 | 4.43M | return m_class; |
238 | 4.43M | } |
239 | | |
240 | | QT_END_NAMESPACE |
241 | | |
242 | | #endif // QSVGNODE_P_H |