diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-24 11:17:16 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-24 12:33:12 +0200 |
commit | 75399b8aad6c0f0998b9d0a6eddb2e29f8bc114c (patch) | |
tree | 02c834bff607acc6a8b5f7ec4c243454fdc5c8ac /svgio | |
parent | 85013c57dd29e32ec0411c159ea72824ebca5aa9 (diff) |
tdf#132246, tdf#155735: Add support for SourceAlpha
Change-Id: I8feae2447b17e15113ca45fe46c0d68cb6b6ab71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153550
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgfecolormatrixnode.hxx | 2 | ||||
-rw-r--r-- | svgio/inc/svgfegaussianblurnode.hxx | 14 | ||||
-rw-r--r-- | svgio/inc/svgfilternode.hxx | 6 | ||||
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 3 | ||||
-rw-r--r-- | svgio/qa/cppunit/data/filterFeGaussianBlur.svg | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfecolormatrixnode.cxx | 21 | ||||
-rw-r--r-- | svgio/source/svgreader/svgfegaussianblurnode.cxx | 18 |
7 files changed, 49 insertions, 17 deletions
diff --git a/svgio/inc/svgfecolormatrixnode.hxx b/svgio/inc/svgfecolormatrixnode.hxx index 78d8b027f653..d3fafb64e969 100644 --- a/svgio/inc/svgfecolormatrixnode.hxx +++ b/svgio/inc/svgfecolormatrixnode.hxx @@ -20,6 +20,7 @@ #pragma once #include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" #include <basegfx/matrix/b3dhommatrix.hxx> @@ -39,6 +40,7 @@ class SvgFeColorMatrixNode final : public SvgNode private: ColorType maType; OUString maValuesContent; + In maIn; public: SvgFeColorMatrixNode(SvgDocument& rDocument, SvgNode* pParent); diff --git a/svgio/inc/svgfegaussianblurnode.hxx b/svgio/inc/svgfegaussianblurnode.hxx index 5dec4463198f..68068d97ce93 100644 --- a/svgio/inc/svgfegaussianblurnode.hxx +++ b/svgio/inc/svgfegaussianblurnode.hxx @@ -20,24 +20,12 @@ #pragma once #include "svgnode.hxx" +#include "svgfilternode.hxx" #include "svgstyleattributes.hxx" #include <basegfx/matrix/b2dhommatrix.hxx> namespace svgio::svgreader { -/* -FIXME: If no value is provided and this is the first filter primitive, -then this filter primitive will use SourceGraphic as its input. -If no value is provided and this is a subsequent filter primitive, -then this filter primitive will use the result from the previous -filter primitive as its input. -*/ -enum class In -{ - None, - SourceGraphic -}; - class SvgFeGaussianBlurNode final : public SvgNode { private: diff --git a/svgio/inc/svgfilternode.hxx b/svgio/inc/svgfilternode.hxx index 19ce2cb34b33..520471501a11 100644 --- a/svgio/inc/svgfilternode.hxx +++ b/svgio/inc/svgfilternode.hxx @@ -25,6 +25,12 @@ namespace svgio::svgreader { +enum class In +{ + SourceGraphic, + SourceAlpha +}; + class SvgFilterNode final : public SvgNode { public: diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 8e7d86c145f2..651e1341521f 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -179,7 +179,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFilterFeGaussianBlur) CPPUNIT_ASSERT (pDocument); - assertXPath(pDocument, "/primitive2D/transform/softedge", "radius", "5"); + assertXPath(pDocument, "/primitive2D/transform/modifiedColor", "modifier", "alpha"); + assertXPath(pDocument, "/primitive2D/transform/modifiedColor/softedge", "radius", "5"); } CPPUNIT_TEST_FIXTURE(Test, testTdf87309) diff --git a/svgio/qa/cppunit/data/filterFeGaussianBlur.svg b/svgio/qa/cppunit/data/filterFeGaussianBlur.svg index e8fd73068a0b..917a7592d51d 100644 --- a/svgio/qa/cppunit/data/filterFeGaussianBlur.svg +++ b/svgio/qa/cppunit/data/filterFeGaussianBlur.svg @@ -4,7 +4,7 @@ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <filter id="blurMe"> - <feGaussianBlur in="SourceGraphic" stdDeviation="5"/> + <feGaussianBlur in="SourceAlpha" stdDeviation="5"/> </filter> <circle cx="170" cy="60" r="50" fill="green" filter="url(#blurMe)" /> </svg> diff --git a/svgio/source/svgreader/svgfecolormatrixnode.cxx b/svgio/source/svgreader/svgfecolormatrixnode.cxx index 5f8e03c4318b..7902144e8bc8 100644 --- a/svgio/source/svgreader/svgfecolormatrixnode.cxx +++ b/svgio/source/svgreader/svgfecolormatrixnode.cxx @@ -26,6 +26,7 @@ namespace svgio::svgreader SvgFeColorMatrixNode::SvgFeColorMatrixNode(SvgDocument& rDocument, SvgNode* pParent) : SvgNode(SVGToken::FeColorMatrix, rDocument, pParent) , maType(ColorType::None) + , maIn(In::SourceGraphic) { } @@ -65,6 +66,17 @@ void SvgFeColorMatrixNode::parseAttribute(const OUString& /*rTokenName*/, SVGTok maValuesContent = aContent; break; } + case SVGToken::In: + { + if (!aContent.isEmpty()) + { + if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"SourceAlpha")) + { + maIn = In::SourceAlpha; + } + } + break; + } default: { break; @@ -112,6 +124,15 @@ void SvgFeColorMatrixNode::apply(drawinglayer::primitive2d::Primitive2DContainer std::move(rTarget), std::make_shared<basegfx::BColorModifier_matrix>(aMatrix))); rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef }; } + + if (maIn == In::SourceAlpha) + { + const drawinglayer::primitive2d::Primitive2DReference xRef( + new drawinglayer::primitive2d::ModifiedColorPrimitive2D( + std::move(rTarget), std::make_shared<basegfx::BColorModifier_alpha>())); + + rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef }; + } } } // end of namespace svgio::svgreader diff --git a/svgio/source/svgreader/svgfegaussianblurnode.cxx b/svgio/source/svgreader/svgfegaussianblurnode.cxx index fff21345c4d8..7dbe808a484a 100644 --- a/svgio/source/svgreader/svgfegaussianblurnode.cxx +++ b/svgio/source/svgreader/svgfegaussianblurnode.cxx @@ -18,6 +18,7 @@ */ #include <svgfegaussianblurnode.hxx> +#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> #include <drawinglayer/primitive2d/softedgeprimitive2d.hxx> #include <o3tl/string_view.hxx> @@ -26,7 +27,7 @@ namespace svgio::svgreader SvgFeGaussianBlurNode::SvgFeGaussianBlurNode(SvgDocument& rDocument, SvgNode* pParent) : SvgNode(SVGToken::FeGaussianBlur, rDocument, pParent) , maStdDeviation(SvgNumber(0.0)) - , maIn(In::None) + , maIn(In::SourceGraphic) { } @@ -59,6 +60,10 @@ void SvgFeGaussianBlurNode::parseAttribute(const OUString& /*rTokenName*/, SVGTo { maIn = In::SourceGraphic; } + else if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"SourceAlpha")) + { + maIn = In::SourceAlpha; + } } break; } @@ -71,7 +76,7 @@ void SvgFeGaussianBlurNode::parseAttribute(const OUString& /*rTokenName*/, SVGTo void SvgFeGaussianBlurNode::apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const { - if (maIn == In::SourceGraphic) + if (maStdDeviation.getNumber() != 0.0) { const drawinglayer::primitive2d::Primitive2DReference xRef( new drawinglayer::primitive2d::SoftEdgePrimitive2D(maStdDeviation.getNumber(), @@ -79,6 +84,15 @@ void SvgFeGaussianBlurNode::apply(drawinglayer::primitive2d::Primitive2DContaine rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef }; } + + if (maIn == In::SourceAlpha) + { + const drawinglayer::primitive2d::Primitive2DReference xRef( + new drawinglayer::primitive2d::ModifiedColorPrimitive2D( + std::move(rTarget), std::make_shared<basegfx::BColorModifier_alpha>())); + + rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef }; + } } } // end of namespace svgio::svgreader |