summaryrefslogtreecommitdiff
path: root/src/static_libs
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-11-19 13:18:42 +0900
committerHermet Park <hermetpark@gmail.com>2019-11-19 13:26:43 +0900
commit29892a26f8eb6b7620d78651a4aabc0dcea15f7e (patch)
tree14735e68154a2a1dfbecba48c786f4c439be0a62 /src/static_libs
parentc30176e7ffac0ab70b8ef92cb0fce62b75499181 (diff)
vector svg: apply fill-opacity to graidents fill objects.
If node has a fill-opacity attirbute it must propagtes it to its fill objects. Previous our implementation missed this behavior. @fix
Diffstat (limited to 'src/static_libs')
-rw-r--r--src/static_libs/vg_common/vg_common_svg.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/static_libs/vg_common/vg_common_svg.c b/src/static_libs/vg_common/vg_common_svg.c
index 1d01f9f243..526787df0d 100644
--- a/src/static_libs/vg_common/vg_common_svg.c
+++ b/src/static_libs/vg_common/vg_common_svg.c
@@ -544,7 +544,7 @@ vg_common_svg_node_free(Svg_Node *node)
544} 544}
545 545
546static Efl_VG * 546static Efl_VG *
547_apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_data) 547_apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_data, int fill_opacity)
548{ 548{
549 Efl_VG *grad_obj = NULL; 549 Efl_VG *grad_obj = NULL;
550 Efl_Gfx_Gradient_Stop *stops, *stop; 550 Efl_Gfx_Gradient_Stop *stops, *stop;
@@ -678,23 +678,26 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F
678 // not a known gradient 678 // not a known gradient
679 return NULL; 679 return NULL;
680 } 680 }
681
681 // apply common prperty 682 // apply common prperty
682 efl_gfx_gradient_spread_set(grad_obj, g->spread); 683 efl_gfx_gradient_spread_set(grad_obj, g->spread);
684
683 // update the stops 685 // update the stops
684 stop_count = eina_list_count(g->stops); 686 stop_count = eina_list_count(g->stops);
685 if (stop_count) 687 if (stop_count)
686 { 688 {
687 double opacity; 689 double opacity;
690 double fopacity = ((double) fill_opacity) / 255; //fill opacity if any exists.
688 stops = calloc(stop_count, sizeof(Efl_Gfx_Gradient_Stop)); 691 stops = calloc(stop_count, sizeof(Efl_Gfx_Gradient_Stop));
689 i = 0; 692 i = 0;
690 EINA_LIST_FOREACH(g->stops, l, stop) 693 EINA_LIST_FOREACH(g->stops, l, stop)
691 { 694 {
692 // Use premultiplied color 695 // Use premultiplied color
693 opacity = (double)stop->a / 255; 696 opacity = ((double) stop->a / 255) * fopacity;
694 stops[i].r = stop->r * opacity; 697 stops[i].r = (stop->r * opacity);
695 stops[i].g = stop->g * opacity; 698 stops[i].g = (stop->g * opacity);
696 stops[i].b = stop->b * opacity; 699 stops[i].b = (stop->b * opacity);
697 stops[i].a = stop->a; 700 stops[i].a = (stop->a * fopacity);
698 stops[i].offset = stop->offset; 701 stops[i].offset = stop->offset;
699 i++; 702 i++;
700 } 703 }
@@ -727,8 +730,8 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
727 } 730 }
728 else if (style->fill.paint.gradient) 731 else if (style->fill.paint.gradient)
729 { 732 {
730 // if the fill has gradient then apply. 733 Efl_VG *gradient = _apply_gradient_property(style->fill.paint.gradient, vg, parent, vg_data, style->fill.opacity);
731 efl_canvas_vg_shape_fill_set(vg, _apply_gradient_property(style->fill.paint.gradient, vg, parent, vg_data)); 734 efl_canvas_vg_shape_fill_set(vg, gradient);
732 } 735 }
733 else if (style->fill.paint.cur_color) 736 else if (style->fill.paint.cur_color)
734 { 737 {
@@ -758,11 +761,11 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
758 761
759 // apply the fill style property 762 // apply the fill style property
760 efl_gfx_shape_fill_rule_set(vg, style->fill.fill_rule); 763 efl_gfx_shape_fill_rule_set(vg, style->fill.fill_rule);
761
762 efl_gfx_shape_stroke_width_set(vg, style->stroke.width); 764 efl_gfx_shape_stroke_width_set(vg, style->stroke.width);
763 efl_gfx_shape_stroke_cap_set(vg, style->stroke.cap); 765 efl_gfx_shape_stroke_cap_set(vg, style->stroke.cap);
764 efl_gfx_shape_stroke_join_set(vg, style->stroke.join); 766 efl_gfx_shape_stroke_join_set(vg, style->stroke.join);
765 efl_gfx_shape_stroke_scale_set(vg, style->stroke.scale); 767 efl_gfx_shape_stroke_scale_set(vg, style->stroke.scale);
768
766 // if stroke property is NULL then do nothing 769 // if stroke property is NULL then do nothing
767 if (style->stroke.paint.none) 770 if (style->stroke.paint.none)
768 { 771 {
@@ -771,7 +774,8 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
771 else if (style->stroke.paint.gradient) 774 else if (style->stroke.paint.gradient)
772 { 775 {
773 // if the fill has gradient then apply. 776 // if the fill has gradient then apply.
774 efl_canvas_vg_shape_stroke_fill_set(vg, _apply_gradient_property(style->stroke.paint.gradient, vg, parent, vg_data)); 777 Efl_VG *gradient = _apply_gradient_property(style->stroke.paint.gradient, vg, parent, vg_data, 255);
778 efl_canvas_vg_shape_stroke_fill_set(vg, gradient);
775 } 779 }
776 else if (style->stroke.paint.url) 780 else if (style->stroke.paint.url)
777 { 781 {