26 , m_widthPercent(
false)
27 , m_heightPercent(
false)
30 , m_animationDuration(0)
41# ifdef QT_BUILD_INTERNAL
59 int zlibResult = Z_OK;
66 zlibStream.next_in = Z_NULL;
67 zlibStream.avail_in = 0;
68 zlibStream.avail_out = 0;
69 zlibStream.zalloc = Z_NULL;
70 zlibStream.zfree = Z_NULL;
71 zlibStream.opaque = Z_NULL;
74 if (inflateInit2(&zlibStream, MAX_WBITS + 16) != Z_OK) {
75 qCWarning(lcSvgHandler,
"Cannot initialize zlib, because: %s",
76 (zlibStream.msg != NULL ? zlibStream.msg :
"Unknown error"));
80 bool stillMoreWorkToDo =
true;
81 while (stillMoreWorkToDo) {
83 if (!zlibStream.avail_in) {
89 zlibStream.avail_in =
source.size();
90 zlibStream.next_in =
reinterpret_cast<Bytef*
>(
source.data());
97 inflateEnd(&zlibStream);
98 qCWarning(lcSvgHandler,
"Error while inflating gzip file: integer size overflow");
103 zlibStream.next_out =
reinterpret_cast<Bytef*
>(
104 destination.data() + oldSize - zlibStream.avail_out);
107 zlibResult =
inflate(&zlibStream, Z_NO_FLUSH);
108 switch (zlibResult) {
113 inflateEnd(&zlibStream);
114 qCWarning(lcSvgHandler,
"Error while inflating gzip file: %s",
115 (zlibStream.msg != NULL ? zlibStream.msg :
"Unknown error"));
122 }
while (!zlibStream.avail_out);
124 if (doCheckContent) {
127 if (!
buf.contains(
"<?xml") && !
buf.contains(
"<svg") && !
buf.contains(
"<!--") && !
buf.contains(
"<!DOCTYPE svg")) {
128 inflateEnd(&zlibStream);
129 qCWarning(lcSvgHandler,
"Error while inflating gzip file: SVG format check failed");
132 doCheckContent =
false;
135 if (zlibResult == Z_STREAM_END) {
137 if (!(zlibStream.avail_in && inflateReset(&zlibStream) == Z_OK))
138 stillMoreWorkToDo =
false;
145 inflateEnd(&zlibStream);
159 qCWarning(lcSvgHandler,
"Cannot open file '%s', because: %s",
175 qCWarning(lcSvgHandler,
"Cannot read file '%s', because: %s (line %d)",
186 if (
contents.startsWith(
"\x1f\x8b")) {
248 node->
draw(
p, m_states);
262 qCDebug(lcSvgHandler,
"Couldn't find node %s. Skipping rendering.",
qPrintable(
id));
275 mapSourceToTarget(
p,
bounds, elementBounds);
276 QTransform originalTransform =
p->worldTransform();
293 for (
int i = parentApplyStack.
size() - 1;
i >= 0; --
i)
299 p->setWorldTransform(originalTransform);
301 node->
draw(
p, m_states);
303 p->setWorldTransform(currentTransform);
305 for (
int i = 0;
i < parentApplyStack.
size(); ++
i)
322 m_widthPercent = percent;
328 m_heightPercent = percent;
333 m_preserveAspectRatio = on;
339 m_implicitViewBox =
rect.isNull();
349 return m_fonts[family];
354 m_namedNodes.
insert(
id, node);
359 return m_namedNodes.
value(
id);
365 m_namedStyles.
insert(
id, style);
367 qCWarning(lcSvgHandler) <<
"Duplicate unique style id:" <<
id;
372 return m_namedStyles.
value(
id);
406void QSvgTinyDocument::mapSourceToTarget(
QPainter *
p,
const QRectF &targetRect,
const QRectF &sourceRect)
460 p->setWorldTransform(oldTransform);
483 qCDebug(lcSvgHandler,
"Couldn't find node %s. Skipping rendering.",
qPrintable(
id));
503 int totalFrames = m_fps * m_animationDuration;
505 return int(runningPercentage * totalFrames);
510 int totalFrames = m_fps * m_animationDuration;
511 double framePercentage =
frame/double(totalFrames);
512 double timeForFrame = m_animationDuration * framePercentage;
513 timeForFrame *= 1000;
IOBluetoothDevice * device
\inmodule QtCore \reentrant
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
static qint64 currentMSecsSinceEpoch() noexcept
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
\inmodule QtCore \reentrant
QString errorString() const
Returns a human-readable description of the last device error that occurred.
qsizetype size() const noexcept
The QPainter class performs low-level painting on widgets and other paint devices.
void setMiterLimit(qreal limit)
Sets the miter limit of this pen to the given limit.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
void scale(qreal w, qreal h, Qt::AspectRatioMode mode) noexcept
Scales the size to a rectangle with the given width and height, according to the specified mode.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
void push(const T &t)
Adds element t to the top of the stack.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QSvgTinyDocument * document() const
int animationDuration() const
QString errorString() const
void revertStyle(QPainter *p, QSvgExtraStates &states) const
virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const
QSvgNode * parent() const
void applyStyle(QPainter *p, QSvgExtraStates &states) const
virtual void draw(QPainter *p, QSvgExtraStates &states)=0
DisplayMode displayMode() const
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
QSvgNode * scopeNode(const QString &id) const
QList< QSvgNode * > m_renderers
QSvgRefCounter< QSvgTransformStyle > transform
bool elementExists(const QString &id) const
QSvgNode * namedNode(const QString &id) const
void setFramesPerSecond(int num)
Type type() const override
void setViewBox(const QRectF &rect)
void setWidth(int len, bool percent)
void draw(QPainter *p, QSvgExtraStates &) override
QRectF boundsOnElement(const QString &id) const
bool preserveAspectRatio() const
void addNamedNode(const QString &id, QSvgNode *node)
QSvgFont * svgFont(const QString &family) const
int currentElapsed() const
void setPreserveAspectRatio(bool on)
QSvgFillStyleProperty * namedStyle(const QString &id) const
void addSvgFont(QSvgFont *)
QTransform transformForElement(const QString &id) const
void setCurrentFrame(int)
static QSvgTinyDocument * load(const QString &file)
void addNamedStyle(const QString &id, QSvgFillStyleProperty *style)
void setHeight(int len, bool percent)
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 * destination
bool qIsFinite(qfloat16 f) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLsizei GLchar * source
GLuint GLenum GLenum transform
#define qPrintable(string)
static QByteArray qt_inflateSvgzDataFrom(QIODevice *device, bool doCheckContent=true)
static bool isValidMatrix(const QTransform &transform)
#define Q_AUTOTEST_EXPORT
static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)