commit:     0e5cc81dff45a27728ebe6611a061d3d8e7e3d11
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 14 09:33:20 2019 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Thu Nov 14 09:33:20 2019 +0000
URL:        https://gitweb.gentoo.org/proj/qt.git/commit/?id=0e5cc81d

dev-qt/qtsvg: Fix misplaced icons

See also: https://bugreports.qt.io/browse/QTBUG-79933

Package-Manager: Portage-2.3.79, Repoman-2.3.18
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../qtsvg-5.14.0_beta3-allow-remove-viewbox.patch  |  32 +++++++
 .../files/qtsvg-5.14.0_beta3-fix-scaling.patch     | 100 +++++++++++++++++++++
 dev-qt/qtsvg/qtsvg-5.14.0_beta3.ebuild             |   5 ++
 3 files changed, 137 insertions(+)

diff --git a/dev-qt/qtsvg/files/qtsvg-5.14.0_beta3-allow-remove-viewbox.patch 
b/dev-qt/qtsvg/files/qtsvg-5.14.0_beta3-allow-remove-viewbox.patch
new file mode 100644
index 00000000..0e9c37ef
--- /dev/null
+++ b/dev-qt/qtsvg/files/qtsvg-5.14.0_beta3-allow-remove-viewbox.patch
@@ -0,0 +1,32 @@
+From beb0d74195ddc642524fe1f5a2d65d944527d1b5 Mon Sep 17 00:00:00 2001
+From: Alessandro Portale <[email protected]>
+Date: Wed, 13 Nov 2019 00:02:50 +0100
+Subject: [PATCH] QSvgRenderer: Allow to remove a viewBox
+
+m_implicitViewBox needs to be true if the explicit viewBox is null. That
+relationship between m_viewBox and m_implicitViewBox can be see in
+QSvgTinyDocument::viewBox().
+
+Task-number: QTBUG-79933
+Change-Id: I6ea5a849479b10117128bcaf1799e3770b145e77
+Reviewed-by: Simon Hausmann <[email protected]>
+---
+ src/svg/qsvgtinydocument.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
+index 7e355086..a2bf1c77 100644
+--- a/src/svg/qsvgtinydocument.cpp
++++ b/src/svg/qsvgtinydocument.cpp
+@@ -338,7 +338,7 @@ void QSvgTinyDocument::setHeight(int len, bool percent)
+ void QSvgTinyDocument::setViewBox(const QRectF &rect)
+ {
+     m_viewBox = rect;
+-    m_implicitViewBox = false;
++    m_implicitViewBox = rect.isNull();
+ }
+ 
+ void QSvgTinyDocument::addSvgFont(QSvgFont *font)
+-- 
+2.16.3
+

diff --git a/dev-qt/qtsvg/files/qtsvg-5.14.0_beta3-fix-scaling.patch 
b/dev-qt/qtsvg/files/qtsvg-5.14.0_beta3-fix-scaling.patch
new file mode 100644
index 00000000..54c46842
--- /dev/null
+++ b/dev-qt/qtsvg/files/qtsvg-5.14.0_beta3-fix-scaling.patch
@@ -0,0 +1,100 @@
+From e489a325769d295ee3b3948d98f5d07814dffd97 Mon Sep 17 00:00:00 2001
+From: Alessandro Portale <[email protected]>
+Date: Tue, 12 Nov 2019 22:10:34 +0100
+Subject: [PATCH] Re-fix scaling when rendering a specific element by id
+
+This is a modification of 14fa4591eb34a35cf3d485fd901e3f1e2caa7770
+
+That patch corrected the handling of the view box when rendering an
+entire SVG document. However, contrary to intention stated in the
+comment of that patch, it turns out that the new viewbox handling code
+path can be taken also for the case of rendering only a single element
+by id. Instead, we want to keep the original behavior where the
+element's origin bounds are transformed to fit into the user requested
+target bounds, allowing non-proportional scaling.
+
+Since the render-single-element case is easily and uniqely
+identifiable by the sourceRect parameter being non-null, just add an
+explicit check for that to the code path branching.
+
+Done-with: Eirik Aavitsland <[email protected]>
+Fixes: QTBUG-79933
+Change-Id: I64a35bbb193db22c33670b48ea165a91df8e719e
+Reviewed-by: Simon Hausmann <[email protected]>
+---
+ src/svg/qsvgtinydocument.cpp                 |  4 +++-
+ tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp | 36 ++++++++++++++++++++++++++++
+ 2 files changed, 39 insertions(+), 1 deletion(-)
+
+diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
+index a2bf1c77..56960bff 100644
+--- a/src/svg/qsvgtinydocument.cpp
++++ b/src/svg/qsvgtinydocument.cpp
+@@ -420,7 +420,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, 
const QRectF &targetRect,
+         source = viewBox();
+ 
+     if (source != target && !source.isNull()) {
+-        if (m_implicitViewBox) {
++        if (m_implicitViewBox || !sourceRect.isNull()) {
++            // Code path used when no view box is set, or when an explicit 
source size is given which
++            // overrides it (which is the case when we're rendering only a 
specific element by id).
+             QTransform transform;
+             transform.scale(target.width() / source.width(),
+                             target.height() / source.height());
+diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp 
b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index eb3ecbaf..309c646e 100644
+--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -59,6 +59,7 @@ private slots:
+     void testStrokeWidth();
+     void testMapViewBoxToTarget();
+     void testRenderElement();
++    void testRenderElementToBounds();
+     void constructorQXmlStreamReader() const;
+     void loadQXmlStreamReader() const;
+     void nestedQXmlStreamReader() const;
+@@ -336,6 +337,41 @@ void tst_QSvgRenderer::testRenderElement()
+ 
+ }
+ 
++void tst_QSvgRenderer::testRenderElementToBounds()
++{
++    // QTBUG-79933
++    QImage reference(400, 200, QImage::Format_ARGB32);
++    {
++        reference.fill(Qt::transparent);
++        QPainter p(&reference);
++        p.fillRect(  0,   0, 200, 100, Qt::blue);
++        p.fillRect(200, 100, 200, 100, Qt::blue);
++        p.fillRect(  0,   0, 100,  50, Qt::red);
++        p.fillRect(100,  50, 100,  50, Qt::red);
++        p.fillRect(200, 100, 100,  50, Qt::red);
++        p.fillRect(300, 150, 100,  50, Qt::red);
++    }
++
++    QImage rendering(400, 200, QImage::Format_ARGB32);
++    {
++        const char *const src =
++                "<svg viewBox=\"0 0 100 100\">" // Presence of a viewBox 
triggered QTBUG-79933
++                "<path id=\"el1\" d=\"M 80,10 H 0 V 0 h 40 v 20 h 40 z\" 
fill=\"red\" />"
++                "<path id=\"el2\" d=\"M 90,100 V 20 h 10 V 60 H 80 v 40 z\" 
fill=\"blue\" />"
++                "</svg>";
++        const QByteArray data(src);
++        QSvgRenderer rend(data);
++        rendering.fill(Qt::transparent);
++        QPainter p(&rendering);
++        rend.render(&p, "el1", QRectF(  0,   0, 200, 100));
++        rend.render(&p, "el2", QRectF(  0,   0, 200, 100));
++        rend.render(&p, "el1", QRectF(200, 100, 200, 100));
++        rend.render(&p, "el2", QRectF(200, 100, 200, 100));
++    }
++
++    QCOMPARE(reference, rendering);
++}
++
+ void tst_QSvgRenderer::constructorQXmlStreamReader() const
+ {
+     const QByteArray data(src);
+-- 
+2.16.3
+

diff --git a/dev-qt/qtsvg/qtsvg-5.14.0_beta3.ebuild 
b/dev-qt/qtsvg/qtsvg-5.14.0_beta3.ebuild
index f143da2e..14a6cc24 100644
--- a/dev-qt/qtsvg/qtsvg-5.14.0_beta3.ebuild
+++ b/dev-qt/qtsvg/qtsvg-5.14.0_beta3.ebuild
@@ -21,3 +21,8 @@ RDEPEND="
 DEPEND="${RDEPEND}
        test? ( ~dev-qt/qtxml-${PV} )
 "
+
+PATCHES=(
+       "${FILESDIR}/${P}-fix-scaling.patch" # QTBUG-79933
+       "${FILESDIR}/${P}-allow-remove-viewbox.patch" # QTBUG-79933
+)

Reply via email to