summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2019-07-15 21:23:38 +0900
committerHermet Park <hermetpark@gmail.com>2019-07-15 21:23:38 +0900
commit2e4c928d81f85826a3ae608d4186dd35f4c282c8 (patch)
tree835e4b92ed3ccf7689ad59ae7c92e6d04424e17f /src/modules
parent84fcc5d073c7be9ff4152745fcbc63383cb95dc3 (diff)
evas_vg_load_svg: Support multiple gradient without <defs> part
Summary: Multiple gradients can be declared. There is a problem of keeping only one gradient information when it is declared outside defs or when defs is not declared. It supports the use of multiple gradients even if no defs are declared. Test Plan: (with D9312 patch) cd src/example/edje edje_cc -beta svg.edc && gcc -o svg-test svg-test.c `pkg-config --libs --cflags evas ecore ecore-evas edje` ./svg-test Reviewers: Hermet, kimcinoo, smohanty Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9315
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
index 5bfdf41728..36edaabdba 100644
--- a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
+++ b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
@@ -35,7 +35,8 @@ struct _Evas_SVG_Loader
35 Eina_Array *stack; 35 Eina_Array *stack;
36 Svg_Node *doc; 36 Svg_Node *doc;
37 Svg_Node *def; 37 Svg_Node *def;
38 Svg_Style_Gradient *gradient; 38 Eina_List *gradients;
39 Svg_Style_Gradient *latest_gradient; //for stops
39 Evas_SVG_Parser *svg_parse; 40 Evas_SVG_Parser *svg_parse;
40 int level; 41 int level;
41 Eina_Bool result:1; 42 Eina_Bool result:1;
@@ -2158,11 +2159,21 @@ _evas_svg_loader_xml_open_parser(Evas_SVG_Loader *loader,
2158 { 2159 {
2159 Svg_Style_Gradient *gradient; 2160 Svg_Style_Gradient *gradient;
2160 gradient = gradient_method(loader, attrs, attrs_length); 2161 gradient = gradient_method(loader, attrs, attrs_length);
2162 /*FIXME: The current parsing structure does not distinguish end tags.
2163 There is no way to know if the currently parsed gradient is in defs.
2164 If a gradient is declared outside of defs after defs is set, it is included in the gradients of defs.
2165 But finally, the loader has a gradient style list regardless of defs.
2166 This is only to support this when multiple gradients are declared, even if no defs are declared.
2167 refer to: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs */
2161 if (loader->doc->node.doc.defs) 2168 if (loader->doc->node.doc.defs)
2162 { 2169 {
2163 loader->def->node.defs.gradients = eina_list_append(loader->def->node.defs.gradients, gradient); 2170 loader->def->node.defs.gradients = eina_list_append(loader->def->node.defs.gradients, gradient);
2164 } 2171 }
2165 loader->gradient = gradient; 2172 else
2173 {
2174 loader->gradients = eina_list_append(loader->gradients, gradient);
2175 }
2176 loader->latest_gradient = gradient;
2166 } 2177 }
2167 else if (!strcmp(tag_name, "stop")) 2178 else if (!strcmp(tag_name, "stop"))
2168 { 2179 {
@@ -2172,8 +2183,10 @@ _evas_svg_loader_xml_open_parser(Evas_SVG_Loader *loader,
2172 stop->a = 255; 2183 stop->a = 255;
2173 eina_simple_xml_attributes_parse(attrs, attrs_length, 2184 eina_simple_xml_attributes_parse(attrs, attrs_length,
2174 _attr_parse_stops, loader); 2185 _attr_parse_stops, loader);
2175 if (loader->gradient) 2186 if (loader->latest_gradient)
2176 loader->gradient->stops = eina_list_append(loader->gradient->stops, stop); 2187 {
2188 loader->latest_gradient->stops = eina_list_append(loader->latest_gradient->stops, stop);
2189 }
2177 } 2190 }
2178 2191
2179} 2192}
@@ -2415,9 +2428,9 @@ evas_vg_load_file_open_svg(Eina_File *file,
2415 _update_gradient(loader.doc, defs->node.defs.gradients); 2428 _update_gradient(loader.doc, defs->node.defs.gradients);
2416 else 2429 else
2417 { 2430 {
2418 if (loader.gradient) 2431 if (loader.gradients)
2419 { 2432 {
2420 Eina_List* gradient_list = eina_list_append(NULL, loader.gradient); 2433 Eina_List* gradient_list = loader.gradients;
2421 _update_gradient(loader.doc, gradient_list); 2434 _update_gradient(loader.doc, gradient_list);
2422 eina_list_free(gradient_list); 2435 eina_list_free(gradient_list);
2423 } 2436 }