Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsvgfilter_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QSVGFILTER_P_H
7#define QSVGFILTER_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 "qsvgnode_p.h"
21#include "qtsvgglobal_p.h"
23#include "qgenericmatrix.h"
24
25#include "QtGui/qvector4d.h"
26
27QT_BEGIN_NAMESPACE
28
29class Q_SVG_EXPORT QSvgFeFilterPrimitive : public QSvgStructureNode
30{
31public:
32 QSvgFeFilterPrimitive(QSvgNode *parent, const QString &input,
33 const QString &result, const QSvgRectF &rect);
34 ~QSvgFeFilterPrimitive() override;
35
36 void drawCommand(QPainter *, QSvgExtraStates &) override {};
37 bool shouldDrawNode(QPainter *, QSvgExtraStates &) const override;
38 QRectF internalFastBounds(QPainter *, QSvgExtraStates &) const override { return QRectF(); }
39 QRectF internalBounds(QPainter *, QSvgExtraStates &) const override { return QRectF(); }
40 QRectF localSubRegion(const QRectF &itemBounds, const QRectF &filterBounds,
41 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const;
42 QRectF globalSubRegion(QPainter *p,
43 const QRectF &itemBounds, const QRectF &filterBounds,
44 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const;
45 void clipToTransformedBounds(QImage *buffer, QPainter *p, const QRectF &localRect) const;
46 virtual QImage apply(const QMap<QString, QImage> &sources,
47 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
48 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const = 0;
49 virtual bool requiresSourceAlpha() const;
50 QString input() const { return m_input; }
51 QString result() const { return m_result; }
52 QSvgRectF rect() const { return m_rect; }
53
54 static const QSvgFeFilterPrimitive *castToFilterPrimitive(const QSvgNode *node);
55
56protected:
57 QString m_input;
58 QString m_result;
59 QSvgRectF m_rect;
60};
61
62class Q_SVG_EXPORT QSvgFeColorMatrix : public QSvgFeFilterPrimitive
63{
64public:
65 enum class ColorShiftType : quint8 {
66 Matrix,
67 Saturate,
68 HueRotate,
69 LuminanceToAlpha
70 };
71
72 typedef QGenericMatrix<5, 5, qreal> Matrix;
73 typedef QGenericMatrix<5, 1, qreal> Vector;
74
75 QSvgFeColorMatrix(QSvgNode *parent, const QString &input, const QString &result,
76 const QSvgRectF &rect, ColorShiftType type, const Matrix &matrix);
77 ~QSvgFeColorMatrix() override;
78
79 Type type() const override;
80 QImage apply(const QMap<QString, QImage> &sources,
81 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
82 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
83 Matrix matrix() const
84 {
85 return m_matrix;
86 }
87
88private:
89 Matrix m_matrix;
90};
91
92class Q_SVG_EXPORT QSvgFeGaussianBlur : public QSvgFeFilterPrimitive
93{
94public:
95 enum class EdgeMode : quint8 {
96 Duplicate,
97 Wrap,
98 None
99 };
100
101 QSvgFeGaussianBlur(QSvgNode *parent, const QString &input, const QString &result,
102 const QSvgRectF &rect, qreal stdDeviationX, qreal stdDeviationY,
103 EdgeMode edgemode);
104 ~QSvgFeGaussianBlur() override;
105
106 Type type() const override;
107 QImage apply(const QMap<QString, QImage> &sources,
108 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
109 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
110
111 qreal stdDeviationX() const { return m_stdDeviationX; }
112 qreal stdDeviationY() const { return m_stdDeviationY; }
113 EdgeMode edgeMode() const { return m_edgemode; }
114
115private:
116 qreal m_stdDeviationX;
117 qreal m_stdDeviationY;
118 EdgeMode m_edgemode; // TODO: Unused. Start using it when there's a reference implementation.
119};
120
121class Q_SVG_EXPORT QSvgFeOffset : public QSvgFeFilterPrimitive
122{
123public:
124 QSvgFeOffset(QSvgNode *parent, const QString &input, const QString &result,
125 const QSvgRectF &rect, qreal dx, qreal dy);
126 ~QSvgFeOffset() override;
127
128 Type type() const override;
129 QImage apply(const QMap<QString, QImage> &sources,
130 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
131 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
132
133 qreal dx() const { return m_dx; }
134 qreal dy() const { return m_dy; }
135
136private:
137 qreal m_dx;
138 qreal m_dy;
139};
140
141class Q_SVG_EXPORT QSvgFeMerge : public QSvgFeFilterPrimitive
142{
143public:
144 QSvgFeMerge(QSvgNode *parent, const QString &input,
145 const QString &result, const QSvgRectF &rect);
146 ~QSvgFeMerge() override;
147
148 Type type() const override;
149 QImage apply(const QMap<QString, QImage> &sources,
150 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
151 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
152 bool requiresSourceAlpha() const override;
153};
154
155class Q_SVG_EXPORT QSvgFeMergeNode : public QSvgFeFilterPrimitive
156{
157public:
158 QSvgFeMergeNode(QSvgNode *parent, const QString &input,
159 const QString &result, const QSvgRectF &rect);
160 ~QSvgFeMergeNode() override;
161
162 Type type() const override;
163 QImage apply(const QMap<QString, QImage> &sources,
164 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
165 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
166};
167
168class Q_SVG_EXPORT QSvgFeComposite : public QSvgFeFilterPrimitive
169{
170public:
171 enum class Operator : quint8 {
172 Over,
173 In,
174 Out,
175 Atop,
176 Xor,
177 Lighter,
178 Arithmetic
179 };
180 QSvgFeComposite(QSvgNode *parent, const QString &input, const QString &result,
181 const QSvgRectF &rect, const QString &input2, Operator op, const QVector4D &k);
182 ~QSvgFeComposite() override;
183
184 Type type() const override;
185 QImage apply(const QMap<QString, QImage> &sources,
186 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
187 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
188 bool requiresSourceAlpha() const override;
189
190 QString input2() const { return m_input2; }
191 Operator compositionOperator() const { return m_operator; }
192 QVector4D k() const { return m_k; }
193
194private:
195 QString m_input2;
196 Operator m_operator;
197 QVector4D m_k;
198};
199
200class Q_SVG_EXPORT QSvgFeFlood : public QSvgFeFilterPrimitive
201{
202public:
203 QSvgFeFlood(QSvgNode *parent, const QString &input, const QString &result,
204 const QSvgRectF &rect, const QColor &color);
205 ~QSvgFeFlood() override;
206
207 Type type() const override;
208 QImage apply(const QMap<QString, QImage> &sources,
209 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
210 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
211
212 QColor color() const { return m_color; }
213private:
214 QColor m_color;
215};
216
217class Q_SVG_EXPORT QSvgFeBlend : public QSvgFeFilterPrimitive
218{
219public:
220 enum class Mode : quint8 {
221 Normal,
222 Multiply,
223 Screen,
224 Darken,
225 Lighten
226 };
227 QSvgFeBlend(QSvgNode *parent, const QString &input, const QString &result,
228 const QSvgRectF &rect, const QString &input2, Mode mode);
229 ~QSvgFeBlend() override;
230
231 Type type() const override;
232 QImage apply(const QMap<QString, QImage> &sources,
233 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
234 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
235 bool requiresSourceAlpha() const override;
236
237 QString input2() const { return m_input2; }
238 Mode mode() const { return m_mode; }
239
240private:
241 QString m_input2;
242 Mode m_mode;
243
244};
245
246class Q_SVG_EXPORT QSvgFeUnsupported : public QSvgFeFilterPrimitive
247{
248public:
249 QSvgFeUnsupported(QSvgNode *parent, const QString &input,
250 const QString &result, const QSvgRectF &rect);
251 ~QSvgFeUnsupported() override;
252
253 Type type() const override;
254 QImage apply(const QMap<QString, QImage> &sources,
255 QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds,
256 QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override;
257};
258
259QT_END_NAMESPACE
260
261#endif // QSVGFILTER_P_H
ColorValues & operator-=(const ColorValues &other)
ColorValues & operator+=(const ColorValues &other)
ColorValues(QRgb rgb)
ColorValues()=default
ColorValues operator+(const ColorValues &other)
ColorValues operator/=(uint64_t div)
ColorValues operator-(const ColorValues &other)
Combined button and popup list for selecting options.
QGenericMatrix< 3, 3, qreal > Matrix3x3