summaryrefslogtreecommitdiff
path: root/src/static_libs/vg_common/vg_common_svg.c
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2020-10-14 19:16:53 +0900
committerHermet Park <chuneon.park@samsung.com>2020-10-14 19:16:53 +0900
commit3274390f7324b561739bdf2b620c939b6e0508fd (patch)
tree0ae5f3d12a09854c7dc00aa59459b2b5c132909c /src/static_libs/vg_common/vg_common_svg.c
parent25e64a9a4e3adc259e81093a223c12996e424bf1 (diff)
vg_load_svg: Implement ClipPath feature
Summary: Supports case of using style attribute for defined <clipPath> and node. In SVG, <clipPath> can be used as a "clipPath" attribute or a style "clip-path". If there is a clip-path node, save it as a composition node and use composition method(matte_alpha) to compose it. Below node types support clip-path. <circle> <ellipse> <g> <path> <polygon> <polyline> <rect> Test Plan: Please see attached svg files {F4026162} Reviewers: Hermet, smohanty Reviewed By: Hermet Subscribers: #reviewers, #committers, cedric, herb, kimcinoo Tags: #efl Differential Revision: https://phab.enlightenment.org/D12179
Diffstat (limited to '')
-rw-r--r--src/static_libs/vg_common/vg_common_svg.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/static_libs/vg_common/vg_common_svg.c b/src/static_libs/vg_common/vg_common_svg.c
index 38e203b205..30fc0c0eb5 100644
--- a/src/static_libs/vg_common/vg_common_svg.c
+++ b/src/static_libs/vg_common/vg_common_svg.c
@@ -763,7 +763,7 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
763 efl_gfx_color_set(vg, ((float) r) * fa, ((float) g) * fa, ((float) b) * fa, ((float) a) * fa); 763 efl_gfx_color_set(vg, ((float) r) * fa, ((float) g) * fa, ((float) b) * fa, ((float) a) * fa);
764 } 764 }
765 765
766 if (node->type == SVG_NODE_G) return; 766 if (node->type == SVG_NODE_G || node->type == SVG_NODE_CLIP_PATH) return;
767 767
768 // apply the fill style property 768 // apply the fill style property
769 efl_gfx_shape_fill_rule_set(vg, style->fill.fill_rule); 769 efl_gfx_shape_fill_rule_set(vg, style->fill.fill_rule);
@@ -829,12 +829,51 @@ _add_polyline(Efl_VG *vg, double *array, int size, Eina_Bool polygon)
829} 829}
830 830
831static Efl_VG * 831static Efl_VG *
832_create_vg_container(Efl_VG *parent)
833{
834 if (!parent)
835 return efl_add_ref(EFL_CANVAS_VG_CONTAINER_CLASS, NULL);
836 else
837 return efl_add(EFL_CANVAS_VG_CONTAINER_CLASS, parent);
838}
839
840static Efl_VG *
832vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent, Vg_File_Data *vg_data) 841vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent, Vg_File_Data *vg_data)
833{ 842{
834 Efl_VG *vg = NULL; 843 Efl_VG *vg = NULL;
835 Svg_Node *child; 844 Svg_Node *child;
836 Eina_List *l; 845 Eina_List *l;
837 846
847 // apply composite node
848 if (node->style->comp.node)
849 {
850 // composite ClipPath
851 if (node->style->comp.flags & SVG_COMPOSITE_FLAGS_CLIP_PATH)
852 {
853 Svg_Node *comp_node = node->style->comp.node;
854 Efl_VG *comp_parent = NULL ,*comp_vg_container = NULL;
855
856 //NOTE:: If node has a composition node, add a container to use VG_COMPOSITION_METHOD.
857 // The composition method is applied to the newly added container.
858 comp_parent = _create_vg_container(parent);
859 comp_vg_container = _create_vg_container(parent);
860
861 // apply the transformation
862 if (comp_node->transform) efl_canvas_vg_node_transformation_set(comp_vg_container, comp_node->transform);
863
864 EINA_LIST_FOREACH(comp_node->child, l, child)
865 {
866 Efl_VG *vg = vg_common_create_vg_node_helper(child, comp_vg_container, vg_data);
867 // clippath does not require color blending. That's why we keep 255 opacity.
868 efl_gfx_color_set(vg, 255, 255, 255, 255);
869 }
870
871 // Composition matte alpha
872 efl_canvas_vg_node_comp_method_set(comp_parent, comp_vg_container, EFL_GFX_VG_COMPOSITE_METHOD_MATTE_ALPHA);
873
874 parent = comp_parent; // replace parent
875 }
876 }
838 switch (node->type) 877 switch (node->type)
839 { 878 {
840 case SVG_NODE_DOC: 879 case SVG_NODE_DOC: