diff options
author | Stefan Schmidt <s.schmidt@samsung.com> | 2020-03-19 17:39:03 +0100 |
---|---|---|
committer | Stefan Schmidt <s.schmidt@samsung.com> | 2020-03-19 17:39:03 +0100 |
commit | 2f7a73da919ce3c2ed90a3176b83d086302a27a8 (patch) | |
tree | 54aed38657c1f1173152e00b0b1e4a14a66d50e7 | |
parent | cf93872cdc90c2bfd39abf326979470d21f7a4f4 (diff) |
exactness: remove exactness library and move code into binary folderdevs/stefan/exactness-fixes
We do not want to have EAPI from exactness exposed at this point without
any real user. I know of no application using the exactness library.
If we come to that point we can move things back into a lib, but for now
having the code shared between the various executables is all we need.
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | src/bin/exactness/common.c | 405 | ||||
-rw-r--r-- | src/bin/exactness/common.h | 234 | ||||
-rw-r--r-- | src/bin/exactness/exactness.c | 1 | ||||
-rw-r--r-- | src/bin/exactness/injector.c | 1 | ||||
-rw-r--r-- | src/bin/exactness/inspect.c | 1 | ||||
-rw-r--r-- | src/bin/exactness/meson.build | 10 | ||||
-rw-r--r-- | src/bin/exactness/player.c | 2 | ||||
-rw-r--r-- | src/bin/exactness/recorder.c | 2 | ||||
-rw-r--r-- | src/lib/exactness/Exactness.h | 259 | ||||
-rw-r--r-- | src/lib/exactness/exactness_private.h | 10 | ||||
-rw-r--r-- | src/lib/exactness/meson.build | 30 | ||||
-rw-r--r-- | src/lib/exactness/unit.c | 409 |
13 files changed, 643 insertions, 723 deletions
diff --git a/meson.build b/meson.build index bbf99d427a..a49be8c620 100644 --- a/meson.build +++ b/meson.build | |||
@@ -335,7 +335,7 @@ subprojects = [ | |||
335 | ['elua' ,['elua'] , false, true, true, false, true, false, ['eina', 'luajit'], []], | 335 | ['elua' ,['elua'] , false, true, true, false, true, false, ['eina', 'luajit'], []], |
336 | ['ecore_wayland' ,['wl-deprecated'] , false, true, false, false, false, false, ['eina'], []], | 336 | ['ecore_wayland' ,['wl-deprecated'] , false, true, false, false, false, false, ['eina'], []], |
337 | ['ecore_drm' ,['drm-deprecated'] , false, true, false, false, false, false, ['eina'], []], | 337 | ['ecore_drm' ,['drm-deprecated'] , false, true, false, false, false, false, ['eina'], []], |
338 | ['exactness' ,[] , false, true, true, false, false, false, ['eina, evas, eet'], []], | 338 | ['exactness' ,[] , false, false, true, false, false, false, ['eina, evas, eet'], []], |
339 | ] | 339 | ] |
340 | 340 | ||
341 | # We generate Efl_Config.h and config.h later, they will be available here | 341 | # We generate Efl_Config.h and config.h later, they will be available here |
diff --git a/src/bin/exactness/common.c b/src/bin/exactness/common.c index 4d770eb584..5646f4c3bb 100644 --- a/src/bin/exactness/common.c +++ b/src/bin/exactness/common.c | |||
@@ -1,3 +1,7 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
1 | #include "common.h" | 5 | #include "common.h" |
2 | 6 | ||
3 | static int _verbose = 0; | 7 | static int _verbose = 0; |
@@ -98,3 +102,404 @@ ex_prg_full_path_guess(const char *prg) | |||
98 | free(env_path); | 102 | free(env_path); |
99 | return ret; | 103 | return ret; |
100 | } | 104 | } |
105 | |||
106 | typedef struct _Dummy | ||
107 | { | ||
108 | } _Dummy; | ||
109 | |||
110 | static Eet_Data_Descriptor * | ||
111 | _mouse_wheel_desc_make(void) | ||
112 | { | ||
113 | Eet_Data_Descriptor_Class eddc; | ||
114 | Eet_Data_Descriptor *_d; | ||
115 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_Wheel); | ||
116 | _d = eet_data_descriptor_stream_new(&eddc); | ||
117 | |||
118 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "direction", direction, EET_T_INT); | ||
119 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "z", z, EET_T_INT); | ||
120 | |||
121 | return _d; | ||
122 | } | ||
123 | |||
124 | static Eet_Data_Descriptor * | ||
125 | _key_down_up_desc_make(void) | ||
126 | { | ||
127 | Eet_Data_Descriptor_Class eddc; | ||
128 | Eet_Data_Descriptor *_d; | ||
129 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Key_Down_Up); | ||
130 | _d = eet_data_descriptor_stream_new(&eddc); | ||
131 | |||
132 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keyname", keyname, EET_T_STRING); | ||
133 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "key", key, EET_T_STRING); | ||
134 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "string", string, EET_T_STRING); | ||
135 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "compose", compose, EET_T_STRING); | ||
136 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keycode", keycode, EET_T_INT); | ||
137 | |||
138 | return _d; | ||
139 | } | ||
140 | |||
141 | static Eet_Data_Descriptor * | ||
142 | _multi_event_desc_make(void) | ||
143 | { | ||
144 | Eet_Data_Descriptor_Class eddc; | ||
145 | Eet_Data_Descriptor *_d; | ||
146 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Event); | ||
147 | _d = eet_data_descriptor_stream_new(&eddc); | ||
148 | |||
149 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "d", d, EET_T_UINT); | ||
150 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "b", b, EET_T_UINT); | ||
151 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "x", x, EET_T_UINT); | ||
152 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "y", y, EET_T_UINT); | ||
153 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rad", rad, EET_T_DOUBLE); | ||
154 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "radx", radx, EET_T_DOUBLE); | ||
155 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rady", rady, EET_T_DOUBLE); | ||
156 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "pres", pres, EET_T_DOUBLE); | ||
157 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "ang", ang, EET_T_DOUBLE); | ||
158 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fx", fx, EET_T_DOUBLE); | ||
159 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fy", fy, EET_T_DOUBLE); | ||
160 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "flags", flags, EET_T_INT); | ||
161 | |||
162 | return _d; | ||
163 | } | ||
164 | |||
165 | static Eet_Data_Descriptor * | ||
166 | _multi_move_desc_make(void) | ||
167 | { | ||
168 | Eet_Data_Descriptor_Class eddc; | ||
169 | Eet_Data_Descriptor *_d; | ||
170 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Move); | ||
171 | _d = eet_data_descriptor_stream_new(&eddc); | ||
172 | |||
173 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "d", d, EET_T_UINT); | ||
174 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "x", x, EET_T_UINT); | ||
175 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "y", y, EET_T_UINT); | ||
176 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rad", rad, EET_T_DOUBLE); | ||
177 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "radx", radx, EET_T_DOUBLE); | ||
178 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rady", rady, EET_T_DOUBLE); | ||
179 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "pres", pres, EET_T_DOUBLE); | ||
180 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "ang", ang, EET_T_DOUBLE); | ||
181 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fx", fx, EET_T_DOUBLE); | ||
182 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fy", fy, EET_T_DOUBLE); | ||
183 | |||
184 | return _d; | ||
185 | } | ||
186 | |||
187 | static Eet_Data_Descriptor * | ||
188 | _efl_event_desc_make(void) | ||
189 | { | ||
190 | Eet_Data_Descriptor_Class eddc; | ||
191 | Eet_Data_Descriptor *_d; | ||
192 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Efl_Event); | ||
193 | _d = eet_data_descriptor_stream_new(&eddc); | ||
194 | |||
195 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "wdg_name", wdg_name, EET_T_STRING); | ||
196 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "event_name", event_name, EET_T_STRING); | ||
197 | |||
198 | return _d; | ||
199 | } | ||
200 | |||
201 | static Eet_Data_Descriptor * | ||
202 | _click_on_desc_make(void) | ||
203 | { | ||
204 | Eet_Data_Descriptor_Class eddc; | ||
205 | Eet_Data_Descriptor *_d; | ||
206 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Click_On); | ||
207 | _d = eet_data_descriptor_stream_new(&eddc); | ||
208 | |||
209 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Click_On, "wdg_name", wdg_name, EET_T_STRING); | ||
210 | |||
211 | return _d; | ||
212 | } | ||
213 | |||
214 | static Eet_Data_Descriptor * | ||
215 | _dummy_desc_make(void) | ||
216 | { | ||
217 | Eet_Data_Descriptor_Class eddc; | ||
218 | Eet_Data_Descriptor *_d; | ||
219 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, _Dummy); | ||
220 | _d = eet_data_descriptor_stream_new(&eddc); | ||
221 | |||
222 | return _d; | ||
223 | } | ||
224 | |||
225 | /* !!! SAME ORDER AS Exactness_Action_Type */ | ||
226 | static const char *_mapping[] = | ||
227 | { | ||
228 | "", | ||
229 | "exactness_action_mouse_in", | ||
230 | "exactness_action_mouse_out", | ||
231 | "exactness_action_mouse_wheel", | ||
232 | "exactness_action_multi_down", | ||
233 | "exactness_action_multi_up", | ||
234 | "exactness_action_multi_move", | ||
235 | "exactness_action_key_down", | ||
236 | "exactness_action_key_up", | ||
237 | "exactness_action_take_shot", | ||
238 | "exactness_action_efl_event", | ||
239 | "exactness_action_click_on", | ||
240 | "exactness_action_stabilize" | ||
241 | }; | ||
242 | |||
243 | const char * | ||
244 | _exactness_action_type_to_string_get(Exactness_Action_Type type) | ||
245 | { | ||
246 | if (type <= EXACTNESS_ACTION_LAST) return _mapping[type]; | ||
247 | return NULL; | ||
248 | } | ||
249 | |||
250 | static const char * | ||
251 | _variant_type_get(const void *data, Eina_Bool *unknow) | ||
252 | { | ||
253 | const Exactness_Action *act = data; | ||
254 | |||
255 | if (unknow) *unknow = EINA_FALSE; | ||
256 | if (act->type <= EXACTNESS_ACTION_LAST) return _mapping[act->type]; | ||
257 | |||
258 | return NULL; | ||
259 | } | ||
260 | |||
261 | static Eina_Bool | ||
262 | _variant_type_set(const char *type, | ||
263 | void *data, | ||
264 | Eina_Bool unknow EINA_UNUSED) | ||
265 | { | ||
266 | int i; | ||
267 | Exactness_Action *act = data; | ||
268 | for (i = 0; i <= EXACTNESS_ACTION_LAST; i++) | ||
269 | { | ||
270 | if (!strcmp(_mapping[i], type)) act->type = i; | ||
271 | } | ||
272 | return EINA_TRUE; | ||
273 | } | ||
274 | |||
275 | static Eet_Data_Descriptor * | ||
276 | _unit_desc_make(void) | ||
277 | { | ||
278 | Eet_Data_Descriptor_Class eddc; | ||
279 | static Eet_Data_Descriptor *unit_d = NULL; | ||
280 | static Eet_Data_Descriptor *action_d = NULL, *action_variant_d = NULL; | ||
281 | static Eet_Data_Descriptor *objs_d = NULL; | ||
282 | static Eet_Data_Descriptor *obj_d = NULL; | ||
283 | if (!obj_d) | ||
284 | { | ||
285 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object); | ||
286 | obj_d = eet_data_descriptor_stream_new(&eddc); | ||
287 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING); | ||
288 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG); | ||
289 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG); | ||
290 | /* Evas stuff */ | ||
291 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT); | ||
292 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT); | ||
293 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT); | ||
294 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT); | ||
295 | |||
296 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects); | ||
297 | objs_d = eet_data_descriptor_stream_new(&eddc); | ||
298 | EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d); | ||
299 | } | ||
300 | if (!unit_d) | ||
301 | { | ||
302 | Eet_Data_Descriptor *code_d = NULL; | ||
303 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Source_Code); | ||
304 | code_d = eet_data_descriptor_stream_new(&eddc); | ||
305 | EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "language", language, EET_T_STRING); | ||
306 | EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "content", content, EET_T_STRING); | ||
307 | EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "command", command, EET_T_STRING); | ||
308 | |||
309 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action); | ||
310 | action_d = eet_data_descriptor_stream_new(&eddc); | ||
311 | |||
312 | eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; | ||
313 | eddc.func.type_get = _variant_type_get; | ||
314 | eddc.func.type_set = _variant_type_set; | ||
315 | action_variant_d = eet_data_descriptor_stream_new(&eddc); | ||
316 | |||
317 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
318 | _mapping[EXACTNESS_ACTION_MOUSE_IN], _dummy_desc_make()); | ||
319 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
320 | _mapping[EXACTNESS_ACTION_MOUSE_OUT], _dummy_desc_make()); | ||
321 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
322 | _mapping[EXACTNESS_ACTION_MOUSE_WHEEL], _mouse_wheel_desc_make()); | ||
323 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
324 | _mapping[EXACTNESS_ACTION_MULTI_DOWN], _multi_event_desc_make()); | ||
325 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
326 | _mapping[EXACTNESS_ACTION_MULTI_UP], _multi_event_desc_make()); | ||
327 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
328 | _mapping[EXACTNESS_ACTION_MULTI_MOVE], _multi_move_desc_make()); | ||
329 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
330 | _mapping[EXACTNESS_ACTION_KEY_DOWN], _key_down_up_desc_make()); | ||
331 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
332 | _mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make()); | ||
333 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
334 | _mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make()); | ||
335 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
336 | _mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make()); | ||
337 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
338 | _mapping[EXACTNESS_ACTION_CLICK_ON], _click_on_desc_make()); | ||
339 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
340 | _mapping[EXACTNESS_ACTION_STABILIZE], _dummy_desc_make()); | ||
341 | |||
342 | EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT); | ||
343 | EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT); | ||
344 | EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d); | ||
345 | |||
346 | /* Exactness_Unit */ | ||
347 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit); | ||
348 | unit_d = eet_data_descriptor_stream_new(&eddc); | ||
349 | EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d); | ||
350 | EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d); | ||
351 | EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "codes", codes, code_d); | ||
352 | EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING); | ||
353 | EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT); | ||
354 | } | ||
355 | |||
356 | return unit_d; | ||
357 | } | ||
358 | /* END Event struct descriptors */ | ||
359 | |||
360 | Exactness_Unit * | ||
361 | exactness_unit_file_read(const char *filename) | ||
362 | { | ||
363 | int i; | ||
364 | Eina_List *itr, *itr2; | ||
365 | Exactness_Objects *e_objs; | ||
366 | Exactness_Object *e_obj, *e_parent; | ||
367 | Exactness_Unit *unit = NULL; | ||
368 | Eet_File *file; | ||
369 | eet_init(); | ||
370 | file = eet_open(filename, EET_FILE_MODE_READ); | ||
371 | if (!file) | ||
372 | { | ||
373 | fprintf(stderr, "Impossible to extract EET from %s\n", filename); | ||
374 | return NULL; | ||
375 | } | ||
376 | unit = eet_data_read(file, _unit_desc_make(), "cache"); | ||
377 | for (i = 0; i < unit->nb_shots; i++) | ||
378 | { | ||
379 | char entry[32]; | ||
380 | Exactness_Image *ex_img = malloc(sizeof(*ex_img)); | ||
381 | sprintf(entry, "images/%d", i + 1); | ||
382 | ex_img->pixels = eet_data_image_read(file, entry, | ||
383 | &ex_img->w, &ex_img->h, NULL, | ||
384 | NULL, NULL, NULL); | ||
385 | unit->imgs = eina_list_append(unit->imgs, ex_img); | ||
386 | } | ||
387 | EINA_LIST_FOREACH(unit->objs, itr, e_objs) | ||
388 | { | ||
389 | Eina_Hash *hash = eina_hash_pointer_new(NULL); | ||
390 | EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) | ||
391 | { | ||
392 | eina_hash_set(hash, &(e_obj->id), e_obj); | ||
393 | } | ||
394 | EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) | ||
395 | { | ||
396 | if (!e_obj->parent_id) | ||
397 | e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj); | ||
398 | else | ||
399 | { | ||
400 | e_parent = eina_hash_find(hash, &(e_obj->parent_id)); | ||
401 | if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj); | ||
402 | } | ||
403 | } | ||
404 | eina_hash_free(hash); | ||
405 | } | ||
406 | eet_close(file); | ||
407 | eet_shutdown(); | ||
408 | return unit; | ||
409 | } | ||
410 | |||
411 | Eina_Bool | ||
412 | exactness_unit_file_write(Exactness_Unit *unit, const char *filename) | ||
413 | { | ||
414 | Eina_List *itr; | ||
415 | Exactness_Image *ex_img; | ||
416 | Eet_File *file; | ||
417 | int i = 1; | ||
418 | eet_init(); | ||
419 | file = eet_open(filename, EET_FILE_MODE_WRITE); | ||
420 | eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE); | ||
421 | EINA_LIST_FOREACH(unit->imgs, itr, ex_img) | ||
422 | { | ||
423 | char entry[32]; | ||
424 | sprintf(entry, "images/%d", i++); | ||
425 | eet_data_image_write(file, entry, | ||
426 | ex_img->pixels, ex_img->w, ex_img->h, 0xFF, | ||
427 | 0, 100, EET_IMAGE_LOSSLESS); | ||
428 | } | ||
429 | eet_close(file); | ||
430 | eet_shutdown(); | ||
431 | return EINA_TRUE; | ||
432 | } | ||
433 | |||
434 | Eina_Bool | ||
435 | exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO) | ||
436 | { | ||
437 | unsigned int w, h; | ||
438 | int *pxs1, *pxs2, *pxsO = NULL; | ||
439 | unsigned int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0; | ||
440 | unsigned int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0; | ||
441 | unsigned int wO = MAX(w1, w2); | ||
442 | unsigned int hO = MAX(h1, h2); | ||
443 | Eina_Bool ret = EINA_FALSE; | ||
444 | if (imgO) *imgO = NULL; | ||
445 | if (!wO || !hO) return EINA_FALSE; | ||
446 | |||
447 | pxs1 = img1 ? img1->pixels : NULL; | ||
448 | pxs2 = img2 ? img2->pixels : NULL; | ||
449 | if (imgO) pxsO = malloc(wO * hO * 4); | ||
450 | |||
451 | for (w = 0; w < wO; w++) | ||
452 | { | ||
453 | for (h = 0; h < hO; h++) | ||
454 | { | ||
455 | Eina_Bool valid1 = img1 ? w < w1 && h < h1 : EINA_FALSE; | ||
456 | Eina_Bool valid2 = img2 ? w < w2 && h < h2 : EINA_FALSE; | ||
457 | int px1 = valid1 ? pxs1[h * w1 + w] : 0; | ||
458 | int px2 = valid2 ? pxs2[h * w2 + w] : 0; | ||
459 | int r1 = (px1 & 0x00FF0000) >> 16; | ||
460 | int r2 = (px2 & 0x00FF0000) >> 16; | ||
461 | int g1 = (px1 & 0x0000FF00) >> 8; | ||
462 | int g2 = (px2 & 0x0000FF00) >> 8; | ||
463 | int b1 = (px1 & 0x000000FF); | ||
464 | int b2 = (px2 & 0x000000FF); | ||
465 | int new_r, new_g, new_b; | ||
466 | if (valid1 || valid2) | ||
467 | { | ||
468 | if (px1 != px2) | ||
469 | { | ||
470 | new_r = 0xFF; | ||
471 | new_g = ((g1 + g2) >> 1) >> 2; | ||
472 | new_b = ((b1 + b2) >> 1) >> 2; | ||
473 | ret = EINA_TRUE; | ||
474 | } | ||
475 | else | ||
476 | { | ||
477 | new_r = (((r1 + r2) >> 1) >> 2) + 0xC0; | ||
478 | new_g = (((g1 + g2) >> 1) >> 2) + 0xC0; | ||
479 | new_b = (((b1 + b2) >> 1) >> 2) + 0xC0; | ||
480 | } | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | new_r = new_g = new_b = 0x0; | ||
485 | } | ||
486 | if (pxsO) pxsO[h * wO + w] = 0xFF000000 | new_r << 16 | new_g << 8 | new_b; | ||
487 | } | ||
488 | } | ||
489 | if (imgO) | ||
490 | { | ||
491 | Exactness_Image *imgR = calloc(1, sizeof(Exactness_Image)); | ||
492 | *imgO = imgR; | ||
493 | imgR->w = wO; | ||
494 | imgR->h = hO; | ||
495 | imgR->pixels = pxsO; | ||
496 | } | ||
497 | return ret; | ||
498 | } | ||
499 | |||
500 | void exactness_image_free(Exactness_Image *img) | ||
501 | { | ||
502 | if (!img) return; | ||
503 | free(img->pixels); | ||
504 | free(img); | ||
505 | } | ||
diff --git a/src/bin/exactness/common.h b/src/bin/exactness/common.h index b3bb2da8c1..c34bc6f8ba 100644 --- a/src/bin/exactness/common.h +++ b/src/bin/exactness/common.h | |||
@@ -2,9 +2,9 @@ | |||
2 | # include <config.h> | 2 | # include <config.h> |
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #include <Eet.h> | ||
6 | #include <Evas.h> | ||
5 | #include <Elementary.h> | 7 | #include <Elementary.h> |
6 | #include <Exactness.h> | ||
7 | #include <exactness_private.h> | ||
8 | 8 | ||
9 | typedef struct | 9 | typedef struct |
10 | { | 10 | { |
@@ -97,7 +97,237 @@ foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \ | |||
97 | _buf += __len; \ | 97 | _buf += __len; \ |
98 | } | 98 | } |
99 | 99 | ||
100 | #define SHOT_DELIMITER '+' | ||
101 | |||
102 | /** | ||
103 | * @page exactness_main Exactness | ||
104 | * | ||
105 | * @date 2018 (created) | ||
106 | * | ||
107 | * This page describes the public structures and APIs available for Exactness. | ||
108 | * | ||
109 | * @addtogroup Exactness | ||
110 | * @{ | ||
111 | */ | ||
112 | |||
113 | /** | ||
114 | * @typedef Exactness_Action_Type | ||
115 | * The type values for an Exactness action. | ||
116 | */ | ||
117 | typedef enum | ||
118 | { | ||
119 | EXACTNESS_ACTION_UNKNOWN = 0, | ||
120 | EXACTNESS_ACTION_MOUSE_IN, | ||
121 | EXACTNESS_ACTION_MOUSE_OUT, | ||
122 | EXACTNESS_ACTION_MOUSE_WHEEL, | ||
123 | EXACTNESS_ACTION_MULTI_DOWN, | ||
124 | EXACTNESS_ACTION_MULTI_UP, | ||
125 | EXACTNESS_ACTION_MULTI_MOVE, | ||
126 | EXACTNESS_ACTION_KEY_DOWN, | ||
127 | EXACTNESS_ACTION_KEY_UP, | ||
128 | EXACTNESS_ACTION_TAKE_SHOT, | ||
129 | EXACTNESS_ACTION_EFL_EVENT, | ||
130 | EXACTNESS_ACTION_CLICK_ON, | ||
131 | EXACTNESS_ACTION_STABILIZE, | ||
132 | EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_STABILIZE | ||
133 | /* Add any supported actions here and update _LAST */ | ||
134 | } Exactness_Action_Type; | ||
135 | |||
136 | /** | ||
137 | * @typedef Exactness_Action_Mouse_Wheel | ||
138 | * The type for the Exactness Mouse Wheel action. | ||
139 | */ | ||
140 | typedef struct | ||
141 | { | ||
142 | int direction; | ||
143 | int z; | ||
144 | } Exactness_Action_Mouse_Wheel; | ||
145 | |||
146 | /** | ||
147 | * @typedef Exactness_Action_Key_Down_Up | ||
148 | * The type for the Exactness Key Down Up action. | ||
149 | */ | ||
150 | typedef struct | ||
151 | { | ||
152 | const char *keyname; | ||
153 | const char *key; | ||
154 | const char *string; | ||
155 | const char *compose; | ||
156 | unsigned int keycode; | ||
157 | } Exactness_Action_Key_Down_Up; | ||
158 | |||
159 | /** | ||
160 | * @typedef Exactness_Action_Multi_Event | ||
161 | * The type for the Exactness Multi Event action. | ||
162 | */ | ||
163 | typedef struct | ||
164 | { | ||
165 | int d; | ||
166 | int b; /* In case of simple mouse down/up, corresponds to the button */ | ||
167 | int x; | ||
168 | int y; | ||
169 | double rad; | ||
170 | double radx; | ||
171 | double rady; | ||
172 | double pres; | ||
173 | double ang; | ||
174 | double fx; | ||
175 | double fy; | ||
176 | Evas_Button_Flags flags; | ||
177 | } Exactness_Action_Multi_Event; | ||
178 | |||
179 | /** | ||
180 | * @typedef Exactness_Action_Multi_Move | ||
181 | * The type for the Exactness Multi Move action. | ||
182 | */ | ||
183 | typedef struct | ||
184 | { | ||
185 | int d; | ||
186 | int x; | ||
187 | int y; | ||
188 | double rad; | ||
189 | double radx; | ||
190 | double rady; | ||
191 | double pres; | ||
192 | double ang; | ||
193 | double fx; | ||
194 | double fy; | ||
195 | } Exactness_Action_Multi_Move; | ||
196 | |||
197 | /** | ||
198 | * @typedef Exactness_Action_Efl_Event | ||
199 | * The type for the Exactness EFL Event action. | ||
200 | */ | ||
201 | typedef struct | ||
202 | { | ||
203 | char *wdg_name; | ||
204 | char *event_name; | ||
205 | } Exactness_Action_Efl_Event; | ||
206 | |||
207 | /** | ||
208 | * @typedef Exactness_Action_Click_On | ||
209 | * The type for the Exactness Click on (widget) action. | ||
210 | */ | ||
211 | typedef struct | ||
212 | { | ||
213 | char *wdg_name; | ||
214 | } Exactness_Action_Click_On; | ||
215 | |||
216 | /** | ||
217 | * @typedef Exactness_Action | ||
218 | * The type for the Exactness action. | ||
219 | */ | ||
220 | typedef struct | ||
221 | { | ||
222 | Exactness_Action_Type type; /**< The action type */ | ||
223 | unsigned int n_evas; /**< The evas number on which the action has to be applied */ | ||
224 | unsigned int delay_ms; /**< The delay (in ms) to wait for this action */ | ||
225 | void *data; /**< The specific action data */ | ||
226 | } Exactness_Action; | ||
227 | |||
228 | /** | ||
229 | * @typedef Exactness_Object | ||
230 | * The type for the Exactness object. | ||
231 | */ | ||
232 | typedef struct | ||
233 | { | ||
234 | long long id; /**< The Eo pointer */ | ||
235 | long long parent_id; /**< The Eo parent pointer */ | ||
236 | const char *kl_name; /**< The class name */ | ||
237 | |||
238 | Eina_List *children; /* NOT EET */ | ||
239 | |||
240 | /* Evas stuff */ | ||
241 | int x; /**< The X coordinate */ | ||
242 | int y; /**< The Y coordinate */ | ||
243 | int w; /**< The object width */ | ||
244 | int h; /**< The object height */ | ||
245 | } Exactness_Object; | ||
246 | |||
247 | /** | ||
248 | * @typedef Exactness_Objects | ||
249 | * The type for the Exactness objects list. | ||
250 | */ | ||
251 | typedef struct | ||
252 | { | ||
253 | Eina_List *objs; /**< List of all the objects */ | ||
254 | /* main_objs not in EET */ | ||
255 | Eina_List *main_objs; /**< List of the main objects */ | ||
256 | } Exactness_Objects; | ||
257 | |||
258 | /** | ||
259 | * @typedef Exactness_Image | ||
260 | * The type for the Exactness Image. | ||
261 | */ | ||
262 | typedef struct | ||
263 | { | ||
264 | unsigned int w; /**< Width of the image */ | ||
265 | unsigned int h; /**< Height of the image */ | ||
266 | void *pixels; /**< Pixels of the image */ | ||
267 | } Exactness_Image; | ||
268 | |||
269 | typedef struct | ||
270 | { | ||
271 | char *language; /**< String describing the language of the content e.g "C"...*/ | ||
272 | char *content; /**< Content used as source */ | ||
273 | char *command; /**< Command needed to generate the application from the content */ | ||
274 | } Exactness_Source_Code; | ||
275 | |||
276 | typedef struct | ||
277 | { | ||
278 | Eina_List *actions; /**< List of Exactness_Action */ | ||
279 | /* imgs not in EET */ | ||
280 | Eina_List *imgs; /**< List of Exactness_Image */ | ||
281 | Eina_List *objs; /**< List of Exactness_Objects */ | ||
282 | Eina_List *codes; /**< List of Exactness_Source_Code */ | ||
283 | const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */ | ||
284 | int nb_shots; /**< The number of shots present in the unit */ | ||
285 | } Exactness_Unit; | ||
286 | |||
100 | Evas *(*_evas_new)(void); | 287 | Evas *(*_evas_new)(void); |
288 | const char *_exactness_action_type_to_string_get(Exactness_Action_Type type); | ||
289 | |||
290 | /** | ||
291 | * @brief Read an unit from a given file | ||
292 | * | ||
293 | * @param filename Name of the file containing the unit | ||
294 | * | ||
295 | * @return the unit | ||
296 | */ | ||
297 | Exactness_Unit *exactness_unit_file_read(const char *filename); | ||
298 | |||
299 | /** | ||
300 | * @brief Write an unit into the given file | ||
301 | * | ||
302 | * @param unit Unit to store | ||
303 | * @param filename Name of the file containing the unit | ||
304 | * | ||
305 | * @return EINA_TRUE on success, EINA_FALSE otherwise | ||
306 | */ | ||
307 | Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename); | ||
308 | |||
309 | /** | ||
310 | * @brief Compare two images | ||
311 | * | ||
312 | * @param img1 first image | ||
313 | * @param img2 second image | ||
314 | * @param imgO pointer for the diff image. Can be NULL | ||
315 | * | ||
316 | * @return EINA_TRUE if the images are different, EINA_FALSE otherwise | ||
317 | */ | ||
318 | Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO); | ||
319 | |||
320 | /** | ||
321 | * @brief Free the given image | ||
322 | * | ||
323 | * @param img the image | ||
324 | * | ||
325 | */ | ||
326 | void exactness_image_free(Exactness_Image *img); | ||
327 | |||
328 | /** | ||
329 | * @} | ||
330 | */ | ||
101 | 331 | ||
102 | void ex_printf(int verbose, const char *fmt, ...); | 332 | void ex_printf(int verbose, const char *fmt, ...); |
103 | int ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player); | 333 | int ex_prg_invoke(const char *full_path, int argc, char **argv, Eina_Bool player); |
diff --git a/src/bin/exactness/exactness.c b/src/bin/exactness/exactness.c index ed999658c9..9fdd0066f5 100644 --- a/src/bin/exactness/exactness.c +++ b/src/bin/exactness/exactness.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <Ecore_Evas.h> | 7 | #include <Ecore_Evas.h> |
8 | #include <Ecore_File.h> | 8 | #include <Ecore_File.h> |
9 | 9 | ||
10 | #include "exactness_private.h" | ||
11 | #include "common.h" | 10 | #include "common.h" |
12 | 11 | ||
13 | #ifdef _WIN32 | 12 | #ifdef _WIN32 |
diff --git a/src/bin/exactness/injector.c b/src/bin/exactness/injector.c index 7530fd8806..c10c58b6b4 100644 --- a/src/bin/exactness/injector.c +++ b/src/bin/exactness/injector.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <Ecore_Getopt.h> | 13 | #include <Ecore_Getopt.h> |
14 | #include <Elementary.h> | 14 | #include <Elementary.h> |
15 | 15 | ||
16 | #include <Exactness.h> | ||
17 | #include "common.h" | 16 | #include "common.h" |
18 | 17 | ||
19 | static Eina_Stringshare *_src_filename = NULL; | 18 | static Eina_Stringshare *_src_filename = NULL; |
diff --git a/src/bin/exactness/inspect.c b/src/bin/exactness/inspect.c index eeb108b95b..68da3548a3 100644 --- a/src/bin/exactness/inspect.c +++ b/src/bin/exactness/inspect.c | |||
@@ -6,7 +6,6 @@ | |||
6 | #include <Ecore_Getopt.h> | 6 | #include <Ecore_Getopt.h> |
7 | #include <Ecore_Evas.h> | 7 | #include <Ecore_Evas.h> |
8 | #include <Elementary.h> | 8 | #include <Elementary.h> |
9 | #include <Exactness.h> | ||
10 | #include <Efl_Ui.h> | 9 | #include <Efl_Ui.h> |
11 | 10 | ||
12 | #include "common.h" | 11 | #include "common.h" |
diff --git a/src/bin/exactness/meson.build b/src/bin/exactness/meson.build index f835cd40ea..4dbfc73d1f 100644 --- a/src/bin/exactness/meson.build +++ b/src/bin/exactness/meson.build | |||
@@ -1,20 +1,20 @@ | |||
1 | exactness_bin = executable('exactness', | 1 | exactness_bin = executable('exactness', |
2 | [ 'exactness.c', 'common.c', 'common.h' ], | 2 | [ 'exactness.c', 'common.c', 'common.h' ], |
3 | dependencies: [ ecore, ecore_evas, ecore_file, elementary, exactness ], | 3 | dependencies: [ ecore, ecore_evas, ecore_file, elementary], |
4 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', | 4 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', |
5 | install: true, | 5 | install: true, |
6 | ) | 6 | ) |
7 | 7 | ||
8 | exactness_inject_bin = executable('exactness_inject', | 8 | exactness_inject_bin = executable('exactness_inject', |
9 | [ 'injector.c', 'common.c', 'common.h' ], | 9 | [ 'injector.c', 'common.c', 'common.h' ], |
10 | dependencies: [ elementary, exactness ], | 10 | dependencies: [ elementary ], |
11 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', | 11 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', |
12 | install: true, | 12 | install: true, |
13 | ) | 13 | ) |
14 | 14 | ||
15 | exactness_inspect_bin = executable('exactness_inspect', | 15 | exactness_inspect_bin = executable('exactness_inspect', |
16 | [ 'inspect.c', 'common.c', 'common.h' ], | 16 | [ 'inspect.c', 'common.c', 'common.h' ], |
17 | dependencies: [ elementary, exactness ], | 17 | dependencies: [ elementary ], |
18 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', | 18 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', |
19 | install: true, | 19 | install: true, |
20 | ) | 20 | ) |
@@ -32,14 +32,14 @@ edjs = custom_target('player_entry', | |||
32 | 32 | ||
33 | exactness_play_bin = executable('exactness_play', | 33 | exactness_play_bin = executable('exactness_play', |
34 | [ 'player.c', 'common.c', 'common.h', edjs ], | 34 | [ 'player.c', 'common.c', 'common.h', edjs ], |
35 | dependencies: [ elementary, exactness ], | 35 | dependencies: [ elementary ], |
36 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', | 36 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', |
37 | install: true, | 37 | install: true, |
38 | ) | 38 | ) |
39 | 39 | ||
40 | exactness_record_bin = executable('exactness_record', | 40 | exactness_record_bin = executable('exactness_record', |
41 | [ 'recorder.c', 'common.c', 'common.h' ], | 41 | [ 'recorder.c', 'common.c', 'common.h' ], |
42 | dependencies: [ elementary, exactness ], | 42 | dependencies: [ elementary ], |
43 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', | 43 | c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', |
44 | install: true, | 44 | install: true, |
45 | ) | 45 | ) |
diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c index cca1d37a0e..54514ae0be 100644 --- a/src/bin/exactness/player.c +++ b/src/bin/exactness/player.c | |||
@@ -27,9 +27,7 @@ | |||
27 | #include <Ecore_File.h> | 27 | #include <Ecore_File.h> |
28 | #include <Ecore_Con.h> | 28 | #include <Ecore_Con.h> |
29 | #include <Elementary.h> | 29 | #include <Elementary.h> |
30 | #include <Exactness.h> | ||
31 | 30 | ||
32 | #include "exactness_private.h" | ||
33 | #include "common.h" | 31 | #include "common.h" |
34 | 32 | ||
35 | #define CMD_LINE_MAX 256 | 33 | #define CMD_LINE_MAX 256 |
diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c index 57c0b208c0..3ecaff7695 100644 --- a/src/bin/exactness/recorder.c +++ b/src/bin/exactness/recorder.c | |||
@@ -20,9 +20,7 @@ | |||
20 | #include <Ecore_Getopt.h> | 20 | #include <Ecore_Getopt.h> |
21 | #include <Ecore_Con.h> | 21 | #include <Ecore_Con.h> |
22 | #include <Elementary.h> | 22 | #include <Elementary.h> |
23 | #include <Exactness.h> | ||
24 | 23 | ||
25 | #include <exactness_private.h> | ||
26 | #include "common.h" | 24 | #include "common.h" |
27 | 25 | ||
28 | #define STABILIZE_KEY_STR "F1" | 26 | #define STABILIZE_KEY_STR "F1" |
diff --git a/src/lib/exactness/Exactness.h b/src/lib/exactness/Exactness.h deleted file mode 100644 index 33c448cf58..0000000000 --- a/src/lib/exactness/Exactness.h +++ /dev/null | |||
@@ -1,259 +0,0 @@ | |||
1 | #ifndef _EXACTNESS_H | ||
2 | #define _EXACTNESS_H | ||
3 | |||
4 | #include <Evas.h> | ||
5 | |||
6 | #ifdef EAPI | ||
7 | # undef EAPI | ||
8 | #endif | ||
9 | |||
10 | #ifdef _WIN32 | ||
11 | # ifdef EXACTNESS_BUILD | ||
12 | # ifdef DLL_EXPORT | ||
13 | # define EAPI __declspec(dllexport) | ||
14 | # else | ||
15 | # define EAPI | ||
16 | # endif /* ! DLL_EXPORT */ | ||
17 | # else | ||
18 | # define EAPI __declspec(dllimport) | ||
19 | # endif /* ! EXACTNESS_BUILD */ | ||
20 | #else | ||
21 | # ifdef __GNUC__ | ||
22 | # if __GNUC__ >= 4 | ||
23 | # define EAPI __attribute__ ((visibility("default"))) | ||
24 | # else | ||
25 | # define EAPI | ||
26 | # endif | ||
27 | # else | ||
28 | # define EAPI | ||
29 | # endif | ||
30 | #endif /* ! _WIN32 */ | ||
31 | |||
32 | /** | ||
33 | * @page exactness_main Exactness | ||
34 | * | ||
35 | * @date 2018 (created) | ||
36 | * | ||
37 | * This page describes the public structures and APIs available for Exactness. | ||
38 | * | ||
39 | * @addtogroup Exactness | ||
40 | * @{ | ||
41 | */ | ||
42 | |||
43 | /** | ||
44 | * @typedef Exactness_Action_Type | ||
45 | * The type values for an Exactness action. | ||
46 | */ | ||
47 | typedef enum | ||
48 | { | ||
49 | EXACTNESS_ACTION_UNKNOWN = 0, | ||
50 | EXACTNESS_ACTION_MOUSE_IN, | ||
51 | EXACTNESS_ACTION_MOUSE_OUT, | ||
52 | EXACTNESS_ACTION_MOUSE_WHEEL, | ||
53 | EXACTNESS_ACTION_MULTI_DOWN, | ||
54 | EXACTNESS_ACTION_MULTI_UP, | ||
55 | EXACTNESS_ACTION_MULTI_MOVE, | ||
56 | EXACTNESS_ACTION_KEY_DOWN, | ||
57 | EXACTNESS_ACTION_KEY_UP, | ||
58 | EXACTNESS_ACTION_TAKE_SHOT, | ||
59 | EXACTNESS_ACTION_EFL_EVENT, | ||
60 | EXACTNESS_ACTION_CLICK_ON, | ||
61 | EXACTNESS_ACTION_STABILIZE, | ||
62 | EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_STABILIZE | ||
63 | /* Add any supported actions here and update _LAST */ | ||
64 | } Exactness_Action_Type; | ||
65 | |||
66 | /** | ||
67 | * @typedef Exactness_Action_Mouse_Wheel | ||
68 | * The type for the Exactness Mouse Wheel action. | ||
69 | */ | ||
70 | typedef struct | ||
71 | { | ||
72 | int direction; | ||
73 | int z; | ||
74 | } Exactness_Action_Mouse_Wheel; | ||
75 | |||
76 | /** | ||
77 | * @typedef Exactness_Action_Key_Down_Up | ||
78 | * The type for the Exactness Key Down Up action. | ||
79 | */ | ||
80 | typedef struct | ||
81 | { | ||
82 | const char *keyname; | ||
83 | const char *key; | ||
84 | const char *string; | ||
85 | const char *compose; | ||
86 | unsigned int keycode; | ||
87 | } Exactness_Action_Key_Down_Up; | ||
88 | |||
89 | /** | ||
90 | * @typedef Exactness_Action_Multi_Event | ||
91 | * The type for the Exactness Multi Event action. | ||
92 | */ | ||
93 | typedef struct | ||
94 | { | ||
95 | int d; | ||
96 | int b; /* In case of simple mouse down/up, corresponds to the button */ | ||
97 | int x; | ||
98 | int y; | ||
99 | double rad; | ||
100 | double radx; | ||
101 | double rady; | ||
102 | double pres; | ||
103 | double ang; | ||
104 | double fx; | ||
105 | double fy; | ||
106 | Evas_Button_Flags flags; | ||
107 | } Exactness_Action_Multi_Event; | ||
108 | |||
109 | /** | ||
110 | * @typedef Exactness_Action_Multi_Move | ||
111 | * The type for the Exactness Multi Move action. | ||
112 | */ | ||
113 | typedef struct | ||
114 | { | ||
115 | int d; | ||
116 | int x; | ||
117 | int y; | ||
118 | double rad; | ||
119 | double radx; | ||
120 | double rady; | ||
121 | double pres; | ||
122 | double ang; | ||
123 | double fx; | ||
124 | double fy; | ||
125 | } Exactness_Action_Multi_Move; | ||
126 | |||
127 | /** | ||
128 | * @typedef Exactness_Action_Efl_Event | ||
129 | * The type for the Exactness EFL Event action. | ||
130 | */ | ||
131 | typedef struct | ||
132 | { | ||
133 | char *wdg_name; | ||
134 | char *event_name; | ||
135 | } Exactness_Action_Efl_Event; | ||
136 | |||
137 | /** | ||
138 | * @typedef Exactness_Action_Click_On | ||
139 | * The type for the Exactness Click on (widget) action. | ||
140 | */ | ||
141 | typedef struct | ||
142 | { | ||
143 | char *wdg_name; | ||
144 | } Exactness_Action_Click_On; | ||
145 | |||
146 | /** | ||
147 | * @typedef Exactness_Action | ||
148 | * The type for the Exactness action. | ||
149 | */ | ||
150 | typedef struct | ||
151 | { | ||
152 | Exactness_Action_Type type; /**< The action type */ | ||
153 | unsigned int n_evas; /**< The evas number on which the action has to be applied */ | ||
154 | unsigned int delay_ms; /**< The delay (in ms) to wait for this action */ | ||
155 | void *data; /**< The specific action data */ | ||
156 | } Exactness_Action; | ||
157 | |||
158 | /** | ||
159 | * @typedef Exactness_Object | ||
160 | * The type for the Exactness object. | ||
161 | */ | ||
162 | typedef struct | ||
163 | { | ||
164 | long long id; /**< The Eo pointer */ | ||
165 | long long parent_id; /**< The Eo parent pointer */ | ||
166 | const char *kl_name; /**< The class name */ | ||
167 | |||
168 | Eina_List *children; /* NOT EET */ | ||
169 | |||
170 | /* Evas stuff */ | ||
171 | int x; /**< The X coordinate */ | ||
172 | int y; /**< The Y coordinate */ | ||
173 | int w; /**< The object width */ | ||
174 | int h; /**< The object height */ | ||
175 | } Exactness_Object; | ||
176 | |||
177 | /** | ||
178 | * @typedef Exactness_Objects | ||
179 | * The type for the Exactness objects list. | ||
180 | */ | ||
181 | typedef struct | ||
182 | { | ||
183 | Eina_List *objs; /**< List of all the objects */ | ||
184 | /* main_objs not in EET */ | ||
185 | Eina_List *main_objs; /**< List of the main objects */ | ||
186 | } Exactness_Objects; | ||
187 | |||
188 | /** | ||
189 | * @typedef Exactness_Image | ||
190 | * The type for the Exactness Image. | ||
191 | */ | ||
192 | typedef struct | ||
193 | { | ||
194 | unsigned int w; /**< Width of the image */ | ||
195 | unsigned int h; /**< Height of the image */ | ||
196 | void *pixels; /**< Pixels of the image */ | ||
197 | } Exactness_Image; | ||
198 | |||
199 | typedef struct | ||
200 | { | ||
201 | char *language; /**< String describing the language of the content e.g "C"...*/ | ||
202 | char *content; /**< Content used as source */ | ||
203 | char *command; /**< Command needed to generate the application from the content */ | ||
204 | } Exactness_Source_Code; | ||
205 | |||
206 | typedef struct | ||
207 | { | ||
208 | Eina_List *actions; /**< List of Exactness_Action */ | ||
209 | /* imgs not in EET */ | ||
210 | Eina_List *imgs; /**< List of Exactness_Image */ | ||
211 | Eina_List *objs; /**< List of Exactness_Objects */ | ||
212 | Eina_List *codes; /**< List of Exactness_Source_Code */ | ||
213 | const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */ | ||
214 | int nb_shots; /**< The number of shots present in the unit */ | ||
215 | } Exactness_Unit; | ||
216 | |||
217 | /** | ||
218 | * @brief Read an unit from a given file | ||
219 | * | ||
220 | * @param filename Name of the file containing the unit | ||
221 | * | ||
222 | * @return the unit | ||
223 | */ | ||
224 | EAPI Exactness_Unit *exactness_unit_file_read(const char *filename); | ||
225 | |||
226 | /** | ||
227 | * @brief Write an unit into the given file | ||
228 | * | ||
229 | * @param unit Unit to store | ||
230 | * @param filename Name of the file containing the unit | ||
231 | * | ||
232 | * @return EINA_TRUE on success, EINA_FALSE otherwise | ||
233 | */ | ||
234 | EAPI Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename); | ||
235 | |||
236 | /** | ||
237 | * @brief Compare two images | ||
238 | * | ||
239 | * @param img1 first image | ||
240 | * @param img2 second image | ||
241 | * @param imgO pointer for the diff image. Can be NULL | ||
242 | * | ||
243 | * @return EINA_TRUE if the images are different, EINA_FALSE otherwise | ||
244 | */ | ||
245 | EAPI Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO); | ||
246 | |||
247 | /** | ||
248 | * @brief Free the given image | ||
249 | * | ||
250 | * @param img the image | ||
251 | * | ||
252 | */ | ||
253 | EAPI void exactness_image_free(Exactness_Image *img); | ||
254 | |||
255 | /** | ||
256 | * @} | ||
257 | */ | ||
258 | |||
259 | #endif /* _EXACTNESS_H */ | ||
diff --git a/src/lib/exactness/exactness_private.h b/src/lib/exactness/exactness_private.h deleted file mode 100644 index 68bf4d8ddb..0000000000 --- a/src/lib/exactness/exactness_private.h +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #ifndef _EXACTNESS_PRIVATE_H | ||
2 | #define _EXACTNESS_PRIVATE_H | ||
3 | |||
4 | #include <Exactness.h> | ||
5 | |||
6 | /* private header */ | ||
7 | EAPI const char *_exactness_action_type_to_string_get(Exactness_Action_Type type); | ||
8 | |||
9 | #define SHOT_DELIMITER '+' | ||
10 | #endif | ||
diff --git a/src/lib/exactness/meson.build b/src/lib/exactness/meson.build deleted file mode 100644 index 11ba1173a4..0000000000 --- a/src/lib/exactness/meson.build +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | exactness_pub_deps = [eina, evas] | ||
2 | exactness_deps = [] | ||
3 | |||
4 | exactness_src = [ | ||
5 | 'Exactness.h', | ||
6 | 'exactness_private.h', | ||
7 | 'unit.c' | ||
8 | ] | ||
9 | |||
10 | exactness_lib = library('exactness', exactness_src, | ||
11 | dependencies: [ eina, eet, evas ], | ||
12 | install: true, | ||
13 | version : meson.project_version() | ||
14 | ) | ||
15 | |||
16 | exactness = declare_dependency( | ||
17 | include_directories: include_directories('.'), | ||
18 | link_with : exactness_lib, | ||
19 | dependencies: [ eina, evas, eet ], | ||
20 | ) | ||
21 | |||
22 | exactness_include_dir = join_paths(dir_data, 'exactness', 'include') | ||
23 | |||
24 | exactness_header_src = [ | ||
25 | 'Exactness.h', | ||
26 | ] | ||
27 | |||
28 | install_headers(exactness_header_src, | ||
29 | install_dir : dir_package_include | ||
30 | ) | ||
diff --git a/src/lib/exactness/unit.c b/src/lib/exactness/unit.c deleted file mode 100644 index 91965331d8..0000000000 --- a/src/lib/exactness/unit.c +++ /dev/null | |||
@@ -1,409 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <Eet.h> | ||
6 | |||
7 | #include "Exactness.h" | ||
8 | #include "exactness_private.h" | ||
9 | |||
10 | typedef struct _Dummy | ||
11 | { | ||
12 | } _Dummy; | ||
13 | |||
14 | static Eet_Data_Descriptor * | ||
15 | _mouse_wheel_desc_make(void) | ||
16 | { | ||
17 | Eet_Data_Descriptor_Class eddc; | ||
18 | Eet_Data_Descriptor *_d; | ||
19 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_Wheel); | ||
20 | _d = eet_data_descriptor_stream_new(&eddc); | ||
21 | |||
22 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "direction", direction, EET_T_INT); | ||
23 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "z", z, EET_T_INT); | ||
24 | |||
25 | return _d; | ||
26 | } | ||
27 | |||
28 | static Eet_Data_Descriptor * | ||
29 | _key_down_up_desc_make(void) | ||
30 | { | ||
31 | Eet_Data_Descriptor_Class eddc; | ||
32 | Eet_Data_Descriptor *_d; | ||
33 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Key_Down_Up); | ||
34 | _d = eet_data_descriptor_stream_new(&eddc); | ||
35 | |||
36 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keyname", keyname, EET_T_STRING); | ||
37 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "key", key, EET_T_STRING); | ||
38 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "string", string, EET_T_STRING); | ||
39 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "compose", compose, EET_T_STRING); | ||
40 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keycode", keycode, EET_T_INT); | ||
41 | |||
42 | return _d; | ||
43 | } | ||
44 | |||
45 | static Eet_Data_Descriptor * | ||
46 | _multi_event_desc_make(void) | ||
47 | { | ||
48 | Eet_Data_Descriptor_Class eddc; | ||
49 | Eet_Data_Descriptor *_d; | ||
50 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Event); | ||
51 | _d = eet_data_descriptor_stream_new(&eddc); | ||
52 | |||
53 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "d", d, EET_T_UINT); | ||
54 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "b", b, EET_T_UINT); | ||
55 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "x", x, EET_T_UINT); | ||
56 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "y", y, EET_T_UINT); | ||
57 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rad", rad, EET_T_DOUBLE); | ||
58 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "radx", radx, EET_T_DOUBLE); | ||
59 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rady", rady, EET_T_DOUBLE); | ||
60 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "pres", pres, EET_T_DOUBLE); | ||
61 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "ang", ang, EET_T_DOUBLE); | ||
62 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fx", fx, EET_T_DOUBLE); | ||
63 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fy", fy, EET_T_DOUBLE); | ||
64 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "flags", flags, EET_T_INT); | ||
65 | |||
66 | return _d; | ||
67 | } | ||
68 | |||
69 | static Eet_Data_Descriptor * | ||
70 | _multi_move_desc_make(void) | ||
71 | { | ||
72 | Eet_Data_Descriptor_Class eddc; | ||
73 | Eet_Data_Descriptor *_d; | ||
74 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Move); | ||
75 | _d = eet_data_descriptor_stream_new(&eddc); | ||
76 | |||
77 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "d", d, EET_T_UINT); | ||
78 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "x", x, EET_T_UINT); | ||
79 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "y", y, EET_T_UINT); | ||
80 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rad", rad, EET_T_DOUBLE); | ||
81 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "radx", radx, EET_T_DOUBLE); | ||
82 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rady", rady, EET_T_DOUBLE); | ||
83 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "pres", pres, EET_T_DOUBLE); | ||
84 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "ang", ang, EET_T_DOUBLE); | ||
85 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fx", fx, EET_T_DOUBLE); | ||
86 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fy", fy, EET_T_DOUBLE); | ||
87 | |||
88 | return _d; | ||
89 | } | ||
90 | |||
91 | static Eet_Data_Descriptor * | ||
92 | _efl_event_desc_make(void) | ||
93 | { | ||
94 | Eet_Data_Descriptor_Class eddc; | ||
95 | Eet_Data_Descriptor *_d; | ||
96 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Efl_Event); | ||
97 | _d = eet_data_descriptor_stream_new(&eddc); | ||
98 | |||
99 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "wdg_name", wdg_name, EET_T_STRING); | ||
100 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "event_name", event_name, EET_T_STRING); | ||
101 | |||
102 | return _d; | ||
103 | } | ||
104 | |||
105 | static Eet_Data_Descriptor * | ||
106 | _click_on_desc_make(void) | ||
107 | { | ||
108 | Eet_Data_Descriptor_Class eddc; | ||
109 | Eet_Data_Descriptor *_d; | ||
110 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Click_On); | ||
111 | _d = eet_data_descriptor_stream_new(&eddc); | ||
112 | |||
113 | EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Click_On, "wdg_name", wdg_name, EET_T_STRING); | ||
114 | |||
115 | return _d; | ||
116 | } | ||
117 | |||
118 | static Eet_Data_Descriptor * | ||
119 | _dummy_desc_make(void) | ||
120 | { | ||
121 | Eet_Data_Descriptor_Class eddc; | ||
122 | Eet_Data_Descriptor *_d; | ||
123 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, _Dummy); | ||
124 | _d = eet_data_descriptor_stream_new(&eddc); | ||
125 | |||
126 | return _d; | ||
127 | } | ||
128 | |||
129 | /* !!! SAME ORDER AS Exactness_Action_Type */ | ||
130 | static const char *_mapping[] = | ||
131 | { | ||
132 | "", | ||
133 | "exactness_action_mouse_in", | ||
134 | "exactness_action_mouse_out", | ||
135 | "exactness_action_mouse_wheel", | ||
136 | "exactness_action_multi_down", | ||
137 | "exactness_action_multi_up", | ||
138 | "exactness_action_multi_move", | ||
139 | "exactness_action_key_down", | ||
140 | "exactness_action_key_up", | ||
141 | "exactness_action_take_shot", | ||
142 | "exactness_action_efl_event", | ||
143 | "exactness_action_click_on", | ||
144 | "exactness_action_stabilize" | ||
145 | }; | ||
146 | |||
147 | const char * | ||
148 | _exactness_action_type_to_string_get(Exactness_Action_Type type) | ||
149 | { | ||
150 | if (type <= EXACTNESS_ACTION_LAST) return _mapping[type]; | ||
151 | return NULL; | ||
152 | } | ||
153 | |||
154 | static const char * | ||
155 | _variant_type_get(const void *data, Eina_Bool *unknow) | ||
156 | { | ||
157 | const Exactness_Action *act = data; | ||
158 | |||
159 | if (unknow) *unknow = EINA_FALSE; | ||
160 | if (act->type <= EXACTNESS_ACTION_LAST) return _mapping[act->type]; | ||
161 | |||
162 | return NULL; | ||
163 | } | ||
164 | |||
165 | static Eina_Bool | ||
166 | _variant_type_set(const char *type, | ||
167 | void *data, | ||
168 | Eina_Bool unknow EINA_UNUSED) | ||
169 | { | ||
170 | int i; | ||
171 | Exactness_Action *act = data; | ||
172 | for (i = 0; i <= EXACTNESS_ACTION_LAST; i++) | ||
173 | { | ||
174 | if (!strcmp(_mapping[i], type)) act->type = i; | ||
175 | } | ||
176 | return EINA_TRUE; | ||
177 | } | ||
178 | |||
179 | static Eet_Data_Descriptor * | ||
180 | _unit_desc_make(void) | ||
181 | { | ||
182 | Eet_Data_Descriptor_Class eddc; | ||
183 | static Eet_Data_Descriptor *unit_d = NULL; | ||
184 | static Eet_Data_Descriptor *action_d = NULL, *action_variant_d = NULL; | ||
185 | static Eet_Data_Descriptor *objs_d = NULL; | ||
186 | static Eet_Data_Descriptor *obj_d = NULL; | ||
187 | if (!obj_d) | ||
188 | { | ||
189 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object); | ||
190 | obj_d = eet_data_descriptor_stream_new(&eddc); | ||
191 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING); | ||
192 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG); | ||
193 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG); | ||
194 | /* Evas stuff */ | ||
195 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT); | ||
196 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT); | ||
197 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT); | ||
198 | EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT); | ||
199 | |||
200 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects); | ||
201 | objs_d = eet_data_descriptor_stream_new(&eddc); | ||
202 | EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d); | ||
203 | } | ||
204 | if (!unit_d) | ||
205 | { | ||
206 | Eet_Data_Descriptor *code_d = NULL; | ||
207 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Source_Code); | ||
208 | code_d = eet_data_descriptor_stream_new(&eddc); | ||
209 | EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "language", language, EET_T_STRING); | ||
210 | EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "content", content, EET_T_STRING); | ||
211 | EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "command", command, EET_T_STRING); | ||
212 | |||
213 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action); | ||
214 | action_d = eet_data_descriptor_stream_new(&eddc); | ||
215 | |||
216 | eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; | ||
217 | eddc.func.type_get = _variant_type_get; | ||
218 | eddc.func.type_set = _variant_type_set; | ||
219 | action_variant_d = eet_data_descriptor_stream_new(&eddc); | ||
220 | |||
221 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
222 | _mapping[EXACTNESS_ACTION_MOUSE_IN], _dummy_desc_make()); | ||
223 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
224 | _mapping[EXACTNESS_ACTION_MOUSE_OUT], _dummy_desc_make()); | ||
225 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
226 | _mapping[EXACTNESS_ACTION_MOUSE_WHEEL], _mouse_wheel_desc_make()); | ||
227 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
228 | _mapping[EXACTNESS_ACTION_MULTI_DOWN], _multi_event_desc_make()); | ||
229 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
230 | _mapping[EXACTNESS_ACTION_MULTI_UP], _multi_event_desc_make()); | ||
231 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
232 | _mapping[EXACTNESS_ACTION_MULTI_MOVE], _multi_move_desc_make()); | ||
233 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
234 | _mapping[EXACTNESS_ACTION_KEY_DOWN], _key_down_up_desc_make()); | ||
235 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
236 | _mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make()); | ||
237 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
238 | _mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make()); | ||
239 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
240 | _mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make()); | ||
241 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
242 | _mapping[EXACTNESS_ACTION_CLICK_ON], _click_on_desc_make()); | ||
243 | EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, | ||
244 | _mapping[EXACTNESS_ACTION_STABILIZE], _dummy_desc_make()); | ||
245 | |||
246 | EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT); | ||
247 | EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT); | ||
248 | EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d); | ||
249 | |||
250 | /* Exactness_Unit */ | ||
251 | EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit); | ||
252 | unit_d = eet_data_descriptor_stream_new(&eddc); | ||
253 | EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d); | ||
254 | EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d); | ||
255 | EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "codes", codes, code_d); | ||
256 | EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING); | ||
257 | EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT); | ||
258 | } | ||
259 | |||
260 | return unit_d; | ||
261 | } | ||
262 | /* END Event struct descriptors */ | ||
263 | |||
264 | EAPI Exactness_Unit * | ||
265 | exactness_unit_file_read(const char *filename) | ||
266 | { | ||
267 | int i; | ||
268 | Eina_List *itr, *itr2; | ||
269 | Exactness_Objects *e_objs; | ||
270 | Exactness_Object *e_obj, *e_parent; | ||
271 | Exactness_Unit *unit = NULL; | ||
272 | Eet_File *file; | ||
273 | eet_init(); | ||
274 | file = eet_open(filename, EET_FILE_MODE_READ); | ||
275 | if (!file) | ||
276 | { | ||
277 | fprintf(stderr, "Impossible to extract EET from %s\n", filename); | ||
278 | return NULL; | ||
279 | } | ||
280 | unit = eet_data_read(file, _unit_desc_make(), "cache"); | ||
281 | for (i = 0; i < unit->nb_shots; i++) | ||
282 | { | ||
283 | char entry[32]; | ||
284 | Exactness_Image *ex_img = malloc(sizeof(*ex_img)); | ||
285 | sprintf(entry, "images/%d", i + 1); | ||
286 | ex_img->pixels = eet_data_image_read(file, entry, | ||
287 | &ex_img->w, &ex_img->h, NULL, | ||
288 | NULL, NULL, NULL); | ||
289 | unit->imgs = eina_list_append(unit->imgs, ex_img); | ||
290 | } | ||
291 | EINA_LIST_FOREACH(unit->objs, itr, e_objs) | ||
292 | { | ||
293 | Eina_Hash *hash = eina_hash_pointer_new(NULL); | ||
294 | EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) | ||
295 | { | ||
296 | eina_hash_set(hash, &(e_obj->id), e_obj); | ||
297 | } | ||
298 | EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) | ||
299 | { | ||
300 | if (!e_obj->parent_id) | ||
301 | e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj); | ||
302 | else | ||
303 | { | ||
304 | e_parent = eina_hash_find(hash, &(e_obj->parent_id)); | ||
305 | if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj); | ||
306 | } | ||
307 | } | ||
308 | eina_hash_free(hash); | ||
309 | } | ||
310 | eet_close(file); | ||
311 | eet_shutdown(); | ||
312 | return unit; | ||
313 | } | ||
314 | |||
315 | EAPI Eina_Bool | ||
316 | exactness_unit_file_write(Exactness_Unit *unit, const char *filename) | ||
317 | { | ||
318 | Eina_List *itr; | ||
319 | Exactness_Image *ex_img; | ||
320 | Eet_File *file; | ||
321 | int i = 1; | ||
322 | eet_init(); | ||
323 | file = eet_open(filename, EET_FILE_MODE_WRITE); | ||
324 | eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE); | ||
325 | EINA_LIST_FOREACH(unit->imgs, itr, ex_img) | ||
326 | { | ||
327 | char entry[32]; | ||
328 | sprintf(entry, "images/%d", i++); | ||
329 | eet_data_image_write(file, entry, | ||
330 | ex_img->pixels, ex_img->w, ex_img->h, 0xFF, | ||
331 | 0, 100, EET_IMAGE_LOSSLESS); | ||
332 | } | ||
333 | eet_close(file); | ||
334 | eet_shutdown(); | ||
335 | return EINA_TRUE; | ||
336 | } | ||
337 | |||
338 | EAPI Eina_Bool | ||
339 | exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO) | ||
340 | { | ||
341 | unsigned int w, h; | ||
342 | int *pxs1, *pxs2, *pxsO = NULL; | ||
343 | unsigned int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0; | ||
344 | unsigned int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0; | ||
345 | unsigned int wO = MAX(w1, w2); | ||
346 | unsigned int hO = MAX(h1, h2); | ||
347 | Eina_Bool ret = EINA_FALSE; | ||
348 | if (imgO) *imgO = NULL; | ||
349 | if (!wO || !hO) return EINA_FALSE; | ||
350 | |||
351 | pxs1 = img1 ? img1->pixels : NULL; | ||
352 | pxs2 = img2 ? img2->pixels : NULL; | ||
353 | if (imgO) pxsO = malloc(wO * hO * 4); | ||
354 | |||
355 | for (w = 0; w < wO; w++) | ||
356 | { | ||
357 | for (h = 0; h < hO; h++) | ||
358 | { | ||
359 | Eina_Bool valid1 = img1 ? w < w1 && h < h1 : EINA_FALSE; | ||
360 | Eina_Bool valid2 = img2 ? w < w2 && h < h2 : EINA_FALSE; | ||
361 | int px1 = valid1 ? pxs1[h * w1 + w] : 0; | ||
362 | int px2 = valid2 ? pxs2[h * w2 + w] : 0; | ||
363 | int r1 = (px1 & 0x00FF0000) >> 16; | ||
364 | int r2 = (px2 & 0x00FF0000) >> 16; | ||
365 | int g1 = (px1 & 0x0000FF00) >> 8; | ||
366 | int g2 = (px2 & 0x0000FF00) >> 8; | ||
367 | int b1 = (px1 & 0x000000FF); | ||
368 | int b2 = (px2 & 0x000000FF); | ||
369 | int new_r, new_g, new_b; | ||
370 | if (valid1 || valid2) | ||
371 | { | ||
372 | if (px1 != px2) | ||
373 | { | ||
374 | new_r = 0xFF; | ||
375 | new_g = ((g1 + g2) >> 1) >> 2; | ||
376 | new_b = ((b1 + b2) >> 1) >> 2; | ||
377 | ret = EINA_TRUE; | ||
378 | } | ||
379 | else | ||
380 | { | ||
381 | new_r = (((r1 + r2) >> 1) >> 2) + 0xC0; | ||
382 | new_g = (((g1 + g2) >> 1) >> 2) + 0xC0; | ||
383 | new_b = (((b1 + b2) >> 1) >> 2) + 0xC0; | ||
384 | } | ||
385 | } | ||
386 | else | ||
387 | { | ||
388 | new_r = new_g = new_b = 0x0; | ||
389 | } | ||
390 | if (pxsO) pxsO[h * wO + w] = 0xFF000000 | new_r << 16 | new_g << 8 | new_b; | ||
391 | } | ||
392 | } | ||
393 | if (imgO) | ||
394 | { | ||
395 | Exactness_Image *imgR = calloc(1, sizeof(Exactness_Image)); | ||
396 | *imgO = imgR; | ||
397 | imgR->w = wO; | ||
398 | imgR->h = hO; | ||
399 | imgR->pixels = pxsO; | ||
400 | } | ||
401 | return ret; | ||
402 | } | ||
403 | |||
404 | EAPI void exactness_image_free(Exactness_Image *img) | ||
405 | { | ||
406 | if (!img) return; | ||
407 | free(img->pixels); | ||
408 | free(img); | ||
409 | } | ||