svgio: factor out common code

Change-Id: Ib86f04364593546f53419b37d35469c561561aa1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166188
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli
2024-04-18 17:24:10 +02:00
parent 830ec75f2f
commit 176406a07e
4 changed files with 28 additions and 44 deletions
+3
View File
@@ -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
+2 -19
View File
@@ -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()),
+2 -25
View File
@@ -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()),
+21
View File
@@ -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: */