summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Rauter <matthias.rauter@qt.io>2024-03-12 17:08:12 +0100
committerMatthias Rauter <matthias.rauter@qt.io>2024-05-08 13:44:27 +0200
commitc58e6c9f276c1c524a3d53a41ee953e3b763b2eb (patch)
tree9b85347609d41e51f77cb1872bec6271ed0e4bec
parent9ea3e687875c74473150131d70152bb094dfaa60 (diff)
Fix filter offset with transformations
There was a missconception in the calculation of localFilterBoundingBox that lead to a rendering error of filter elements if there was a transformation set. The bounding box is always positioned relative to the node that the filter is applied to. This patch corrects the calculation of the bounding box. Fixes: QTBUG-123138 Change-Id: I9ed5ed3a2bb55bc61002cd0c506c1f2310962156 Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-rw-r--r--src/svg/qsvghelper_p.h4
-rw-r--r--tests/baseline/data/bugs/filterWithTransformsOnParent.svg22
2 files changed, 24 insertions, 2 deletions
diff --git a/src/svg/qsvghelper_p.h b/src/svg/qsvghelper_p.h
index 832bf7f..fa1296c 100644
--- a/src/svg/qsvghelper_p.h
+++ b/src/svg/qsvghelper_p.h
@@ -76,13 +76,13 @@ public:
if (units == QtSvg::UnitTypes::objectBoundingBox)
result.setX(localRect.x() + x() * localRect.width());
else if (m_unitX == QtSvg::UnitTypes::objectBoundingBox)
- result.setX(canvasRect.x() + x() * canvasRect.width());
+ result.setX(localRect.x() + x() * canvasRect.width());
else
result.setX(x());
if (units == QtSvg::UnitTypes::objectBoundingBox)
result.setY(localRect.y() + y() * localRect.height());
else if (m_unitY == QtSvg::UnitTypes::objectBoundingBox)
- result.setY(canvasRect.y() + y() * canvasRect.height());
+ result.setY(localRect.y() + y() * canvasRect.height());
else
result.setY(y());
if (units == QtSvg::UnitTypes::objectBoundingBox)
diff --git a/tests/baseline/data/bugs/filterWithTransformsOnParent.svg b/tests/baseline/data/bugs/filterWithTransformsOnParent.svg
new file mode 100644
index 0000000..1e9a94c
--- /dev/null
+++ b/tests/baseline/data/bugs/filterWithTransformsOnParent.svg
@@ -0,0 +1,22 @@
+<svg
+ xml:space="preserve"
+ version="1.1"
+ height="200"
+ width="200"
+ viewport="0 0 32 32"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns="http://www.w3.org/2000/svg">
+ <filter id="filter1">
+ <feFlood flood-color="blue"/>
+ </filter>
+ <g>
+ <path
+ transform="translate(-20,-741)"
+ style="display:inline;opacity:0.5;fill:#FF0000"
+ d="m 24 745 l 20 0 l 0 20 l -20 0 z" />
+ <path
+ transform="translate(-20,-741)"
+ style="display:inline;opacity:0.5;fill:#000000;filter:url(#filter1)"
+ d="m 24 745 l 20 0 l 0 20 l -20 0 z" />
+ </g>
+</svg>