10#include <QLoggingCategory>
11#include <QtGui/qimageiohandler.h>
40 localBounds = itemBounds;
42 localBounds = filterBounds;
101 m_matrix.
data()[0+0*5] = 0.213f + 0.787f *
s;
102 m_matrix.
data()[1+0*5] = 0.715f - 0.717f *
s;
103 m_matrix.
data()[2+0*5] = 0.072f - 0.072f *
s;
105 m_matrix.
data()[0+1*5] = 0.213f - 0.213f *
s;
106 m_matrix.
data()[1+1*5] = 0.715f + 0.285f *
s;
107 m_matrix.
data()[2+1*5] = 0.072f - 0.072f *
s;
109 m_matrix.
data()[0+2*5] = 0.213f - 0.213f *
s;
110 m_matrix.
data()[1+2*5] = 0.715f - 0.715f *
s;
111 m_matrix.
data()[2+2*5] = 0.072f + 0.928f *
s;
113 m_matrix.
data()[3+3*5] = 1;
123 m1.
data()[0+0*3] = 0.213f;
124 m1.data()[1+0*3] = 0.715f;
125 m1.data()[2+0*3] = 0.072f;
127 m1.data()[0+1*3] = 0.213f;
128 m1.data()[1+1*3] = 0.715f;
129 m1.data()[2+1*3] = 0.072f;
131 m1.data()[0+2*3] = 0.213f;
132 m1.data()[1+2*3] = 0.715f;
133 m1.data()[2+2*3] = 0.072f;
136 m2.
data()[0+0*3] = 0.787 *
c;
137 m2.data()[1+0*3] = -0.715 *
c;
138 m2.data()[2+0*3] = -0.072 *
c;
140 m2.data()[0+1*3] = -0.213 *
c;
141 m2.data()[1+1*3] = 0.285 *
c;
142 m2.data()[2+1*3] = -0.072 *
c;
144 m2.data()[0+2*3] = -0.213 *
c;
145 m2.data()[1+2*3] = -0.715 *
c;
146 m2.data()[2+2*3] = 0.928 *
c;
149 m3.
data()[0+0*3] = -0.213 *
s;
150 m3.data()[1+0*3] = -0.715 *
s;
151 m3.data()[2+0*3] = 0.928 *
s;
153 m3.data()[0+1*3] = 0.143 *
s;
154 m3.data()[1+1*3] = 0.140 *
s;
155 m3.data()[2+1*3] = -0.283 *
s;
157 m3.data()[0+2*3] = -0.787 *
s;
158 m3.data()[1+2*3] = 0.715 *
s;
159 m3.data()[2+2*3] = 0.072 *
s;
163 m_matrix.
data()[0+0*5] =
m.data()[0+0*3];
164 m_matrix.
data()[1+0*5] =
m.data()[1+0*3];
165 m_matrix.
data()[2+0*5] =
m.data()[2+0*3];
167 m_matrix.
data()[0+1*5] =
m.data()[0+1*3];
168 m_matrix.
data()[1+1*5] =
m.data()[1+1*3];
169 m_matrix.
data()[2+1*5] =
m.data()[2+1*3];
171 m_matrix.
data()[0+2*5] =
m.data()[0+2*3];
172 m_matrix.
data()[1+2*5] =
m.data()[1+2*3];
173 m_matrix.
data()[2+2*5] =
m.data()[2+2*3];
175 m_matrix.
data()[3+3*5] = 1;
179 m_matrix.
data()[0+3*5] = 0.2125;
180 m_matrix.
data()[1+3*5] = 0.7154;
181 m_matrix.
data()[2+3*5] = 0.0721;
199 QRect requiredRect =
p->transform().mapRect(itemBounds).toRect();
200 clipRectGlob = clipRectGlob.
intersected(requiredRect);
201 if (clipRectGlob.isEmpty())
206 qCWarning(lcSvgDraw) <<
"The requested filter buffer is too big, ignoring";
209 result.setOffset(clipRectGlob.topLeft());
214 for (
int i = 0;
i <
result.height();
i++) {
217 if (sourceI < 0 || sourceI >=
source.height())
220 QRgb *sourceLine =
reinterpret_cast<QRgb *
>(
source.scanLine(sourceI));
223 for (
int j = 0;
j <
result.width();
j++) {
226 if (sourceJ < 0 || sourceJ >=
source.width())
235 m_matrix.
data()[1+0*5] *
g +
236 m_matrix.
data()[2+0*5] *
b +
237 m_matrix.
data()[3+0*5] *
a +
238 m_matrix.
data()[4+0*5] * 255.;
240 m_matrix.
data()[1+1*5] *
g +
241 m_matrix.
data()[2+1*5] *
b +
242 m_matrix.
data()[3+1*5] *
a +
243 m_matrix.
data()[4+1*5] * 255.;
245 m_matrix.
data()[1+2*5] *
g +
246 m_matrix.
data()[2+2*5] *
b +
247 m_matrix.
data()[3+2*5] *
a +
248 m_matrix.
data()[4+2*5] * 255.;
250 m_matrix.
data()[1+3*5] *
g +
251 m_matrix.
data()[2+3*5] *
b +
252 m_matrix.
data()[3+3*5] *
a +
253 m_matrix.
data()[4+3*5] * 255.;
269 , m_stdDeviationX(stdDeviationX)
270 , m_stdDeviationY(stdDeviationY)
271 , m_edgemode(edgemode)
290 QPointF sigma_scaled =
p->transform().map(
QPointF(m_stdDeviationX, m_stdDeviationY)) -
292 qreal sigma_x = sigma_scaled.
x();
293 qreal sigma_y = sigma_scaled.y();
295 sigma_x *= itemBounds.width();
296 sigma_y *= itemBounds.height();
304 int dx =
qMax(1,
int(floor(sigma_x * 3. * sqrt(2. *
M_PI) / 4. + 0.5)));
305 int dy =
qMax(1,
int(floor(sigma_y * 3. * sqrt(2. *
M_PI) / 4. + 0.5)));
308 QRect requiredRect =
p->transform().mapRect(itemBounds).toRect();
309 requiredRect.
adjust(- 3 * dx, -3 * dy, 3 * dx, 3 * dy);
310 clipRectGlob = clipRectGlob.intersected(requiredRect);
311 if (clipRectGlob.isEmpty())
316 qCWarning(lcSvgDraw) <<
"The requested filter buffer is too big, ignoring";
319 tempSource.setOffset(clipRectGlob.topLeft());
322 copyPainter.drawImage(
source.offset() - clipRectGlob.topLeft(),
source);
328 for (
int m = 0;
m < 6;
m++) {
329 QRgb *rawSource =
reinterpret_cast<QRgb *
>(tempSource.bits());
332 int d = (
m % 2 == 0) ? dx : dy;
333 int maxdim = (
m % 2 == 0) ? tempSource.width() : tempSource.height();
338 for (
int i = 0;
i < tempSource.width();
i++) {
339 for (
int j = 0;
j < tempSource.height();
j++) {
341 int iipos = (
m % 2 == 0) ?
i :
j;
344 for (
int k = 0; k <
d; k++) {
345 int ii = iipos + k -
d / 2;
346 if (ii < 0 || ii >= maxdim)
348 QRgb rgbVal = (
m % 2 == 0) ? rawSource[ii +
j * tempSource.width()] : rawSource[
i + ii * tempSource.width()];
391 QRect clipRectGlob =
p->transform().mapRect(clipRect).toRect();
396 m_dy * itemBounds.height());
401 clipRectGlob = clipRectGlob.intersected(requiredRect);
403 if (clipRectGlob.isEmpty())
408 qCWarning(lcSvgDraw) <<
"The requested filter buffer is too big, ignoring";
411 result.setOffset(clipRectGlob.topLeft());
415 copyPainter.drawImage(
source.offset()
439 QList<QImage> mergeNodeResults;
446 mergeNodeResults.append(
filter->apply(
item,
sources,
p, itemBounds, filterBounds, primitiveUnits, filterUnits));
447 requiredRect = requiredRect.united(
QRect(mergeNodeResults.last().offset(),
448 mergeNodeResults.last().size()));
453 QRect clipRectGlob =
p->transform().mapRect(clipRect).toRect();
454 clipRectGlob = clipRectGlob.
intersected(requiredRect);
455 if (clipRectGlob.isEmpty())
460 qCWarning(lcSvgDraw) <<
"The requested filter buffer is too big, ignoring";
463 result.setOffset(clipRectGlob.topLeft());
467 for (
const QImage &
i : mergeNodeResults) {
468 proxyPainter.drawImage(
QRect(
i.offset() -
result.offset(),
i.size()),
i);
482 if (
filter->requiresSourceAlpha())
527 if (!
sources.contains(m_input2))
537 QRect(source2.offset(), source2.size()));
538 clipRectGlob = clipRectGlob.
intersected(requiredRect);
539 if (clipRectGlob.isEmpty())
544 qCWarning(lcSvgDraw) <<
"The requested filter buffer is too big, ignoring";
547 result.setOffset(clipRectGlob.topLeft());
556 for (
int j = 0;
j <
result.height();
j++) {
557 int jj1 =
j - source1.offset().y() +
result.offset().y();
558 int jj2 =
j - source2.offset().y() +
result.offset().y();
561 QRgb *source1Line =
nullptr;
562 QRgb *source2Line =
nullptr;
564 if (jj1 >= 0 && jj1 < source1.size().height())
565 source1Line =
reinterpret_cast<QRgb *
>(source1.scanLine(jj1));
566 if (jj2 >= 0 && jj2 < source2.size().height())
567 source2Line =
reinterpret_cast<QRgb *
>(source2.scanLine(jj2));
569 for (
int i = 0;
i <
result.width();
i++) {
570 int ii1 =
i - source1.offset().x() +
result.offset().x();
571 int ii2 =
i - source2.offset().x() +
result.offset().x();
576 if (ii1 >= 0 && ii1 < source1.size().width() && source1Line) {
577 QRgb pixel1 = source1Line[ii1];
584 if (ii2 >= 0 && ii2 < source2.size().width() && source2Line) {
585 QRgb pixel2 = source2Line[ii2];
592 int r =
k1 *
s1.x() *
s2.x() / 255. + k2 *
s1.x() + k3 *
s2.x() + k4 * 255.;
593 int g =
k1 *
s1.y() *
s2.y() / 255. + k2 *
s1.y() + k3 *
s2.y() + k4 * 255.;
594 int b =
k1 *
s1.z() *
s2.z() / 255. + k2 *
s1.z() + k3 *
s2.z() + k4 * 255.;
595 int a =
k1 *
s1.w() *
s2.w() / 255. + k2 *
s1.w() + k3 *
s2.w() + k4 * 255.;
608 proxyPainter.drawImage(
QRect(source1.offset() -
result.offset(), source1.size()), source1);
610 switch (m_operator) {
633 proxyPainter.drawImage(
QRect(source2.offset()-
result.offset(), source2.size()), source2);
668 QRect clipRectGlob =
p->transform().mapRect(clipRect).toRect();
672 qCWarning(lcSvgDraw) <<
"The requested filter buffer is too big, ignoring";
675 result.setOffset(clipRectGlob.topLeft());
697 qCDebug(lcSvgDraw) <<
"Unsupported filter primitive should not be applied.";
The QColor class provides colors based on RGB, HSV or CMYK values.
void fill(T value)
Fills all elements of this matrix with value.
T * data()
Returns a pointer to the raw data of this matrix.
static bool allocateImage(QSize size, QImage::Format format, QImage *image)
@ Format_RGBA8888_Premultiplied
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
The QPainter class performs low-level painting on widgets and other paint devices.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
@ CompositionMode_Lighten
@ CompositionMode_DestinationAtop
@ CompositionMode_DestinationOut
@ CompositionMode_DestinationOver
@ CompositionMode_DestinationIn
@ CompositionMode_SourceIn
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void setRenderHints(RenderHints hints, bool on=true)
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
\inmodule QtCore\reentrant
The QPolygonF class provides a list of points using floating point precision.
\inmodule QtCore\reentrant
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
QRectF intersected(const QRectF &other) const noexcept
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
QRect intersected(const QRect &other) const noexcept
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
QRect united(const QRect &other) const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Type type() const override
QSvgFeColorMatrix(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect, ColorShiftType type, Matrix matrix)
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
bool requiresSourceAlpha() const override
QSvgFeComposite(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect, QString input2, Operator op, QVector4D k)
Type type() const override
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
QRectF localFilterBoundingBox(QSvgNode *item, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const
QSvgFeFilterPrimitive(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect)
bool shouldDrawNode(QPainter *, QSvgExtraStates &) const override
static const QSvgFeFilterPrimitive * castToFilterPrimitive(const QSvgNode *node)
virtual bool requiresSourceAlpha() const
void clipToTransformedBounds(QImage *buffer, QPainter *p, const QRectF &localRect) const
QRectF globalFilterBoundingBox(QSvgNode *item, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const
QSvgFeFlood(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect, const QColor &color)
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
Type type() const override
Type type() const override
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
QSvgFeGaussianBlur(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect, qreal stdDeviationX, qreal stdDeviationY, EdgeMode edgemode)
Type type() const override
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
QSvgFeMergeNode(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect)
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
bool requiresSourceAlpha() const override
QSvgFeMerge(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect)
Type type() const override
QSvgFeOffset(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect, qreal dx, qreal dy)
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
Type type() const override
QSvgFeUnsupported(QSvgNode *parent, QString input, QString result, const QSvgRectF &rect)
QImage apply(QSvgNode *item, const QMap< QString, QImage > &sources, QPainter *p, const QRectF &itemBounds, const QRectF &filterBounds, QtSvg::UnitTypes primitiveUnits, QtSvg::UnitTypes filterUnits) const override
Type type() const override
QSvgTinyDocument * document() const
virtual Type type() const =0
QRectF combinedWithLocalRect(const QRectF &localRect) const
QList< QSvgNode * > renderers() const
The QVector4D class represents a vector or vertex in 4D space.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr float w() const noexcept
Returns the w coordinate of this point.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float z() const noexcept
Returns the z coordinate of this point.
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLenum input
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
constexpr int qRed(QRgb rgb)
constexpr int qGreen(QRgb rgb)
constexpr QRgb qRgba(int r, int g, int b, int a)
constexpr int qBlue(QRgb rgb)
constexpr int qAlpha(QRgb rgb)