summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/examples/edje/gradients.svg62
-rw-r--r--src/examples/edje/svg.edc5
-rw-r--r--src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c25
3 files changed, 85 insertions, 7 deletions
diff --git a/src/examples/edje/gradients.svg b/src/examples/edje/gradients.svg
new file mode 100644
index 0000000000..c0f85c4941
--- /dev/null
+++ b/src/examples/edje/gradients.svg
@@ -0,0 +1,62 @@
1<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
2 <defs>
3 <linearGradient
4 id="linearGradient1"
5 x1="0"
6 y1="0"
7 x2="0.2"
8 y2="0.2"
9 spreadMethod="reflect">
10 <stop
11 style="stop-color:#FF0000;stop-opacity:1;"
12 offset="0"/>
13 <stop
14 style="stop-color:#0000FF;stop-opacity:1;"
15 offset="1"/>
16 </linearGradient>
17 <radialGradient
18 id="radialGradient1"
19 r="0.2"
20 cx="0.3"
21 cy="0.3"
22 spreadMethod="reflect">
23 <stop
24 style="stop-color:#FFFF00;stop-opacity:1;"
25 offset="0"/>
26 <stop
27 style="stop-color:#00FFFF;stop-opacity:1;"
28 offset="1"/>
29 </radialGradient>
30 </defs>
31 <linearGradient
32 id="linearGradient2"
33 x1="0"
34 y1="0"
35 x2="0.2"
36 y2="0.2"
37 spreadMethod="reflect">
38 <stop
39 style="stop-color:#0F00F0;stop-opacity:1;"
40 offset="0"/>
41 <stop
42 style="stop-color:#0F000F;stop-opacity:1;"
43 offset="1"/>
44 </linearGradient>
45 <radialGradient
46 id="radialGradient2"
47 r="0.2"
48 cx="0.3"
49 cy="0.3"
50 spreadMethod="reflect">
51 <stop
52 style="stop-color:#00FF00;stop-opacity:1;"
53 offset="0"/>
54 <stop
55 style="stop-color:#FF00FF;stop-opacity:1;"
56 offset="1"/>
57 </radialGradient>
58 <rect x="0" y="0" width="50" height="50" fill="url(#linearGradient1)"/>
59 <rect x="50" y="0" width="50" height="50" fill="url(#radialGradient1)"/>
60 <rect x="0" y="50" width="50" height="50" fill="url(#linearGradient2)"/>
61 <rect x="50" y="50" width="50" height="50" fill="url(#radialGradient2)"/>
62</svg>
diff --git a/src/examples/edje/svg.edc b/src/examples/edje/svg.edc
index 208d95bf0c..f702bcfae6 100644
--- a/src/examples/edje/svg.edc
+++ b/src/examples/edje/svg.edc
@@ -72,6 +72,7 @@ collections {
72 vector: "favorite_off.svg"; 72 vector: "favorite_off.svg";
73 vector: "batman1.svg"; 73 vector: "batman1.svg";
74 vector: "batman2.svg"; 74 vector: "batman2.svg";
75 vector: "gradients.svg";
75 } 76 }
76 group { 77 group {
77 name: "svg-test"; 78 name: "svg-test";
@@ -104,6 +105,7 @@ collections {
104 SVG_PART("bg22", "vg22", 0.2, 0.8, .4, 1.0,"favorite_on.svg") 105 SVG_PART("bg22", "vg22", 0.2, 0.8, .4, 1.0,"favorite_on.svg")
105 SVG_PART("bg23", "vg23", 0.4, 0.8, .6, 1.0,"favorite_off.svg") 106 SVG_PART("bg23", "vg23", 0.4, 0.8, .6, 1.0,"favorite_off.svg")
106 SVG_PART_INTERPOLATE("bg24", "vg24", 0.6, 0.8, .8, 1.0,"batman1.svg", "batman2.svg") 107 SVG_PART_INTERPOLATE("bg24", "vg24", 0.6, 0.8, .8, 1.0,"batman1.svg", "batman2.svg")
108 SVG_PART("bg25", "vg25", 0.8, 0.8, 1.0, 1.0,"gradients.svg")
107 } 109 }
108 programs { 110 programs {
109 SVG_PROGRAM("bg1", "vg1") 111 SVG_PROGRAM("bg1", "vg1")
@@ -130,6 +132,7 @@ collections {
130 SVG_PROGRAM("bg22", "vg22") 132 SVG_PROGRAM("bg22", "vg22")
131 SVG_PROGRAM("bg23", "vg23") 133 SVG_PROGRAM("bg23", "vg23")
132 SVG_PROGRAM("bg24", "vg24") 134 SVG_PROGRAM("bg24", "vg24")
135 SVG_PROGRAM("bg25", "vg25")
133 } 136 }
134 } 137 }
135} \ No newline at end of file 138}
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 }