diff options
author | Matthias Rauter <matthias.rauter@qt.io> | 2024-03-06 13:17:18 +0100 |
---|---|---|
committer | Matthias Rauter <matthias.rauter@qt.io> | 2024-03-15 16:35:04 +0100 |
commit | 247453e7d5c84837b80444c26b1afd6165f63477 (patch) | |
tree | 9350c128db094514cc5429b45843e205065f75dc /src/svg/qsvgstructure.cpp | |
parent | d99f357bb7b3e07d2a7b061140ab430bcaa5010e (diff) |
Enable <use> elements in <mask> and propagate state to mask children
The use node could not be created within a mask due to a missing entry
in a switch statement. This is corrected with this patch.
The mask element was implemented such that states do not propagate to
it's children. This is not correct and states are propagated correctly
with this patch.
Pick-to: 6.7 6.7.0
Fixes: QTBUG-123010
Change-Id: I4aab070c73b2e8a9bd0c642c70ea5b28eaef3416
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/svg/qsvgstructure.cpp')
-rw-r--r-- | src/svg/qsvgstructure.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/svg/qsvgstructure.cpp b/src/svg/qsvgstructure.cpp index 02e6b64..01fe1f5 100644 --- a/src/svg/qsvgstructure.cpp +++ b/src/svg/qsvgstructure.cpp @@ -743,17 +743,17 @@ QImage QSvgMask::createMask(QPainter *p, QSvgExtraStates &states, const QRectF & mask.fill(Qt::transparent); QPainter painter(&mask); + initPainter(&painter); - painter.setRenderHints(p->renderHints()); + QSvgExtraStates maskNodeStates; + applyStyleRecursive(&painter, maskNodeStates); + + // The transformation of the mask node is not relevant. What matters are the contentUnits + // and the position/scale of the node that the mask is applied to. + painter.resetTransform(); painter.translate(-imageBound.topLeft()); painter.setTransform(p->transform(), true); - // This is required because the QPen is scaled if contentUnits is objectBoundingBox, - // which does not match Chrome and Firefox. - painter.setPen(Qt::NoPen); - - QSvgExtraStates states2; // Fake states so scopes do not propagate - QTransform oldT = painter.transform(); if (m_contentUnits == QtSvg::UnitTypes::objectBoundingBox){ painter.translate(localRect.topLeft()); @@ -765,7 +765,7 @@ QImage QSvgMask::createMask(QPainter *p, QSvgExtraStates &states, const QRectF & while (itr != m_renderers.end()) { QSvgNode *node = *itr; if ((node->isVisible()) && (node->displayMode() != QSvgNode::NoneMode)) - node->draw(&painter, states2); + node->draw(&painter, maskNodeStates); ++itr; } |