summaryrefslogtreecommitdiff
path: root/src/static_libs
diff options
context:
space:
mode:
authorVitalii Vorobiov <vi.vorobiov@samsung.com>2017-02-21 17:40:15 +0200
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-07 11:54:09 +0900
commitf81f031ceb799f22bd8b6ea216a9b565244af12c (patch)
treef24506cff879b5447de4418daf49b64b6ed700cb /src/static_libs
parent405e56ac553db21f3e53d1702cc3db3863142811 (diff)
vg_common: apply related coordinates for linear gradient
multiply it with object size or with view box sizes depending on gradientUnits value
Diffstat (limited to 'src/static_libs')
-rw-r--r--src/static_libs/vg_common/vg_common.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/static_libs/vg_common/vg_common.c b/src/static_libs/vg_common/vg_common.c
index 410588e..eb6c992 100644
--- a/src/static_libs/vg_common/vg_common.c
+++ b/src/static_libs/vg_common/vg_common.c
@@ -547,23 +547,29 @@ vg_common_svg_node_free(Svg_Node *node)
547} 547}
548 548
549static Efl_VG * 549static Efl_VG *
550_apply_gradient_property(Svg_Style_Gradient *g) 550_apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Vg_File_Data *vg_data)
551{ 551{
552 Efl_VG *grad_obj = NULL; 552 Efl_VG *grad_obj = NULL;
553 Efl_Gfx_Gradient_Stop *stops, *stop; 553 Efl_Gfx_Gradient_Stop *stops, *stop;
554 int stop_count = 0, i = 0; 554 int stop_count = 0, i = 0;
555 Eina_List *l; 555 Eina_List *l;
556 Eina_Rect r = { 0, 0, 1, 1 };
556 557
557 /* 558 //TODO: apply actual sizes (imporve bounds_get function?)...
559 //for example with figures and paths
558 if (!g->user_space) 560 if (!g->user_space)
559 //get bounding box 561 evas_vg_node_bounds_get(vg, &r);
560 */ 562 else
563 {
564 r.w = vg_data->view_box.w;
565 r.h = vg_data->view_box.h;
566 }
561 567
562 if (g->type == SVG_LINEAR_GRADIENT) 568 if (g->type == SVG_LINEAR_GRADIENT)
563 { 569 {
564 grad_obj = evas_vg_gradient_linear_add(NULL); 570 grad_obj = evas_vg_gradient_linear_add(NULL);
565 evas_vg_gradient_linear_start_set(grad_obj, g->linear->x1, g->linear->y1); 571 evas_vg_gradient_linear_start_set(grad_obj, g->linear->x1 * r.w + r.x, g->linear->y1 * r.h + r.y);
566 evas_vg_gradient_linear_end_set(grad_obj, g->linear->x2, g->linear->y2); 572 evas_vg_gradient_linear_end_set(grad_obj, g->linear->x2 * r.w + r.x, g->linear->y2 * r.h + r.y);
567 } 573 }
568 else if (g->type == SVG_RADIAL_GRADIENT) 574 else if (g->type == SVG_RADIAL_GRADIENT)
569 { 575 {
@@ -590,7 +596,7 @@ _apply_gradient_property(Svg_Style_Gradient *g)
590 stops[i].r = stop->r; 596 stops[i].r = stop->r;
591 stops[i].g = stop->g; 597 stops[i].g = stop->g;
592 stops[i].b = stop->b; 598 stops[i].b = stop->b;
593 stops[i].a = stop->a; 599 stops[i].a = 255;
594 stops[i].offset = stop->offset; 600 stops[i].offset = stop->offset;
595 i++; 601 i++;
596 } 602 }
@@ -602,7 +608,7 @@ _apply_gradient_property(Svg_Style_Gradient *g)
602 608
603// vg tree creation 609// vg tree creation
604static void 610static void
605_apply_vg_property(Svg_Node *node, Efl_VG *vg) 611_apply_vg_property(Svg_Node *node, Efl_VG *vg, Vg_File_Data *vg_data)
606{ 612{
607 Svg_Style_Property *style = node->style; 613 Svg_Style_Property *style = node->style;
608 614
@@ -626,7 +632,7 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg)
626 else if (style->fill.paint.gradient) 632 else if (style->fill.paint.gradient)
627 { 633 {
628 // if the fill has gradient then apply. 634 // if the fill has gradient then apply.
629 evas_vg_shape_fill_set(vg, _apply_gradient_property(style->fill.paint.gradient)); 635 evas_vg_shape_fill_set(vg, _apply_gradient_property(style->fill.paint.gradient, vg, vg_data));
630 } 636 }
631 else if (style->fill.paint.cur_color) 637 else if (style->fill.paint.cur_color)
632 { 638 {
@@ -653,7 +659,7 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg)
653 else if (style->stroke.paint.gradient) 659 else if (style->stroke.paint.gradient)
654 { 660 {
655 // if the fill has gradient then apply. 661 // if the fill has gradient then apply.
656 evas_vg_shape_stroke_fill_set(vg, _apply_gradient_property(style->stroke.paint.gradient)); 662 evas_vg_shape_stroke_fill_set(vg, _apply_gradient_property(style->stroke.paint.gradient, vg, vg_data));
657 } 663 }
658 else if (style->stroke.paint.url) 664 else if (style->stroke.paint.url)
659 { 665 {
@@ -690,7 +696,7 @@ _add_polyline(Efl_VG *vg, double *array, int size, Eina_Bool polygon)
690} 696}
691 697
692static Efl_VG * 698static Efl_VG *
693vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent) 699vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent, Vg_File_Data *vg_data)
694{ 700{
695 Efl_VG *vg = NULL; 701 Efl_VG *vg = NULL;
696 Svg_Node *child; 702 Svg_Node *child;
@@ -702,10 +708,10 @@ vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent)
702 case SVG_NODE_G: 708 case SVG_NODE_G:
703 { 709 {
704 vg = evas_vg_container_add(parent); 710 vg = evas_vg_container_add(parent);
705 _apply_vg_property(node, vg); 711 _apply_vg_property(node, vg, vg_data);
706 EINA_LIST_FOREACH(node->child, l, child) 712 EINA_LIST_FOREACH(node->child, l, child)
707 { 713 {
708 vg_common_create_vg_node_helper(child, vg); 714 vg_common_create_vg_node_helper(child, vg, vg_data);
709 } 715 }
710 return vg; 716 return vg;
711 } 717 }
@@ -751,7 +757,7 @@ vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent)
751 break; 757 break;
752 } 758 }
753 if (vg) 759 if (vg)
754 _apply_vg_property(node, vg); 760 _apply_vg_property(node, vg, vg_data);
755 return vg; 761 return vg;
756} 762}
757 763
@@ -768,7 +774,7 @@ vg_common_create_vg_node(Svg_Node *node)
768 vg_data->view_box.w = node->node.doc.vw; 774 vg_data->view_box.w = node->node.doc.vw;
769 vg_data->view_box.h = node->node.doc.vh; 775 vg_data->view_box.h = node->node.doc.vh;
770 vg_data->preserve_aspect = node->node.doc.preserve_aspect; 776 vg_data->preserve_aspect = node->node.doc.preserve_aspect;
771 vg_data->root = vg_common_create_vg_node_helper(node, NULL); 777 vg_data->root = vg_common_create_vg_node_helper(node, NULL, vg_data);
772 778
773 return vg_data; 779 return vg_data;
774} 780}