svg_loader: clipping composite layer is added independently on the bounds of the shapes

This commit is contained in:
Mira Grudzinska 2021-05-27 12:54:08 +02:00
parent ed8dfbc529
commit c38e4e40a7

View file

@ -402,13 +402,8 @@ unique_ptr<Scene> svgSceneBuild(SvgNode* node, float vx, float vy, float vw, flo
{
if (!node || (node->type != SvgNodeType::Doc)) return nullptr;
unique_ptr<Scene> root;
auto docNode = _sceneBuildHelper(node, vx, vy, vw, vh);
float x, y, w, h;
if (docNode->bounds(&x, &y, &w, &h) != Result::Success) return nullptr;
if (x < vx || y < vy || w > vh || h > vh) {
auto viewBoxClip = Shape::gen();
viewBoxClip->appendRect(vx, vy ,vw, vh, 0, 0);
viewBoxClip->fill(0, 0, 0, 255);
@ -417,10 +412,8 @@ unique_ptr<Scene> svgSceneBuild(SvgNode* node, float vx, float vy, float vw, flo
compositeLayer->composite(move(viewBoxClip), CompositeMethod::ClipPath);
compositeLayer->push(move(docNode));
root = Scene::gen();
auto root = Scene::gen();
root->push(move(compositeLayer));
} else {
root = move(docNode);
}
return root;
}