canvas svg: fix to apply premultipled color.
authorHermet Park <hermetpark@gmail.com>
Tue, 20 Aug 2019 02:23:59 +0000 (11:23 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Wed, 21 Aug 2019 00:28:16 +0000 (09:28 +0900)
fill colors should be premultiplied with fill opcaity.

src/static_libs/vg_common/vg_common_svg.c

index 91bcec1..4f96bec 100644 (file)
@@ -711,12 +711,10 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
    Svg_Style_Property *style = node->style;
 
    // update the vg name
-   if (node->id)
-     efl_name_set(vg, node->id);
+   if (node->id) efl_name_set(vg, node->id);
 
    // apply the transformation
-   if (node->transform)
-     efl_canvas_vg_node_transformation_set(vg, node->transform);
+   if (node->transform) efl_canvas_vg_node_transformation_set(vg, node->transform);
 
    if (!node->display) efl_gfx_entity_visible_set(vg, EINA_FALSE);
 
@@ -724,6 +722,7 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
 
    // apply the fill style property
    efl_gfx_shape_fill_rule_set(vg, style->fill.fill_rule);
+
    // if fill property is NULL then do nothing
    if (style->fill.paint.none)
      {
@@ -737,14 +736,16 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
    else if (style->fill.paint.cur_color)
      {
         // apply the current style color
-        efl_gfx_color_set(vg, style->r, style->g,
-                          style->b, style->fill.opacity);
+        float fa = ((float) style->fill.opacity / 255);
+        efl_gfx_color_set(vg, ((float) style->r) * fa, ((float) style->g) * fa, ((float) style->b) * fa,
+                          style->fill.opacity);
      }
    else
      {
         // apply the fill color
-        efl_gfx_color_set(vg, style->fill.paint.r, style->fill.paint.g,
-                          style->fill.paint.b, style->fill.opacity);
+        float fa = ((float) style->fill.opacity / 255);
+        efl_gfx_color_set(vg, ((float) style->fill.paint.r) * fa, ((float) style->fill.paint.g) * fa,
+                          ((float) style->fill.paint.b) * fa, style->fill.opacity);
      }
 
    //apply node opacity