summaryrefslogtreecommitdiff
path: root/svgio/source
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-07-28 18:37:32 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-07-29 08:21:59 +0200
commit4f61276dae10fdaf2ed33ab23d98adbe311cb7ee (patch)
tree4a00f4c0aea4f648261a31e3070109284ffcf200 /svgio/source
parentd07f18e0c3f8d50deea643c0ecab171795bd1231 (diff)
svgio: Add support for clip-rule="evenodd"
Change-Id: I028aa88bdd72b4f87526a3d1edabd612d7686571 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137577 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio/source')
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx44
1 files changed, 33 insertions, 11 deletions
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 6ad1b1d25cc2..c787c4dffa92 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1125,17 +1125,18 @@ namespace svgio::svgreader
{
// create fill
basegfx::B2DPolyPolygon aPath(rPath);
- const bool bNeedToCheckClipRule(SVGToken::Path == mrOwner.getType() || SVGToken::Polygon == mrOwner.getType());
- const bool bClipPathIsNonzero(bNeedToCheckClipRule && mbIsClipPathContent && FillRule::nonzero == maClipRule);
- const bool bFillRuleIsNonzero(bNeedToCheckClipRule && !mbIsClipPathContent && FillRule::nonzero == getFillRule());
- if(bClipPathIsNonzero || bFillRuleIsNonzero)
+ if(SVGToken::Path == mrOwner.getType() || SVGToken::Polygon == mrOwner.getType())
{
- if(getFill() || getSvgGradientNodeFill() || getSvgPatternNodeFill()) {
- // nonzero is wanted, solve geometrically (see description on basegfx)
- // basegfx::utils::createNonzeroConform() is expensive for huge paths
- // and is only needed if path will be filled later on
- aPath = basegfx::utils::createNonzeroConform(aPath);
+ if(FillRule::evenodd != getClipRule() && FillRule::evenodd != getFillRule())
+ {
+ if(getFill() || getSvgGradientNodeFill() || getSvgPatternNodeFill())
+ {
+ // nonzero is wanted, solve geometrically (see description on basegfx)
+ // basegfx::utils::createNonzeroConform() is expensive for huge paths
+ // and is only needed if path will be filled later on
+ aPath = basegfx::utils::createNonzeroConform(aPath);
+ }
}
}
@@ -1275,10 +1276,10 @@ namespace svgio::svgreader
mpMarkerMidXLink(nullptr),
mpMarkerEndXLink(nullptr),
maFillRule(FillRule::notset),
- maClipRule(FillRule::nonzero),
+ maClipRule(FillRule::notset),
maBaselineShift(BaselineShift::Baseline),
maBaselineShiftNumber(0),
- maResolvingParent(31, 0),
+ maResolvingParent(32, 0),
mbIsClipPathContent(SVGToken::ClipPathNode == mrOwner.getType()),
mbStrokeDasharraySet(false)
{
@@ -2348,6 +2349,27 @@ namespace svgio::svgreader
return FillRule::nonzero;
}
+ FillRule SvgStyleAttributes::getClipRule() const
+ {
+ if(FillRule::notset != maClipRule)
+ {
+ return maClipRule;
+ }
+
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+ if (pSvgStyleAttributes && maResolvingParent[31] < nStyleDepthLimit)
+ {
+ ++maResolvingParent[31];
+ auto ret = pSvgStyleAttributes->getClipRule();
+ --maResolvingParent[31];
+ return ret;
+ }
+
+ // default is NonZero
+ return FillRule::nonzero;
+ }
+
const SvgNumberVector& SvgStyleAttributes::getStrokeDasharray() const
{
if(!maStrokeDasharray.empty())