svg_loader: the viewBox clipping composite layer added independently of the shapes bounds

For now the bounding box of all the shapes was established and if it was larger
than the viewBox of the SVG, the clipping layer was added. The bounds api
returns the rectangle that encloses the shapes before any transformations.
So comparing it with the viewBox doesn't make sense. The comparison is removed
and the clipping layer is always added.
This commit is contained in:
Mira Grudzinska 2021-05-27 13:05:42 +02:00 committed by Hermet Park
parent 61f07677c5
commit 3911a252e2

View file

@ -402,25 +402,18 @@ 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;
auto viewBoxClip = Shape::gen();
viewBoxClip->appendRect(vx, vy ,vw, vh, 0, 0);
viewBoxClip->fill(0, 0, 0, 255);
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);
auto compositeLayer = Scene::gen();
compositeLayer->composite(move(viewBoxClip), CompositeMethod::ClipPath);
compositeLayer->push(move(docNode));
auto compositeLayer = Scene::gen();
compositeLayer->composite(move(viewBoxClip), CompositeMethod::ClipPath);
compositeLayer->push(move(docNode));
auto root = Scene::gen();
root->push(move(compositeLayer));
root = Scene::gen();
root->push(move(compositeLayer));
} else {
root = move(docNode);
}
return root;
}