summaryrefslogtreecommitdiff
path: root/src/static_libs
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-03-11 16:23:27 +0900
committerHermet Park <hermetpark@gmail.com>2019-03-11 16:27:19 +0900
commit2fdbc21c030e0cafd3ea85f4f6a9d728ce4d5a6d (patch)
treef3bffc2fc8fe177bd71aeedea5557436cbcc883c /src/static_libs
parentb200fce1decb294e37d4b0682266ff96c7c2e419 (diff)
evas svg: replace internal vg legacy calls with interfaces.
Diffstat (limited to 'src/static_libs')
-rw-r--r--src/static_libs/vg_common/vg_common_svg.c134
1 files changed, 66 insertions, 68 deletions
diff --git a/src/static_libs/vg_common/vg_common_svg.c b/src/static_libs/vg_common/vg_common_svg.c
index c55a057..d960d9d 100644
--- a/src/static_libs/vg_common/vg_common_svg.c
+++ b/src/static_libs/vg_common/vg_common_svg.c
@@ -566,9 +566,9 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F
566 566
567 if (g->type == SVG_LINEAR_GRADIENT) 567 if (g->type == SVG_LINEAR_GRADIENT)
568 { 568 {
569 grad_obj = evas_vg_gradient_linear_add(parent); 569 grad_obj = efl_add(EFL_CANVAS_VG_GRADIENT_LINEAR_CLASS, parent);
570 evas_vg_gradient_linear_start_set(grad_obj, g->linear->x1 * r.w + r.x, g->linear->y1 * r.h + r.y); 570 efl_gfx_gradient_linear_start_set(grad_obj, g->linear->x1 * r.w + r.x, g->linear->y1 * r.h + r.y);
571 evas_vg_gradient_linear_end_set(grad_obj, g->linear->x2 * r.w + r.x, g->linear->y2 * r.h + r.y); 571 efl_gfx_gradient_linear_end_set(grad_obj, g->linear->x2 * r.w + r.x, g->linear->y2 * r.h + r.y);
572 } 572 }
573 else if (g->type == SVG_RADIAL_GRADIENT) 573 else if (g->type == SVG_RADIAL_GRADIENT)
574 { 574 {
@@ -583,10 +583,10 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F
583 int min = (r.h > r.w) ? r.w : r.h; 583 int min = (r.h > r.w) ? r.w : r.h;
584 radius = sqrt(pow(min, 2) + pow(min, 2)) / sqrt(2.0); 584 radius = sqrt(pow(min, 2) + pow(min, 2)) / sqrt(2.0);
585 } 585 }
586 grad_obj = evas_vg_gradient_radial_add(parent); 586 grad_obj = efl_add(EFL_CANVAS_VG_GRADIENT_RADIAL_CLASS, parent);
587 evas_vg_gradient_radial_center_set(grad_obj, g->radial->cx * r.w + r.x, g->radial->cy * r.h + r.y); 587 efl_gfx_gradient_radial_center_set(grad_obj, g->radial->cx * r.w + r.x, g->radial->cy * r.h + r.y);
588 evas_vg_gradient_radial_radius_set(grad_obj, g->radial->r * radius); 588 efl_gfx_gradient_radial_radius_set(grad_obj, g->radial->r * radius);
589 evas_vg_gradient_radial_focal_set(grad_obj, g->radial->fx * r.w + r.x, g->radial->fy * r.h + r.y); 589 efl_gfx_gradient_radial_focal_set(grad_obj, g->radial->fx * r.w + r.x, g->radial->fy * r.h + r.y);
590 590
591 /* in case of objectBoundingBox it need proper scaling */ 591 /* in case of objectBoundingBox it need proper scaling */
592 if (!g->user_space) 592 if (!g->user_space)
@@ -635,7 +635,7 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F
635 return NULL; 635 return NULL;
636 } 636 }
637 // apply common prperty 637 // apply common prperty
638 evas_vg_gradient_spread_set(grad_obj, g->spread); 638 efl_gfx_gradient_spread_set(grad_obj, g->spread);
639 // update the stops 639 // update the stops
640 stop_count = eina_list_count(g->stops); 640 stop_count = eina_list_count(g->stops);
641 if (stop_count) 641 if (stop_count)
@@ -651,7 +651,7 @@ _apply_gradient_property(Svg_Style_Gradient *g, Efl_VG *vg, Efl_VG *parent, Vg_F
651 stops[i].offset = stop->offset; 651 stops[i].offset = stop->offset;
652 i++; 652 i++;
653 } 653 }
654 evas_vg_gradient_stop_set(grad_obj, stops, stop_count); 654 efl_gfx_gradient_stop_set(grad_obj, stops, stop_count);
655 free(stops); 655 free(stops);
656 } 656 }
657 return grad_obj; 657 return grad_obj;
@@ -669,7 +669,7 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
669 669
670 // apply the transformation 670 // apply the transformation
671 if (node->transform) 671 if (node->transform)
672 evas_vg_node_transformation_set(vg, node->transform); 672 efl_canvas_vg_node_transformation_set(vg, node->transform);
673 673
674 if ((node->type == SVG_NODE_G) || (node->type == SVG_NODE_DOC)) return; 674 if ((node->type == SVG_NODE_G) || (node->type == SVG_NODE_DOC)) return;
675 675
@@ -683,25 +683,25 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
683 else if (style->fill.paint.gradient) 683 else if (style->fill.paint.gradient)
684 { 684 {
685 // if the fill has gradient then apply. 685 // if the fill has gradient then apply.
686 evas_vg_shape_fill_set(vg, _apply_gradient_property(style->fill.paint.gradient, vg, parent, vg_data)); 686 efl_canvas_vg_shape_fill_set(vg, _apply_gradient_property(style->fill.paint.gradient, vg, parent, vg_data));
687 } 687 }
688 else if (style->fill.paint.cur_color) 688 else if (style->fill.paint.cur_color)
689 { 689 {
690 // apply the current style color 690 // apply the current style color
691 evas_vg_node_color_set(vg, style->r, style->g, 691 efl_gfx_color_set(vg, style->r, style->g,
692 style->b, style->fill.opacity); 692 style->b, style->fill.opacity);
693 } 693 }
694 else 694 else
695 { 695 {
696 // apply the fill color 696 // apply the fill color
697 evas_vg_node_color_set(vg, style->fill.paint.r, style->fill.paint.g, 697 efl_gfx_color_set(vg, style->fill.paint.r, style->fill.paint.g,
698 style->fill.paint.b, style->fill.opacity); 698 style->fill.paint.b, style->fill.opacity);
699 } 699 }
700 700
701 evas_vg_shape_stroke_width_set(vg, style->stroke.width); 701 efl_gfx_shape_stroke_width_set(vg, style->stroke.width);
702 evas_vg_shape_stroke_cap_set(vg, style->stroke.cap); 702 efl_gfx_shape_stroke_cap_set(vg, style->stroke.cap);
703 evas_vg_shape_stroke_join_set(vg, style->stroke.join); 703 efl_gfx_shape_stroke_join_set(vg, style->stroke.join);
704 evas_vg_shape_stroke_scale_set(vg, style->stroke.scale); 704 efl_gfx_shape_stroke_scale_set(vg, style->stroke.scale);
705 // if stroke property is NULL then do nothing 705 // if stroke property is NULL then do nothing
706 if (style->stroke.paint.none) 706 if (style->stroke.paint.none)
707 { 707 {
@@ -710,7 +710,7 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
710 else if (style->stroke.paint.gradient) 710 else if (style->stroke.paint.gradient)
711 { 711 {
712 // if the fill has gradient then apply. 712 // if the fill has gradient then apply.
713 evas_vg_shape_stroke_fill_set(vg, _apply_gradient_property(style->stroke.paint.gradient, vg, parent, vg_data)); 713 efl_canvas_vg_shape_stroke_fill_set(vg, _apply_gradient_property(style->stroke.paint.gradient, vg, parent, vg_data));
714 } 714 }
715 else if (style->stroke.paint.url) 715 else if (style->stroke.paint.url)
716 { 716 {
@@ -720,13 +720,13 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
720 else if (style->stroke.paint.cur_color) 720 else if (style->stroke.paint.cur_color)
721 { 721 {
722 // apply the current style color 722 // apply the current style color
723 evas_vg_shape_stroke_color_set(vg, style->r, style->g, 723 efl_gfx_shape_stroke_color_set(vg, style->r, style->g,
724 style->b, style->stroke.opacity); 724 style->b, style->stroke.opacity);
725 } 725 }
726 else 726 else
727 { 727 {
728 // apply the stroke color 728 // apply the stroke color
729 evas_vg_shape_stroke_color_set(vg, style->stroke.paint.r, style->stroke.paint.g, 729 efl_gfx_shape_stroke_color_set(vg, style->stroke.paint.r, style->stroke.paint.g,
730 style->stroke.paint.b, style->stroke.opacity); 730 style->stroke.paint.b, style->stroke.opacity);
731 } 731 }
732} 732}
@@ -738,12 +738,12 @@ _add_polyline(Efl_VG *vg, double *array, int size, Eina_Bool polygon)
738 738
739 if (size < 2) return; 739 if (size < 2) return;
740 740
741 evas_vg_shape_append_move_to(vg, array[0], array[1]); 741 efl_gfx_path_append_move_to(vg, array[0], array[1]);
742 for (i=2; i < size; i+=2) 742 for (i=2; i < size; i+=2)
743 evas_vg_shape_append_line_to(vg, array[i], array[i+1]); 743 efl_gfx_path_append_line_to(vg, array[i], array[i+1]);
744 744
745 if (polygon) 745 if (polygon)
746 evas_vg_shape_append_close(vg); 746 efl_gfx_path_append_close(vg);
747} 747}
748 748
749static Efl_VG * 749static Efl_VG *
@@ -764,48 +764,46 @@ vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent, Vg_File_Data *vg
764 vg = efl_add(EFL_CANVAS_VG_CONTAINER_CLASS, parent); 764 vg = efl_add(EFL_CANVAS_VG_CONTAINER_CLASS, parent);
765 _apply_vg_property(node, vg, parent, vg_data); 765 _apply_vg_property(node, vg, parent, vg_data);
766 EINA_LIST_FOREACH(node->child, l, child) 766 EINA_LIST_FOREACH(node->child, l, child)
767 { 767 vg_common_create_vg_node_helper(child, vg, vg_data);
768 vg_common_create_vg_node_helper(child, vg, vg_data);
769 }
770 return vg; 768 return vg;
771 } 769 }
772 break; 770 break;
773 case SVG_NODE_PATH: 771 case SVG_NODE_PATH:
774 vg = evas_vg_shape_add(parent); 772 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
775 evas_vg_shape_append_svg_path(vg, node->node.path.path); 773 efl_gfx_path_append_svg_path(vg, node->node.path.path);
776 break; 774 break;
777 case SVG_NODE_POLYGON: 775 case SVG_NODE_POLYGON:
778 vg = evas_vg_shape_add(parent); 776 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
779 _add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_TRUE); 777 _add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_TRUE);
780 break; 778 break;
781 case SVG_NODE_POLYLINE: 779 case SVG_NODE_POLYLINE:
782 vg = evas_vg_shape_add(parent); 780 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
783 _add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_FALSE); 781 _add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_FALSE);
784 break; 782 break;
785 case SVG_NODE_ELLIPSE: 783 case SVG_NODE_ELLIPSE:
786 vg = evas_vg_shape_add(parent); 784 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
787 evas_vg_shape_append_arc(vg, node->node.ellipse.cx - node->node.ellipse.rx, 785 efl_gfx_path_append_arc(vg, node->node.ellipse.cx - node->node.ellipse.rx,
788 node->node.ellipse.cy - node->node.ellipse.ry, 786 node->node.ellipse.cy - node->node.ellipse.ry,
789 2*node->node.ellipse.rx, 2*node->node.ellipse.ry, 0, 360); 787 2*node->node.ellipse.rx, 2*node->node.ellipse.ry, 0, 360);
790 evas_vg_shape_append_close(vg); 788 efl_gfx_path_append_close(vg);
791 break; 789 break;
792 case SVG_NODE_CIRCLE: 790 case SVG_NODE_CIRCLE:
793 vg = evas_vg_shape_add(parent); 791 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
794 evas_vg_shape_append_circle(vg, node->node.circle.cx, node->node.circle.cy, node->node.circle.r); 792 efl_gfx_path_append_circle(vg, node->node.circle.cx, node->node.circle.cy, node->node.circle.r);
795 break; 793 break;
796 case SVG_NODE_RECT: 794 case SVG_NODE_RECT:
797 vg = evas_vg_shape_add(parent); 795 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
798 evas_vg_shape_append_rect(vg, node->node.rect.x, node->node.rect.y, node->node.rect.w, node->node.rect.h, 796 efl_gfx_path_append_rect(vg, node->node.rect.x, node->node.rect.y, node->node.rect.w, node->node.rect.h,
799 node->node.rect.rx, node->node.rect.ry); 797 node->node.rect.rx, node->node.rect.ry);
800 break; 798 break;
801 case SVG_NODE_LINE: 799 case SVG_NODE_LINE:
802 vg = evas_vg_shape_add(parent); 800 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
803 evas_vg_shape_append_move_to(vg, node->node.line.x1, node->node.line.y1); 801 efl_gfx_path_append_move_to(vg, node->node.line.x1, node->node.line.y1);
804 evas_vg_shape_append_line_to(vg, node->node.line.x2, node->node.line.y2); 802 efl_gfx_path_append_line_to(vg, node->node.line.x2, node->node.line.y2);
805 break; 803 break;
806 case SVG_NODE_CUSTOME_COMMAND: 804 case SVG_NODE_CUSTOME_COMMAND:
807 vg = evas_vg_shape_add(parent); 805 vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
808 evas_vg_shape_path_set(vg, node->node.command.commands, node->node.command.points); 806 efl_gfx_path_set(vg, node->node.command.commands, node->node.command.points);
809 break; 807 break;
810 default: 808 default:
811 break; 809 break;
@@ -895,8 +893,8 @@ _create_gradient_node(Efl_VG *vg)
895 Svg_Style_Gradient *grad = calloc(1, sizeof(Svg_Style_Gradient)); 893 Svg_Style_Gradient *grad = calloc(1, sizeof(Svg_Style_Gradient));
896 EINA_SAFETY_ON_NULL_RETURN_VAL(grad, NULL); 894 EINA_SAFETY_ON_NULL_RETURN_VAL(grad, NULL);
897 895
898 grad->spread = evas_vg_gradient_spread_get(vg); 896 grad->spread = efl_gfx_gradient_spread_get(vg);
899 evas_vg_gradient_stop_get(vg, &stops, &count); 897 efl_gfx_gradient_stop_get(vg, &stops, &count);
900 for (i = 0; i < count; i++) 898 for (i = 0; i < count; i++)
901 { 899 {
902 new_stop = calloc(1, sizeof(Efl_Gfx_Gradient_Stop)); 900 new_stop = calloc(1, sizeof(Efl_Gfx_Gradient_Stop));
@@ -910,17 +908,17 @@ _create_gradient_node(Efl_VG *vg)
910 grad->type = SVG_LINEAR_GRADIENT; 908 grad->type = SVG_LINEAR_GRADIENT;
911 grad->linear = calloc(1, sizeof(Svg_Linear_Gradient)); 909 grad->linear = calloc(1, sizeof(Svg_Linear_Gradient));
912 if (!grad->linear) goto oom_error; 910 if (!grad->linear) goto oom_error;
913 evas_vg_gradient_linear_start_get(vg, &grad->linear->x1, &grad->linear->y1); 911 efl_gfx_gradient_linear_start_get(vg, &grad->linear->x1, &grad->linear->y1);
914 evas_vg_gradient_linear_end_get(vg, &grad->linear->x2, &grad->linear->y2); 912 efl_gfx_gradient_linear_end_get(vg, &grad->linear->x2, &grad->linear->y2);
915 } 913 }
916 else 914 else
917 { 915 {
918 grad->type = SVG_RADIAL_GRADIENT; 916 grad->type = SVG_RADIAL_GRADIENT;
919 grad->radial = calloc(1, sizeof(Svg_Radial_Gradient)); 917 grad->radial = calloc(1, sizeof(Svg_Radial_Gradient));
920 if (!grad->radial) goto oom_error; 918 if (!grad->radial) goto oom_error;
921 evas_vg_gradient_radial_center_get(vg, &grad->radial->cx, &grad->radial->cy); 919 efl_gfx_gradient_radial_center_get(vg, &grad->radial->cx, &grad->radial->cy);
922 evas_vg_gradient_radial_focal_get(vg, &grad->radial->fx, &grad->radial->fy); 920 efl_gfx_gradient_radial_focal_get(vg, &grad->radial->fx, &grad->radial->fy);
923 grad->radial->r = evas_vg_gradient_radial_radius_get(vg); 921 grad->radial->r = efl_gfx_gradient_radial_radius_get(vg);
924 } 922 }
925 923
926 return grad; 924 return grad;
@@ -939,7 +937,7 @@ _apply_svg_property(Svg_Node *node, Efl_VG *vg)
939 Svg_Style_Property *style = node->style; 937 Svg_Style_Property *style = node->style;
940 938
941 // transformation 939 // transformation
942 if ((matrix = evas_vg_node_transformation_get(vg))) 940 if ((matrix = efl_canvas_vg_node_transformation_get(vg)))
943 { 941 {
944 node->transform = calloc(1, sizeof(Eina_Matrix3)); 942 node->transform = calloc(1, sizeof(Eina_Matrix3));
945 eina_matrix3_copy(node->transform, matrix); 943 eina_matrix3_copy(node->transform, matrix);
@@ -956,36 +954,36 @@ _apply_svg_property(Svg_Node *node, Efl_VG *vg)
956 // apply the fill style property 954 // apply the fill style property
957 style->fill.fill_rule = efl_gfx_shape_fill_rule_get(vg); 955 style->fill.fill_rule = efl_gfx_shape_fill_rule_get(vg);
958 style->fill.paint.none = EINA_FALSE; 956 style->fill.paint.none = EINA_FALSE;
959 if (evas_vg_shape_fill_get(vg)) 957 if (efl_canvas_vg_shape_fill_get(vg))
960 { 958 {
961 // if the fill has gradient then apply. 959 // if the fill has gradient then apply.
962 style->fill.paint.gradient = _create_gradient_node(evas_vg_shape_fill_get(vg)); 960 style->fill.paint.gradient = _create_gradient_node(efl_canvas_vg_shape_fill_get(vg));
963 } 961 }
964 else 962 else
965 { 963 {
966 evas_vg_node_color_get(vg, &style->fill.paint.r, &style->fill.paint.g, 964 efl_gfx_color_get(vg, &style->fill.paint.r, &style->fill.paint.g,
967 &style->fill.paint.b, &style->fill.opacity); 965 &style->fill.paint.b, &style->fill.opacity);
968 } 966 }
969 967
970 // apply stroke style property 968 // apply stroke style property
971 style->stroke.paint.none = EINA_FALSE; 969 style->stroke.paint.none = EINA_FALSE;
972 970
973 if (evas_vg_shape_stroke_fill_get(vg)) 971 if (efl_canvas_vg_shape_stroke_fill_get(vg))
974 { 972 {
975 // if the stroke has gradient then apply. 973 // if the stroke has gradient then apply.
976 style->stroke.paint.gradient = _create_gradient_node(evas_vg_shape_stroke_fill_get(vg)); 974 style->stroke.paint.gradient = _create_gradient_node(efl_canvas_vg_shape_stroke_fill_get(vg));
977 } 975 }
978 else 976 else
979 { 977 {
980 // apply the stroke color 978 // apply the stroke color
981 evas_vg_shape_stroke_color_get(vg, &style->stroke.paint.r, &style->stroke.paint.g, 979 efl_gfx_shape_stroke_color_get(vg, &style->stroke.paint.r, &style->stroke.paint.g,
982 &style->stroke.paint.b, &style->stroke.opacity); 980 &style->stroke.paint.b, &style->stroke.opacity);
983 } 981 }
984 982
985 style->stroke.width = (evas_vg_shape_stroke_width_get(vg)); 983 style->stroke.width = efl_gfx_shape_stroke_width_get(vg);
986 style->stroke.cap = evas_vg_shape_stroke_cap_get(vg); 984 style->stroke.cap = efl_gfx_shape_stroke_cap_get(vg);
987 style->stroke.join = evas_vg_shape_stroke_join_get(vg); 985 style->stroke.join = efl_gfx_shape_stroke_join_get(vg);
988 style->stroke.scale = evas_vg_shape_stroke_scale_get(vg); 986 style->stroke.scale = efl_gfx_shape_stroke_scale_get(vg);
989 987
990 988
991} 989}
@@ -1014,8 +1012,8 @@ vg_common_create_svg_node_helper(Efl_VG *vg, Svg_Node *parent)
1014 else if (efl_isa(vg, EFL_CANVAS_VG_SHAPE_CLASS)) 1012 else if (efl_isa(vg, EFL_CANVAS_VG_SHAPE_CLASS))
1015 { 1013 {
1016 svg_node = _create_node(parent, SVG_NODE_CUSTOME_COMMAND); 1014 svg_node = _create_node(parent, SVG_NODE_CUSTOME_COMMAND);
1017 evas_vg_shape_path_get(vg, &commands, &points); 1015 efl_gfx_path_get(vg, &commands, &points);
1018 evas_vg_shape_path_length_get(vg, &commands_count, &points_count); 1016 efl_gfx_path_length_get(vg, &commands_count, &points_count);
1019 svg_node->node.command.commands_count = commands_count; 1017 svg_node->node.command.commands_count = commands_count;
1020 svg_node->node.command.points_count = points_count; 1018 svg_node->node.command.points_count = points_count;
1021 svg_node->node.command.points = calloc(points_count, sizeof(double)); 1019 svg_node->node.command.points = calloc(points_count, sizeof(double));