From fdd262e30718b2d97bccc98db913687a0cd5a8bd Mon Sep 17 00:00:00 2001 From: OnionsYu Date: Thu, 11 Jun 2026 19:06:43 +0800 Subject: [PATCH 1/4] Fix invisible mask layers being merged with visible shape layers causing painters to disappear in SVG import. --- src/pagx/svg/SVGImporter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pagx/svg/SVGImporter.cpp b/src/pagx/svg/SVGImporter.cpp index b351bc25be..f779df20c0 100644 --- a/src/pagx/svg/SVGImporter.cpp +++ b/src/pagx/svg/SVGImporter.cpp @@ -2792,6 +2792,12 @@ static bool isSimpleShapeLayer(const Layer* layer, const Element*& outGeometry, if (!layer || layer->contents.size() != 2) { return false; } + // Invisible layers (e.g., mask reference layers) must not be merged with visible layers, + // even when they share the same geometry. Otherwise the visible layer's painter would be + // pulled into the invisible layer and disappear from the final output. + if (!layer->visible) { + return false; + } if (!layer->children.empty() || !layer->filters.empty() || !layer->styles.empty()) { return false; } From 77fe2445053ecaff6040640bbd988cca31974527 Mon Sep 17 00:00:00 2001 From: OnionsYu Date: Thu, 11 Jun 2026 19:26:36 +0800 Subject: [PATCH 2/4] Apply stroke-opacity to gradient strokes to match SVG rendering. --- src/pagx/svg/SVGImporter.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pagx/svg/SVGImporter.cpp b/src/pagx/svg/SVGImporter.cpp index f779df20c0..378cfbaa65 100644 --- a/src/pagx/svg/SVGImporter.cpp +++ b/src/pagx/svg/SVGImporter.cpp @@ -1817,6 +1817,15 @@ void SVGParserContext::addFillStroke(const std::shared_ptr& element, auto strokeNode = _document->makeNode(); + // Determine effective stroke-opacity. Applies to both url() and solid color strokes. + std::string strokeOpacity = getAttribute(element, "stroke-opacity"); + if (strokeOpacity.empty()) { + strokeOpacity = inheritedStyle.strokeOpacity; + } + if (!strokeOpacity.empty()) { + strokeNode->alpha = strtof(strokeOpacity.c_str(), nullptr); + } + if (stroke.compare(0, 4, "url(") == 0) { std::string refId = resolveUrl(stroke); // Use getColorSourceForRef which handles reference counting. @@ -1826,15 +1835,6 @@ void SVGParserContext::addFillStroke(const std::shared_ptr& element, } strokeNode->color = getColorSourceForRef(refId, shapeBounds); } else { - // Determine effective stroke-opacity. - std::string strokeOpacity = getAttribute(element, "stroke-opacity"); - if (strokeOpacity.empty()) { - strokeOpacity = inheritedStyle.strokeOpacity; - } - if (!strokeOpacity.empty()) { - strokeNode->alpha = strtof(strokeOpacity.c_str(), nullptr); - } - // Convert color to SolidColor for PAGX compatibility. // SolidColor is always inlined (no id). Color parsedColor = parseColor(stroke); From cc18a22ee2f0852a21995fb461637496031bde5b Mon Sep 17 00:00:00 2001 From: OnionsYu Date: Thu, 11 Jun 2026 19:35:59 +0800 Subject: [PATCH 3/4] Honor SVG mask-type attribute to preserve mask alpha rendering on import. --- src/pagx/svg/SVGImporter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pagx/svg/SVGImporter.cpp b/src/pagx/svg/SVGImporter.cpp index 378cfbaa65..8be5fadffb 100644 --- a/src/pagx/svg/SVGImporter.cpp +++ b/src/pagx/svg/SVGImporter.cpp @@ -443,8 +443,10 @@ Layer* SVGParserContext::convertToLayer(const std::shared_ptr& element, auto maskLayer = convertMaskElement(maskIt->second, inheritedStyle); if (maskLayer) { layer->mask = maskLayer; - // SVG masks use luminance by default. - layer->maskType = MaskType::Luminance; + // SVG mask-type property determines how the mask is computed. + // Default is "luminance" (uses luminance of mask content); "alpha" uses alpha channel. + std::string maskTypeStr = getAttribute(maskIt->second, "mask-type"); + layer->maskType = (maskTypeStr == "alpha") ? MaskType::Alpha : MaskType::Luminance; // Add mask layer as invisible layer to the document. _maskLayers.push_back(maskLayer); } From 1e33b131ec65a4e9b7169519ac1a8e9af6861692 Mon Sep 17 00:00:00 2001 From: OnionsYu Date: Thu, 11 Jun 2026 21:09:34 +0800 Subject: [PATCH 4/4] Update baseline for svg_Guidelines and svg_Overview after SVG mask-type fix. --- test/baseline/version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/baseline/version.json b/test/baseline/version.json index fb22ceedbc..123c1b662f 100644 --- a/test/baseline/version.json +++ b/test/baseline/version.json @@ -8812,8 +8812,8 @@ "spec_trim_path": "eb9361216", "svg_Baseline": "73083086", "svg_ColorPicker": "eb9361216", - "svg_Guidelines": "14d4d93b7", - "svg_Overview": "451bc13e", + "svg_Guidelines": "cc18a22e", + "svg_Overview": "cc18a22e", "svg_Switch": "73083086", "svg_UIkit": "eb9361216", "svg_blur": "b4fef60e9",