SvgLoader: Support display=none feature

If display is none, scene does not create a child shape,
and shape does not draw fills and strokes.

Change-Id: I8af72c904be00107dff115429e27df7ba4cb83b6
This commit is contained in:
JunsuChoi 2020-07-21 10:42:22 +09:00 committed by Hermet Park
parent 6cfb3cdb6c
commit 27ca82c140

View file

@ -206,7 +206,7 @@ void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float vw, floa
SvgStyleProperty* style = node->style;
if (node->transform) vg->transform(*node->transform);
if (node->type == SvgNodeType::Doc) return;
if (node->type == SvgNodeType::Doc || !node->display) return;
//If fill property is nullptr then do nothing
if (style->fill.paint.none) {
@ -333,11 +333,13 @@ unique_ptr<Scene> _sceneBuildHelper(SvgNode* node, float vx, float vy, float vw,
auto scene = Scene::gen();
if (node->transform) scene->transform(*node->transform);
node->style->opacity = (node->style->opacity * parentOpacity) / 255.0f;
if (node->display) {
for (auto child : node->child) {
child->style->opacity = (child->style->opacity * node->style->opacity) / 255.0f;
if (child->type == SvgNodeType::Doc || child->type == SvgNodeType::G) scene->push(_sceneBuildHelper(child, vx, vy, vw, vh, node->style->opacity));
else scene->push(_shapeBuildHelper(child, vx, vy, vw, vh));
}
}
return move(scene);
}
return nullptr;