svg_loader: fixing clipper transformation

In a case where both the clipper and the clippee
are transformed, the final clipper transformation
matrix should be calculated as the multiplication
of both matrices.

@Issue: https://github.com/thorvg/thorvg/issues/1255
This commit is contained in:
Mira Grudzinska 2023-04-18 01:48:51 +02:00 committed by Hermet Park
parent 219e23855f
commit 46147dcec7

View file

@ -254,7 +254,6 @@ static void _applyComposition(Paint* paint, const SvgNode* node, const Box& vBox
node->style->clipPath.applying = true;
auto comp = Shape::gen();
if (node->transform) comp->transform(*node->transform);
auto child = compNode->child.data;
auto valid = false; //Composite only when valid shapes are existed
@ -263,6 +262,12 @@ static void _applyComposition(Paint* paint, const SvgNode* node, const Box& vBox
if (_appendChildShape(*child, comp.get(), vBox, svgPath)) valid = true;
}
if (node->transform) {
auto m = comp->transform();
m = mathMultiply(node->transform, &m);
comp->transform(m);
}
if (valid) paint->composite(move(comp), CompositeMethod::ClipPath);
node->style->clipPath.applying = false;