summaryrefslogtreecommitdiff
path: root/src/static_libs
diff options
context:
space:
mode:
authorSubhransu Mohanty <sub.mohanty@samsung.com>2016-11-02 19:22:55 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-27 14:58:38 +0900
commit48c1c4850a486b1d416665d7e7536842d4d68979 (patch)
treef292314a4ae8671a4748f38eacbabd9091b01d4d /src/static_libs
parent21259e411d1d16956196d0ac5c12f5c96ab5a490 (diff)
static_lib: added vg_common static lib
Features: Copied vg eet descriptor from edje_data Copied convert func from Svg_Node to Efl_VG from edje added convert function from Efl_VG to Svg_Node
Diffstat (limited to 'src/static_libs')
-rw-r--r--src/static_libs/vg_common/vg_common.c965
-rw-r--r--src/static_libs/vg_common/vg_common.h299
2 files changed, 1264 insertions, 0 deletions
diff --git a/src/static_libs/vg_common/vg_common.c b/src/static_libs/vg_common/vg_common.c
new file mode 100644
index 0000000..673ab0a
--- /dev/null
+++ b/src/static_libs/vg_common/vg_common.c
@@ -0,0 +1,965 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "vg_common.h"
6
7#include <Eet.h>
8#include <Evas.h>
9
10
11
12Eet_Data_Descriptor *_eet_rect_node = NULL;
13Eet_Data_Descriptor *_eet_circle_node = NULL;
14Eet_Data_Descriptor *_eet_ellipse_node = NULL;
15Eet_Data_Descriptor *_eet_gradient_stops_node = NULL;
16Eet_Data_Descriptor *_eet_linear_gradient_node = NULL;
17Eet_Data_Descriptor *_eet_radial_gradient_node = NULL;
18Eet_Data_Descriptor *_eet_style_gradient_node = NULL;
19Eet_Data_Descriptor *_eet_style_property_node = NULL;
20Eet_Data_Descriptor *_eet_matrix3_node = NULL;
21Eet_Data_Descriptor *_eet_doc_node = NULL;
22Eet_Data_Descriptor *_eet_defs_node = NULL;
23Eet_Data_Descriptor *_eet_g_node = NULL;
24Eet_Data_Descriptor *_eet_arc_node = NULL;
25Eet_Data_Descriptor *_eet_path_node = NULL;
26Eet_Data_Descriptor *_eet_polygon_node = NULL;
27Eet_Data_Descriptor *_eet_vg_node = NULL;
28Eet_Data_Descriptor *_eet_line_node = NULL;
29Eet_Data_Descriptor *_eet_custom_command_node = NULL;
30
31#define FREE_DESCRIPTOR(eed) \
32 if (eed) \
33 { \
34 eet_data_descriptor_free((eed)); \
35 (eed) = NULL; \
36 }
37
38static inline Eet_Data_Descriptor*
39_eet_for_rect_node(void)
40{
41 Eet_Data_Descriptor *eet;
42 Eet_Data_Descriptor_Class eetc;
43
44 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Rect_Node);
45 eet = eet_data_descriptor_stream_new(&eetc);
46 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Rect_Node, "x", x, EET_T_DOUBLE);
47 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Rect_Node, "y", y, EET_T_DOUBLE);
48 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Rect_Node, "w", w, EET_T_DOUBLE);
49 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Rect_Node, "h", h, EET_T_DOUBLE);
50 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Rect_Node, "rx", rx, EET_T_DOUBLE);
51 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Rect_Node, "ry", ry, EET_T_DOUBLE);
52 return eet;
53}
54
55static inline Eet_Data_Descriptor*
56_eet_for_line_node(void)
57{
58 Eet_Data_Descriptor *eet;
59 Eet_Data_Descriptor_Class eetc;
60
61 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Line_Node);
62 eet = eet_data_descriptor_stream_new(&eetc);
63 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Line_Node, "x1", x1, EET_T_DOUBLE);
64 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Line_Node, "y1", y1, EET_T_DOUBLE);
65 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Line_Node, "x2", x2, EET_T_DOUBLE);
66 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Line_Node, "y2", y2, EET_T_DOUBLE);
67 return eet;
68}
69
70static inline Eet_Data_Descriptor*
71_eet_for_circle_node(void)
72{
73 Eet_Data_Descriptor *eet;
74 Eet_Data_Descriptor_Class eetc;
75
76 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Circle_Node);
77 eet = eet_data_descriptor_stream_new(&eetc);
78 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Circle_Node, "cx", cx, EET_T_DOUBLE);
79 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Circle_Node, "cy", cy, EET_T_DOUBLE);
80 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Circle_Node, "r", r, EET_T_DOUBLE);
81 return eet;
82}
83
84static inline Eet_Data_Descriptor*
85_eet_for_ellipse_node(void)
86{
87 Eet_Data_Descriptor *eet;
88 Eet_Data_Descriptor_Class eetc;
89
90 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Ellipse_Node);
91 eet = eet_data_descriptor_stream_new(&eetc);
92 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Ellipse_Node, "cx", cx, EET_T_DOUBLE);
93 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Ellipse_Node, "cy", cy, EET_T_DOUBLE);
94 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Ellipse_Node, "rx", rx, EET_T_DOUBLE);
95 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Ellipse_Node, "ry", ry, EET_T_DOUBLE);
96 return eet;
97}
98
99
100static inline Eet_Data_Descriptor*
101_eet_for_gradient_stops(void)
102{
103 Eet_Data_Descriptor *eet;
104 Eet_Data_Descriptor_Class eetc;
105
106 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Efl_Gfx_Gradient_Stop);
107 eet = eet_data_descriptor_stream_new(&eetc);
108 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Efl_Gfx_Gradient_Stop, "offset", offset, EET_T_DOUBLE);
109 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Efl_Gfx_Gradient_Stop, "r", r, EET_T_INT);
110 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Efl_Gfx_Gradient_Stop, "g", g, EET_T_INT);
111 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Efl_Gfx_Gradient_Stop, "b", b, EET_T_INT);
112 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Efl_Gfx_Gradient_Stop, "a", a, EET_T_INT);
113 return eet;
114}
115
116static inline Eet_Data_Descriptor*
117_eet_for_linear_gradient(void)
118{
119 Eet_Data_Descriptor *eet;
120 Eet_Data_Descriptor_Class eetc;
121
122 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Linear_Gradient);
123 eet = eet_data_descriptor_stream_new(&eetc);
124 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Linear_Gradient, "x1", x1, EET_T_DOUBLE);
125 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Linear_Gradient, "y1", y1, EET_T_DOUBLE);
126 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Linear_Gradient, "x2", x2, EET_T_DOUBLE);
127 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Linear_Gradient, "y2", y2, EET_T_DOUBLE);
128 return eet;
129}
130
131static inline Eet_Data_Descriptor*
132_eet_for_radial_gradient(void)
133{
134 Eet_Data_Descriptor *eet;
135 Eet_Data_Descriptor_Class eetc;
136
137 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Radial_Gradient);
138 eet = eet_data_descriptor_stream_new(&eetc);
139 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Radial_Gradient, "cx", cx, EET_T_DOUBLE);
140 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Radial_Gradient, "cy", cy, EET_T_DOUBLE);
141 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Radial_Gradient, "fx", fx, EET_T_DOUBLE);
142 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Radial_Gradient, "fy", fy, EET_T_DOUBLE);
143 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Radial_Gradient, "r", r, EET_T_DOUBLE);
144 return eet;
145}
146
147static inline Eet_Data_Descriptor*
148_eet_for_style_gradient(void)
149{
150 Eet_Data_Descriptor_Class eetc;
151
152 if (_eet_style_gradient_node) return _eet_style_gradient_node;
153
154 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Style_Gradient);
155 _eet_style_gradient_node = eet_data_descriptor_stream_new(&eetc);
156 _eet_gradient_stops_node = _eet_for_gradient_stops();
157 _eet_linear_gradient_node = _eet_for_linear_gradient();
158 _eet_radial_gradient_node = _eet_for_radial_gradient();
159
160 EET_DATA_DESCRIPTOR_ADD_BASIC(_eet_style_gradient_node, Svg_Style_Gradient, "type", type, EET_T_INT);
161 EET_DATA_DESCRIPTOR_ADD_BASIC(_eet_style_gradient_node, Svg_Style_Gradient, "id", id, EET_T_STRING);
162 EET_DATA_DESCRIPTOR_ADD_BASIC(_eet_style_gradient_node, Svg_Style_Gradient, "spread", spread, EET_T_INT);
163 EET_DATA_DESCRIPTOR_ADD_LIST(_eet_style_gradient_node, Svg_Style_Gradient, "stops", stops, _eet_gradient_stops_node);
164 EET_DATA_DESCRIPTOR_ADD_SUB(_eet_style_gradient_node, Svg_Style_Gradient, "radial", radial, _eet_radial_gradient_node);
165 EET_DATA_DESCRIPTOR_ADD_SUB(_eet_style_gradient_node, Svg_Style_Gradient, "linear", linear, _eet_linear_gradient_node);
166
167 return _eet_style_gradient_node;
168}
169
170static inline Eet_Data_Descriptor*
171_eet_for_style_property(void)
172{
173 Eet_Data_Descriptor *eet, *eet_gradient, *eet_dash;
174 Eet_Data_Descriptor_Class eetc, eetc_dash;
175
176 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Style_Property);
177 eet = eet_data_descriptor_stream_new(&eetc);
178 eet_gradient = _eet_for_style_gradient();
179
180 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc_dash, Efl_Gfx_Dash);
181 eet_dash = eet_data_descriptor_stream_new(&eetc_dash);
182 EET_DATA_DESCRIPTOR_ADD_BASIC(eet_dash, Efl_Gfx_Dash, "length", length, EET_T_DOUBLE);
183 EET_DATA_DESCRIPTOR_ADD_BASIC(eet_dash, Efl_Gfx_Dash, "gap", gap, EET_T_DOUBLE);
184
185 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "r", r, EET_T_INT);
186 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "g", g, EET_T_INT);
187 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "b", b, EET_T_INT);
188 // for fill
189 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.flags", fill.flags, EET_T_INT);
190 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.r", fill.paint.r, EET_T_INT);
191 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.g", fill.paint.g, EET_T_INT);
192 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.b", fill.paint.b, EET_T_INT);
193 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.none", fill.paint.none, EET_T_INT);
194 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.cur_color", fill.paint.cur_color, EET_T_INT);
195 EET_DATA_DESCRIPTOR_ADD_SUB(eet, Svg_Style_Property, "fill.paint.gradient", fill.paint.gradient, eet_gradient);
196 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.paint.url", fill.paint.url, EET_T_STRING);
197 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.opacity", fill.opacity, EET_T_INT);
198 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "fill.fill_rule", fill.fill_rule, EET_T_INT);
199
200 // for stroke
201 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.flags", stroke.flags, EET_T_INT);
202 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.paint.r", stroke.paint.r, EET_T_INT);
203 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.paint.g", stroke.paint.g, EET_T_INT);
204 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.paint.b", stroke.paint.b, EET_T_INT);
205 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.paint.none", stroke.paint.none, EET_T_INT);
206 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.paint.cur_color", stroke.paint.cur_color, EET_T_INT);
207 EET_DATA_DESCRIPTOR_ADD_SUB(eet, Svg_Style_Property, "stroke.paint.gradient", stroke.paint.gradient, eet_gradient);
208 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.paint.url", stroke.paint.url, EET_T_STRING);
209 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.opacity", stroke.opacity, EET_T_INT);
210 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.scale", stroke.scale, EET_T_DOUBLE);
211 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.width", stroke.width, EET_T_DOUBLE);
212 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.centered", stroke.centered, EET_T_DOUBLE);
213 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.cap", stroke.cap, EET_T_INT);
214 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.join", stroke.join, EET_T_INT);
215 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(eet, Svg_Style_Property, "stroke.dash", stroke.dash, eet_dash);
216 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Style_Property, "stroke.dash_count", stroke.dash_count, EET_T_INT);
217
218 return eet;
219}
220
221static Eet_Data_Descriptor*
222_eet_for_eina_matrix3(void)
223{
224 Eet_Data_Descriptor *eet;
225 Eet_Data_Descriptor_Class eetc;
226
227 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Eina_Matrix3);
228 eet = eet_data_descriptor_stream_new(&eetc);
229 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "xx", xx, EET_T_DOUBLE);
230 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "xy", xy, EET_T_DOUBLE);
231 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "xz", xz, EET_T_DOUBLE);
232 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "yx", yx, EET_T_DOUBLE);
233 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "yy", yy, EET_T_DOUBLE);
234 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "yz", yz, EET_T_DOUBLE);
235 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "zx", zx, EET_T_DOUBLE);
236 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "zy", zy, EET_T_DOUBLE);
237 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Eina_Matrix3, "zz", zz, EET_T_DOUBLE);
238
239 return eet;
240}
241
242static inline Eet_Data_Descriptor*
243_eet_for_doc_node(void)
244{
245 Eet_Data_Descriptor *eet;
246 Eet_Data_Descriptor_Class eetc;
247
248 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Doc_Node);
249 eet = eet_data_descriptor_stream_new(&eetc);
250 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Doc_Node, "width", width, EET_T_DOUBLE);
251 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Doc_Node, "height", height, EET_T_DOUBLE);
252 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Doc_Node, "vx", vx, EET_T_DOUBLE);
253 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Doc_Node, "vy", vy, EET_T_DOUBLE);
254 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Doc_Node, "vw", vw, EET_T_DOUBLE);
255 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Doc_Node, "vh", vh, EET_T_DOUBLE);
256 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Doc_Node, "preserve_aspect", preserve_aspect, EET_T_INT);
257 return eet;
258}
259
260static inline Eet_Data_Descriptor*
261_eet_for_defs_node(void)
262{
263 Eet_Data_Descriptor *eet, *eet_gradient;
264 Eet_Data_Descriptor_Class eetc;
265
266 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Defs_Node);
267 eet = eet_data_descriptor_stream_new(&eetc);
268 eet_gradient = _eet_for_style_gradient();
269
270 EET_DATA_DESCRIPTOR_ADD_LIST(eet, Svg_Defs_Node, "gradients", gradients, eet_gradient);
271 return eet;
272}
273
274static inline Eet_Data_Descriptor*
275_eet_for_g_node(void)
276{
277 Eet_Data_Descriptor *eet;
278 Eet_Data_Descriptor_Class eetc;
279
280 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_G_Node);
281 eet = eet_data_descriptor_stream_new(&eetc);
282 return eet;
283}
284
285static inline Eet_Data_Descriptor*
286_eet_for_arc_node(void)
287{
288 Eet_Data_Descriptor *eet;
289 Eet_Data_Descriptor_Class eetc;
290
291 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Arc_Node);
292 eet = eet_data_descriptor_stream_new(&eetc);
293 return eet;
294}
295
296static inline Eet_Data_Descriptor*
297_eet_for_polygon_node(void)
298{
299 Eet_Data_Descriptor *eet;
300 Eet_Data_Descriptor_Class eetc;
301
302 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Polygon_Node);
303 eet = eet_data_descriptor_stream_new(&eetc);
304 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Polygon_Node, "points_count", points_count, EET_T_INT);
305 EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(eet, Svg_Polygon_Node, "points", points, EET_T_DOUBLE);
306 return eet;
307}
308
309static inline Eet_Data_Descriptor*
310_eet_for_custom_command_node(void)
311{
312 Eet_Data_Descriptor *eet;
313 Eet_Data_Descriptor_Class eetc;
314
315 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Custom_Command_Node);
316 eet = eet_data_descriptor_stream_new(&eetc);
317 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Custom_Command_Node, "points_count", points_count, EET_T_INT);
318 EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(eet, Svg_Custom_Command_Node, "points", points, EET_T_DOUBLE);
319 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Custom_Command_Node, "commands_count", commands_count, EET_T_INT);
320 EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(eet, Svg_Custom_Command_Node, "commands", commands, EET_T_INT);
321 return eet;
322}
323
324static inline Eet_Data_Descriptor*
325_eet_for_path_node(void)
326{
327 Eet_Data_Descriptor *eet;
328 Eet_Data_Descriptor_Class eetc;
329
330 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Path_Node);
331 eet = eet_data_descriptor_stream_new(&eetc);
332 EET_DATA_DESCRIPTOR_ADD_BASIC(eet, Svg_Path_Node, "path", path, EET_T_STRING);
333 return eet;
334}
335
336struct
337{
338 Svg_Node_Type u;
339 const char *name;
340} eet_mapping[] = {
341 { SVG_NODE_DOC, "doc" },
342 { SVG_NODE_G, "g" },
343 { SVG_NODE_DEFS, "defs" },
344 { SVG_NODE_ARC, "arc" },
345 { SVG_NODE_CIRCLE, "circle" },
346 { SVG_NODE_ELLIPSE, "ellipse" },
347 { SVG_NODE_POLYGON, "polygon" },
348 { SVG_NODE_POLYLINE, "polyline" },
349 { SVG_NODE_RECT, "rect" },
350 { SVG_NODE_PATH, "path" },
351 { SVG_NODE_LINE, "line" },
352 { SVG_NODE_CUSTOME_COMMAND, "command" },
353 { SVG_NODE_UNKNOWN, NULL }
354};
355
356static const char *
357/* union
358 type_get() */
359_union_type_get(const void *data,
360 Eina_Bool *unknow)
361{
362 const Svg_Node_Type *u = data;
363 int i;
364
365 if (unknow)
366 *unknow = EINA_FALSE;
367
368 for (i = 0; eet_mapping[i].name != NULL; ++i)
369 if (*u == eet_mapping[i].u)
370 return eet_mapping[i].name;
371
372 if (unknow)
373 *unknow = EINA_TRUE;
374 return NULL;
375} /* _union_type_get */
376
377static Eina_Bool
378_union_type_set(const char *type,
379 void *data,
380 Eina_Bool unknow)
381{
382 Svg_Node_Type *u = data;
383 int i;
384
385 if (unknow)
386 return EINA_FALSE;
387
388 for (i = 0; eet_mapping[i].name != NULL; ++i)
389 if (strcmp(eet_mapping[i].name, type) == 0)
390 {
391 *u = eet_mapping[i].u;
392 return EINA_TRUE;
393 }
394 return EINA_FALSE;
395} /* _union_type_set */
396
397Eet_Data_Descriptor *
398vg_common_svg_node_eet(void)
399{
400 Eet_Data_Descriptor *eet_union;
401 Eet_Data_Descriptor_Class eetc;
402
403 if (_eet_vg_node) return _eet_vg_node;
404
405 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eetc, Svg_Node);
406 _eet_vg_node = eet_data_descriptor_stream_new(&eetc);
407
408 eetc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
409 eetc.func.type_get = _union_type_get;
410 eetc.func.type_set = _union_type_set;
411 eet_union = eet_data_descriptor_stream_new(&eetc);
412
413 _eet_doc_node = _eet_for_doc_node();
414 _eet_g_node = _eet_for_g_node();
415 _eet_defs_node = _eet_for_defs_node();
416 _eet_arc_node = _eet_for_arc_node();
417 _eet_circle_node = _eet_for_circle_node();
418 _eet_ellipse_node = _eet_for_ellipse_node();
419 _eet_rect_node = _eet_for_rect_node();
420 _eet_line_node = _eet_for_line_node();
421 _eet_path_node = _eet_for_path_node();
422 _eet_polygon_node = _eet_for_polygon_node();
423 _eet_custom_command_node = _eet_for_custom_command_node();
424 _eet_style_property_node = _eet_for_style_property();
425 _eet_matrix3_node = _eet_for_eina_matrix3();
426
427
428
429 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "doc", _eet_doc_node);
430 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "g", _eet_g_node);
431 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "defs", _eet_defs_node);
432 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "arc", _eet_arc_node);
433 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "circle", _eet_circle_node);
434 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "ellipse", _eet_ellipse_node);
435 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "rect", _eet_rect_node);
436 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "line", _eet_line_node);
437 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "path", _eet_path_node);
438 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "polygon", _eet_polygon_node);
439 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "polyline", _eet_polygon_node);
440 EET_DATA_DESCRIPTOR_ADD_MAPPING(eet_union, "command", _eet_custom_command_node);
441
442 EET_DATA_DESCRIPTOR_ADD_UNION(_eet_vg_node, Svg_Node, "node", node, type, eet_union);
443
444
445 EET_DATA_DESCRIPTOR_ADD_LIST(_eet_vg_node, Svg_Node, "child", child, _eet_vg_node);
446 EET_DATA_DESCRIPTOR_ADD_BASIC(_eet_vg_node, Svg_Node, "id", id, EET_T_STRING);
447 EET_DATA_DESCRIPTOR_ADD_SUB(_eet_vg_node, Svg_Node, "style", style, _eet_style_property_node);
448 EET_DATA_DESCRIPTOR_ADD_SUB(_eet_vg_node, Svg_Node, "transform", transform, _eet_matrix3_node);
449
450 return _eet_vg_node;
451}
452
453void
454vg_common_svg_node_eet_destroy(void)
455{
456 FREE_DESCRIPTOR(_eet_rect_node);
457 FREE_DESCRIPTOR(_eet_circle_node);
458 FREE_DESCRIPTOR(_eet_ellipse_node);
459 FREE_DESCRIPTOR(_eet_gradient_stops_node);
460 FREE_DESCRIPTOR(_eet_linear_gradient_node);
461 FREE_DESCRIPTOR(_eet_radial_gradient_node);
462 FREE_DESCRIPTOR(_eet_style_gradient_node);
463 FREE_DESCRIPTOR(_eet_style_property_node);
464 FREE_DESCRIPTOR(_eet_matrix3_node);
465 FREE_DESCRIPTOR(_eet_doc_node);
466 FREE_DESCRIPTOR(_eet_defs_node);
467 FREE_DESCRIPTOR(_eet_g_node);
468 FREE_DESCRIPTOR(_eet_arc_node);
469 FREE_DESCRIPTOR(_eet_path_node);
470 FREE_DESCRIPTOR(_eet_polygon_node);
471 FREE_DESCRIPTOR(_eet_vg_node);
472 FREE_DESCRIPTOR(_eet_line_node);
473 FREE_DESCRIPTOR(_eet_custom_command_node);
474}
475
476static void
477_svg_style_gradient_free(Svg_Style_Gradient *grad)
478{
479 Efl_Gfx_Gradient_Stop *stop;
480
481 if (!grad) return;
482
483 eina_stringshare_del(grad->id);
484 eina_stringshare_del(grad->ref);
485 free(grad->radial);
486 free(grad->linear);
487
488 EINA_LIST_FREE(grad->stops, stop)
489 {
490 free(stop);
491 }
492 free(grad);
493}
494
495static void
496_node_style_free(Svg_Style_Property *style)
497{
498 if (!style) return;
499
500 _svg_style_gradient_free(style->fill.paint.gradient);
501 eina_stringshare_del(style->fill.paint.url);
502 _svg_style_gradient_free(style->stroke.paint.gradient);
503 eina_stringshare_del(style->stroke.paint.url);
504 free(style);
505}
506
507void
508vg_common_svg_node_free(Svg_Node *node)
509{
510 Svg_Node *child;
511 Svg_Style_Gradient *grad;
512
513 if (!node) return;
514
515 EINA_LIST_FREE(node->child, child)
516 {
517 vg_common_svg_node_free(child);
518 }
519
520 eina_stringshare_del(node->id);
521 free(node->transform);
522 _node_style_free(node->style);
523 switch (node->type)
524 {
525 case SVG_NODE_PATH:
526 eina_stringshare_del(node->node.path.path);
527 break;
528 case SVG_NODE_POLYGON:
529 free(node->node.polygon.points);
530 break;
531 case SVG_NODE_POLYLINE:
532 free(node->node.polyline.points);
533 break;
534 case SVG_NODE_DOC:
535 vg_common_svg_node_free(node->node.doc.defs);
536 break;
537 case SVG_NODE_DEFS:
538 EINA_LIST_FREE(node->node.defs.gradients, grad)
539 {
540 _svg_style_gradient_free(grad);
541 }
542 break;
543 default:
544 break;
545 }
546 free(node);
547}
548
549static Efl_VG *
550_apply_gradient_property(Svg_Style_Gradient *g)
551{
552 Efl_VG *grad_obj = NULL;
553 Efl_Gfx_Gradient_Stop *stops, *stop;
554 int stop_count = 0, i = 0;
555 Eina_List *l;
556
557 if (g->type == SVG_LINEAR_GRADIENT)
558 {
559 grad_obj = evas_vg_gradient_linear_add(NULL);
560 evas_vg_gradient_linear_start_set(grad_obj, g->linear->x1, g->linear->y1);
561 evas_vg_gradient_linear_end_set(grad_obj, g->linear->x2, g->linear->y2);
562 }
563 else if (g->type == SVG_RADIAL_GRADIENT)
564 {
565 grad_obj = evas_vg_gradient_radial_add(NULL);
566 evas_vg_gradient_radial_center_set(grad_obj, g->radial->cx, g->radial->cy);
567 evas_vg_gradient_radial_radius_set(grad_obj, g->radial->r);
568 evas_vg_gradient_radial_focal_set(grad_obj, g->radial->fx, g->radial->fy);
569 }
570 else
571 {
572 // not a known gradient
573 return NULL;
574 }
575 // apply common prperty
576 evas_vg_gradient_spread_set(grad_obj, g->spread);
577 // update the stops
578 stop_count = eina_list_count(g->stops);
579 if (stop_count)
580 {
581 stops = calloc(stop_count, sizeof(Efl_Gfx_Gradient_Stop));
582 i = 0;
583 EINA_LIST_FOREACH(g->stops, l, stop)
584 {
585 stops[i].r = stop->r;
586 stops[i].g = stop->g;
587 stops[i].b = stop->b;
588 stops[i].a = stop->a;
589 stops[i].offset = stop->offset;
590 i++;
591 }
592 evas_vg_gradient_stop_set(grad_obj, stops, stop_count);
593 free(stops);
594 }
595 return grad_obj;
596}
597
598// vg tree creation
599static void
600_apply_vg_property(Svg_Node *node, Efl_VG *vg)
601{
602 Svg_Style_Property *style = node->style;
603
604 // update the vg name
605 if (node->id)
606 evas_vg_node_name_set(vg, node->id);
607
608 // apply the transformation
609 if (node->transform)
610 evas_vg_node_transformation_set(vg, node->transform);
611
612 if ((node->type == SVG_NODE_G) || (node->type == SVG_NODE_DOC)) return;
613
614 // apply the fill style property
615 efl_gfx_shape_fill_rule_set(vg, style->fill.fill_rule);
616 // if fill property is NULL then do nothing
617 if (style->fill.paint.none)
618 {
619 //do nothing
620 }
621 else if (style->fill.paint.gradient)
622 {
623 // if the fill has gradient then apply.
624 evas_vg_shape_fill_set(vg, _apply_gradient_property(style->fill.paint.gradient));
625 }
626 else if (style->fill.paint.cur_color)
627 {
628 // apply the current style color
629 evas_vg_node_color_set(vg, style->r, style->g,
630 style->b, style->fill.opacity);
631 }
632 else
633 {
634 // apply the fill color
635 evas_vg_node_color_set(vg, style->fill.paint.r, style->fill.paint.g,
636 style->fill.paint.b, style->fill.opacity);
637 }
638
639 // apply the stroke style property
640 //@TODO HACK, fix the below api to take the stroke width as pixels
641 // rightnow it draws double the pixel (inside and outside the outline)
642 evas_vg_shape_stroke_width_set(vg, style->stroke.width/2.0);
643 evas_vg_shape_stroke_cap_set(vg, style->stroke.cap);
644 evas_vg_shape_stroke_join_set(vg, style->stroke.join);
645 evas_vg_shape_stroke_scale_set(vg, style->stroke.scale);
646 // if stroke property is NULL then do nothing
647 if (style->stroke.paint.none)
648 {
649 //do nothing
650 }
651 else if (style->stroke.paint.gradient)
652 {
653 // if the fill has gradient then apply.
654 evas_vg_shape_stroke_fill_set(vg, _apply_gradient_property(style->stroke.paint.gradient));
655 }
656 else if (style->stroke.paint.url)
657 {
658 // apply the color pointed by url
659 // TODO
660 }
661 else if (style->stroke.paint.cur_color)
662 {
663 // apply the current style color
664 evas_vg_shape_stroke_color_set(vg, style->r, style->g,
665 style->b, style->stroke.opacity);
666 }
667 else
668 {
669 // apply the stroke color
670 evas_vg_shape_stroke_color_set(vg, style->stroke.paint.r, style->stroke.paint.g,
671 style->stroke.paint.b, style->stroke.opacity);
672 }
673}
674
675static void
676_add_polyline(Efl_VG *vg, double *array, int size, Eina_Bool polygon)
677{
678 int i;
679
680 if (size < 2) return;
681
682 evas_vg_shape_append_move_to(vg, array[0], array[1]);
683 for (i=2; i < size; i+=2)
684 evas_vg_shape_append_line_to(vg, array[i], array[i+1]);
685
686 if (polygon)
687 evas_vg_shape_append_close(vg);
688}
689
690static Efl_VG *
691vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent)
692{
693 Efl_VG *vg = NULL;
694 Svg_Node *child;
695 Eina_List *l;
696
697 switch (node->type)
698 {
699 case SVG_NODE_DOC:
700 case SVG_NODE_G:
701 {
702 vg = evas_vg_container_add(parent);
703 _apply_vg_property(node, vg);
704 EINA_LIST_FOREACH(node->child, l, child)
705 {
706 vg_common_create_vg_node_helper(child, vg);
707 }
708 return vg;
709 }
710 break;
711 case SVG_NODE_PATH:
712 vg = evas_vg_shape_add(parent);
713 evas_vg_shape_append_svg_path(vg, node->node.path.path);
714 break;
715 case SVG_NODE_POLYGON:
716 vg = evas_vg_shape_add(parent);
717 _add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_TRUE);
718 break;
719 case SVG_NODE_POLYLINE:
720 vg = evas_vg_shape_add(parent);
721 _add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_FALSE);
722 break;
723 case SVG_NODE_ELLIPSE:
724 vg = evas_vg_shape_add(parent);
725 evas_vg_shape_append_arc(vg, node->node.ellipse.cx - node->node.ellipse.rx,
726 node->node.ellipse.cy - node->node.ellipse.ry,
727 2*node->node.ellipse.rx, 2*node->node.ellipse.ry, 0, 360);
728 evas_vg_shape_append_close(vg);
729 break;
730 case SVG_NODE_CIRCLE:
731 vg = evas_vg_shape_add(parent);
732 evas_vg_shape_append_circle(vg, node->node.circle.cx, node->node.circle.cy, node->node.circle.r);
733 break;
734 case SVG_NODE_RECT:
735 vg = evas_vg_shape_add(parent);
736 evas_vg_shape_append_rect(vg, node->node.rect.x, node->node.rect.y, node->node.rect.w, node->node.rect.h,
737 node->node.rect.rx, node->node.rect.ry);
738 break;
739 case SVG_NODE_LINE:
740 vg = evas_vg_shape_add(parent);
741 evas_vg_shape_append_move_to(vg, node->node.line.x1, node->node.line.y1);
742 evas_vg_shape_append_line_to(vg, node->node.line.x2, node->node.line.y2);
743 break;
744 case SVG_NODE_CUSTOME_COMMAND:
745 vg = evas_vg_shape_add(parent);
746 evas_vg_shape_path_set(vg, node->node.command.commands, node->node.command.points);
747 break;
748 default:
749 break;
750 }
751 if (vg)
752 _apply_vg_property(node, vg);
753 return vg;
754}
755
756Vg_File_Data *
757vg_common_create_vg_node(Svg_Node *node)
758{
759 Vg_File_Data *vg_data;
760
761 if (!node || (node->type != SVG_NODE_DOC)) return NULL;
762
763 vg_data = calloc(1, sizeof(Vg_File_Data));
764 vg_data->view_box.x = node->node.doc.vx;
765 vg_data->view_box.y = node->node.doc.vy;
766 vg_data->view_box.w = node->node.doc.vw;
767 vg_data->view_box.h = node->node.doc.vh;
768 vg_data->preserve_aspect = node->node.doc.preserve_aspect;
769 vg_data->root = vg_common_create_vg_node_helper(node, NULL);
770
771 return vg_data;
772}
773
774static Svg_Node *
775_create_node(Svg_Node *parent, Svg_Node_Type type)
776{
777 Svg_Node *node = calloc(1, sizeof(Svg_Node));
778
779 // default fill property
780 node->style = calloc(1, sizeof(Svg_Style_Property));
781
782 // update the default value of stroke and fill
783 //https://www.w3.org/TR/SVGTiny12/painting.html#SpecifyingPaint
784 // default fill color is black
785 node->style->fill.paint.r = 0;
786 node->style->fill.paint.g = 0;
787 node->style->fill.paint.b = 0;
788 node->style->fill.paint.none = EINA_FALSE;
789 // default fill opacity is 1
790 node->style->fill.opacity = 255;
791
792 // default fill rule is nonzero
793 node->style->fill.fill_rule = EFL_GFX_FILL_RULE_WINDING;
794
795 // default stroke is none
796 node->style->stroke.paint.none = EINA_TRUE;
797 // default stroke opacity is 1
798 node->style->stroke.opacity = 255;
799 // default stroke width is 1
800 node->style->stroke.width = 1;
801 // default line cap is butt
802 node->style->stroke.cap = EFL_GFX_CAP_BUTT;
803 // default line join is miter
804 node->style->stroke.join = EFL_GFX_JOIN_MITER;
805 node->style->stroke.scale = 1.0;
806
807 node->parent = parent;
808 node->type = type;
809 node->child = NULL;
810
811 if (parent)
812 parent->child = eina_list_append(parent->child, node);
813 return node;
814}
815
816static Svg_Style_Gradient*
817_create_gradient_node(Efl_VG *vg)
818{
819 const Efl_Gfx_Gradient_Stop *stops = NULL;
820 Efl_Gfx_Gradient_Stop *new_stop;
821 unsigned int count, i;
822
823 Svg_Style_Gradient *grad = calloc(1, sizeof(Svg_Style_Gradient));
824
825 grad->spread = evas_vg_gradient_spread_get(vg);
826 evas_vg_gradient_stop_get(vg, &stops, &count);
827 for (i=0 ; i < count; i++)
828 {
829 new_stop = calloc(1, sizeof(Efl_Gfx_Gradient_Stop));
830 memcpy(new_stop, stops, sizeof(Efl_Gfx_Gradient_Stop));
831 grad->stops = eina_list_append(grad->stops, new_stop);
832 stops++;
833 }
834 if (efl_isa(vg, EFL_VG_GRADIENT_LINEAR_CLASS))
835 {
836 grad->type = SVG_LINEAR_GRADIENT;
837 grad->linear = calloc(1, sizeof(Svg_Linear_Gradient));
838 evas_vg_gradient_linear_start_get(vg, &grad->linear->x1, &grad->linear->y1);
839 evas_vg_gradient_linear_end_get(vg, &grad->linear->x2, &grad->linear->y2);
840 }
841 else
842 {
843 grad->type = SVG_RADIAL_GRADIENT;
844 grad->radial = calloc(1, sizeof(Svg_Radial_Gradient));
845 evas_vg_gradient_radial_center_get(vg, &grad->radial->cx, &grad->radial->cy);
846 evas_vg_gradient_radial_focal_get(vg, &grad->radial->fx, &grad->radial->fy);
847 grad->radial->r = evas_vg_gradient_radial_radius_get(vg);
848 }
849
850 return grad;
851}
852
853static void
854_apply_svg_property(Svg_Node *node, Efl_VG *vg)
855{
856 const Eina_Matrix3 *matrix;
857 const char *id;
858 Svg_Style_Property *style = node->style;
859
860 // transformation
861 if ((matrix = evas_vg_node_transformation_get(vg)))
862 {
863 node->transform = calloc(1, sizeof(Eina_Matrix3));
864 eina_matrix3_copy(node->transform, matrix);
865 }
866
867 if ((id = evas_vg_node_name_get(vg)))
868 {
869 node->id = eina_stringshare_add(id);
870 }
871
872 if (node->type == SVG_NODE_G) return;
873
874
875 // apply the fill style property
876 style->fill.fill_rule = efl_gfx_shape_fill_rule_get(vg);
877 style->fill.paint.none = EINA_FALSE;
878 if (evas_vg_shape_fill_get(vg))
879 {
880 // if the fill has gradient then apply.
881 style->fill.paint.gradient = _create_gradient_node(evas_vg_shape_fill_get(vg));
882 }
883 else
884 {
885 evas_vg_node_color_get(vg, &style->fill.paint.r, &style->fill.paint.g,
886 &style->fill.paint.b, &style->fill.opacity);
887 }
888
889 // apply stroke style property
890 style->stroke.paint.none = EINA_FALSE;
891
892 if (evas_vg_shape_stroke_fill_get(vg))
893 {
894 // if the stroke has gradient then apply.
895 style->stroke.paint.gradient = _create_gradient_node(evas_vg_shape_stroke_fill_get(vg));
896 }
897 else
898 {
899 // apply the stroke color
900 evas_vg_shape_stroke_color_get(vg, &style->stroke.paint.r, &style->stroke.paint.g,
901 &style->stroke.paint.b, &style->stroke.opacity);
902 }
903
904 // keep the stroke width same as svg spec.
905 style->stroke.width = (evas_vg_shape_stroke_width_get(vg) * 2.0);
906 style->stroke.cap = evas_vg_shape_stroke_cap_get(vg);
907 style->stroke.join = evas_vg_shape_stroke_join_get(vg);
908 style->stroke.scale = evas_vg_shape_stroke_scale_get(vg);
909
910
911}
912
913static void
914vg_common_create_svg_node_helper(Efl_VG *vg, Svg_Node *parent)
915{
916 Eina_Iterator *it;
917 Efl_VG *child;
918 Svg_Node *svg_node;
919 const Efl_Gfx_Path_Command *commands;
920 unsigned int points_count, commands_count;
921 const double *points;
922
923 if (efl_isa(vg, EFL_VG_CONTAINER_CLASS))
924 {
925 svg_node = _create_node(parent, SVG_NODE_G);
926 _apply_svg_property(svg_node, vg);
927 // apply property
928 it = efl_vg_container_children_get(vg);
929 EINA_ITERATOR_FOREACH(it, child)
930 {
931 vg_common_create_svg_node_helper(child, svg_node);
932 }
933 }
934 else
935 {
936 svg_node = _create_node(parent, SVG_NODE_CUSTOME_COMMAND);
937 evas_vg_shape_path_get(vg, &commands, &points);
938 evas_vg_shape_path_length_get(vg, &commands_count, &points_count);
939 svg_node->node.command.commands_count = commands_count;
940 svg_node->node.command.points_count = points_count;
941 svg_node->node.command.points = calloc(points_count, sizeof(double));
942 svg_node->node.command.commands = calloc(commands_count, sizeof(Efl_Gfx_Path_Command));
943 memcpy(svg_node->node.command.commands, commands, sizeof (Efl_Gfx_Path_Command) * commands_count);
944 memcpy(svg_node->node.command.points, points, sizeof (double) * points_count);
945 _apply_svg_property(svg_node, vg);
946 }
947}
948
949Svg_Node *
950vg_common_create_svg_node(Vg_File_Data *node)
951{
952 Svg_Node *doc;
953
954 if (!node || !node->root) return NULL;
955
956 doc = _create_node(NULL, SVG_NODE_DOC);
957
958 doc->node.doc.vx = node->view_box.x;
959 doc->node.doc.vy = node->view_box.y;
960 doc->node.doc.vw = node->view_box.w;
961 doc->node.doc.vh = node->view_box.h;
962 doc->node.doc.preserve_aspect = node->preserve_aspect;
963 vg_common_create_svg_node_helper(node->root, doc);
964 return doc;
965}
diff --git a/src/static_libs/vg_common/vg_common.h b/src/static_libs/vg_common/vg_common.h
new file mode 100644
index 0000000..70c7449
--- /dev/null
+++ b/src/static_libs/vg_common/vg_common.h
@@ -0,0 +1,299 @@
1#ifndef VG_COMMON_H_
2#define VG_COMMON_H_
3
4#ifdef HAVE_CONFIG_H
5# include <config.h>
6#endif
7
8#include "evas_common_private.h"
9#include "evas_private.h"
10
11typedef enum _Svg_Node_Type Svg_Node_Type;
12typedef enum _Svg_Length_Type Svg_Length_Type;
13
14typedef struct _Svg_Node Svg_Node;
15typedef struct _Svg_Doc_Node Svg_Doc_Node;
16typedef struct _Svg_G_Node Svg_G_Node;
17typedef struct _Svg_Defs_Node Svg_Defs_Node;
18typedef struct _Svg_Arc_Node Svg_Arc_Node;
19typedef struct _Svg_Circle_Node Svg_Circle_Node;
20typedef struct _Svg_Ellipse_Node Svg_Ellipse_Node;
21typedef struct _Svg_Polygon_Node Svg_Polygon_Node;
22typedef struct _Svg_Rect_Node Svg_Rect_Node;
23typedef struct _Svg_Path_Node Svg_Path_Node;
24typedef struct _Svg_Style_Property Svg_Style_Property;
25typedef struct _Svg_Line_Node Svg_Line_Node;
26typedef struct _Svg_Custom_Command_Node Svg_Custom_Command_Node;
27
28
29typedef struct _Svg_Style_Stroke Svg_Style_Stroke;
30typedef struct _Svg_Style_Fill Svg_Style_Fill;
31typedef enum _Svg_Fill_Flags Svg_Fill_Flags;
32typedef enum _Svg_Stroke_Flags Svg_Stroke_Flags;
33
34
35typedef enum _Svg_Gradient_Type Svg_Gradient_Type;
36typedef struct _Svg_Style_Gradient Svg_Style_Gradient;
37typedef struct _Svg_Linear_Gradient Svg_Linear_Gradient;
38typedef struct _Svg_Radial_Gradient Svg_Radial_Gradient;
39typedef struct _Svg_Paint Svg_Paint;
40
41enum _Svg_Node_Type
42{
43 SVG_NODE_DOC,
44 SVG_NODE_G,
45 SVG_NODE_DEFS,
46 SVG_NODE_SWITCH,
47 SVG_NODE_ANIMATION,
48 SVG_NODE_ARC,
49 SVG_NODE_CIRCLE,
50 SVG_NODE_ELLIPSE,
51 SVG_NODE_IMAGE,
52 SVG_NODE_LINE,
53 SVG_NODE_PATH,
54 SVG_NODE_POLYGON,
55 SVG_NODE_POLYLINE,
56 SVG_NODE_RECT,
57 SVG_NODE_TEXT,
58 SVG_NODE_TEXTAREA,
59 SVG_NODE_TSPAN,
60 SVG_NODE_USE,
61 SVG_NODE_VIDEO,
62 SVG_NODE_CUSTOME_COMMAND,
63 SVG_NODE_UNKNOWN
64};
65
66enum _Svg_Length_Type
67{
68 SVG_LT_PERCENT,
69 SVG_LT_PX,
70 SVG_LT_PC,
71 SVG_LT_PT,
72 SVG_LT_MM,
73 SVG_LT_CM,
74 SVG_LT_IN,
75};
76
77struct _Svg_Doc_Node
78{
79 double width;
80 double height;
81 double vx;
82 double vy;
83 double vw;
84 double vh;
85 Eina_Bool preserve_aspect;
86 Svg_Node *defs;
87};
88
89struct _Svg_G_Node
90{
91
92};
93
94struct _Svg_Defs_Node
95{
96 Eina_List *gradients;
97};
98
99struct _Svg_Arc_Node
100{
101
102};
103
104struct _Svg_Ellipse_Node
105{
106 double cx;
107 double cy;
108 double rx;
109 double ry;
110};
111
112struct _Svg_Circle_Node
113{
114 double cx;
115 double cy;
116 double r;
117};
118
119struct _Svg_Rect_Node
120{
121 double x;
122 double y;
123 double w;
124 double h;
125 double rx;
126 double ry;
127};
128
129struct _Svg_Line_Node
130{
131 double x1;
132 double y1;
133 double x2;
134 double y2;
135};
136
137struct _Svg_Custom_Command_Node
138{
139 int points_count;
140 int commands_count;
141 double *points;
142 Efl_Gfx_Path_Command *commands;
143};
144
145struct _Svg_Path_Node
146{
147 Eina_Stringshare *path;
148};
149
150struct _Svg_Polygon_Node
151{
152 int points_count;
153 double *points;
154};
155
156
157enum _Svg_Gradient_Type
158{
159 SVG_LINEAR_GRADIENT,
160 SVG_RADIAL_GRADIENT
161};
162struct _Svg_Linear_Gradient
163{
164 double x1;
165 double y1;
166 double x2;
167 double y2;
168};
169
170struct _Svg_Radial_Gradient
171{
172 double cx;
173 double cy;
174 double fx;
175 double fy;
176 double r;
177};
178
179struct _Svg_Style_Gradient
180{
181 Svg_Gradient_Type type;
182 Eina_Stringshare *id;
183 Eina_Stringshare *ref;
184 Efl_Gfx_Gradient_Spread spread;
185 Eina_List *stops; // Efl_Gfx_Gradient_Stop
186 Svg_Radial_Gradient *radial;
187 Svg_Linear_Gradient *linear;
188};
189
190struct _Svg_Paint
191{
192 int r;
193 int g;
194 int b;
195 Eina_Bool none;
196 Eina_Bool cur_color;
197 Svg_Style_Gradient *gradient;
198 Eina_Stringshare *url;
199};
200
201enum _Svg_Fill_Flags
202{
203 SVG_FILL_FLAGS_PAINT = 0x1,
204 SVG_FILL_FLAGS_OPACITY = 0x2,
205 SVG_FILL_FLAGS_GRADIENT = 0x4,
206 SVG_FILL_FLAGS_FILL_RULE = 0x8
207};
208
209enum _Svg_Stroke_Flags
210{
211 SVG_STROKE_FLAGS_PAINT = 0x1,
212 SVG_STROKE_FLAGS_OPACITY = 0x2,
213 SVG_STROKE_FLAGS_GRADIENT = 0x4,
214 SVG_STROKE_FLAGS_SCALE = 0x8,
215 SVG_STROKE_FLAGS_WIDTH = 0x10,
216 SVG_STROKE_FLAGS_CAP = 0x20,
217 SVG_STROKE_FLAGS_JOIN = 0x40,
218 SVG_STROKE_FLAGS_DASH = 0x80,
219};
220
221struct _Svg_Style_Fill
222{
223 Svg_Fill_Flags flags;
224 Svg_Paint paint;
225 int opacity;
226 Efl_Gfx_Fill_Rule fill_rule;
227};
228
229struct _Svg_Style_Stroke
230{
231 Svg_Stroke_Flags flags;
232 Svg_Paint paint;
233 int opacity;
234 double scale;
235 double width;
236 double centered;
237 Efl_Gfx_Cap cap;
238 Efl_Gfx_Join join;
239 Efl_Gfx_Dash *dash;
240 int dash_count;
241};
242
243struct _Svg_Style_Property
244{
245 Svg_Style_Fill fill;
246 Svg_Style_Stroke stroke;
247 // the color property indirectly
248 // used by fill and stroke
249 int r;
250 int g;
251 int b;
252};
253
254struct _Svg_Node
255{
256 Svg_Node_Type type;
257 Svg_Node *parent;
258 Eina_List *child;
259 Eina_Stringshare *id;
260 Svg_Style_Property *style;
261 Eina_Matrix3 *transform;
262 union
263 {
264 Svg_G_Node g;
265 Svg_Doc_Node doc;
266 Svg_Defs_Node defs;
267 Svg_Arc_Node arc;
268 Svg_Circle_Node circle;
269 Svg_Ellipse_Node ellipse;
270 Svg_Polygon_Node polygon;
271 Svg_Polygon_Node polyline;
272 Svg_Rect_Node rect;
273 Svg_Path_Node path;
274 Svg_Line_Node line;
275 Svg_Custom_Command_Node command;
276 }node;
277};
278
279enum _Svg_Style_Type
280{
281 SVG_STYLE_QUALITY,
282 SVG_STYLE_FILL,
283 SVG_STYLE_VIEWPORT_FILL,
284 SVG_STYLE_FONT,
285 SVG_STYLE_STROKE,
286 SVG_STYLE_SOLID_COLOR,
287 SVG_STYLE_GRADIENT,
288 SVG_STYLE_TRANSFORM,
289 SVG_STYLE_OPACITY,
290 SVG_STYLE_COMP_OP
291};
292
293Eet_Data_Descriptor * vg_common_svg_node_eet(void);
294void vg_common_svg_node_eet_destroy(void);
295Vg_File_Data * vg_common_create_vg_node(Svg_Node *node);
296Svg_Node * vg_common_create_svg_node(Vg_File_Data *node);
297void vg_common_svg_node_free(Svg_Node *node);
298
299#endif //EVAS_VG_COMMON_H_