summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-06-27 13:16:36 +0900
committerHermet Park <hermetpark@gmail.com>2019-06-27 13:18:28 +0900
commit7fcf887b6380efa43be6cdea91f85078a83d29dd (patch)
treee3169f2710e6afa654d3643cacd726040dc52dee /src
parent35a5ed14942600626ab5c257288867e3e75039fb (diff)
evas svg: fix missing node opacity attribute.
Any svg node could have its opacity value, we missed implementing it. If a node have a opacity, it's opacity could be multiply with fill and stroke colors. @fix
Diffstat (limited to 'src')
-rw-r--r--src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c8
-rw-r--r--src/static_libs/vg_common/vg_common.h1
-rw-r--r--src/static_libs/vg_common/vg_common_svg.c12
3 files changed, 21 insertions, 0 deletions
diff --git a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
index 0bd37248d6..32bfb17d76 100644
--- a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
+++ b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
@@ -888,6 +888,12 @@ _handle_fill_rule_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, cons
888} 888}
889 889
890static void 890static void
891_handle_opacity_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, const char *value)
892{
893 node->style->opacity = _to_opacity(value);
894}
895
896static void
891_handle_fill_opacity_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, const char *value) 897_handle_fill_opacity_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, const char *value)
892{ 898{
893 node->style->fill.flags |= SVG_FILL_FLAGS_OPACITY; 899 node->style->fill.flags |= SVG_FILL_FLAGS_OPACITY;
@@ -915,6 +921,7 @@ static const struct {
915 STYLE_DEF(fill, fill), 921 STYLE_DEF(fill, fill),
916 STYLE_DEF(fill-rule, fill_rule), 922 STYLE_DEF(fill-rule, fill_rule),
917 STYLE_DEF(fill-opacity, fill_opacity), 923 STYLE_DEF(fill-opacity, fill_opacity),
924 STYLE_DEF(opacity, opacity),
918 STYLE_DEF(stroke, stroke), 925 STYLE_DEF(stroke, stroke),
919 STYLE_DEF(stroke-width, stroke_width), 926 STYLE_DEF(stroke-width, stroke_width),
920 STYLE_DEF(stroke-linejoin, stroke_linejoin), 927 STYLE_DEF(stroke-linejoin, stroke_linejoin),
@@ -1001,6 +1008,7 @@ _create_node(Svg_Node *parent, Svg_Node_Type type)
1001 node->style->fill.paint.none = EINA_FALSE; 1008 node->style->fill.paint.none = EINA_FALSE;
1002 // default fill opacity is 1 1009 // default fill opacity is 1
1003 node->style->fill.opacity = 255; 1010 node->style->fill.opacity = 255;
1011 node->style->opacity = 255;
1004 1012
1005 // default fill rule is nonzero 1013 // default fill rule is nonzero
1006 node->style->fill.fill_rule = EFL_GFX_FILL_RULE_WINDING; 1014 node->style->fill.fill_rule = EFL_GFX_FILL_RULE_WINDING;
diff --git a/src/static_libs/vg_common/vg_common.h b/src/static_libs/vg_common/vg_common.h
index fc8d566144..731a8d2796 100644
--- a/src/static_libs/vg_common/vg_common.h
+++ b/src/static_libs/vg_common/vg_common.h
@@ -272,6 +272,7 @@ struct _Svg_Style_Property
272 int r; 272 int r;
273 int g; 273 int g;
274 int b; 274 int b;
275 int opacity;
275}; 276};
276 277
277struct _Svg_Node 278struct _Svg_Node
diff --git a/src/static_libs/vg_common/vg_common_svg.c b/src/static_libs/vg_common/vg_common_svg.c
index d14d9dd847..e753e229d0 100644
--- a/src/static_libs/vg_common/vg_common_svg.c
+++ b/src/static_libs/vg_common/vg_common_svg.c
@@ -183,6 +183,8 @@ _eet_for_style_property(void)
183 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "r", r, EET_T_INT); 183 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "r", r, EET_T_INT);
184 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "g", g, EET_T_INT); 184 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "g", g, EET_T_INT);
185 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "b", b, EET_T_INT); 185 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "b", b, EET_T_INT);
186 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "opacity", opacity, EET_T_INT);
187
186 // for fill 188 // for fill
187 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.flags", fill.flags, EET_T_INT); 189 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.flags", fill.flags, EET_T_INT);
188 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.r", fill.paint.r, EET_T_INT); 190 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.r", fill.paint.r, EET_T_INT);
@@ -731,6 +733,15 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
731 style->fill.paint.b, style->fill.opacity); 733 style->fill.paint.b, style->fill.opacity);
732 } 734 }
733 735
736 //apply node opacity
737 if (style->opacity < 255)
738 {
739 int r, g, b, a;
740 efl_gfx_color_get(vg, &r, &g, &b, &a);
741 float fa = ((float) style->opacity / 255);
742 efl_gfx_color_set(vg, ((float) r) * fa, ((float) g) * fa, ((float) b) * fa, ((float) a) * fa);
743 }
744
734 efl_gfx_shape_stroke_width_set(vg, style->stroke.width); 745 efl_gfx_shape_stroke_width_set(vg, style->stroke.width);
735 efl_gfx_shape_stroke_cap_set(vg, style->stroke.cap); 746 efl_gfx_shape_stroke_cap_set(vg, style->stroke.cap);
736 efl_gfx_shape_stroke_join_set(vg, style->stroke.join); 747 efl_gfx_shape_stroke_join_set(vg, style->stroke.join);
@@ -906,6 +917,7 @@ _create_node(Svg_Node *parent, Svg_Node_Type type)
906 // default line join is miter 917 // default line join is miter
907 node->style->stroke.join = EFL_GFX_JOIN_MITER; 918 node->style->stroke.join = EFL_GFX_JOIN_MITER;
908 node->style->stroke.scale = 1.0; 919 node->style->stroke.scale = 1.0;
920 node->style->opacity = 255;
909 921
910 node->parent = parent; 922 node->parent = parent;
911 node->type = type; 923 node->type = type;