svgio/inc/svgfilternode.hxx                   |    3 ++
 svgio/source/svgreader/svgfeblendnode.cxx     |   21 +-------------------
 svgio/source/svgreader/svgfecompositenode.cxx |   27 +-------------------------
 svgio/source/svgreader/svgfilternode.cxx      |   21 ++++++++++++++++++++
 4 files changed, 28 insertions(+), 44 deletions(-)

New commits:
commit 176406a07edc29f59a67464c7812358f46421f4d
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Apr 17 22:08:31 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Apr 18 17:24:10 2024 +0200

    svgio: factor out common code
    
    Change-Id: Ib86f04364593546f53419b37d35469c561561aa1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166188
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/svgio/inc/svgfilternode.hxx b/svgio/inc/svgfilternode.hxx
index 7aa522173a87..ec42d3c52df4 100644
--- a/svgio/inc/svgfilternode.hxx
+++ b/svgio/inc/svgfilternode.hxx
@@ -23,6 +23,7 @@
 #include "svgnode.hxx"
 #include "svgstyleattributes.hxx"
 #include <basegfx/matrix/b2dhommatrix.hxx>
+#include <vcl/bitmapex.hxx>
 
 typedef std::unordered_map<OUString, 
drawinglayer::primitive2d::Primitive2DContainer>
     IdGraphicSourceMapper;
@@ -46,6 +47,8 @@ public:
                              drawinglayer::primitive2d::Primitive2DContainer 
pGraphicSource) const;
     const drawinglayer::primitive2d::Primitive2DContainer*
     findGraphicSource(const OUString& rStr) const;
+
+    static BitmapEx convertToBitmapEx(const 
drawinglayer::primitive2d::Primitive2DContainer* pSeq);
 };
 
 } // end of namespace svgio::svgreader
diff --git a/svgio/source/svgreader/svgfeblendnode.cxx 
b/svgio/source/svgreader/svgfeblendnode.cxx
index d106ea6e643b..e1440185ff23 100644
--- a/svgio/source/svgreader/svgfeblendnode.cxx
+++ b/svgio/source/svgreader/svgfeblendnode.cxx
@@ -111,15 +111,7 @@ void 
SvgFeBlendNode::apply(drawinglayer::primitive2d::Primitive2DContainer& rTar
         {
             const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
             aRange = pSource->getB2DRange(aViewInformation2D);
-            basegfx::B2DHomMatrix aEmbedding(
-                basegfx::utils::createTranslateB2DHomMatrix(-aRange.getMinX(), 
-aRange.getMinY()));
-            aEmbedding.scale(aRange.getWidth(), aRange.getHeight());
-            const drawinglayer::primitive2d::Primitive2DReference xEmbedRef(
-                new drawinglayer::primitive2d::TransformPrimitive2D(
-                    aEmbedding, 
drawinglayer::primitive2d::Primitive2DContainer(*pSource)));
-            drawinglayer::primitive2d::Primitive2DContainer xEmbedSeq{ 
xEmbedRef };
-            aBmpEx = drawinglayer::convertToBitmapEx(std::move(xEmbedSeq), 
aViewInformation2D,
-                                                     aRange.getWidth(), 
aRange.getHeight(), 500000);
+            aBmpEx = convertToBitmapEx(pSource);
         }
 
         if (const drawinglayer::primitive2d::Primitive2DContainer* pSource2
@@ -127,16 +119,7 @@ void 
SvgFeBlendNode::apply(drawinglayer::primitive2d::Primitive2DContainer& rTar
         {
             const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
             aRange2 = pSource2->getB2DRange(aViewInformation2D);
-            basegfx::B2DHomMatrix 
aEmbedding(basegfx::utils::createTranslateB2DHomMatrix(
-                -aRange2.getMinX(), -aRange2.getMinY()));
-            aEmbedding.scale(aRange2.getWidth(), aRange2.getHeight());
-            const drawinglayer::primitive2d::Primitive2DReference xEmbedRef(
-                new drawinglayer::primitive2d::TransformPrimitive2D(
-                    aEmbedding, 
drawinglayer::primitive2d::Primitive2DContainer(*pSource2)));
-            drawinglayer::primitive2d::Primitive2DContainer xEmbedSeq{ 
xEmbedRef };
-            aBmpEx2
-                = drawinglayer::convertToBitmapEx(std::move(xEmbedSeq), 
aViewInformation2D,
-                                                  aRange2.getWidth(), 
aRange2.getHeight(), 500000);
+            aBmpEx2 = convertToBitmapEx(pSource2);
         }
 
         basegfx::B2DRectangle aBaseRect(std::min(aRange.getMinX(), 
aRange2.getMinX()),
diff --git a/svgio/source/svgreader/svgfecompositenode.cxx 
b/svgio/source/svgreader/svgfecompositenode.cxx
index 28f161d7b6ce..c396eec78c0a 100644
--- a/svgio/source/svgreader/svgfecompositenode.cxx
+++ b/svgio/source/svgreader/svgfecompositenode.cxx
@@ -216,18 +216,7 @@ void 
SvgFeCompositeNode::apply(drawinglayer::primitive2d::Primitive2DContainer&
         {
             const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
             aRange = pSource->getB2DRange(aViewInformation2D);
-            basegfx::B2DHomMatrix aEmbedding(
-                basegfx::utils::createTranslateB2DHomMatrix(-aRange.getMinX(), 
-aRange.getMinY()));
-
-            aEmbedding.scale(aRange.getWidth(), aRange.getHeight());
-
-            const drawinglayer::primitive2d::Primitive2DReference xEmbedRef(
-                new drawinglayer::primitive2d::TransformPrimitive2D(
-                    aEmbedding, 
drawinglayer::primitive2d::Primitive2DContainer(*pSource)));
-            drawinglayer::primitive2d::Primitive2DContainer xEmbedSeq{ 
xEmbedRef };
-
-            aBmpEx = drawinglayer::convertToBitmapEx(std::move(xEmbedSeq), 
aViewInformation2D,
-                                                     aRange.getWidth(), 
aRange.getHeight(), 500000);
+            aBmpEx = convertToBitmapEx(pSource);
         }
 
         if (const drawinglayer::primitive2d::Primitive2DContainer* pSource2
@@ -235,19 +224,7 @@ void 
SvgFeCompositeNode::apply(drawinglayer::primitive2d::Primitive2DContainer&
         {
             const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
             aRange2 = pSource2->getB2DRange(aViewInformation2D);
-            basegfx::B2DHomMatrix 
aEmbedding(basegfx::utils::createTranslateB2DHomMatrix(
-                -aRange2.getMinX(), -aRange2.getMinY()));
-
-            aEmbedding.scale(aRange2.getWidth(), aRange2.getHeight());
-
-            const drawinglayer::primitive2d::Primitive2DReference xEmbedRef(
-                new drawinglayer::primitive2d::TransformPrimitive2D(
-                    aEmbedding, 
drawinglayer::primitive2d::Primitive2DContainer(*pSource2)));
-            drawinglayer::primitive2d::Primitive2DContainer xEmbedSeq{ 
xEmbedRef };
-
-            aBmpEx2
-                = drawinglayer::convertToBitmapEx(std::move(xEmbedSeq), 
aViewInformation2D,
-                                                  aRange2.getWidth(), 
aRange2.getHeight(), 500000);
+            aBmpEx2 = convertToBitmapEx(pSource2);
         }
 
         basegfx::B2DRectangle aBaseRect(std::min(aRange.getMinX(), 
aRange2.getMinX()),
diff --git a/svgio/source/svgreader/svgfilternode.cxx 
b/svgio/source/svgreader/svgfilternode.cxx
index 5b2f7e867523..4b97563478e1 100644
--- a/svgio/source/svgreader/svgfilternode.cxx
+++ b/svgio/source/svgreader/svgfilternode.cxx
@@ -25,6 +25,10 @@
 #include <svgfegaussianblurnode.hxx>
 #include <svgfeoffsetnode.hxx>
 
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/converters.hxx>
+
 namespace svgio::svgreader
 {
 SvgFilterNode::SvgFilterNode(SVGToken aType, SvgDocument& rDocument, SvgNode* 
pParent)
@@ -91,6 +95,23 @@ SvgFilterNode::findGraphicSource(const OUString& rStr) const
     }
 }
 
+BitmapEx
+SvgFilterNode::convertToBitmapEx(const 
drawinglayer::primitive2d::Primitive2DContainer* pSeq)
+{
+    drawinglayer::primitive2d::Primitive2DContainer aSequence(*pSeq);
+
+    const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
+    basegfx::B2DRange aRange = aSequence.getB2DRange(aViewInformation2D);
+    basegfx::B2DHomMatrix aEmbedding(
+        basegfx::utils::createTranslateB2DHomMatrix(-aRange.getMinX(), 
-aRange.getMinY()));
+    aEmbedding.scale(aRange.getWidth(), aRange.getHeight());
+    const drawinglayer::primitive2d::Primitive2DReference xEmbedRef(
+        new drawinglayer::primitive2d::TransformPrimitive2D(aEmbedding, 
std::move(aSequence)));
+    drawinglayer::primitive2d::Primitive2DContainer xEmbedSeq{ xEmbedRef };
+    return drawinglayer::convertToBitmapEx(std::move(xEmbedSeq), 
aViewInformation2D,
+                                           aRange.getWidth(), 
aRange.getHeight(), 500000);
+}
+
 } // end of namespace svgio::svgreader
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to