forked from enlightenment/efl
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
This commit is contained in:
parent
35a5ed1494
commit
7fcf887b63
|
@ -887,6 +887,12 @@ _handle_fill_rule_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, cons
|
|||
node->style->fill.fill_rule = _to_fill_rule(value);
|
||||
}
|
||||
|
||||
static void
|
||||
_handle_opacity_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, const char *value)
|
||||
{
|
||||
node->style->opacity = _to_opacity(value);
|
||||
}
|
||||
|
||||
static void
|
||||
_handle_fill_opacity_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, const char *value)
|
||||
{
|
||||
|
@ -915,6 +921,7 @@ static const struct {
|
|||
STYLE_DEF(fill, fill),
|
||||
STYLE_DEF(fill-rule, fill_rule),
|
||||
STYLE_DEF(fill-opacity, fill_opacity),
|
||||
STYLE_DEF(opacity, opacity),
|
||||
STYLE_DEF(stroke, stroke),
|
||||
STYLE_DEF(stroke-width, stroke_width),
|
||||
STYLE_DEF(stroke-linejoin, stroke_linejoin),
|
||||
|
@ -1001,6 +1008,7 @@ _create_node(Svg_Node *parent, Svg_Node_Type type)
|
|||
node->style->fill.paint.none = EINA_FALSE;
|
||||
// default fill opacity is 1
|
||||
node->style->fill.opacity = 255;
|
||||
node->style->opacity = 255;
|
||||
|
||||
// default fill rule is nonzero
|
||||
node->style->fill.fill_rule = EFL_GFX_FILL_RULE_WINDING;
|
||||
|
|
|
@ -272,6 +272,7 @@ struct _Svg_Style_Property
|
|||
int r;
|
||||
int g;
|
||||
int b;
|
||||
int opacity;
|
||||
};
|
||||
|
||||
struct _Svg_Node
|
||||
|
|
|
@ -183,6 +183,8 @@ _eet_for_style_property(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "r", r, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "g", g, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "b", b, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "opacity", opacity, EET_T_INT);
|
||||
|
||||
// for fill
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.flags", fill.flags, EET_T_INT);
|
||||
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_
|
|||
style->fill.paint.b, style->fill.opacity);
|
||||
}
|
||||
|
||||
//apply node opacity
|
||||
if (style->opacity < 255)
|
||||
{
|
||||
int r, g, b, a;
|
||||
efl_gfx_color_get(vg, &r, &g, &b, &a);
|
||||
float fa = ((float) style->opacity / 255);
|
||||
efl_gfx_color_set(vg, ((float) r) * fa, ((float) g) * fa, ((float) b) * fa, ((float) a) * fa);
|
||||
}
|
||||
|
||||
efl_gfx_shape_stroke_width_set(vg, style->stroke.width);
|
||||
efl_gfx_shape_stroke_cap_set(vg, style->stroke.cap);
|
||||
efl_gfx_shape_stroke_join_set(vg, style->stroke.join);
|
||||
|
@ -906,6 +917,7 @@ _create_node(Svg_Node *parent, Svg_Node_Type type)
|
|||
// default line join is miter
|
||||
node->style->stroke.join = EFL_GFX_JOIN_MITER;
|
||||
node->style->stroke.scale = 1.0;
|
||||
node->style->opacity = 255;
|
||||
|
||||
node->parent = parent;
|
||||
node->type = type;
|
||||
|
|
Loading…
Reference in New Issue