summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/plugins/CMakeLists.txt3
-rw-r--r--src/plugins/iconengines/CMakeLists.txt3
-rw-r--r--src/plugins/iconengines/svgiconengine/CMakeLists.txt11
-rw-r--r--src/plugins/iconengines/svgiconengine/main.cpp40
-rw-r--r--src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp46
-rw-r--r--src/plugins/iconengines/svgiconengine/qsvgiconengine.h40
-rw-r--r--src/plugins/imageformats/CMakeLists.txt3
-rw-r--r--src/plugins/imageformats/svg/CMakeLists.txt10
-rw-r--r--src/plugins/imageformats/svg/main.cpp40
-rw-r--r--src/plugins/imageformats/svg/qsvgiohandler.cpp90
-rw-r--r--src/plugins/imageformats/svg/qsvgiohandler.h40
-rw-r--r--src/svg/CMakeLists.txt28
-rw-r--r--src/svg/doc/qtsvg.qdocconf9
-rw-r--r--src/svg/doc/snippets/doc_src_qtsvg.cpp51
-rw-r--r--src/svg/doc/snippets/doc_src_qtsvg.pro51
-rw-r--r--src/svg/doc/snippets/src_svg_qgraphicssvgitem.cpp51
-rw-r--r--src/svg/doc/src/qt6-changes.qdoc28
-rw-r--r--src/svg/doc/src/qtsvg-index.qdoc84
-rw-r--r--src/svg/doc/src/qtsvg.qdoc28
-rw-r--r--src/svg/doc/src/svgrendering.qdoc28
-rw-r--r--src/svg/qsvgfont.cpp40
-rw-r--r--src/svg/qsvgfont_p.h45
-rw-r--r--src/svg/qsvggenerator.cpp217
-rw-r--r--src/svg/qsvggenerator.h49
-rw-r--r--src/svg/qsvggraphics.cpp529
-rw-r--r--src/svg/qsvggraphics_p.h53
-rw-r--r--src/svg/qsvghandler.cpp544
-rw-r--r--src/svg/qsvghandler_p.h49
-rw-r--r--src/svg/qsvgnode.cpp73
-rw-r--r--src/svg/qsvgnode_p.h43
-rw-r--r--src/svg/qsvgrenderer.cpp40
-rw-r--r--src/svg/qsvgrenderer.h40
-rw-r--r--src/svg/qsvgstructure.cpp48
-rw-r--r--src/svg/qsvgstructure_p.h40
-rw-r--r--src/svg/qsvgstyle.cpp53
-rw-r--r--src/svg/qsvgstyle_p.h46
-rw-r--r--src/svg/qsvgtinydocument.cpp59
-rw-r--r--src/svg/qsvgtinydocument_p.h40
-rw-r--r--src/svg/qt_attribution.json2
-rw-r--r--src/svg/qtsvgglobal.h57
-rw-r--r--src/svg/qtsvgglobal_p.h43
-rw-r--r--src/svgwidgets/CMakeLists.txt10
-rw-r--r--src/svgwidgets/qgraphicssvgitem.cpp44
-rw-r--r--src/svgwidgets/qgraphicssvgitem.h40
-rw-r--r--src/svgwidgets/qsvgwidget.cpp40
-rw-r--r--src/svgwidgets/qsvgwidget.h40
-rw-r--r--src/svgwidgets/qtsvgwidgetsglobal.h57
48 files changed, 967 insertions, 2061 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4d059f4..a139a05 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from src.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(TARGET Qt::Gui)
add_subdirectory(svg)
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 4a8ccf9..e71099a 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from plugins.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(iconengines)
if(QT_FEATURE_imageformatplugin)
diff --git a/src/plugins/iconengines/CMakeLists.txt b/src/plugins/iconengines/CMakeLists.txt
index f2491a0..bb8d2d3 100644
--- a/src/plugins/iconengines/CMakeLists.txt
+++ b/src/plugins/iconengines/CMakeLists.txt
@@ -1,3 +1,4 @@
-# Generated from iconengines.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(svgiconengine)
diff --git a/src/plugins/iconengines/svgiconengine/CMakeLists.txt b/src/plugins/iconengines/svgiconengine/CMakeLists.txt
index 9371b6e..7e4c4a6 100644
--- a/src/plugins/iconengines/svgiconengine/CMakeLists.txt
+++ b/src/plugins/iconengines/svgiconengine/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from svgiconengine.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## QSvgIconPlugin Plugin:
@@ -6,18 +7,14 @@
qt_internal_add_plugin(QSvgIconPlugin
OUTPUT_NAME qsvgicon
- TYPE iconengines
+ PLUGIN_TYPE iconengines
SOURCES
main.cpp
qsvgiconengine.cpp qsvgiconengine.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
Qt::Svg
)
-
-#### Keys ignored in scope 1:.:.:svgiconengine.pro:<TRUE>:
-# OTHER_FILES = "qsvgiconengine.json" "qsvgiconengine-nocompress.json"
-# PLUGIN_EXTENDS = "svg"
diff --git a/src/plugins/iconengines/svgiconengine/main.cpp b/src/plugins/iconengines/svgiconengine/main.cpp
index cedeb7a..5d09f29 100644
--- a/src/plugins/iconengines/svgiconengine/main.cpp
+++ b/src/plugins/iconengines/svgiconengine/main.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <qiconengineplugin.h>
#include <qstringlist.h>
diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
index 1211328..1a0d4ad 100644
--- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
+++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgiconengine.h"
#ifndef QT_NO_SVGRENDERER
@@ -45,8 +9,10 @@
#include "qsvgrenderer.h"
#include "qpixmapcache.h"
#include "qfileinfo.h"
+#if QT_CONFIG(mimetype)
#include <qmimedatabase.h>
#include <qmimetype.h>
+#endif
#include <QAtomicInt>
#include "qdebug.h"
#include <private/qguiapplication_p.h>
@@ -259,13 +225,13 @@ static FileType fileType(const QFileInfo &fi)
|| abs.endsWith(QLatin1String(".svg.gz"), Qt::CaseInsensitive)) {
return CompressedSvgFile;
}
-#ifndef QT_NO_MIMETYPE
+#if QT_CONFIG(mimetype)
const QString &mimeTypeName = QMimeDatabase().mimeTypeForFile(fi).name();
if (mimeTypeName == QLatin1String("image/svg+xml"))
return SvgFile;
if (mimeTypeName == QLatin1String("image/svg+xml-compressed"))
return CompressedSvgFile;
-#endif // !QT_NO_MIMETYPE
+#endif
return OtherFile;
}
diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.h b/src/plugins/iconengines/svgiconengine/qsvgiconengine.h
index 672828c..06468d4 100644
--- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.h
+++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGICONENGINE_H
#define QSVGICONENGINE_H
diff --git a/src/plugins/imageformats/CMakeLists.txt b/src/plugins/imageformats/CMakeLists.txt
index 4336bbf..858c5c1 100644
--- a/src/plugins/imageformats/CMakeLists.txt
+++ b/src/plugins/imageformats/CMakeLists.txt
@@ -1,3 +1,4 @@
-# Generated from imageformats.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(svg)
diff --git a/src/plugins/imageformats/svg/CMakeLists.txt b/src/plugins/imageformats/svg/CMakeLists.txt
index cec6f77..140e281 100644
--- a/src/plugins/imageformats/svg/CMakeLists.txt
+++ b/src/plugins/imageformats/svg/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from svg.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## QSvgPlugin Plugin:
@@ -6,15 +7,12 @@
qt_internal_add_plugin(QSvgPlugin
OUTPUT_NAME qsvg
- TYPE imageformats
+ PLUGIN_TYPE imageformats
SOURCES
main.cpp
qsvgiohandler.cpp qsvgiohandler.h
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Gui
Qt::Svg
)
-
-#### Keys ignored in scope 1:.:.:svg.pro:<TRUE>:
-# PLUGIN_EXTENDS = "svg"
diff --git a/src/plugins/imageformats/svg/main.cpp b/src/plugins/imageformats/svg/main.cpp
index d3fe476..694608f 100644
--- a/src/plugins/imageformats/svg/main.cpp
+++ b/src/plugins/imageformats/svg/main.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <qimageiohandler.h>
#include <qstringlist.h>
diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp
index bd39b2a..b04ee6b 100644
--- a/src/plugins/imageformats/svg/qsvgiohandler.cpp
+++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgiohandler.h"
@@ -118,6 +82,24 @@ QSvgIOHandler::~QSvgIOHandler()
delete d;
}
+static bool isPossiblySvg(QIODevice *device, bool *isCompressed = nullptr)
+{
+ constexpr int bufSize = 64;
+ char buf[bufSize];
+ const qint64 readLen = device->peek(buf, bufSize);
+ if (readLen < 8)
+ return false;
+# ifndef QT_NO_COMPRESS
+ if (quint8(buf[0]) == 0x1f && quint8(buf[1]) == 0x8b) {
+ if (isCompressed)
+ *isCompressed = true;
+ return true;
+ }
+# endif
+ QTextStream str(QByteArray::fromRawData(buf, readLen));
+ QByteArray ba = str.read(16).trimmed().toLatin1();
+ return ba.startsWith("<?xml") || ba.startsWith("<svg") || ba.startsWith("<!--") || ba.startsWith("<!DOCTYPE svg");
+}
bool QSvgIOHandler::canRead() const
{
@@ -126,15 +108,9 @@ bool QSvgIOHandler::canRead() const
if (d->loaded && !d->readDone)
return true; // Will happen if we have been asked for the size
- QByteArray buf = device()->peek(16);
-#ifndef QT_NO_COMPRESS
- if (buf.startsWith("\x1f\x8b")) {
- setFormat("svgz");
- return true;
- } else
-#endif
- if (buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--") || buf.contains("<!DOCTYPE svg")) {
- setFormat("svg");
+ bool isCompressed = false;
+ if (isPossiblySvg(device(), &isCompressed)) {
+ setFormat(isCompressed ? "svgz" : "svg");
return true;
}
return false;
@@ -169,14 +145,13 @@ bool QSvgIOHandler::read(QImage *image)
t.translate(tr1.x(), tr1.y());
bounds = t.mapRect(bounds);
}
- if (image->size() != finalSize || !image->reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied)) {
- *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied);
- if (!finalSize.isEmpty() && image->isNull()) {
- qWarning("QSvgIOHandler: QImage allocation failed (size %i x %i)", finalSize.width(), finalSize.height());
+ if (finalSize.isEmpty()) {
+ *image = QImage();
+ } else {
+ if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
+ return false; // Assume corrupted file
+ if (!QImageIOHandler::allocateImage(finalSize, QImage::Format_ARGB32_Premultiplied, image))
return false;
- }
- }
- if (!finalSize.isEmpty()) {
image->fill(d->backColor.rgba());
QPainter p(image);
d->r.render(&p, bounds);
@@ -260,12 +235,7 @@ bool QSvgIOHandler::supportsOption(ImageOption option) const
bool QSvgIOHandler::canRead(QIODevice *device)
{
- QByteArray buf = device->peek(16);
- return
-#ifndef QT_NO_COMPRESS
- buf.startsWith("\x1f\x8b") ||
-#endif
- buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--") || buf.contains("<!DOCTYPE svg");
+ return isPossiblySvg(device);
}
QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/svg/qsvgiohandler.h b/src/plugins/imageformats/svg/qsvgiohandler.h
index 5a952e1..a1e206d 100644
--- a/src/plugins/imageformats/svg/qsvgiohandler.h
+++ b/src/plugins/imageformats/svg/qsvgiohandler.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGIOHANDLER_H
#define QSVGIOHANDLER_H
diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt
index 1d3b23e..ff2c0df 100644
--- a/src/svg/CMakeLists.txt
+++ b/src/svg/CMakeLists.txt
@@ -1,17 +1,16 @@
-# Generated from svg.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## Svg Module:
#####################################################################
-# special case begin
# Handle the conditional finding of either system zlib or qt zlib.
if(NOT QT_FEATURE_system_zlib)
- find_package(Qt6 COMPONENTS Zlib)
-elseif(NOT TARGET ZLIB::ZLIB)
- qt_find_package(ZLIB PROVIDED_TARGETS ZLIB::ZLIB)
+ find_package(Qt6 COMPONENTS ZlibPrivate)
+elseif(NOT TARGET WrapZLIB::WrapZLIB)
+ qt_find_package(WrapZLIB PROVIDED_TARGETS WrapZLIB::WrapZLIB)
endif()
-# special case end
qt_internal_add_module(Svg
SOURCES
@@ -36,31 +35,21 @@ qt_internal_add_module(Svg
PRIVATE_MODULE_INTERFACE
Qt::CorePrivate
Qt::GuiPrivate
+ GENERATE_CPP_EXPORTS
+ GENERATE_PRIVATE_CPP_EXPORTS
)
## Scopes:
#####################################################################
-qt_internal_extend_target(Svg CONDITION TARGET Qt::Widgets
- LIBRARIES
- Qt::WidgetsPrivate
- PUBLIC_LIBRARIES
- Qt::Widgets
- PRIVATE_MODULE_INTERFACE
- Qt::WidgetsPrivate
-)
-
qt_internal_extend_target(Svg CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386")
LINK_OPTIONS
"/BASE:0x66000000"
)
-#### Keys ignored in scope 4:.:.:svg.pro:solaris-cc_x_:
-# QMAKE_CXXFLAGS_RELEASE = "--O2"
-
qt_internal_extend_target(Svg CONDITION QT_FEATURE_system_zlib
LIBRARIES
- ZLIB::ZLIB
+ WrapZLIB::WrapZLIB
)
qt_internal_extend_target(Svg CONDITION NOT QT_FEATURE_system_zlib
@@ -70,4 +59,3 @@ qt_internal_extend_target(Svg CONDITION NOT QT_FEATURE_system_zlib
qt_internal_add_docs(Svg
doc/qtsvg.qdocconf
)
-
diff --git a/src/svg/doc/qtsvg.qdocconf b/src/svg/doc/qtsvg.qdocconf
index c68beab..b2c5126 100644
--- a/src/svg/doc/qtsvg.qdocconf
+++ b/src/svg/doc/qtsvg.qdocconf
@@ -13,9 +13,6 @@ qhp.QtSvg.virtualFolder = qtsvg
qhp.QtSvg.indexTitle = Qt SVG
qhp.QtSvg.indexRoot =
-qhp.QtSvg.filterAttributes = qtsvg $QT_VERSION qtrefdoc
-qhp.QtSvg.customFilters.Qt.name = QtSvg $QT_VERSION
-qhp.QtSvg.customFilters.Qt.filterAttributes = qtsvg $QT_VERSION
qhp.QtSvg.subprojects = classes
qhp.QtSvg.subprojects.classes.title = C++ Classes
qhp.QtSvg.subprojects.classes.indexTitle = Qt SVG C++ Classes
@@ -27,7 +24,8 @@ depends += qtcore \
qtgui \
qtdesigner \
qtdoc \
- qmake
+ qmake \
+ qtcmake
tagfile = ../../../doc/qtsvg/qtsvg.tags
@@ -50,3 +48,6 @@ imagedirs += images
navigation.landingpage = "Qt SVG"
navigation.cppclassespage = "Qt SVG C++ Classes"
+
+# Fail the documentation build if there are more warnings than the limit
+warninglimit = 0
diff --git a/src/svg/doc/snippets/doc_src_qtsvg.cpp b/src/svg/doc/snippets/doc_src_qtsvg.cpp
index dc754c3..9635d26 100644
--- a/src/svg/doc/snippets/doc_src_qtsvg.cpp
+++ b/src/svg/doc/snippets/doc_src_qtsvg.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
#include <QtSvg>
diff --git a/src/svg/doc/snippets/doc_src_qtsvg.pro b/src/svg/doc/snippets/doc_src_qtsvg.pro
index 0c9aeed..e19860e 100644
--- a/src/svg/doc/snippets/doc_src_qtsvg.pro
+++ b/src/svg/doc/snippets/doc_src_qtsvg.pro
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#! [1]
QT += svg
diff --git a/src/svg/doc/snippets/src_svg_qgraphicssvgitem.cpp b/src/svg/doc/snippets/src_svg_qgraphicssvgitem.cpp
index 60018b6..f754c5a 100644
--- a/src/svg/doc/snippets/src_svg_qgraphicssvgitem.cpp
+++ b/src/svg/doc/snippets/src_svg_qgraphicssvgitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
QSvgRenderer *renderer = new QSvgRenderer(QLatin1String("SvgCardDeck.svg"));
diff --git a/src/svg/doc/src/qt6-changes.qdoc b/src/svg/doc/src/qt6-changes.qdoc
index 31a4639..940d513 100644
--- a/src/svg/doc/src/qt6-changes.qdoc
+++ b/src/svg/doc/src/qt6-changes.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtsvg-changes-qt6.html
diff --git a/src/svg/doc/src/qtsvg-index.qdoc b/src/svg/doc/src/qtsvg-index.qdoc
index 6e1d35a..544a569 100644
--- a/src/svg/doc/src/qtsvg-index.qdoc
+++ b/src/svg/doc/src/qtsvg-index.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt SVG module.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\title Qt SVG
@@ -35,17 +11,38 @@
for rendering and displaying SVG drawings in widgets and on other
paint devices.
- \section1 Getting Started
+ \section1 Using the Module
- Qt SVG provides classes for rendering SVG files. To include the definitions
- of the module's classes, use the following directive:
+ \include {module-use.qdocinc} {using the c++ api}
- \snippet doc_src_qtsvg.cpp 0
+ \section2 Building with CMake
- To link against the module, add this line to your \l qmake \c
- .pro file:
+ \include {module-use.qdocinc} {building with cmake} {Svg}
- \snippet doc_src_qtsvg.pro 1
+ \section2 Building with qmake
+
+ \include {module-use.qdocinc} {building_with_qmake} {svg}
+
+ \section1 Articles and Guides
+
+ \list
+ \li \l {Rendering SVG Files} contains information about how to
+ render SVG files
+ \endlist
+
+ \section1 Examples
+
+ \list
+ \li \l {SVG Generator Example}
+ \li \l {SVG Viewer Example}
+ \endlist
+
+ \section1 References
+
+ \list
+ \li \l {Qt SVG C++ Classes}
+ \li \l {Qt SVG Widgets C++ Classes}
+ \endlist
\section1 Module Evolution
\l{Changes to Qt SVG} lists important changes in the module API
@@ -59,27 +56,8 @@
the \l{GNU General Public License, version 2}.
See \l{Qt Licensing} for further details.
- Furthermore Qt SVG contains third party
+ Furthermore, Qt SVG contains third party
code under following permissive licenses:
\generatelist{groupsbymodule attributions-qtsvg}
-
- \section1 Articles
- \list
- \li \l{Rendering SVG Files} contains information about how to
- render SVG files
- \endlist
-
- \section1 References
- \list
- \li \l{Qt SVG C++ Classes}
- \li \l{Qt SVG Widgets C++ Classes}
- \endlist
-
- Qt SVG comes with the following examples:
-
- \list
- \li \l{SVG Generator Example}
- \li \l{SVG Viewer Example}
- \endlist
*/
diff --git a/src/svg/doc/src/qtsvg.qdoc b/src/svg/doc/src/qtsvg.qdoc
index bee0a29..a0ae55c 100644
--- a/src/svg/doc/src/qtsvg.qdoc
+++ b/src/svg/doc/src/qtsvg.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt SVG module.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\module QtSvg
diff --git a/src/svg/doc/src/svgrendering.qdoc b/src/svg/doc/src/svgrendering.qdoc
index 48a8d14..7a4330b 100644
--- a/src/svg/doc/src/svgrendering.qdoc
+++ b/src/svg/doc/src/svgrendering.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt SVG module.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page svgrendering.html
diff --git a/src/svg/qsvgfont.cpp b/src/svg/qsvgfont.cpp
index eb6c9cf..fc54f1e 100644
--- a/src/svg/qsvgfont.cpp
+++ b/src/svg/qsvgfont.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgfont_p.h"
diff --git a/src/svg/qsvgfont_p.h b/src/svg/qsvgfont_p.h
index fd0a3fa..9cf3dfe 100644
--- a/src/svg/qsvgfont_p.h
+++ b/src/svg/qsvgfont_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGFONT_P_H
#define QSVGFONT_P_H
@@ -74,6 +38,7 @@ public:
class Q_SVG_PRIVATE_EXPORT QSvgFont : public QSvgRefCounted
{
public:
+ static constexpr qreal DEFAULT_UNITS_PER_EM = 1000;
QSvgFont(qreal horizAdvX);
void setFamilyName(const QString &name);
@@ -86,9 +51,7 @@ public:
void draw(QPainter *p, const QPointF &point, const QString &str, qreal pixelSize, Qt::Alignment alignment) const;
public:
QString m_familyName;
- qreal m_unitsPerEm;
- qreal m_ascent;
- qreal m_descent;
+ qreal m_unitsPerEm = DEFAULT_UNITS_PER_EM;
qreal m_horizAdvX;
QHash<QChar, QSvgGlyph> m_glyphs;
};
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp
index 7306551..af39bb9 100644
--- a/src/svg/qsvggenerator.cpp
+++ b/src/svg/qsvggenerator.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvggenerator.h"
@@ -56,6 +20,8 @@
#include "qdebug.h"
+#include <optional>
+
QT_BEGIN_NAMESPACE
static void translate_color(const QColor &color, QString *color_string,
@@ -86,11 +52,12 @@ static void translate_dashPattern(const QList<qreal> &pattern, qreal width, QStr
class QSvgPaintEnginePrivate : public QPaintEnginePrivate
{
public:
- QSvgPaintEnginePrivate()
+ explicit QSvgPaintEnginePrivate(QSvgGenerator::SvgVersion version)
+ : svgVersion(version)
{
size = QSize();
viewBox = QRectF();
- outputDevice = 0;
+ outputDevice = nullptr;
resolution = 72;
attributes.document_title = QLatin1String("Qt SVG Document");
@@ -104,6 +71,7 @@ public:
numGradients = 0;
}
+ QSvgGenerator::SvgVersion svgVersion;
QSize size;
QRectF viewBox;
QIODevice *outputDevice;
@@ -143,6 +111,21 @@ public:
QString dashPattern, dashOffset;
QString fill, fillOpacity;
} attributes;
+
+ QString generateClipPathName() {
+ ++numClipPaths;
+ currentClipPathName = QStringLiteral("clipPath%1").arg(numClipPaths);
+ return currentClipPathName;
+ }
+
+ std::optional<QPainterPath> clipPath;
+ bool clipEnabled = false;
+ bool isClippingEffective() const {
+ return clipEnabled && clipPath.has_value();
+ }
+ QString currentClipPathName;
+ int numClipPaths = 0;
+ bool hasEmittedClipGroup = false;
};
static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
@@ -161,8 +144,8 @@ class QSvgPaintEngine : public QPaintEngine
Q_DECLARE_PRIVATE(QSvgPaintEngine)
public:
- QSvgPaintEngine()
- : QPaintEngine(*new QSvgPaintEnginePrivate,
+ explicit QSvgPaintEngine(QSvgGenerator::SvgVersion version)
+ : QPaintEngine(*new QSvgPaintEnginePrivate(version),
svgEngineFeatures())
{
}
@@ -171,6 +154,7 @@ public:
bool end() override;
void updateState(const QPaintEngineState &state) override;
+ void updateClipState(const QPaintEngineState &state);
void popGroup();
void drawEllipse(const QRectF &r) override;
@@ -212,12 +196,14 @@ public:
d_func()->outputDevice = device;
}
- int resolution() { return d_func()->resolution; }
+ int resolution() const { return d_func()->resolution; }
void setResolution(int resolution) {
Q_ASSERT(!isActive());
d_func()->resolution = resolution;
}
+ QSvgGenerator::SvgVersion svgVersion() const { return d_func()->svgVersion; }
+
QString savePatternMask(Qt::BrushStyle style)
{
QString maskId = QString(QStringLiteral("patternmask%1")).arg(style);
@@ -323,7 +309,7 @@ public:
}
}
- for (const QGradientStop &stop : qAsConst(stops)) {
+ for (const QGradientStop &stop : std::as_const(stops)) {
const QString color = stop.second.name(QColor::HexRgb);
str << QLatin1String(" <stop offset=\"")<< stop.first << QLatin1String("\" ")
<< QLatin1String("stop-color=\"") << color << QLatin1String("\" ")
@@ -581,14 +567,35 @@ public:
*/
/*!
- Constructs a new generator.
+ \enum QSvgGenerator::SvgVersion
+ \since 6.5
+
+ This enumeration describes the version of the SVG output of the
+ generator.
+
+ \value SvgTiny12 The generated document follows the SVG Tiny 1.2 specification.
+ \value Svg11 The generated document follows the SVG 1.1 specification.
+*/
+
+/*!
+ Constructs a new generator using the SVG Tiny 1.2 profile.
+*/
+QSvgGenerator::QSvgGenerator() // ### Qt 7: inline
+ : QSvgGenerator(SvgVersion::SvgTiny12)
+{
+}
+
+/*!
+ \since 6.5
+
+ Constructs a new generator that uses the SVG version \a version.
*/
-QSvgGenerator::QSvgGenerator()
+QSvgGenerator::QSvgGenerator(SvgVersion version)
: d_ptr(new QSvgGeneratorPrivate)
{
Q_D(QSvgGenerator);
- d->engine = new QSvgPaintEngine;
+ d->engine = new QSvgPaintEngine(version);
d->owns_iodevice = false;
}
@@ -803,6 +810,18 @@ void QSvgGenerator::setResolution(int dpi)
}
/*!
+ \since 6.5
+
+ Returns the version of the SVG document that this generator is
+ producing.
+*/
+QSvgGenerator::SvgVersion QSvgGenerator::svgVersion() const
+{
+ Q_D(const QSvgGenerator);
+ return d->engine->svgVersion();
+}
+
+/*!
Returns the paint engine used to render graphics to be converted to SVG
format information.
*/
@@ -891,15 +910,23 @@ bool QSvgPaintEngine::begin(QPaintDevice *)
}
*d->stream << " xmlns=\"http://www.w3.org/2000/svg\""
- " xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
- " version=\"1.2\" baseProfile=\"tiny\">" << Qt::endl;
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
+ switch (d->svgVersion) {
+ case QSvgGenerator::SvgVersion::SvgTiny12:
+ *d->stream << " version=\"1.2\" baseProfile=\"tiny\">";
+ break;
+ case QSvgGenerator::SvgVersion::Svg11:
+ *d->stream << " version=\"1.1\">";
+ break;
+ }
+ *d->stream << Qt::endl;
if (!d->attributes.document_title.isEmpty()) {
- *d->stream << "<title>" << d->attributes.document_title << "</title>" << Qt::endl;
+ *d->stream << "<title>" << d->attributes.document_title.toHtmlEscaped() << "</title>" << Qt::endl;
}
if (!d->attributes.document_description.isEmpty()) {
- *d->stream << "<desc>" << d->attributes.document_description << "</desc>" << Qt::endl;
+ *d->stream << "<desc>" << d->attributes.document_description.toHtmlEscaped() << "</desc>" << Qt::endl;
}
d->stream->setString(&d->defs);
@@ -926,6 +953,8 @@ bool QSvgPaintEngine::end()
*d->stream << d->header;
*d->stream << d->defs;
*d->stream << d->body;
+ if (d->hasEmittedClipGroup)
+ *d->stream << "</g>";
if (d->afterFirstUpdate)
*d->stream << "</g>" << Qt::endl; // close the updateState
@@ -978,49 +1007,85 @@ void QSvgPaintEngine::drawImage(const QRectF &r, const QImage &image,
void QSvgPaintEngine::updateState(const QPaintEngineState &state)
{
Q_D(QSvgPaintEngine);
- QPaintEngine::DirtyFlags flags = state.state();
-
// always stream full gstate, which is not required, but...
- flags |= QPaintEngine::AllDirty;
// close old state and start a new one...
+ if (d->hasEmittedClipGroup)
+ *d->stream << "</g>\n";
if (d->afterFirstUpdate)
*d->stream << "</g>\n\n";
- *d->stream << "<g ";
+ updateClipState(state);
- if (flags & QPaintEngine::DirtyBrush) {
- qbrushToSvg(state.brush());
+ if (d->isClippingEffective()) {
+ *d->stream << QStringLiteral("<g clip-path=\"url(#%1)\">").arg(d->currentClipPathName);
+ d->hasEmittedClipGroup = true;
+ } else {
+ d->hasEmittedClipGroup = false;
}
- if (flags & QPaintEngine::DirtyPen) {
- qpenToSvg(state.pen());
- }
+ *d->stream << "<g ";
- if (flags & QPaintEngine::DirtyTransform) {
- d->matrix = state.transform();
- *d->stream << "transform=\"matrix(" << d->matrix.m11() << ','
- << d->matrix.m12() << ','
- << d->matrix.m21() << ',' << d->matrix.m22() << ','
- << d->matrix.dx() << ',' << d->matrix.dy()
- << ")\""
- << Qt::endl;
- }
+ qbrushToSvg(state.brush());
+ qpenToSvg(state.pen());
- if (flags & QPaintEngine::DirtyFont) {
- qfontToSvg(state.font());
- }
+ d->matrix = state.transform();
+ *d->stream << "transform=\"matrix(" << d->matrix.m11() << ','
+ << d->matrix.m12() << ','
+ << d->matrix.m21() << ',' << d->matrix.m22() << ','
+ << d->matrix.dx() << ',' << d->matrix.dy()
+ << ")\""
+ << Qt::endl;
- if (flags & QPaintEngine::DirtyOpacity) {
- if (!qFuzzyIsNull(state.opacity() - 1))
- stream() << "opacity=\""<<state.opacity()<<"\" ";
- }
+ qfontToSvg(state.font());
+
+ if (!qFuzzyIsNull(state.opacity() - 1))
+ stream() << "opacity=\""<<state.opacity()<<"\" ";
*d->stream << '>' << Qt::endl;
d->afterFirstUpdate = true;
}
+void QSvgPaintEngine::updateClipState(const QPaintEngineState &state)
+{
+ Q_D(QSvgPaintEngine);
+ switch (d->svgVersion) {
+ case QSvgGenerator::SvgVersion::SvgTiny12:
+ // no clip handling in Tiny 1.2
+ return;
+ case QSvgGenerator::SvgVersion::Svg11:
+ break;
+ }
+
+ const QPaintEngine::DirtyFlags flags = state.state();
+
+ const bool clippingChanged = flags.testAnyFlags(DirtyClipPath | DirtyClipRegion);
+ if (clippingChanged) {
+ switch (state.clipOperation()) {
+ case Qt::NoClip:
+ d->clipEnabled = false;
+ d->clipPath.reset();
+ break;
+ case Qt::ReplaceClip:
+ case Qt::IntersectClip:
+ d->clipPath = painter()->transform().map(painter()->clipPath());
+ break;
+ }
+ }
+
+ if (flags & DirtyClipEnabled)
+ d->clipEnabled = state.isClipEnabled();
+
+ if (d->isClippingEffective() && clippingChanged) {
+ d->stream->setString(&d->defs);
+ *d->stream << QLatin1String("<clipPath id=\"%1\">\n").arg(d->generateClipPathName());
+ drawPath(*d->clipPath);
+ *d->stream << "</clipPath>\n";
+ d->stream->setString(&d->body);
+ }
+}
+
void QSvgPaintEngine::drawEllipse(const QRectF &r)
{
Q_D(QSvgPaintEngine);
diff --git a/src/svg/qsvggenerator.h b/src/svg/qsvggenerator.h
index bd215b2..6c2059d 100644
--- a/src/svg/qsvggenerator.h
+++ b/src/svg/qsvggenerator.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGGENERATOR_H
#define QSVGGENERATOR_H
@@ -59,6 +23,7 @@ class Q_SVG_EXPORT QSvgGenerator : public QPaintDevice
{
Q_DECLARE_PRIVATE(QSvgGenerator)
+ // Not a QObject; just a hack to get documentation from qdoc
Q_PROPERTY(QSize size READ size WRITE setSize)
Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
Q_PROPERTY(QString title READ title WRITE setTitle)
@@ -67,7 +32,13 @@ class Q_SVG_EXPORT QSvgGenerator : public QPaintDevice
Q_PROPERTY(QIODevice* outputDevice READ outputDevice WRITE setOutputDevice)
Q_PROPERTY(int resolution READ resolution WRITE setResolution)
public:
+ enum class SvgVersion {
+ SvgTiny12,
+ Svg11,
+ };
+
QSvgGenerator();
+ explicit QSvgGenerator(SvgVersion version);
~QSvgGenerator();
QString title() const;
@@ -92,6 +63,8 @@ public:
void setResolution(int dpi);
int resolution() const;
+
+ SvgVersion svgVersion() const;
protected:
QPaintEngine *paintEngine() const override;
int metric(QPaintDevice::PaintDeviceMetric metric) const override;
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp
index 65b9304..ac8051d 100644
--- a/src/svg/qsvggraphics.cpp
+++ b/src/svg/qsvggraphics.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvggraphics_p.h"
@@ -49,15 +13,26 @@
#include <qtextcursor.h>
#include <qtextdocument.h>
+#include <QElapsedTimer>
+#include <QLoggingCategory>
+
#include <math.h>
#include <limits.h>
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcSvgDraw, "qt.svg.draw")
+Q_LOGGING_CATEGORY(lcSvgTiming, "qt.svg.timing")
+
+#define QT_SVG_TIMING_ENTER \
+ QElapsedTimer qtSvgTimer; qtSvgTimer.start();
+
+#define QT_SVG_TIMING_EXIT(TYPE) \
+ if (Q_UNLIKELY(lcSvgTiming().isDebugEnabled())) \
+ qCDebug(lcSvgTiming) << "Drawing" << TYPE << "took" << (qtSvgTimer.nsecsElapsed() / 1000000.0f) << "ms";
#define QT_SVG_DRAW_SHAPE(command) \
- qreal oldOpacity = p->opacity(); \
+ { qreal oldOpacity = p->opacity(); \
QBrush oldBrush = p->brush(); \
QPen oldPen = p->pen(); \
p->setPen(Qt::NoPen); \
@@ -70,7 +45,7 @@ Q_LOGGING_CATEGORY(lcSvgDraw, "qt.svg.draw")
command; \
p->setBrush(oldBrush); \
} \
- p->setOpacity(oldOpacity);
+ p->setOpacity(oldOpacity); }
void QSvgAnimation::draw(QPainter *, QSvgExtraStates &)
@@ -91,6 +66,10 @@ QSvgEllipse::QSvgEllipse(QSvgNode *parent, const QRectF &rect)
{
}
+QRectF QSvgEllipse::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ return p->transform().mapRect(m_bounds);
+}
QRectF QSvgEllipse::bounds(QPainter *p, QSvgExtraStates &) const
{
@@ -102,9 +81,12 @@ QRectF QSvgEllipse::bounds(QPainter *p, QSvgExtraStates &) const
void QSvgEllipse::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
applyStyle(p, states);
- QT_SVG_DRAW_SHAPE(p->drawEllipse(m_bounds));
+ if (shouldDrawNode(p, states))
+ QT_SVG_DRAW_SHAPE(p->drawEllipse(m_bounds));
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Ellipse")
}
QSvgArc::QSvgArc(QSvgNode *parent, const QPainterPath &path)
@@ -114,14 +96,18 @@ QSvgArc::QSvgArc(QSvgNode *parent, const QPainterPath &path)
void QSvgArc::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
applyStyle(p, states);
- if (p->pen().widthF() != 0) {
- qreal oldOpacity = p->opacity();
- p->setOpacity(oldOpacity * states.strokeOpacity);
- p->drawPath(m_path);
- p->setOpacity(oldOpacity);
+ if (shouldDrawNode(p, states)) {
+ if (p->pen().widthF() != 0) {
+ qreal oldOpacity = p->opacity();
+ p->setOpacity(oldOpacity * states.strokeOpacity);
+ p->drawPath(m_path);
+ p->setOpacity(oldOpacity);
+ }
}
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Arc")
}
QSvgImage::QSvgImage(QSvgNode *parent, const QImage &image,
@@ -137,9 +123,13 @@ QSvgImage::QSvgImage(QSvgNode *parent, const QImage &image,
void QSvgImage::draw(QPainter *p, QSvgExtraStates &states)
{
- applyStyle(p, states);
- p->drawImage(m_bounds, m_image);
- revertStyle(p, states);
+ QT_SVG_TIMING_ENTER
+ if (shouldDrawNode(p, states)) {
+ applyStyle(p, states);
+ p->drawImage(m_bounds, m_image);
+ revertStyle(p, states);
+ }
+ QT_SVG_TIMING_EXIT("Image")
}
@@ -151,14 +141,18 @@ QSvgLine::QSvgLine(QSvgNode *parent, const QLineF &line)
void QSvgLine::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
applyStyle(p, states);
- if (p->pen().widthF() != 0) {
- qreal oldOpacity = p->opacity();
- p->setOpacity(oldOpacity * states.strokeOpacity);
- p->drawLine(m_line);
- p->setOpacity(oldOpacity);
+ if (shouldDrawNode(p, states)) {
+ if (p->pen().widthF() != 0) {
+ qreal oldOpacity = p->opacity();
+ p->setOpacity(oldOpacity * states.strokeOpacity);
+ p->drawLine(m_line);
+ p->setOpacity(oldOpacity);
+ }
}
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Line")
}
QSvgPath::QSvgPath(QSvgNode *parent, const QPainterPath &qpath)
@@ -168,10 +162,19 @@ QSvgPath::QSvgPath(QSvgNode *parent, const QPainterPath &qpath)
void QSvgPath::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
applyStyle(p, states);
- m_path.setFillRule(states.fillRule);
- QT_SVG_DRAW_SHAPE(p->drawPath(m_path));
+ if (shouldDrawNode(p, states)) {
+ m_path.setFillRule(states.fillRule);
+ QT_SVG_DRAW_SHAPE(p->drawPath(m_path));
+ }
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Path")
+}
+
+QRectF QSvgPath::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ return p->transform().mapRect(m_path.controlPointRect());
}
QRectF QSvgPath::bounds(QPainter *p, QSvgExtraStates &) const
@@ -186,6 +189,11 @@ QSvgPolygon::QSvgPolygon(QSvgNode *parent, const QPolygonF &poly)
{
}
+QRectF QSvgPolygon::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ return p->transform().mapRect(m_poly.boundingRect());
+}
+
QRectF QSvgPolygon::bounds(QPainter *p, QSvgExtraStates &) const
{
qreal sw = strokeWidth(p);
@@ -200,9 +208,12 @@ QRectF QSvgPolygon::bounds(QPainter *p, QSvgExtraStates &) const
void QSvgPolygon::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
applyStyle(p, states);
- QT_SVG_DRAW_SHAPE(p->drawPolygon(m_poly, states.fillRule));
+ if (shouldDrawNode(p, states))
+ QT_SVG_DRAW_SHAPE(p->drawPolygon(m_poly, states.fillRule));
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Polygon")
}
@@ -214,21 +225,25 @@ QSvgPolyline::QSvgPolyline(QSvgNode *parent, const QPolygonF &poly)
void QSvgPolyline::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
applyStyle(p, states);
- qreal oldOpacity = p->opacity();
- if (p->brush().style() != Qt::NoBrush) {
- QPen save = p->pen();
- p->setPen(QPen(Qt::NoPen));
- p->setOpacity(oldOpacity * states.fillOpacity);
- p->drawPolygon(m_poly, states.fillRule);
- p->setPen(save);
- }
- if (p->pen().widthF() != 0) {
- p->setOpacity(oldOpacity * states.strokeOpacity);
- p->drawPolyline(m_poly);
+ if (shouldDrawNode(p, states)) {
+ qreal oldOpacity = p->opacity();
+ if (p->brush().style() != Qt::NoBrush) {
+ QPen save = p->pen();
+ p->setPen(QPen(Qt::NoPen));
+ p->setOpacity(oldOpacity * states.fillOpacity);
+ p->drawPolygon(m_poly, states.fillRule);
+ p->setPen(save);
+ }
+ if (p->pen().widthF() != 0) {
+ p->setOpacity(oldOpacity * states.strokeOpacity);
+ p->drawPolyline(m_poly);
+ }
+ p->setOpacity(oldOpacity);
}
- p->setOpacity(oldOpacity);
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Polyline")
}
QSvgRect::QSvgRect(QSvgNode *node, const QRectF &rect, int rx, int ry)
@@ -237,6 +252,11 @@ QSvgRect::QSvgRect(QSvgNode *node, const QRectF &rect, int rx, int ry)
{
}
+QRectF QSvgRect::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ return p->transform().mapRect(m_rect);
+}
+
QRectF QSvgRect::bounds(QPainter *p, QSvgExtraStates &) const
{
qreal sw = strokeWidth(p);
@@ -251,13 +271,17 @@ QRectF QSvgRect::bounds(QPainter *p, QSvgExtraStates &) const
void QSvgRect::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
applyStyle(p, states);
- if (m_rx || m_ry) {
- QT_SVG_DRAW_SHAPE(p->drawRoundedRect(m_rect, m_rx, m_ry, Qt::RelativeSize));
- } else {
- QT_SVG_DRAW_SHAPE(p->drawRect(m_rect));
+ if (shouldDrawNode(p, states)) {
+ if (m_rx || m_ry) {
+ QT_SVG_DRAW_SHAPE(p->drawRoundedRect(m_rect, m_rx, m_ry, Qt::RelativeSize));
+ } else {
+ QT_SVG_DRAW_SHAPE(p->drawRect(m_rect));
+ }
}
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Rect")
}
QSvgTspan * const QSvgText::LINEBREAK = 0;
@@ -285,172 +309,212 @@ void QSvgText::setTextArea(const QSizeF &size)
m_type = TEXTAREA;
}
-//QRectF QSvgText::bounds(QPainter *p, QSvgExtraStates &) const {}
+QRectF QSvgText::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ QFont font = p->font();
+ QFontMetricsF fm(font);
+
+ int charCount = 0;
+ for (int i = 0; i < m_tspans.size(); ++i)
+ charCount += m_tspans.at(i)->text().size();
+
+ QRectF approxMaximumBrect(m_coord.x(),
+ m_coord.y(),
+ charCount * fm.averageCharWidth(),
+ m_tspans.size() * fm.height());
+ return p->transform().mapRect(approxMaximumBrect);
+}
+
+QRectF QSvgText::bounds(QPainter *p, QSvgExtraStates &states) const
+{
+ QRectF boundingRect;
+ draw_helper(p, states, &boundingRect);
+ return p->transform().mapRect(boundingRect);
+}
void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
{
- applyStyle(p, states);
- qreal oldOpacity = p->opacity();
- p->setOpacity(oldOpacity * states.fillOpacity);
-
- // Force the font to have a size of 100 pixels to avoid truncation problems
- // when the font is very small.
- qreal scale = 100.0 / p->font().pointSizeF();
- Qt::Alignment alignment = states.textAnchor;
-
- QTransform oldTransform = p->worldTransform();
- p->scale(1 / scale, 1 / scale);
-
- qreal y = 0;
- bool initial = true;
- qreal px = m_coord.x() * scale;
- qreal py = m_coord.y() * scale;
- QSizeF scaledSize = m_size * scale;
-
- if (m_type == TEXTAREA) {
- if (alignment == Qt::AlignHCenter)
- px += scaledSize.width() / 2;
- else if (alignment == Qt::AlignRight)
- px += scaledSize.width();
- }
+ QT_SVG_TIMING_ENTER
+ draw_helper(p, states);
+ QT_SVG_TIMING_EXIT("Text")
+}
- QRectF bounds;
- if (m_size.height() != 0)
- bounds = QRectF(0, py, 1, scaledSize.height()); // x and width are not used.
+void QSvgText::draw_helper(QPainter *p, QSvgExtraStates &states, QRectF *boundingRect) const
+{
+ const bool isPainting = (boundingRect == nullptr);
+ applyStyle(p, states);
+ if (!isPainting || shouldDrawNode(p, states)) {
+ qreal oldOpacity = p->opacity();
+ p->setOpacity(oldOpacity * states.fillOpacity);
- bool appendSpace = false;
- QList<QString> paragraphs;
- QList<QList<QTextLayout::FormatRange> > formatRanges(1);
- paragraphs.push_back(QString());
+ // Force the font to have a size of 100 pixels to avoid truncation problems
+ // when the font is very small.
+ qreal scale = 100.0 / p->font().pointSizeF();
+ Qt::Alignment alignment = states.textAnchor;
+
+ QTransform oldTransform = p->worldTransform();
+ p->scale(1 / scale, 1 / scale);
+
+ qreal y = 0;
+ bool initial = true;
+ qreal px = m_coord.x() * scale;
+ qreal py = m_coord.y() * scale;
+ QSizeF scaledSize = m_size * scale;
+
+ if (m_type == TEXTAREA) {
+ if (alignment == Qt::AlignHCenter)
+ px += scaledSize.width() / 2;
+ else if (alignment == Qt::AlignRight)
+ px += scaledSize.width();
+ }
- for (int i = 0; i < m_tspans.size(); ++i) {
- if (m_tspans[i] == LINEBREAK) {
- if (m_type == TEXTAREA) {
- if (paragraphs.back().isEmpty()) {
- QFont font = p->font();
- font.setPixelSize(font.pointSizeF() * scale);
-
- QTextLayout::FormatRange range;
- range.start = 0;
- range.length = 1;
- range.format.setFont(font);
- formatRanges.back().append(range);
-
- paragraphs.back().append(QLatin1Char(' '));;
+ QRectF bounds;
+ if (m_size.height() != 0)
+ bounds = QRectF(0, py, 1, scaledSize.height()); // x and width are not used.
+
+ bool appendSpace = false;
+ QList<QString> paragraphs;
+ QList<QList<QTextLayout::FormatRange> > formatRanges(1);
+ paragraphs.push_back(QString());
+
+ for (int i = 0; i < m_tspans.size(); ++i) {
+ if (m_tspans[i] == LINEBREAK) {
+ if (m_type == TEXTAREA) {
+ if (paragraphs.back().isEmpty()) {
+ QFont font = p->font();
+ font.setPixelSize(font.pointSizeF() * scale);
+
+ QTextLayout::FormatRange range;
+ range.start = 0;
+ range.length = 1;
+ range.format.setFont(font);
+ formatRanges.back().append(range);
+
+ paragraphs.back().append(QLatin1Char(' '));;
+ }
+ appendSpace = false;
+ paragraphs.push_back(QString());
+ formatRanges.resize(formatRanges.size() + 1);
}
- appendSpace = false;
- paragraphs.push_back(QString());
- formatRanges.resize(formatRanges.size() + 1);
- }
- } else {
- WhitespaceMode mode = m_tspans[i]->whitespaceMode();
- m_tspans[i]->applyStyle(p, states);
+ } else {
+ WhitespaceMode mode = m_tspans[i]->whitespaceMode();
+ m_tspans[i]->applyStyle(p, states);
- QFont font = p->font();
- font.setPixelSize(font.pointSizeF() * scale);
+ QFont font = p->font();
+ font.setPixelSize(font.pointSizeF() * scale);
- QString newText(m_tspans[i]->text());
- newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
- newText.replace(QLatin1Char('\n'), QLatin1Char(' '));
+ QString newText(m_tspans[i]->text());
+ newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
+ newText.replace(QLatin1Char('\n'), QLatin1Char(' '));
- bool prependSpace = !appendSpace && !m_tspans[i]->isTspan() && (mode == Default) && !paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
- if (appendSpace || prependSpace)
- paragraphs.back().append(QLatin1Char(' '));
+ bool prependSpace = !appendSpace && !m_tspans[i]->isTspan() && (mode == Default) && !paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
+ if (appendSpace || prependSpace)
+ paragraphs.back().append(QLatin1Char(' '));
- bool appendSpaceNext = (!m_tspans[i]->isTspan() && (mode == Default) && newText.endsWith(QLatin1Char(' ')));
+ bool appendSpaceNext = (!m_tspans[i]->isTspan() && (mode == Default) && newText.endsWith(QLatin1Char(' ')));
- if (mode == Default) {
- newText = newText.simplified();
- if (newText.isEmpty())
- appendSpaceNext = false;
- }
+ if (mode == Default) {
+ newText = newText.simplified();
+ if (newText.isEmpty())
+ appendSpaceNext = false;
+ }
- QTextLayout::FormatRange range;
- range.start = paragraphs.back().length();
- range.length = newText.length();
- range.format.setFont(font);
- range.format.setTextOutline(p->pen());
- range.format.setForeground(p->brush());
-
- if (appendSpace) {
- Q_ASSERT(!formatRanges.back().isEmpty());
- ++formatRanges.back().back().length;
- } else if (prependSpace) {
- --range.start;
- ++range.length;
- }
- formatRanges.back().append(range);
+ QTextLayout::FormatRange range;
+ range.start = paragraphs.back().size();
+ range.length = newText.size();
+ range.format.setFont(font);
+ range.format.setTextOutline(p->pen());
+ range.format.setForeground(p->brush());
+
+ if (appendSpace) {
+ Q_ASSERT(!formatRanges.back().isEmpty());
+ ++formatRanges.back().back().length;
+ } else if (prependSpace) {
+ --range.start;
+ ++range.length;
+ }
+ formatRanges.back().append(range);
- appendSpace = appendSpaceNext;
- paragraphs.back() += newText;
+ appendSpace = appendSpaceNext;
+ paragraphs.back() += newText;
- m_tspans[i]->revertStyle(p, states);
+ m_tspans[i]->revertStyle(p, states);
+ }
}
- }
- if (states.svgFont) {
- // SVG fonts not fully supported...
- QString text = paragraphs.front();
- for (int i = 1; i < paragraphs.size(); ++i) {
- text.append(QLatin1Char('\n'));
- text.append(paragraphs[i]);
- }
- states.svgFont->draw(p, m_coord * scale, text, p->font().pointSizeF() * scale, states.textAnchor);
- } else {
- for (int i = 0; i < paragraphs.size(); ++i) {
- QTextLayout tl(paragraphs[i]);
- QTextOption op = tl.textOption();
- op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
- tl.setTextOption(op);
- tl.setFormats(formatRanges[i]);
- tl.beginLayout();
-
- forever {
- QTextLine line = tl.createLine();
- if (!line.isValid())
- break;
- if (m_size.width() != 0)
- line.setLineWidth(scaledSize.width());
+ if (states.svgFont) {
+ // SVG fonts not fully supported...
+ QString text = paragraphs.front();
+ for (int i = 1; i < paragraphs.size(); ++i) {
+ text.append(QLatin1Char('\n'));
+ text.append(paragraphs[i]);
}
- tl.endLayout();
-
- bool endOfBoundsReached = false;
- for (int i = 0; i < tl.lineCount(); ++i) {
- QTextLine line = tl.lineAt(i);
-
- qreal x = 0;
- if (alignment == Qt::AlignHCenter)
- x -= 0.5 * line.naturalTextWidth();
- else if (alignment == Qt::AlignRight)
- x -= line.naturalTextWidth();
-
- if (initial && m_type == TEXT)
- y -= line.ascent();
- initial = false;
-
- line.setPosition(QPointF(x, y));
-
- // Check if the current line fits into the bounding rectangle.
- if ((m_size.width() != 0 && line.naturalTextWidth() > scaledSize.width())
- || (m_size.height() != 0 && y + line.height() > scaledSize.height())) {
- // I need to set the bounds height to 'y-epsilon' to avoid drawing the current
- // line. Since the font is scaled to 100 units, 1 should be a safe epsilon.
- bounds.setHeight(y - 1);
- endOfBoundsReached = true;
- break;
+ states.svgFont->draw(p, m_coord * scale, text, p->font().pointSizeF() * scale, states.textAnchor);
+ } else {
+ QRectF brect;
+ for (int i = 0; i < paragraphs.size(); ++i) {
+ QTextLayout tl(paragraphs[i]);
+ QTextOption op = tl.textOption();
+ op.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
+ tl.setTextOption(op);
+ tl.setFormats(formatRanges[i]);
+ tl.beginLayout();
+
+ forever {
+ QTextLine line = tl.createLine();
+ if (!line.isValid())
+ break;
+ if (m_size.width() != 0)
+ line.setLineWidth(scaledSize.width());
+ }
+ tl.endLayout();
+
+ bool endOfBoundsReached = false;
+ for (int i = 0; i < tl.lineCount(); ++i) {
+ QTextLine line = tl.lineAt(i);
+
+ qreal x = 0;
+ if (alignment == Qt::AlignHCenter)
+ x -= 0.5 * line.naturalTextWidth();
+ else if (alignment == Qt::AlignRight)
+ x -= line.naturalTextWidth();
+
+ if (initial && m_type == TEXT)
+ y -= line.ascent();
+ initial = false;
+
+ line.setPosition(QPointF(x, y));
+ brect |= line.naturalTextRect();
+
+ // Check if the current line fits into the bounding rectangle.
+ if ((m_size.width() != 0 && line.naturalTextWidth() > scaledSize.width())
+ || (m_size.height() != 0 && y + line.height() > scaledSize.height())) {
+ // I need to set the bounds height to 'y-epsilon' to avoid drawing the current
+ // line. Since the font is scaled to 100 units, 1 should be a safe epsilon.
+ bounds.setHeight(y - 1);
+ endOfBoundsReached = true;
+ break;
+ }
+
+ y += 1.1 * line.height();
}
+ if (isPainting)
+ tl.draw(p, QPointF(px, py), QList<QTextLayout::FormatRange>(), bounds);
- y += 1.1 * line.height();
+ if (endOfBoundsReached)
+ break;
+ }
+ if (boundingRect) {
+ brect.translate(m_coord * scale);
+ if (bounds.height() > 0)
+ brect.setBottom(qMin(brect.bottom(), bounds.bottom()));
+ *boundingRect = QTransform::fromScale(1 / scale, 1 / scale).mapRect(brect);
}
- tl.draw(p, QPointF(px, py), QList<QTextLayout::FormatRange>(), bounds);
-
- if (endOfBoundsReached)
- break;
}
- }
- p->setWorldTransform(oldTransform, false);
- p->setOpacity(oldOpacity);
+ p->setWorldTransform(oldTransform, false);
+ p->setOpacity(oldOpacity);
+ }
revertStyle(p, states);
}
@@ -469,6 +533,7 @@ QSvgUse::QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *node)
void QSvgUse::draw(QPainter *p, QSvgExtraStates &states)
{
+ QT_SVG_TIMING_ENTER
if (Q_UNLIKELY(!m_link || isDescendantOf(m_link) || m_recursing))
return;
@@ -498,6 +563,7 @@ void QSvgUse::draw(QPainter *p, QSvgExtraStates &states)
}
revertStyle(p, states);
+ QT_SVG_TIMING_EXIT("Use")
}
void QSvgVideo::draw(QPainter *p, QSvgExtraStates &states)
@@ -584,6 +650,11 @@ QRectF QSvgUse::bounds(QPainter *p, QSvgExtraStates &states) const
return bounds;
}
+QRectF QSvgPolyline::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ return p->transform().mapRect(m_poly.boundingRect());
+}
+
QRectF QSvgPolyline::bounds(QPainter *p, QSvgExtraStates &) const
{
qreal sw = strokeWidth(p);
@@ -596,6 +667,11 @@ QRectF QSvgPolyline::bounds(QPainter *p, QSvgExtraStates &) const
}
}
+QRectF QSvgArc::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ return p->transform().mapRect(m_path.controlPointRect());
+}
+
QRectF QSvgArc::bounds(QPainter *p, QSvgExtraStates &) const
{
qreal sw = strokeWidth(p);
@@ -608,17 +684,22 @@ QRectF QSvgImage::bounds(QPainter *p, QSvgExtraStates &) const
return p->transform().mapRect(m_bounds);
}
-QRectF QSvgLine::bounds(QPainter *p, QSvgExtraStates &) const
+QRectF QSvgLine::fastBounds(QPainter *p, QSvgExtraStates &) const
+{
+ QPointF p1 = p->transform().map(m_line.p1());
+ QPointF p2 = p->transform().map(m_line.p2());
+ qreal minX = qMin(p1.x(), p2.x());
+ qreal minY = qMin(p1.y(), p2.y());
+ qreal maxX = qMax(p1.x(), p2.x());
+ qreal maxY = qMax(p1.y(), p2.y());
+ return QRectF(minX, minY, maxX - minX, maxY - minY);
+}
+
+QRectF QSvgLine::bounds(QPainter *p, QSvgExtraStates &s) const
{
qreal sw = strokeWidth(p);
if (qFuzzyIsNull(sw)) {
- QPointF p1 = p->transform().map(m_line.p1());
- QPointF p2 = p->transform().map(m_line.p2());
- qreal minX = qMin(p1.x(), p2.x());
- qreal minY = qMin(p1.y(), p2.y());
- qreal maxX = qMax(p1.x(), p2.x());
- qreal maxY = qMax(p1.y(), p2.y());
- return QRectF(minX, minY, maxX - minX, maxY - minY);
+ return fastBounds(p, s);
} else {
QPainterPath path;
path.moveTo(m_line.p1());
diff --git a/src/svg/qsvggraphics_p.h b/src/svg/qsvggraphics_p.h
index d2af6d6..96be929 100644
--- a/src/svg/qsvggraphics_p.h
+++ b/src/svg/qsvggraphics_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGGRAPHICS_P_H
#define QSVGGRAPHICS_P_H
@@ -77,6 +41,7 @@ public:
QSvgArc(QSvgNode *parent, const QPainterPath &path);
void draw(QPainter *p, QSvgExtraStates &states) override;
Type type() const override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
private:
QPainterPath m_path;
@@ -88,6 +53,7 @@ public:
QSvgEllipse(QSvgNode *parent, const QRectF &rect);
void draw(QPainter *p, QSvgExtraStates &states) override;
Type type() const override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
private:
QRectF m_bounds;
@@ -119,6 +85,7 @@ public:
QSvgLine(QSvgNode *parent, const QLineF &line);
void draw(QPainter *p, QSvgExtraStates &states) override;
Type type() const override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
private:
QLineF m_line;
@@ -130,6 +97,7 @@ public:
QSvgPath(QSvgNode *parent, const QPainterPath &qpath);
void draw(QPainter *p, QSvgExtraStates &states) override;
Type type() const override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
QPainterPath *qpath() {
@@ -145,6 +113,7 @@ public:
QSvgPolygon(QSvgNode *parent, const QPolygonF &poly);
void draw(QPainter *p, QSvgExtraStates &states) override;
Type type() const override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
private:
QPolygonF m_poly;
@@ -156,6 +125,7 @@ public:
QSvgPolyline(QSvgNode *parent, const QPolygonF &poly);
void draw(QPainter *p, QSvgExtraStates &states) override;
Type type() const override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
private:
QPolygonF m_poly;
@@ -167,6 +137,7 @@ public:
QSvgRect(QSvgNode *paren, const QRectF &rect, int rx=0, int ry=0);
Type type() const override;
void draw(QPainter *p, QSvgExtraStates &states) override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
private:
QRectF m_rect;
@@ -196,8 +167,12 @@ public:
void addLineBreak() {m_tspans.append(LINEBREAK);}
void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;}
- //QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
+ QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const override;
+ QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
+
private:
+ void draw_helper(QPainter *p, QSvgExtraStates &states, QRectF *boundingRect = nullptr) const;
+
static QSvgTspan * const LINEBREAK;
QPointF m_coord;
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index e554b47..a891848 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformdefs.h"
@@ -231,113 +195,7 @@ struct QSvgAttributes
QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHandler *handler)
{
-#ifndef QT_NO_CSSPARSER
- QStringView style = xmlAttributes.value(QLatin1String("style"));
- if (!style.isEmpty()) {
- handler->parseCSStoXMLAttrs(style.toString(), &m_cssAttributes);
- for (int j = 0; j < m_cssAttributes.count(); ++j) {
- const QSvgCssAttribute &attribute = m_cssAttributes.at(j);
- QStringView name = attribute.name;
- QStringView value = attribute.value;
- if (name.isEmpty())
- continue;
-
- switch (name.at(0).unicode()) {
-
- case 'c':
- if (name == QLatin1String("color"))
- color = value;
- else if (name == QLatin1String("color-opacity"))
- colorOpacity = value;
- else if (name == QLatin1String("comp-op"))
- compOp = value;
- break;
-
- case 'd':
- if (name == QLatin1String("display"))
- display = value;
- break;
-
- case 'f':
- if (name == QLatin1String("fill"))
- fill = value;
- else if (name == QLatin1String("fill-rule"))
- fillRule = value;
- else if (name == QLatin1String("fill-opacity"))
- fillOpacity = value;
- else if (name == QLatin1String("font-family"))
- fontFamily = value;
- else if (name == QLatin1String("font-size"))
- fontSize = value;
- else if (name == QLatin1String("font-style"))
- fontStyle = value;
- else if (name == QLatin1String("font-weight"))
- fontWeight = value;
- else if (name == QLatin1String("font-variant"))
- fontVariant = value;
- break;
- case 'i':
- if (name == QLatin1String("image-rendering"))
- imageRendering = value;
- break;
-
- case 'o':
- if (name == QLatin1String("opacity"))
- opacity = value;
- else if (name == QLatin1String("offset"))
- offset = value;
- break;
-
- case 's':
- if (name.length() > 5 && name.mid(1, 5) == QLatin1String("troke")) {
- QStringView strokeRef = name.mid(6, name.length() - 6);
- if (strokeRef.isEmpty())
- stroke = value;
- else if (strokeRef == QLatin1String("-dasharray"))
- strokeDashArray = value;
- else if (strokeRef == QLatin1String("-dashoffset"))
- strokeDashOffset = value;
- else if (strokeRef == QLatin1String("-linecap"))
- strokeLineCap = value;
- else if (strokeRef == QLatin1String("-linejoin"))
- strokeLineJoin = value;
- else if (strokeRef == QLatin1String("-miterlimit"))
- strokeMiterLimit = value;
- else if (strokeRef == QLatin1String("-opacity"))
- strokeOpacity = value;
- else if (strokeRef == QLatin1String("-width"))
- strokeWidth = value;
- }
- else if (name == QLatin1String("stop-color"))
- stopColor = value;
- else if (name == QLatin1String("stop-opacity"))
- stopOpacity = value;
- break;
-
- case 't':
- if (name == QLatin1String("text-anchor"))
- textAnchor = value;
- else if (name == QLatin1String("transform"))
- transform = value;
- break;
-
- case 'v':
- if (name == QLatin1String("vector-effect"))
- vectorEffect = value;
- else if (name == QLatin1String("visibility"))
- visibility = value;
- break;
-
- default:
- break;
- }
- }
- }
-#else
- Q_UNUSED(handler);
-#endif // QT_NO_CSSPARSER
-
- for (int i = 0; i < xmlAttributes.count(); ++i) {
+ for (int i = 0; i < xmlAttributes.size(); ++i) {
const QXmlStreamAttribute &attribute = xmlAttributes.at(i);
QStringView name = attribute.qualifiedName();
if (name.isEmpty())
@@ -394,8 +252,8 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa
break;
case 's':
- if (name.length() > 5 && name.mid(1, 5) == QLatin1String("troke")) {
- QStringView strokeRef = name.mid(6, name.length() - 6);
+ if (name.size() > 5 && name.mid(1, 5) == QLatin1String("troke")) {
+ QStringView strokeRef = name.mid(6, name.size() - 6);
if (strokeRef.isEmpty())
stroke = value;
else if (strokeRef == QLatin1String("-dasharray"))
@@ -412,8 +270,7 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa
strokeOpacity = value;
else if (strokeRef == QLatin1String("-width"))
strokeWidth = value;
- }
- else if (name == QLatin1String("stop-color"))
+ } else if (name == QLatin1String("stop-color"))
stopColor = value;
else if (name == QLatin1String("stop-opacity"))
stopOpacity = value;
@@ -443,6 +300,112 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa
}
}
+ // If a style attribute is present, let its attribute settings override the plain attribute
+ // values. The spec seems to indicate that, and it is common behavior in svg renderers.
+#ifndef QT_NO_CSSPARSER
+ QStringView style = xmlAttributes.value(QLatin1String("style"));
+ if (!style.isEmpty()) {
+ handler->parseCSStoXMLAttrs(style.toString(), &m_cssAttributes);
+ for (int j = 0; j < m_cssAttributes.size(); ++j) {
+ const QSvgCssAttribute &attribute = m_cssAttributes.at(j);
+ QStringView name = attribute.name;
+ QStringView value = attribute.value;
+ if (name.isEmpty())
+ continue;
+
+ switch (name.at(0).unicode()) {
+
+ case 'c':
+ if (name == QLatin1String("color"))
+ color = value;
+ else if (name == QLatin1String("color-opacity"))
+ colorOpacity = value;
+ else if (name == QLatin1String("comp-op"))
+ compOp = value;
+ break;
+
+ case 'd':
+ if (name == QLatin1String("display"))
+ display = value;
+ break;
+
+ case 'f':
+ if (name == QLatin1String("fill"))
+ fill = value;
+ else if (name == QLatin1String("fill-rule"))
+ fillRule = value;
+ else if (name == QLatin1String("fill-opacity"))
+ fillOpacity = value;
+ else if (name == QLatin1String("font-family"))
+ fontFamily = value;
+ else if (name == QLatin1String("font-size"))
+ fontSize = value;
+ else if (name == QLatin1String("font-style"))
+ fontStyle = value;
+ else if (name == QLatin1String("font-weight"))
+ fontWeight = value;
+ else if (name == QLatin1String("font-variant"))
+ fontVariant = value;
+ break;
+ case 'i':
+ if (name == QLatin1String("image-rendering"))
+ imageRendering = value;
+ break;
+
+ case 'o':
+ if (name == QLatin1String("opacity"))
+ opacity = value;
+ else if (name == QLatin1String("offset"))
+ offset = value;
+ break;
+
+ case 's':
+ if (name.size() > 5 && name.mid(1, 5) == QLatin1String("troke")) {
+ QStringView strokeRef = name.mid(6, name.size() - 6);
+ if (strokeRef.isEmpty())
+ stroke = value;
+ else if (strokeRef == QLatin1String("-dasharray"))
+ strokeDashArray = value;
+ else if (strokeRef == QLatin1String("-dashoffset"))
+ strokeDashOffset = value;
+ else if (strokeRef == QLatin1String("-linecap"))
+ strokeLineCap = value;
+ else if (strokeRef == QLatin1String("-linejoin"))
+ strokeLineJoin = value;
+ else if (strokeRef == QLatin1String("-miterlimit"))
+ strokeMiterLimit = value;
+ else if (strokeRef == QLatin1String("-opacity"))
+ strokeOpacity = value;
+ else if (strokeRef == QLatin1String("-width"))
+ strokeWidth = value;
+ } else if (name == QLatin1String("stop-color"))
+ stopColor = value;
+ else if (name == QLatin1String("stop-opacity"))
+ stopOpacity = value;
+ break;
+
+ case 't':
+ if (name == QLatin1String("text-anchor"))
+ textAnchor = value;
+ else if (name == QLatin1String("transform"))
+ transform = value;
+ break;
+
+ case 'v':
+ if (name == QLatin1String("vector-effect"))
+ vectorEffect = value;
+ else if (name == QLatin1String("visibility"))
+ visibility = value;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+#else
+ Q_UNUSED(handler);
+#endif // QT_NO_CSSPARSER
}
#ifndef QT_NO_CSSPARSER
@@ -516,8 +479,9 @@ public:
QString name = nodeToName(n);
return QString::compare(name, nodeName, Qt::CaseInsensitive) == 0;
}
- QString attribute(NodePtr node, const QString &name) const override
+ QString attributeValue(NodePtr node, const QCss::AttributeSelector &asel) const override
{
+ const QString &name = asel.name;
QSvgNode *n = svgNode(node);
if ((!n->nodeId().isEmpty() && (name == QLatin1String("id") ||
name == QLatin1String("xml:id"))))
@@ -693,7 +657,7 @@ static qreal toDouble(QStringView str, bool *ok = NULL)
const QChar *c = str.constData();
qreal res = (c == nullptr ? qreal{} : toDouble(c));
if (ok)
- *ok = (c == (str.constData() + str.length()));
+ *ok = (c == (str.constData() + str.size()));
return res;
}
@@ -725,15 +689,25 @@ static QList<qreal> parseNumbersList(const QChar *&str)
return points;
}
-static inline void parseNumbersArray(const QChar *&str, QVarLengthArray<qreal, 8> &points)
+static inline void parseNumbersArray(const QChar *&str, QVarLengthArray<qreal, 8> &points,
+ const char *pattern = nullptr)
{
+ const size_t patternLen = qstrlen(pattern);
while (str->isSpace())
++str;
while (isDigit(str->unicode()) ||
*str == QLatin1Char('-') || *str == QLatin1Char('+') ||
*str == QLatin1Char('.')) {
- points.append(toDouble(str));
+ if (patternLen && pattern[points.size() % patternLen] == 'f') {
+ // flag expected, may only be 0 or 1
+ if (*str != QLatin1Char('0') && *str != QLatin1Char('1'))
+ return;
+ points.append(*str == QLatin1Char('0') ? 0.0 : 1.0);
+ ++str;
+ } else {
+ points.append(toDouble(str));
+ }
while (str->isSpace())
++str;
@@ -824,7 +798,7 @@ static bool resolveColor(QStringView colorStr, QColor &color, QSvgHandler *handl
// #rrggbb is very very common, so let's tackle it here
// rather than falling back to QColor
QRgb rgb;
- bool ok = qsvg_get_hex_rgb(colorStrTr.constData(), colorStrTr.length(), &rgb);
+ bool ok = qsvg_get_hex_rgb(colorStrTr.constData(), colorStrTr.size(), &rgb);
if (ok)
color.setRgb(rgb);
return ok;
@@ -834,7 +808,7 @@ static bool resolveColor(QStringView colorStr, QColor &color, QSvgHandler *handl
case 'r':
{
// starts with "rgb(", ends with ")" and consists of at least 7 characters "rgb(,,)"
- if (colorStrTr.length() >= 7 && colorStrTr.at(colorStrTr.length() - 1) == QLatin1Char(')')
+ if (colorStrTr.size() >= 7 && colorStrTr.at(colorStrTr.size() - 1) == QLatin1Char(')')
&& colorStrTr.mid(0, 4) == QLatin1String("rgb(")) {
const QChar *s = colorStrTr.constData() + 4;
QList<qreal> compo = parseNumbersList(s);
@@ -872,7 +846,7 @@ static bool resolveColor(QStringView colorStr, QColor &color, QSvgHandler *handl
break;
}
- color = QColor(colorStrTr.toString());
+ color = QColor::fromString(colorStrTr.toString());
return color.isValid();
}
@@ -1023,8 +997,8 @@ static void parseBrush(QSvgNode *node,
//fill attribute handling
if ((!attributes.fill.isEmpty()) && (attributes.fill != QT_INHERIT) ) {
- if (attributes.fill.length() > 3 && attributes.fill.mid(0, 3) == QLatin1String("url")) {
- QString value = attributes.fill.mid(3, attributes.fill.length() - 3).toString();
+ if (attributes.fill.size() > 3 && attributes.fill.mid(0, 3) == QLatin1String("url")) {
+ QString value = attributes.fill.mid(3, attributes.fill.size() - 3).toString();
QSvgStyleProperty *style = styleFromUrl(node, value);
if (style) {
if (style->type() == QSvgStyleProperty::SOLID_COLOR || style->type() == QSvgStyleProperty::GRADIENT)
@@ -1055,7 +1029,7 @@ static QTransform parseTransformationMatrix(QStringView value)
QTransform matrix;
const QChar *str = value.constData();
- const QChar *end = str + value.length();
+ const QChar *end = str + value.size();
while (str < end) {
if (str->isSpace() || *str == QLatin1Char(',')) {
@@ -1134,22 +1108,22 @@ static QTransform parseTransformationMatrix(QStringView value)
++str;
if(state == Matrix) {
- if(points.count() != 6)
+ if(points.size() != 6)
goto error;
matrix = QTransform(points[0], points[1],
points[2], points[3],
points[4], points[5]) * matrix;
} else if (state == Translate) {
- if (points.count() == 1)
+ if (points.size() == 1)
matrix.translate(points[0], 0);
- else if (points.count() == 2)
+ else if (points.size() == 2)
matrix.translate(points[0], points[1]);
else
goto error;
} else if (state == Rotate) {
- if(points.count() == 1) {
+ if(points.size() == 1) {
matrix.rotate(points[0]);
- } else if (points.count() == 3) {
+ } else if (points.size() == 3) {
matrix.translate(points[1], points[2]);
matrix.rotate(points[0]);
matrix.translate(-points[1], -points[2]);
@@ -1157,23 +1131,21 @@ static QTransform parseTransformationMatrix(QStringView value)
goto error;
}
} else if (state == Scale) {
- if (points.count() < 1 || points.count() > 2)
+ if (points.size() < 1 || points.size() > 2)
goto error;
qreal sx = points[0];
qreal sy = sx;
- if(points.count() == 2)
+ if(points.size() == 2)
sy = points[1];
matrix.scale(sx, sy);
} else if (state == SkewX) {
- if (points.count() != 1)
+ if (points.size() != 1)
goto error;
- const qreal deg2rad = qreal(0.017453292519943295769);
- matrix.shear(qTan(points[0]*deg2rad), 0);
+ matrix.shear(qTan(qDegreesToRadians(points[0])), 0);
} else if (state == SkewY) {
- if (points.count() != 1)
+ if (points.size() != 1)
goto error;
- const qreal deg2rad = qreal(0.017453292519943295769);
- matrix.shear(0, qTan(points[0]*deg2rad));
+ matrix.shear(0, qTan(qDegreesToRadians(points[0])));
}
}
error:
@@ -1194,8 +1166,8 @@ static void parsePen(QSvgNode *node,
//stroke attribute handling
if ((!attributes.stroke.isEmpty()) && (attributes.stroke != QT_INHERIT) ) {
- if (attributes.stroke.length() > 3 && attributes.stroke.mid(0, 3) == QLatin1String("url")) {
- QString value = attributes.stroke.mid(3, attributes.stroke.length() - 3).toString();
+ if (attributes.stroke.size() > 3 && attributes.stroke.mid(0, 3) == QLatin1String("url")) {
+ QString value = attributes.stroke.mid(3, attributes.stroke.size() - 3).toString();
QSvgStyleProperty *style = styleFromUrl(node, value);
if (style) {
if (style->type() == QSvgStyleProperty::SOLID_COLOR || style->type() == QSvgStyleProperty::GRADIENT)
@@ -1331,7 +1303,7 @@ static void parseFont(QSvgNode *node,
return;
QSvgTinyDocument *doc = node->document();
- QSvgFontStyle *fontStyle = 0;
+ QSvgFontStyle *fontStyle = nullptr;
if (!attributes.fontFamily.isEmpty()) {
QSvgFont *svgFont = doc->svgFont(attributes.fontFamily.toString());
if (svgFont)
@@ -1342,7 +1314,7 @@ static void parseFont(QSvgNode *node,
if (!attributes.fontFamily.isEmpty() && attributes.fontFamily != QT_INHERIT) {
QString family = attributes.fontFamily.toString().trimmed();
if (family.at(0) == QLatin1Char('\'') || family.at(0) == QLatin1Char('\"'))
- family = family.mid(1, family.length() - 2);
+ family = family.mid(1, family.size() - 2);
fontStyle->setFamily(family);
}
@@ -1353,8 +1325,10 @@ static void parseFont(QSvgNode *node,
case FontSizeNone:
break;
case FontSizeValue: {
- QSvgHandler::LengthType dummy; // should always be pixel size
- fontStyle->setSize(parseLength(attributes.fontSize, dummy, handler));
+ QSvgHandler::LengthType type;
+ qreal fs = parseLength(attributes.fontSize, type, handler);
+ fs = convertToPixels(fs, true, type);
+ fontStyle->setSize(qMin(fs, qreal(0xffff)));
}
break;
default:
@@ -1585,6 +1559,7 @@ static void pathArc(QPainterPath &path,
static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
{
+ const int maxElementCount = 0x7fff; // Assume file corruption if more path elements than this
qreal x0 = 0, y0 = 0; // starting point
qreal x = 0, y = 0; // current point
char lastMode = 0;
@@ -1592,28 +1567,31 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
const QChar *str = dataStr.constData();
const QChar *end = str + dataStr.size();
- while (str != end) {
+ bool ok = true;
+ while (ok && str != end) {
while (str->isSpace() && (str + 1) != end)
++str;
QChar pathElem = *str;
++str;
QChar endc = *end;
*const_cast<QChar *>(end) = u'\0'; // parseNumbersArray requires 0-termination that QStringView cannot guarantee
+ const char *pattern = nullptr;
+ if (pathElem == QLatin1Char('a') || pathElem == QLatin1Char('A'))
+ pattern = "rrrffrr";
QVarLengthArray<qreal, 8> arg;
- parseNumbersArray(str, arg);
+ parseNumbersArray(str, arg, pattern);
*const_cast<QChar *>(end) = endc;
if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z'))
arg.append(0);//dummy
const qreal *num = arg.constData();
- int count = arg.count();
- while (count > 0) {
+ int count = arg.size();
+ while (ok && count > 0) {
qreal offsetX = x; // correction offsets
qreal offsetY = y; // for relative commands
switch (pathElem.unicode()) {
case 'm': {
if (count < 2) {
- num++;
- count--;
+ ok = false;
break;
}
x = x0 = num[0] + offsetX;
@@ -1630,8 +1608,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
break;
case 'M': {
if (count < 2) {
- num++;
- count--;
+ ok = false;
break;
}
x = x0 = num[0];
@@ -1657,8 +1634,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
break;
case 'l': {
if (count < 2) {
- num++;
- count--;
+ ok = false;
break;
}
x = num[0] + offsetX;
@@ -1671,8 +1647,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
break;
case 'L': {
if (count < 2) {
- num++;
- count--;
+ ok = false;
break;
}
x = num[0];
@@ -1712,8 +1687,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
break;
case 'c': {
if (count < 6) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF c1(num[0] + offsetX, num[1] + offsetY);
@@ -1729,8 +1703,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 'C': {
if (count < 6) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF c1(num[0], num[1]);
@@ -1746,8 +1719,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 's': {
if (count < 4) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF c1;
@@ -1768,8 +1740,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 'S': {
if (count < 4) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF c1;
@@ -1790,8 +1761,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 'q': {
if (count < 4) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF c(num[0] + offsetX, num[1] + offsetY);
@@ -1806,8 +1776,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 'Q': {
if (count < 4) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF c(num[0], num[1]);
@@ -1822,8 +1791,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 't': {
if (count < 2) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF e(num[0] + offsetX, num[1] + offsetY);
@@ -1843,8 +1811,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 'T': {
if (count < 2) {
- num += count;
- count = 0;
+ ok = false;
break;
}
QPointF e(num[0], num[1]);
@@ -1864,8 +1831,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
case 'a': {
if (count < 7) {
- num += count;
- count = 0;
+ ok = false;
break;
}
qreal rx = (*num++);
@@ -1887,8 +1853,7 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
break;
case 'A': {
if (count < 7) {
- num += count;
- count = 0;
+ ok = false;
break;
}
qreal rx = (*num++);
@@ -1909,12 +1874,15 @@ static bool parsePathDataFast(QStringView dataStr, QPainterPath &path)
}
break;
default:
- return false;
+ ok = false;
+ break;
}
lastMode = pathElem.toLatin1();
+ if (path.elementCount() > maxElementCount)
+ ok = false;
}
}
- return true;
+ return ok;
}
static bool parseStyle(QSvgNode *node,
@@ -1930,13 +1898,13 @@ static bool parseStyle(QSvgNode *node,
static void parseCSStoXMLAttrs(const QList<QCss::Declaration> &declarations,
QXmlStreamAttributes &attributes)
{
- for (int i = 0; i < declarations.count(); ++i) {
+ for (int i = 0; i < declarations.size(); ++i) {
const QCss::Declaration &decl = declarations.at(i);
if (decl.d->property.isEmpty())
continue;
QCss::Value val = decl.d->values.first();
QString valueStr;
- const int valCount = decl.d->values.count();
+ const int valCount = decl.d->values.size();
if (valCount != 1) {
for (int i = 0; i < valCount; ++i) {
valueStr += decl.d->values[i].toString();
@@ -1953,9 +1921,9 @@ static void parseCSStoXMLAttrs(const QList<QCss::Declaration> &declarations,
QStringList lst = val.variant.toStringList();
valueStr.append(lst.at(0));
valueStr.append(QLatin1Char('('));
- for (int i = 1; i < lst.count(); ++i) {
+ for (int i = 1; i < lst.size(); ++i) {
valueStr.append(lst.at(i));
- if ((i +1) < lst.count())
+ if ((i +1) < lst.size())
valueStr.append(QLatin1Char(','));
}
valueStr.append(QLatin1Char(')'));
@@ -2076,7 +2044,7 @@ static bool parseCoreNode(QSvgNode *node,
QStringList fonts;
QString xmlClassStr;
- for (int i = 0; i < attributes.count(); ++i) {
+ for (int i = 0; i < attributes.size(); ++i) {
const QXmlStreamAttribute &attribute = attributes.at(i);
QStringView name = attribute.qualifiedName();
if (name.isEmpty())
@@ -2349,6 +2317,27 @@ static bool parseAnimateNode(QSvgNode *parent,
return true;
}
+static int parseClockValue(QStringView str, bool *ok)
+{
+ int res = 0;
+ int ms = 1000;
+ str = str.trimmed();
+ if (str.endsWith(QLatin1String("ms"))) {
+ str.chop(2);
+ ms = 1;
+ } else if (str.endsWith(QLatin1String("s"))) {
+ str.chop(1);
+ }
+ double val = ms * toDouble(str, ok);
+ if (ok) {
+ if (val > std::numeric_limits<int>::min() && val < std::numeric_limits<int>::max())
+ res = static_cast<int>(val);
+ else
+ *ok = false;
+ }
+ return res;
+}
+
static bool parseAnimateColorNode(QSvgNode *parent,
const QXmlStreamAttributes &attributes,
QSvgHandler *handler)
@@ -2372,7 +2361,7 @@ static bool parseAnimateColorNode(QSvgNode *parent,
colors.append(endColor);
} else {
QStringList str = valuesStr.split(QLatin1Char(';'));
- colors.reserve(str.count());
+ colors.reserve(str.size());
QStringList::const_iterator itr;
for (itr = str.constBegin(); itr != str.constEnd(); ++itr) {
QColor color;
@@ -2381,23 +2370,13 @@ static bool parseAnimateColorNode(QSvgNode *parent,
}
}
- int ms = 1000;
- beginStr = beginStr.trimmed();
- if (beginStr.endsWith(QLatin1String("ms"))) {
- beginStr.chop(2);
- ms = 1;
- } else if (beginStr.endsWith(QLatin1String("s"))) {
- beginStr.chop(1);
- }
- durStr = durStr.trimmed();
- if (durStr.endsWith(QLatin1String("ms"))) {
- durStr.chop(2);
- ms = 1;
- } else if (durStr.endsWith(QLatin1String("s"))) {
- durStr.chop(1);
- }
- int begin = static_cast<int>(toDouble(beginStr) * ms);
- int end = static_cast<int>((toDouble(durStr) + begin) * ms);
+ bool ok = true;
+ int begin = parseClockValue(beginStr, &ok);
+ if (!ok)
+ return false;
+ int end = begin + parseClockValue(durStr, &ok);
+ if (!ok || end <= begin)
+ return false;
QSvgAnimateColor *anim = new QSvgAnimateColor(begin, end, 0);
anim->setArgs((targetStr == QLatin1String("fill")), colors);
@@ -2486,25 +2465,16 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
++s;
}
}
+ if (vals.size() % 3 != 0)
+ return false;
- int ms = 1000;
- beginStr = beginStr.trimmed();
- if (beginStr.endsWith(QLatin1String("ms"))) {
- beginStr.chop(2);
- ms = 1;
- } else if (beginStr.endsWith(QLatin1String("s"))) {
- beginStr.chop(1);
- }
- int begin = static_cast<int>(toDouble(beginStr) * ms);
- durStr = durStr.trimmed();
- if (durStr.endsWith(QLatin1String("ms"))) {
- durStr.chop(2);
- ms = 1;
- } else if (durStr.endsWith(QLatin1String("s"))) {
- durStr.chop(1);
- ms = 1000;
- }
- int end = static_cast<int>(toDouble(durStr)*ms) + begin;
+ bool ok = true;
+ int begin = parseClockValue(beginStr, &ok);
+ if (!ok)
+ return false;
+ int end = begin + parseClockValue(durStr, &ok);
+ if (!ok || end <= begin)
+ return false;
QSvgAnimateTransform::TransformType type = QSvgAnimateTransform::Empty;
if (typeStr == QLatin1String("translate")) {
@@ -2652,7 +2622,7 @@ static bool parseFontFaceNode(QSvgStyleProperty *parent,
qreal unitsPerEm = toDouble(unitsPerEmStr);
if (!unitsPerEm)
- unitsPerEm = 1000;
+ unitsPerEm = QSvgFont::DEFAULT_UNITS_PER_EM;
if (!name.isEmpty())
font->setFamilyName(name);
@@ -2857,7 +2827,7 @@ static void parseBaseGradient(QSvgNode *node,
QTransform matrix;
QGradient *grad = gradProp->qgradient();
- if (!link.isEmpty()) {
+ if (node && !link.isEmpty()) {
QSvgStyleProperty *prop = node->styleProperty(link);
//qDebug()<<"inherited "<<prop<<" ("<<link<<")";
if (prop && prop->type() == QSvgStyleProperty::GRADIENT) {
@@ -2972,8 +2942,8 @@ static QSvgNode *createPathNode(QSvgNode *parent,
QPainterPath qpath;
qpath.setFillRule(Qt::WindingFill);
- //XXX do error handling
- parsePathDataFast(data, qpath);
+ if (!parsePathDataFast(data, qpath))
+ qCWarning(lcSvgHandler, "Invalid path data; path truncated.");
QSvgNode *path = new QSvgPath(parent, qpath);
return path;
@@ -2988,7 +2958,7 @@ static QSvgNode *createPolygonNode(QSvgNode *parent,
//same QPolygon parsing is in createPolylineNode
const QChar *s = pointsStr.constData();
QList<qreal> points = parseNumbersList(s);
- QPolygonF poly(points.count()/2);
+ QPolygonF poly(points.size()/2);
for (int i = 0; i < poly.size(); ++i)
poly[i] = QPointF(points.at(2 * i), points.at(2 * i + 1));
QSvgNode *polygon = new QSvgPolygon(parent, poly);
@@ -3004,7 +2974,7 @@ static QSvgNode *createPolylineNode(QSvgNode *parent,
//same QPolygon parsing is in createPolygonNode
const QChar *s = pointsStr.constData();
QList<qreal> points = parseNumbersList(s);
- QPolygonF poly(points.count()/2);
+ QPolygonF poly(points.size()/2);
for (int i = 0; i < poly.size(); ++i)
poly[i] = QPointF(points.at(2 * i), points.at(2 * i + 1));
@@ -3170,12 +3140,12 @@ static bool parseStopNode(QSvgStyleProperty *parent,
cssNode.ptr = &anim;
QList<QCss::Declaration> decls = handler->selector()->declarationsForNode(cssNode);
- for (int i = 0; i < decls.count(); ++i) {
+ for (int i = 0; i < decls.size(); ++i) {
const QCss::Declaration &decl = decls.at(i);
if (decl.d->property.isEmpty())
continue;
- if (decl.d->values.count() != 1)
+ if (decl.d->values.size() != 1)
continue;
QCss::Value val = decl.d->values.first();
QString valueStr = val.toString();
@@ -3283,7 +3253,7 @@ static QSvgNode *createSvgNode(QSvgNode *parent,
viewBoxStr = viewBoxStr.replace(QLatin1Char('\t'), QLatin1Char(','));
viewBoxValues = viewBoxStr.split(QLatin1Char(','), Qt::SkipEmptyParts);
}
- if (viewBoxValues.count() == 4) {
+ if (viewBoxValues.size() == 4) {
QString xStr = viewBoxValues.at(0).trimmed();
QString yStr = viewBoxValues.at(1).trimmed();
QString widthStr = viewBoxValues.at(2).trimmed();
@@ -3337,7 +3307,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
//### editable and rotate not handled
QSvgHandler::LengthType type;
qreal nx = parseLength(x.toString(), type, handler);
+ nx = convertToPixels(nx, true, type);
qreal ny = parseLength(y.toString(), type, handler);
+ ny = convertToPixels(ny, true, type);
QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
return text;
@@ -3379,7 +3351,7 @@ static QSvgNode *createUseNode(QSvgNode *parent,
QString linkId = attributes.value(QLatin1String("xlink:href")).toString().remove(0, 1);
const QStringView xStr = attributes.value(QLatin1String("x"));
const QStringView yStr = attributes.value(QLatin1String("y"));
- QSvgStructureNode *group = 0;
+ QSvgStructureNode *group = nullptr;
if (linkId.isEmpty())
linkId = attributes.value(QLatin1String("href")).toString().remove(0, 1);
@@ -3437,7 +3409,7 @@ static FactoryMethod findGroupFactory(const QString &name)
if (name.isEmpty())
return 0;
- QStringView ref = QStringView{name}.mid(1, name.length() - 1);
+ QStringView ref = QStringView{name}.mid(1, name.size() - 1);
switch (name.at(0).unicode()) {
case 'd':
if (ref == QLatin1String("efs")) return createDefsNode;
@@ -3460,7 +3432,7 @@ static FactoryMethod findGraphicsFactory(const QString &name)
if (name.isEmpty())
return 0;
- QStringView ref = QStringView{name}.mid(1, name.length() - 1);
+ QStringView ref = QStringView{name}.mid(1, name.size() - 1);
switch (name.at(0).unicode()) {
case 'a':
if (ref == QLatin1String("nimation")) return createAnimationNode;
@@ -3509,7 +3481,7 @@ static ParseMethod findUtilFactory(const QString &name)
if (name.isEmpty())
return 0;
- QStringView ref = QStringView{name}.mid(1, name.length() - 1);
+ QStringView ref = QStringView{name}.mid(1, name.size() - 1);
switch (name.at(0).unicode()) {
case 'a':
if (ref.isEmpty()) return parseAnchorNode;
@@ -3561,7 +3533,7 @@ static StyleFactoryMethod findStyleFactoryMethod(const QString &name)
if (name.isEmpty())
return 0;
- QStringView ref = QStringView{name}.mid(1, name.length() - 1);
+ QStringView ref = QStringView{name}.mid(1, name.size() - 1);
switch (name.at(0).unicode()) {
case 'f':
if (ref == QLatin1String("ont")) return createFontNode;
@@ -3590,7 +3562,7 @@ static StyleParseMethod findStyleUtilFactoryMethod(const QString &name)
if (name.isEmpty())
return 0;
- QStringView ref = QStringView{name}.mid(1, name.length() - 1);
+ QStringView ref = QStringView{name}.mid(1, name.size() - 1);
switch (name.at(0).unicode()) {
case 'f':
if (ref == QLatin1String("ont-face")) return parseFontFaceNode;
@@ -3671,16 +3643,14 @@ void QSvgHandler::parse()
--remainingUnfinishedElements;
} else {
delete m_doc;
- m_doc = 0;
+ m_doc = nullptr;
return;
}
break;
case QXmlStreamReader::EndElement:
endElement(xml->name());
++remainingUnfinishedElements;
- // if we are using somebody else's qxmlstreamreader
- // we should not read until the end of the stream
- done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
+ done = (xml->name() == QLatin1String("svg"));
break;
case QXmlStreamReader::Characters:
characters(xml->text());
@@ -3699,7 +3669,7 @@ void QSvgHandler::parse()
bool QSvgHandler::startElement(const QString &localName,
const QXmlStreamAttributes &attributes)
{
- QSvgNode *node = 0;
+ QSvgNode *node = nullptr;
pushColorCopy();
@@ -3812,8 +3782,9 @@ bool QSvgHandler::startElement(const QString &localName,
} else if (node->type() == QSvgNode::TSPAN) {
static_cast<QSvgTspan *>(node)->setWhitespaceMode(m_whitespaceMode.top());
} else if (node->type() == QSvgNode::USE) {
- if (!static_cast<QSvgUse *>(node)->isResolved())
- m_resolveNodes.append(node);
+ auto useNode = static_cast<QSvgUse *>(node);
+ if (!useNode->isResolved())
+ m_toBeResolved.append(useNode);
}
}
}
@@ -3920,17 +3891,16 @@ void QSvgHandler::resolveGradients(QSvgNode *node, int nestedDepth)
void QSvgHandler::resolveNodes()
{
- for (QSvgNode *node : qAsConst(m_resolveNodes)) {
- if (!node || !node->parent() || node->type() != QSvgNode::USE)
- continue;
- QSvgUse *useNode = static_cast<QSvgUse *>(node);
- if (useNode->isResolved())
+ for (QSvgUse *useNode : std::as_const(m_toBeResolved)) {
+ const auto parent = useNode->parent();
+ if (!parent)
continue;
- QSvgNode::Type t = useNode->parent()->type();
- if (!(t == QSvgNode::DOC || t == QSvgNode::DEFS || t == QSvgNode::G || t == QSvgNode::SWITCH))
+
+ QSvgNode::Type t = parent->type();
+ if (t != QSvgNode::DOC && t != QSvgNode::DEFS && t != QSvgNode::G && t != QSvgNode::SWITCH)
continue;
- QSvgStructureNode *group = static_cast<QSvgStructureNode *>(useNode->parent());
+ QSvgStructureNode *group = static_cast<QSvgStructureNode *>(parent);
QSvgNode *link = group->scopeNode(useNode->linkId());
if (!link) {
qCWarning(lcSvgHandler, "link #%s is undefined!", qPrintable(useNode->linkId()));
@@ -3942,7 +3912,7 @@ void QSvgHandler::resolveNodes()
useNode->setLink(link);
}
- m_resolveNodes.clear();
+ m_toBeResolved.clear();
}
bool QSvgHandler::characters(const QStringView str)
@@ -3973,7 +3943,7 @@ QIODevice *QSvgHandler::device() const
return xml->device();
}
-QSvgTinyDocument * QSvgHandler::document() const
+QSvgTinyDocument *QSvgHandler::document() const
{
return m_doc;
}
@@ -3996,7 +3966,7 @@ void QSvgHandler::pushColor(const QColor &color)
void QSvgHandler::pushColorCopy()
{
- if (m_colorTagCount.count())
+ if (m_colorTagCount.size())
++m_colorTagCount.top();
else
pushColor(Qt::black);
@@ -4004,7 +3974,7 @@ void QSvgHandler::pushColorCopy()
void QSvgHandler::popColor()
{
- if (m_colorTagCount.count()) {
+ if (m_colorTagCount.size()) {
if (!--m_colorTagCount.top()) {
m_colorStack.pop();
m_colorTagCount.pop();
diff --git a/src/svg/qsvghandler_p.h b/src/svg/qsvghandler_p.h
index 86b9fa4..bea6a34 100644
--- a/src/svg/qsvghandler_p.h
+++ b/src/svg/qsvghandler_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGHANDLER_P_H
#define QSVGHANDLER_P_H
@@ -56,7 +20,9 @@
#include "QtCore/qstack.h"
#include <QtCore/QLoggingCategory>
#include "qsvgstyle_p.h"
+#if QT_CONFIG(cssparser)
#include "private/qcssparser_p.h"
+#endif
#include "qsvggraphics_p.h"
#include "qtsvgglobal_p.h"
@@ -144,9 +110,10 @@ private:
void init();
QSvgTinyDocument *m_doc;
- QStack<QSvgNode*> m_nodes;
-
- QList<QSvgNode*> m_resolveNodes;
+ QStack<QSvgNode *> m_nodes;
+ // TODO: This is only needed during parsing, so it unnecessarily takes up space after that.
+ // Temporary container for <use> nodes which haven't been resolved yet.
+ QList<QSvgUse *> m_toBeResolved;
enum CurrentNode
{
diff --git a/src/svg/qsvgnode.cpp b/src/svg/qsvgnode.cpp
index 29fd4e5..31e5338 100644
--- a/src/svg/qsvgnode.cpp
+++ b/src/svg/qsvgnode.cpp
@@ -1,50 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgnode_p.h"
#include "qsvgtinydocument_p.h"
+#include <QLoggingCategory>
+
#include "qdebug.h"
#include "qstack.h"
+#include <QtGui/private/qoutlinemapper_p.h>
+
+#if !defined(QT_SVG_SIZE_LIMIT)
+# define QT_SVG_SIZE_LIMIT QT_RASTER_COORD_LIMIT
+#endif
+
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcSvgDraw)
+
QSvgNode::QSvgNode(QSvgNode *parent)
: m_parent(parent),
m_visible(true),
@@ -203,6 +177,11 @@ QSvgFillStyleProperty * QSvgNode::styleProperty(const QString &id) const
return doc ? doc->namedStyle(rid) : 0;
}
+QRectF QSvgNode::fastBounds(QPainter *p, QSvgExtraStates &states) const
+{
+ return bounds(p, states);
+}
+
QRectF QSvgNode::bounds(QPainter *, QSvgExtraStates &) const
{
return QRectF(0, 0, 0, 0);
@@ -239,7 +218,7 @@ QRectF QSvgNode::transformedBounds() const
QSvgTinyDocument * QSvgNode::document() const
{
- QSvgTinyDocument *doc = 0;
+ QSvgTinyDocument *doc = nullptr;
QSvgNode *node = const_cast<QSvgNode*>(this);
while (node && node->type() != QSvgNode::DOC) {
node = node->parent();
@@ -347,4 +326,20 @@ qreal QSvgNode::strokeWidth(QPainter *p)
return pen.widthF();
}
+bool QSvgNode::shouldDrawNode(QPainter *p, QSvgExtraStates &states) const
+{
+ static bool alwaysDraw = qEnvironmentVariableIntValue("QT_SVG_DISABLE_SIZE_LIMIT");
+ if (alwaysDraw)
+ return true;
+
+ QRectF brect = fastBounds(p, states);
+ if (brect.width() <= QT_SVG_SIZE_LIMIT && brect.height() <= QT_SVG_SIZE_LIMIT) {
+ return true;
+ } else {
+ qCWarning(lcSvgDraw) << "Shape of type" << type() << "ignored because it will take too long to rasterize (bounding rect=" << brect << ")."
+ << "Set QT_SVG_DISABLE_SIZE_LIMIT=1 to disable this check.";
+ return false;
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/svg/qsvgnode_p.h b/src/svg/qsvgnode_p.h
index f2502e4..df9ef8a 100644
--- a/src/svg/qsvgnode_p.h
+++ b/src/svg/qsvgnode_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGNODE_P_H
#define QSVGNODE_P_H
@@ -124,6 +88,7 @@ public:
QSvgTinyDocument *document() const;
virtual Type type() const =0;
+ virtual QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const;
virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const;
QRectF transformedBounds() const;
@@ -154,6 +119,8 @@ public:
QString xmlClass() const;
void setXmlClass(const QString &str);
+
+ bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const;
protected:
mutable QSvgStyle m_style;
diff --git a/src/svg/qsvgrenderer.cpp b/src/svg/qsvgrenderer.cpp
index 53e6ec7..4342583 100644
--- a/src/svg/qsvgrenderer.cpp
+++ b/src/svg/qsvgrenderer.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgrenderer.h"
diff --git a/src/svg/qsvgrenderer.h b/src/svg/qsvgrenderer.h
index 418da85..e5610e5 100644
--- a/src/svg/qsvgrenderer.h
+++ b/src/svg/qsvgrenderer.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGRENDERER_H
#define QSVGRENDERER_H
diff --git a/src/svg/qsvgstructure.cpp b/src/svg/qsvgstructure.cpp
index 89c9e4e..b4ac368 100644
--- a/src/svg/qsvgstructure.cpp
+++ b/src/svg/qsvgstructure.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgstructure_p.h"
@@ -254,12 +218,12 @@ inline static bool isSupportedSvgFeature(const QString &str)
"http://www.w3.org/Graphics/SVG/feature/1.2/#ExternalResourcesRequiredAttribute"
};
- if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
+ if (str.size() <= MAX_WORD_LENGTH && str.size() >= MIN_WORD_LENGTH) {
const char16_t unicode44 = str.at(44).unicode();
const char16_t unicode45 = str.at(45).unicode();
if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
return false;
- const int key = str.length()
+ const int key = str.size()
+ asso_values[unicode45]
+ asso_values[unicode44];
if (key <= MAX_HASH_VALUE && key >= 0)
@@ -364,7 +328,7 @@ QRectF QSvgStructureNode::bounds(QPainter *p, QSvgExtraStates &states) const
QRectF bounds;
if (!m_recursing) {
QScopedValueRollback<bool> guard(m_recursing, true);
- for (QSvgNode *node : qAsConst(m_renderers))
+ for (QSvgNode *node : std::as_const(m_renderers))
bounds |= node->transformedBounds(p, states);
}
return bounds;
@@ -372,7 +336,7 @@ QRectF QSvgStructureNode::bounds(QPainter *p, QSvgExtraStates &states) const
QSvgNode * QSvgStructureNode::previousSiblingNode(QSvgNode *n) const
{
- QSvgNode *prev = 0;
+ QSvgNode *prev = nullptr;
QList<QSvgNode*>::const_iterator itr = m_renderers.constBegin();
for (; itr != m_renderers.constEnd(); ++itr) {
QSvgNode *node = *itr;
diff --git a/src/svg/qsvgstructure_p.h b/src/svg/qsvgstructure_p.h
index 6b69364..f2c0c0f 100644
--- a/src/svg/qsvgstructure_p.h
+++ b/src/svg/qsvgstructure_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGSTRUCTURE_P_H
#define QSVGSTRUCTURE_P_H
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index e82d89c..604b4e4 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgstyle_p.h"
@@ -158,7 +122,7 @@ void QSvgFillStyle::setFillStyle(QSvgFillStyleProperty* style)
void QSvgFillStyle::setBrush(QBrush brush)
{
m_fill = std::move(brush);
- m_style = 0;
+ m_style = nullptr;
m_fillSet = 1;
}
@@ -666,8 +630,8 @@ void QSvgAnimateTransform::setArgs(TransformType type, Additive additive, const
m_type = type;
m_args = args;
m_additive = additive;
- Q_ASSERT(!(args.count()%3));
- m_count = args.count() / 3;
+ Q_ASSERT(!(args.size()%3));
+ m_count = args.size() / 3;
}
void QSvgAnimateTransform::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &)
@@ -686,7 +650,6 @@ void QSvgAnimateTransform::revert(QPainter *p, QSvgExtraStates &)
void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
{
- static const qreal deg2rad = qreal(0.017453292519943295769);
qreal totalTimeElapsed = node->document()->currentElapsed();
if (totalTimeElapsed < m_from || m_finished)
return;
@@ -786,7 +749,7 @@ void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
qreal transXDiff = (to1-from1) * percentOfAnimation;
qreal transX = from1 + transXDiff;
m_transform = QTransform();
- m_transform.shear(qTan(transX * deg2rad), 0);
+ m_transform.shear(qTan(qDegreesToRadians(transX)), 0);
break;
}
case SkewY: {
@@ -801,7 +764,7 @@ void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
qreal transYDiff = (to1 - from1) * percentOfAnimation;
qreal transY = from1 + transYDiff;
m_transform = QTransform();
- m_transform.shear(0, qTan(transY * deg2rad));
+ m_transform.shear(0, qTan(qDegreesToRadians(transY)));
break;
}
default:
@@ -873,7 +836,7 @@ void QSvgAnimateColor::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates
percentOfAnimation -= ((int)percentOfAnimation);
}
- qreal currentPosition = percentOfAnimation * (m_colors.count() - 1);
+ qreal currentPosition = percentOfAnimation * (m_colors.size() - 1);
int startElem = qFloor(currentPosition);
int endElem = qCeil(currentPosition);
diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h
index 8664f7a..20bd6d5 100644
--- a/src/svg/qsvgstyle_p.h
+++ b/src/svg/qsvgstyle_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGSTYLE_P_H
#define QSVGSTYLE_P_H
@@ -70,7 +34,7 @@ class QSvgTinyDocument;
template <class T> class QSvgRefCounter
{
public:
- QSvgRefCounter() { t = 0; }
+ QSvgRefCounter() { t = nullptr; }
QSvgRefCounter(T *_t)
{
t = _t;
@@ -221,7 +185,7 @@ private:
// 'inherit'
qint32 m_imageRendering: 4;
qint32 m_oldImageRendering: 4;
- qint32 m_imageRenderingSet: 1;
+ quint32 m_imageRenderingSet: 1;
};
@@ -424,7 +388,7 @@ public:
void setStroke(QBrush brush)
{
m_stroke.setBrush(brush);
- m_style = 0;
+ m_style = nullptr;
m_strokeSet = 1;
}
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
index 63d0797..49a796c 100644
--- a/src/svg/qsvgtinydocument.cpp
+++ b/src/svg/qsvgtinydocument.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgtinydocument_p.h"
@@ -202,7 +166,7 @@ QSvgTinyDocument * QSvgTinyDocument::load(const QString &fileName)
return load(qt_inflateSvgzDataFrom(&file));
}
- QSvgTinyDocument *doc = 0;
+ QSvgTinyDocument *doc = nullptr;
QSvgHandler handler(&file);
if (handler.ok()) {
doc = handler.document();
@@ -248,7 +212,7 @@ QSvgTinyDocument * QSvgTinyDocument::load(QXmlStreamReader *contents)
{
QSvgHandler handler(contents);
- QSvgTinyDocument *doc = 0;
+ QSvgTinyDocument *doc = nullptr;
if (handler.ok()) {
doc = handler.document();
doc->m_animationDuration = handler.animationDuration();
@@ -433,8 +397,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
draw(p);
}
+static bool isValidMatrix(const QTransform &transform)
+{
+ qreal determinant = transform.determinant();
+ return qIsFinite(determinant);
+}
+
void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
{
+ QTransform oldTransform = p->worldTransform();
+
QRectF target = targetRect;
if (target.isEmpty()) {
QPaintDevice *dev = p->device();
@@ -454,10 +426,8 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
source = viewBox();
if (source != target && !qFuzzyIsNull(source.width()) && !qFuzzyIsNull(source.height())) {
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
if (m_implicitViewBox || !preserveAspectRatio()) {
// Code path used when no view box is set, or IgnoreAspectRatio requested
-#endif
QTransform transform;
transform.scale(target.width() / source.width(),
target.height() / source.height());
@@ -466,7 +436,6 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
target.y() - c2.y());
p->scale(target.width() / source.width(),
target.height() / source.height());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
} else {
// Code path used when KeepAspectRatio is requested. This attempts to emulate the default values
// of the <preserveAspectRatio tag that's implicitly defined when <viewbox> is used.
@@ -485,8 +454,10 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
// Apply the view box translation if specified.
p->translate(-source.x(), -source.y());
}
-#endif
}
+
+ if (!isValidMatrix(p->worldTransform()))
+ p->setWorldTransform(oldTransform);
}
QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
diff --git a/src/svg/qsvgtinydocument_p.h b/src/svg/qsvgtinydocument_p.h
index d4b92e8..99984f5 100644
--- a/src/svg/qsvgtinydocument_p.h
+++ b/src/svg/qsvgtinydocument_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGTINYDOCUMENT_P_H
#define QSVGTINYDOCUMENT_P_H
diff --git a/src/svg/qt_attribution.json b/src/svg/qt_attribution.json
index 9b17698..f0fc05c 100644
--- a/src/svg/qt_attribution.json
+++ b/src/svg/qt_attribution.json
@@ -3,7 +3,7 @@
"Name": "XSVG",
"QDocModule": "qtsvg",
"QtUsage": "Used in the Qt SVG library.",
- "Files": "qtsvghandler.cpp",
+ "Files": "qsvghandler.cpp",
"Description": "Some code for arc handling is derived from code from the XSVG project.",
"License": "Historical Permission Notice and Disclaimer - sell variant",
diff --git a/src/svg/qtsvgglobal.h b/src/svg/qtsvgglobal.h
index 92075c9..985a7aa 100644
--- a/src/svg/qtsvgglobal.h
+++ b/src/svg/qtsvgglobal.h
@@ -1,61 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTSVGGLOBAL_H
#define QTSVGGLOBAL_H
#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef Q_SVG_EXPORT
-# ifndef QT_STATIC
-# if defined(QT_BUILD_SVG_LIB)
-# define Q_SVG_EXPORT Q_DECL_EXPORT
-# else
-# define Q_SVG_EXPORT Q_DECL_IMPORT
-# endif
-# else
-# define Q_SVG_EXPORT
-# endif
-#endif
-
-QT_END_NAMESPACE
+#include <QtSvg/qtsvgexports.h>
#endif
diff --git a/src/svg/qtsvgglobal_p.h b/src/svg/qtsvgglobal_p.h
index ff93a36..f82ee60 100644
--- a/src/svg/qtsvgglobal_p.h
+++ b/src/svg/qtsvgglobal_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTSVGGLOBAL_P_H
#define QTSVGGLOBAL_P_H
@@ -52,7 +16,6 @@
//
#include "qtsvgglobal.h"
-
-#define Q_SVG_PRIVATE_EXPORT Q_SVG_EXPORT
+#include <QtSvg/private/qtsvgexports_p.h>
#endif // QTSVGGLOBAL_P_H
diff --git a/src/svgwidgets/CMakeLists.txt b/src/svgwidgets/CMakeLists.txt
index 5f2ae6f..8708799 100644
--- a/src/svgwidgets/CMakeLists.txt
+++ b/src/svgwidgets/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from svgwidgets.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## SvgWidgets Module:
@@ -6,7 +7,6 @@
qt_internal_add_module(SvgWidgets
SOURCES
- qgraphicssvgitem.cpp qgraphicssvgitem.h
qsvgwidget.cpp qsvgwidget.h
qtsvgwidgetsglobal.h
DEFINES
@@ -24,6 +24,12 @@ qt_internal_add_module(SvgWidgets
Qt::CorePrivate
Qt::GuiPrivate
Qt::WidgetsPrivate
+ GENERATE_CPP_EXPORTS
+)
+
+qt_internal_extend_target(SvgWidgets CONDITION QT_FEATURE_graphicsview
+ SOURCES
+ qgraphicssvgitem.cpp qgraphicssvgitem.h
)
## Scopes:
diff --git a/src/svgwidgets/qgraphicssvgitem.cpp b/src/svgwidgets/qgraphicssvgitem.cpp
index 667f765..f2dc497 100644
--- a/src/svgwidgets/qgraphicssvgitem.cpp
+++ b/src/svgwidgets/qgraphicssvgitem.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qgraphicssvgitem.h"
#if !defined(QT_NO_GRAPHICSVIEW)
@@ -305,7 +269,7 @@ void QGraphicsSvgItem::setSharedRenderer(QSvgRenderer *renderer)
}
/*!
- \obsolete
+ \deprecated
Use QGraphicsItem::setCacheMode() instead. Passing true to this function is equivalent
to QGraphicsItem::setCacheMode(QGraphicsItem::DeviceCoordinateCache).
@@ -316,7 +280,7 @@ void QGraphicsSvgItem::setCachingEnabled(bool caching)
}
/*!
- \obsolete
+ \deprecated
Use QGraphicsItem::cacheMode() instead.
*/
diff --git a/src/svgwidgets/qgraphicssvgitem.h b/src/svgwidgets/qgraphicssvgitem.h
index fa2db61..b0e2a0f 100644
--- a/src/svgwidgets/qgraphicssvgitem.h
+++ b/src/svgwidgets/qgraphicssvgitem.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QGRAPHICSSVGITEM_H
#define QGRAPHICSSVGITEM_H
diff --git a/src/svgwidgets/qsvgwidget.cpp b/src/svgwidgets/qsvgwidget.cpp
index c043d39..a57bf04 100644
--- a/src/svgwidgets/qsvgwidget.cpp
+++ b/src/svgwidgets/qsvgwidget.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsvgwidget.h"
diff --git a/src/svgwidgets/qsvgwidget.h b/src/svgwidgets/qsvgwidget.h
index 5e4cecd..88cf452 100644
--- a/src/svgwidgets/qsvgwidget.h
+++ b/src/svgwidgets/qsvgwidget.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSVGWIDGET_H
#define QSVGWIDGET_H
diff --git a/src/svgwidgets/qtsvgwidgetsglobal.h b/src/svgwidgets/qtsvgwidgetsglobal.h
index 9802247..44a0bf8 100644
--- a/src/svgwidgets/qtsvgwidgetsglobal.h
+++ b/src/svgwidgets/qtsvgwidgetsglobal.h
@@ -1,61 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt SVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTSVGWIDGETSGLOBAL_H
#define QTSVGWIDGETSGLOBAL_H
#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef Q_SVGWIDGETS_EXPORT
-# ifndef QT_STATIC
-# if defined(QT_BUILD_SVGWIDGETS_LIB)
-# define Q_SVGWIDGETS_EXPORT Q_DECL_EXPORT
-# else
-# define Q_SVGWIDGETS_EXPORT Q_DECL_IMPORT
-# endif
-# else
-# define Q_SVGWIDGETS_EXPORT
-# endif
-#endif
-
-QT_END_NAMESPACE
+#include <QtSvgWidgets/qtsvgwidgetsexports.h>
#endif