From 9da0235d74637b3ee0049eddd1a3ef2c44a3849e Mon Sep 17 00:00:00 2001 From: Stefan Schmidt Date: Thu, 19 Mar 2020 17:39:03 +0100 Subject: [PATCH] exactness: remove exactness library and move code into binary folder 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. Reviewed-by: Mike Blumenkrantz Differential Revision: https://phab.enlightenment.org/D11545 --- meson.build | 2 +- src/bin/exactness/common.c | 405 +++++++++++++++++++++++++ src/bin/exactness/common.h | 181 +++++++++++- src/bin/exactness/exactness.c | 1 - src/bin/exactness/injector.c | 1 - src/bin/exactness/inspect.c | 1 - src/bin/exactness/meson.build | 10 +- src/bin/exactness/player.c | 2 - src/bin/exactness/recorder.c | 2 - src/lib/exactness/Exactness.h | 267 ----------------- src/lib/exactness/exactness_private.h | 10 - src/lib/exactness/meson.build | 30 -- src/lib/exactness/unit.c | 409 -------------------------- 13 files changed, 590 insertions(+), 731 deletions(-) delete mode 100644 src/lib/exactness/Exactness.h delete mode 100644 src/lib/exactness/exactness_private.h delete mode 100644 src/lib/exactness/meson.build delete mode 100644 src/lib/exactness/unit.c diff --git a/meson.build b/meson.build index bbf99d427a..a49be8c620 100644 --- a/meson.build +++ b/meson.build @@ -335,7 +335,7 @@ subprojects = [ ['elua' ,['elua'] , false, true, true, false, true, false, ['eina', 'luajit'], []], ['ecore_wayland' ,['wl-deprecated'] , false, true, false, false, false, false, ['eina'], []], ['ecore_drm' ,['drm-deprecated'] , false, true, false, false, false, false, ['eina'], []], -['exactness' ,[] , false, true, true, false, false, false, ['eina, evas, eet'], []], +['exactness' ,[] , false, false, true, false, false, false, ['eina, evas, eet'], []], ] # 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 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "common.h" static int _verbose = 0; @@ -98,3 +102,404 @@ ex_prg_full_path_guess(const char *prg) free(env_path); return ret; } + +typedef struct _Dummy +{ +} _Dummy; + +static Eet_Data_Descriptor * +_mouse_wheel_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + Eet_Data_Descriptor *_d; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_Wheel); + _d = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "direction", direction, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "z", z, EET_T_INT); + + return _d; +} + +static Eet_Data_Descriptor * +_key_down_up_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + Eet_Data_Descriptor *_d; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Key_Down_Up); + _d = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keyname", keyname, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "key", key, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "string", string, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "compose", compose, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keycode", keycode, EET_T_INT); + + return _d; +} + +static Eet_Data_Descriptor * +_multi_event_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + Eet_Data_Descriptor *_d; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Event); + _d = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "d", d, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "b", b, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "x", x, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "y", y, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rad", rad, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "radx", radx, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rady", rady, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "pres", pres, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "ang", ang, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fx", fx, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fy", fy, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "flags", flags, EET_T_INT); + + return _d; +} + +static Eet_Data_Descriptor * +_multi_move_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + Eet_Data_Descriptor *_d; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Move); + _d = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "d", d, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "x", x, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "y", y, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rad", rad, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "radx", radx, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rady", rady, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "pres", pres, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "ang", ang, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fx", fx, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fy", fy, EET_T_DOUBLE); + + return _d; +} + +static Eet_Data_Descriptor * +_efl_event_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + Eet_Data_Descriptor *_d; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Efl_Event); + _d = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "wdg_name", wdg_name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "event_name", event_name, EET_T_STRING); + + return _d; +} + +static Eet_Data_Descriptor * +_click_on_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + Eet_Data_Descriptor *_d; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Click_On); + _d = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Click_On, "wdg_name", wdg_name, EET_T_STRING); + + return _d; +} + +static Eet_Data_Descriptor * +_dummy_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + Eet_Data_Descriptor *_d; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, _Dummy); + _d = eet_data_descriptor_stream_new(&eddc); + + return _d; +} + +/* !!! SAME ORDER AS Exactness_Action_Type */ +static const char *_mapping[] = +{ + "", + "exactness_action_mouse_in", + "exactness_action_mouse_out", + "exactness_action_mouse_wheel", + "exactness_action_multi_down", + "exactness_action_multi_up", + "exactness_action_multi_move", + "exactness_action_key_down", + "exactness_action_key_up", + "exactness_action_take_shot", + "exactness_action_efl_event", + "exactness_action_click_on", + "exactness_action_stabilize" +}; + +const char * +_exactness_action_type_to_string_get(Exactness_Action_Type type) +{ + if (type <= EXACTNESS_ACTION_LAST) return _mapping[type]; + return NULL; +} + +static const char * +_variant_type_get(const void *data, Eina_Bool *unknow) +{ + const Exactness_Action *act = data; + + if (unknow) *unknow = EINA_FALSE; + if (act->type <= EXACTNESS_ACTION_LAST) return _mapping[act->type]; + + return NULL; +} + +static Eina_Bool +_variant_type_set(const char *type, + void *data, + Eina_Bool unknow EINA_UNUSED) +{ + int i; + Exactness_Action *act = data; + for (i = 0; i <= EXACTNESS_ACTION_LAST; i++) + { + if (!strcmp(_mapping[i], type)) act->type = i; + } + return EINA_TRUE; +} + +static Eet_Data_Descriptor * +_unit_desc_make(void) +{ + Eet_Data_Descriptor_Class eddc; + static Eet_Data_Descriptor *unit_d = NULL; + static Eet_Data_Descriptor *action_d = NULL, *action_variant_d = NULL; + static Eet_Data_Descriptor *objs_d = NULL; + static Eet_Data_Descriptor *obj_d = NULL; + if (!obj_d) + { + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object); + obj_d = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG); + EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG); + /* Evas stuff */ + EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT); + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects); + objs_d = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d); + } + if (!unit_d) + { + Eet_Data_Descriptor *code_d = NULL; + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Source_Code); + code_d = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "language", language, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "content", content, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "command", command, EET_T_STRING); + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action); + action_d = eet_data_descriptor_stream_new(&eddc); + + eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; + eddc.func.type_get = _variant_type_get; + eddc.func.type_set = _variant_type_set; + action_variant_d = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_MOUSE_IN], _dummy_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_MOUSE_OUT], _dummy_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_MOUSE_WHEEL], _mouse_wheel_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_MULTI_DOWN], _multi_event_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_MULTI_UP], _multi_event_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_MULTI_MOVE], _multi_move_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_KEY_DOWN], _key_down_up_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_CLICK_ON], _click_on_desc_make()); + EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, + _mapping[EXACTNESS_ACTION_STABILIZE], _dummy_desc_make()); + + EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d); + + /* Exactness_Unit */ + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit); + unit_d = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d); + EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d); + EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "codes", codes, code_d); + EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT); + } + + return unit_d; +} +/* END Event struct descriptors */ + +Exactness_Unit * +exactness_unit_file_read(const char *filename) +{ + int i; + Eina_List *itr, *itr2; + Exactness_Objects *e_objs; + Exactness_Object *e_obj, *e_parent; + Exactness_Unit *unit = NULL; + Eet_File *file; + eet_init(); + file = eet_open(filename, EET_FILE_MODE_READ); + if (!file) + { + fprintf(stderr, "Impossible to extract EET from %s\n", filename); + return NULL; + } + unit = eet_data_read(file, _unit_desc_make(), "cache"); + for (i = 0; i < unit->nb_shots; i++) + { + char entry[32]; + Exactness_Image *ex_img = malloc(sizeof(*ex_img)); + sprintf(entry, "images/%d", i + 1); + ex_img->pixels = eet_data_image_read(file, entry, + &ex_img->w, &ex_img->h, NULL, + NULL, NULL, NULL); + unit->imgs = eina_list_append(unit->imgs, ex_img); + } + EINA_LIST_FOREACH(unit->objs, itr, e_objs) + { + Eina_Hash *hash = eina_hash_pointer_new(NULL); + EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) + { + eina_hash_set(hash, &(e_obj->id), e_obj); + } + EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) + { + if (!e_obj->parent_id) + e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj); + else + { + e_parent = eina_hash_find(hash, &(e_obj->parent_id)); + if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj); + } + } + eina_hash_free(hash); + } + eet_close(file); + eet_shutdown(); + return unit; +} + +Eina_Bool +exactness_unit_file_write(Exactness_Unit *unit, const char *filename) +{ + Eina_List *itr; + Exactness_Image *ex_img; + Eet_File *file; + int i = 1; + eet_init(); + file = eet_open(filename, EET_FILE_MODE_WRITE); + eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE); + EINA_LIST_FOREACH(unit->imgs, itr, ex_img) + { + char entry[32]; + sprintf(entry, "images/%d", i++); + eet_data_image_write(file, entry, + ex_img->pixels, ex_img->w, ex_img->h, 0xFF, + 0, 100, EET_IMAGE_LOSSLESS); + } + eet_close(file); + eet_shutdown(); + return EINA_TRUE; +} + +Eina_Bool +exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO) +{ + unsigned int w, h; + int *pxs1, *pxs2, *pxsO = NULL; + unsigned int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0; + unsigned int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0; + unsigned int wO = MAX(w1, w2); + unsigned int hO = MAX(h1, h2); + Eina_Bool ret = EINA_FALSE; + if (imgO) *imgO = NULL; + if (!wO || !hO) return EINA_FALSE; + + pxs1 = img1 ? img1->pixels : NULL; + pxs2 = img2 ? img2->pixels : NULL; + if (imgO) pxsO = malloc(wO * hO * 4); + + for (w = 0; w < wO; w++) + { + for (h = 0; h < hO; h++) + { + Eina_Bool valid1 = img1 ? w < w1 && h < h1 : EINA_FALSE; + Eina_Bool valid2 = img2 ? w < w2 && h < h2 : EINA_FALSE; + int px1 = valid1 ? pxs1[h * w1 + w] : 0; + int px2 = valid2 ? pxs2[h * w2 + w] : 0; + int r1 = (px1 & 0x00FF0000) >> 16; + int r2 = (px2 & 0x00FF0000) >> 16; + int g1 = (px1 & 0x0000FF00) >> 8; + int g2 = (px2 & 0x0000FF00) >> 8; + int b1 = (px1 & 0x000000FF); + int b2 = (px2 & 0x000000FF); + int new_r, new_g, new_b; + if (valid1 || valid2) + { + if (px1 != px2) + { + new_r = 0xFF; + new_g = ((g1 + g2) >> 1) >> 2; + new_b = ((b1 + b2) >> 1) >> 2; + ret = EINA_TRUE; + } + else + { + new_r = (((r1 + r2) >> 1) >> 2) + 0xC0; + new_g = (((g1 + g2) >> 1) >> 2) + 0xC0; + new_b = (((b1 + b2) >> 1) >> 2) + 0xC0; + } + } + else + { + new_r = new_g = new_b = 0x0; + } + if (pxsO) pxsO[h * wO + w] = 0xFF000000 | new_r << 16 | new_g << 8 | new_b; + } + } + if (imgO) + { + Exactness_Image *imgR = calloc(1, sizeof(Exactness_Image)); + *imgO = imgR; + imgR->w = wO; + imgR->h = hO; + imgR->pixels = pxsO; + } + return ret; +} + +void exactness_image_free(Exactness_Image *img) +{ + if (!img) return; + free(img->pixels); + free(img); +} diff --git a/src/bin/exactness/common.h b/src/bin/exactness/common.h index b3bb2da8c1..b002a404c0 100644 --- a/src/bin/exactness/common.h +++ b/src/bin/exactness/common.h @@ -2,9 +2,9 @@ # include #endif +#include +#include #include -#include -#include typedef struct { @@ -97,7 +97,184 @@ foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \ _buf += __len; \ } +#define SHOT_DELIMITER '+' + +/** + * The type values for an Exactness action. + */ +typedef enum +{ + EXACTNESS_ACTION_UNKNOWN = 0, + EXACTNESS_ACTION_MOUSE_IN, + EXACTNESS_ACTION_MOUSE_OUT, + EXACTNESS_ACTION_MOUSE_WHEEL, + EXACTNESS_ACTION_MULTI_DOWN, + EXACTNESS_ACTION_MULTI_UP, + EXACTNESS_ACTION_MULTI_MOVE, + EXACTNESS_ACTION_KEY_DOWN, + EXACTNESS_ACTION_KEY_UP, + EXACTNESS_ACTION_TAKE_SHOT, + EXACTNESS_ACTION_EFL_EVENT, + EXACTNESS_ACTION_CLICK_ON, + EXACTNESS_ACTION_STABILIZE, + EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_STABILIZE + /* Add any supported actions here and update _LAST */ +} Exactness_Action_Type; + +/** + * The type for the Exactness Mouse Wheel action. + */ +typedef struct +{ + int direction; + int z; +} Exactness_Action_Mouse_Wheel; + +/** + * The type for the Exactness Key Down Up action. + */ +typedef struct +{ + const char *keyname; + const char *key; + const char *string; + const char *compose; + unsigned int keycode; +} Exactness_Action_Key_Down_Up; + +/** + * The type for the Exactness Multi Event action. + */ +typedef struct +{ + int d; + int b; /* In case of simple mouse down/up, corresponds to the button */ + int x; + int y; + double rad; + double radx; + double rady; + double pres; + double ang; + double fx; + double fy; + Evas_Button_Flags flags; +} Exactness_Action_Multi_Event; + +/** + * The type for the Exactness Multi Move action. + */ +typedef struct +{ + int d; + int x; + int y; + double rad; + double radx; + double rady; + double pres; + double ang; + double fx; + double fy; +} Exactness_Action_Multi_Move; + +/** + * The type for the Exactness EFL Event action. + */ +typedef struct +{ + char *wdg_name; /**< Name of the widget */ + char *event_name; /**< Name of the event */ +} Exactness_Action_Efl_Event; + +/** + * The type for the Exactness Click on (widget) action. + */ +typedef struct +{ + char *wdg_name; /**< Name of the widget */ +} Exactness_Action_Click_On; + +/** + * The type for the Exactness action. + */ +typedef struct +{ + Exactness_Action_Type type; /**< The action type */ + unsigned int n_evas; /**< The evas number on which the action has to be applied */ + unsigned int delay_ms; /**< The delay (in ms) to wait for this action */ + void *data; /**< The specific action data */ +} Exactness_Action; + +/** + * The type for the Exactness object. + */ +typedef struct +{ + long long id; /**< The Eo pointer */ + long long parent_id; /**< The Eo parent pointer */ + const char *kl_name; /**< The class name */ + + Eina_List *children; /* NOT EET */ + + /* Evas stuff */ + int x; /**< The X coordinate */ + int y; /**< The Y coordinate */ + int w; /**< The object width */ + int h; /**< The object height */ +} Exactness_Object; + +/** + * The type for the Exactness objects list. + */ +typedef struct +{ + Eina_List *objs; /**< List of all the objects */ + /* main_objs not in EET */ + Eina_List *main_objs; /**< List of the main objects */ +} Exactness_Objects; + +/** + * The type for the Exactness Image. + */ +typedef struct +{ + unsigned int w; /**< Width of the image */ + unsigned int h; /**< Height of the image */ + void *pixels; /**< Pixels of the image */ +} Exactness_Image; + +/** + * Description of the source code used to generate the tested application. + */ +typedef struct +{ + char *language; /**< String describing the language of the content e.g "C"...*/ + char *content; /**< Content used as source */ + char *command; /**< Command needed to generate the application from the content */ +} Exactness_Source_Code; + +/** + * An Exactness test unit, including the list of tested actions and produced images. + */ +typedef struct +{ + Eina_List *actions; /**< List of Exactness_Action */ + /* imgs not in EET */ + Eina_List *imgs; /**< List of Exactness_Image */ + Eina_List *objs; /**< List of Exactness_Objects */ + Eina_List *codes; /**< List of Exactness_Source_Code */ + const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */ + int nb_shots; /**< The number of shots present in the unit */ +} Exactness_Unit; + Evas *(*_evas_new)(void); +const char *_exactness_action_type_to_string_get(Exactness_Action_Type type); + +Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **diff_img); +Exactness_Unit *exactness_unit_file_read(const char *filename); +Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename); +void exactness_image_free(Exactness_Image *img); void ex_printf(int verbose, const char *fmt, ...); 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 @@ #include #include -#include "exactness_private.h" #include "common.h" #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 @@ #include #include -#include #include "common.h" 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 @@ #include #include #include -#include #include #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 @@ exactness_bin = executable('exactness', [ 'exactness.c', 'common.c', 'common.h' ], - dependencies: [ ecore, ecore_evas, ecore_file, elementary, exactness ], + dependencies: [ ecore, ecore_evas, ecore_file, elementary], c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', install: true, ) exactness_inject_bin = executable('exactness_inject', [ 'injector.c', 'common.c', 'common.h' ], - dependencies: [ elementary, exactness ], + dependencies: [ elementary ], c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', install: true, ) exactness_inspect_bin = executable('exactness_inspect', [ 'inspect.c', 'common.c', 'common.h' ], - dependencies: [ elementary, exactness ], + dependencies: [ elementary ], c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', install: true, ) @@ -32,14 +32,14 @@ edjs = custom_target('player_entry', exactness_play_bin = executable('exactness_play', [ 'player.c', 'common.c', 'common.h', edjs ], - dependencies: [ elementary, exactness ], + dependencies: [ elementary ], c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', install: true, ) exactness_record_bin = executable('exactness_record', [ 'recorder.c', 'common.c', 'common.h' ], - dependencies: [ elementary, exactness ], + dependencies: [ elementary ], c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', install: true, ) 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 @@ #include #include #include -#include -#include "exactness_private.h" #include "common.h" #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 @@ #include #include #include -#include -#include #include "common.h" #define STABILIZE_KEY_STR "F1" diff --git a/src/lib/exactness/Exactness.h b/src/lib/exactness/Exactness.h deleted file mode 100644 index ce80b984f2..0000000000 --- a/src/lib/exactness/Exactness.h +++ /dev/null @@ -1,267 +0,0 @@ -#ifndef _EXACTNESS_H -#define _EXACTNESS_H - -#include - -#ifdef EAPI -# undef EAPI -#endif - -#ifdef _WIN32 -# ifdef EXACTNESS_BUILD -# ifdef DLL_EXPORT -# define EAPI __declspec(dllexport) -# else -# define EAPI -# endif /* ! DLL_EXPORT */ -# else -# define EAPI __declspec(dllimport) -# endif /* ! EXACTNESS_BUILD */ -#else -# ifdef __GNUC__ -# if __GNUC__ >= 4 -# define EAPI __attribute__ ((visibility("default"))) -# else -# define EAPI -# endif -# else -# define EAPI -# endif -#endif /* ! _WIN32 */ - -/** - * @page exactness_main Exactness - * - * @date 2018 (created) - * - * This page describes the public structures and APIs available for Exactness. - * - * @addtogroup Exactness - * @{ - */ - -/** - * @enum Exactness_Action_Type - * The type values for an Exactness action. - */ -typedef enum -{ - EXACTNESS_ACTION_UNKNOWN = 0, - EXACTNESS_ACTION_MOUSE_IN, - EXACTNESS_ACTION_MOUSE_OUT, - EXACTNESS_ACTION_MOUSE_WHEEL, - EXACTNESS_ACTION_MULTI_DOWN, - EXACTNESS_ACTION_MULTI_UP, - EXACTNESS_ACTION_MULTI_MOVE, - EXACTNESS_ACTION_KEY_DOWN, - EXACTNESS_ACTION_KEY_UP, - EXACTNESS_ACTION_TAKE_SHOT, - EXACTNESS_ACTION_EFL_EVENT, - EXACTNESS_ACTION_CLICK_ON, - EXACTNESS_ACTION_STABILIZE, - EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_STABILIZE - /* Add any supported actions here and update _LAST */ -} Exactness_Action_Type; - -/** - * @struct Exactness_Action_Mouse_Wheel - * The type for the Exactness Mouse Wheel action. - */ -typedef struct -{ - int direction; - int z; -} Exactness_Action_Mouse_Wheel; - -/** - * @struct Exactness_Action_Key_Down_Up - * The type for the Exactness Key Down Up action. - */ -typedef struct -{ - const char *keyname; - const char *key; - const char *string; - const char *compose; - unsigned int keycode; -} Exactness_Action_Key_Down_Up; - -/** - * @struct Exactness_Action_Multi_Event - * The type for the Exactness Multi Event action. - */ -typedef struct -{ - int d; - int b; /* In case of simple mouse down/up, corresponds to the button */ - int x; - int y; - double rad; - double radx; - double rady; - double pres; - double ang; - double fx; - double fy; - Evas_Button_Flags flags; -} Exactness_Action_Multi_Event; - -/** - * @struct Exactness_Action_Multi_Move - * The type for the Exactness Multi Move action. - */ -typedef struct -{ - int d; - int x; - int y; - double rad; - double radx; - double rady; - double pres; - double ang; - double fx; - double fy; -} Exactness_Action_Multi_Move; - -/** - * @struct Exactness_Action_Efl_Event - * The type for the Exactness EFL Event action. - */ -typedef struct -{ - char *wdg_name; - char *event_name; -} Exactness_Action_Efl_Event; - -/** - * @struct Exactness_Action_Click_On - * The type for the Exactness Click on (widget) action. - */ -typedef struct -{ - char *wdg_name; -} Exactness_Action_Click_On; - -/** - * @struct Exactness_Action - * The type for the Exactness action. - */ -typedef struct -{ - Exactness_Action_Type type; /**< The action type */ - unsigned int n_evas; /**< The evas number on which the action has to be applied */ - unsigned int delay_ms; /**< The delay (in ms) to wait for this action */ - void *data; /**< The specific action data */ -} Exactness_Action; - -/** - * @struct Exactness_Object - * The type for the Exactness object. - */ -typedef struct -{ - long long id; /**< The Eo pointer */ - long long parent_id; /**< The Eo parent pointer */ - const char *kl_name; /**< The class name */ - - Eina_List *children; /* NOT EET */ - - /* Evas stuff */ - int x; /**< The X coordinate */ - int y; /**< The Y coordinate */ - int w; /**< The object width */ - int h; /**< The object height */ -} Exactness_Object; - -/** - * @struct Exactness_Objects - * The type for the Exactness objects list. - */ -typedef struct -{ - Eina_List *objs; /**< List of all the objects */ - /* main_objs not in EET */ - Eina_List *main_objs; /**< List of the main objects */ -} Exactness_Objects; - -/** - * @struct Exactness_Image - * The type for the Exactness Image. - */ -typedef struct -{ - unsigned int w; /**< Width of the image */ - unsigned int h; /**< Height of the image */ - void *pixels; /**< Pixels of the image */ -} Exactness_Image; - -/** - * @struct Exactness_Source_Code - * Description of the source code used to generate the tested application. - */ -typedef struct -{ - char *language; /**< String describing the language of the content e.g "C"...*/ - char *content; /**< Content used as source */ - char *command; /**< Command needed to generate the application from the content */ -} Exactness_Source_Code; - -/** - * @struct Exactness_Unit - * An Exactness test unit, including the list of tested actions and produced images. - */ -typedef struct -{ - Eina_List *actions; /**< List of Exactness_Action */ - /* imgs not in EET */ - Eina_List *imgs; /**< List of Exactness_Image */ - Eina_List *objs; /**< List of Exactness_Objects */ - Eina_List *codes; /**< List of Exactness_Source_Code */ - const char *fonts_path; /**< Path to the fonts to use, relative to the fonts dir given in parameter to the player/recorder */ - int nb_shots; /**< The number of shots present in the unit */ -} Exactness_Unit; - -/** - * @brief Read an unit from a given file - * - * @param filename Name of the file containing the unit - * - * @return the unit - */ -EAPI Exactness_Unit *exactness_unit_file_read(const char *filename); - -/** - * @brief Write an unit into the given file - * - * @param unit Unit to store - * @param filename Name of the file containing the unit - * - * @return EINA_TRUE on success, EINA_FALSE otherwise - */ -EAPI Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename); - -/** - * @brief Compare two images - * - * @param img1 first image - * @param img2 second image - * @param imgO pointer for the diff image. Can be NULL - * - * @return EINA_TRUE if the images are different, EINA_FALSE otherwise - */ -EAPI Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO); - -/** - * @brief Free the given image - * - * @param img the image - * - */ -EAPI void exactness_image_free(Exactness_Image *img); - -/** - * @} - */ - -#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 @@ -#ifndef _EXACTNESS_PRIVATE_H -#define _EXACTNESS_PRIVATE_H - -#include - -/* private header */ -EAPI const char *_exactness_action_type_to_string_get(Exactness_Action_Type type); - -#define SHOT_DELIMITER '+' -#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 @@ -exactness_pub_deps = [eina, evas] -exactness_deps = [] - -exactness_src = [ - 'Exactness.h', - 'exactness_private.h', - 'unit.c' -] - -exactness_lib = library('exactness', exactness_src, - dependencies: [ eina, eet, evas ], - install: true, - version : meson.project_version() -) - -exactness = declare_dependency( - include_directories: include_directories('.'), - link_with : exactness_lib, - dependencies: [ eina, evas, eet ], -) - -exactness_include_dir = join_paths(dir_data, 'exactness', 'include') - -exactness_header_src = [ -'Exactness.h', -] - -install_headers(exactness_header_src, - install_dir : dir_package_include -) 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 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "Exactness.h" -#include "exactness_private.h" - -typedef struct _Dummy -{ -} _Dummy; - -static Eet_Data_Descriptor * -_mouse_wheel_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - Eet_Data_Descriptor *_d; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Mouse_Wheel); - _d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "direction", direction, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Mouse_Wheel, "z", z, EET_T_INT); - - return _d; -} - -static Eet_Data_Descriptor * -_key_down_up_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - Eet_Data_Descriptor *_d; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Key_Down_Up); - _d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keyname", keyname, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "key", key, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "string", string, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "compose", compose, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Key_Down_Up, "keycode", keycode, EET_T_INT); - - return _d; -} - -static Eet_Data_Descriptor * -_multi_event_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - Eet_Data_Descriptor *_d; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Event); - _d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "d", d, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "b", b, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "x", x, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "y", y, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rad", rad, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "radx", radx, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "rady", rady, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "pres", pres, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "ang", ang, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fx", fx, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "fy", fy, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Event, "flags", flags, EET_T_INT); - - return _d; -} - -static Eet_Data_Descriptor * -_multi_move_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - Eet_Data_Descriptor *_d; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Multi_Move); - _d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "d", d, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "x", x, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "y", y, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rad", rad, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "radx", radx, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "rady", rady, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "pres", pres, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "ang", ang, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fx", fx, EET_T_DOUBLE); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Multi_Move, "fy", fy, EET_T_DOUBLE); - - return _d; -} - -static Eet_Data_Descriptor * -_efl_event_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - Eet_Data_Descriptor *_d; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Efl_Event); - _d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "wdg_name", wdg_name, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Efl_Event, "event_name", event_name, EET_T_STRING); - - return _d; -} - -static Eet_Data_Descriptor * -_click_on_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - Eet_Data_Descriptor *_d; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action_Click_On); - _d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_d, Exactness_Action_Click_On, "wdg_name", wdg_name, EET_T_STRING); - - return _d; -} - -static Eet_Data_Descriptor * -_dummy_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - Eet_Data_Descriptor *_d; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, _Dummy); - _d = eet_data_descriptor_stream_new(&eddc); - - return _d; -} - -/* !!! SAME ORDER AS Exactness_Action_Type */ -static const char *_mapping[] = -{ - "", - "exactness_action_mouse_in", - "exactness_action_mouse_out", - "exactness_action_mouse_wheel", - "exactness_action_multi_down", - "exactness_action_multi_up", - "exactness_action_multi_move", - "exactness_action_key_down", - "exactness_action_key_up", - "exactness_action_take_shot", - "exactness_action_efl_event", - "exactness_action_click_on", - "exactness_action_stabilize" -}; - -const char * -_exactness_action_type_to_string_get(Exactness_Action_Type type) -{ - if (type <= EXACTNESS_ACTION_LAST) return _mapping[type]; - return NULL; -} - -static const char * -_variant_type_get(const void *data, Eina_Bool *unknow) -{ - const Exactness_Action *act = data; - - if (unknow) *unknow = EINA_FALSE; - if (act->type <= EXACTNESS_ACTION_LAST) return _mapping[act->type]; - - return NULL; -} - -static Eina_Bool -_variant_type_set(const char *type, - void *data, - Eina_Bool unknow EINA_UNUSED) -{ - int i; - Exactness_Action *act = data; - for (i = 0; i <= EXACTNESS_ACTION_LAST; i++) - { - if (!strcmp(_mapping[i], type)) act->type = i; - } - return EINA_TRUE; -} - -static Eet_Data_Descriptor * -_unit_desc_make(void) -{ - Eet_Data_Descriptor_Class eddc; - static Eet_Data_Descriptor *unit_d = NULL; - static Eet_Data_Descriptor *action_d = NULL, *action_variant_d = NULL; - static Eet_Data_Descriptor *objs_d = NULL; - static Eet_Data_Descriptor *obj_d = NULL; - if (!obj_d) - { - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object); - obj_d = eet_data_descriptor_stream_new(&eddc); - EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG); - EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG); - /* Evas stuff */ - EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT); - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects); - objs_d = eet_data_descriptor_stream_new(&eddc); - EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d); - } - if (!unit_d) - { - Eet_Data_Descriptor *code_d = NULL; - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Source_Code); - code_d = eet_data_descriptor_stream_new(&eddc); - EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "language", language, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "content", content, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(code_d, Exactness_Source_Code, "command", command, EET_T_STRING); - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Action); - action_d = eet_data_descriptor_stream_new(&eddc); - - eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; - eddc.func.type_get = _variant_type_get; - eddc.func.type_set = _variant_type_set; - action_variant_d = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_MOUSE_IN], _dummy_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_MOUSE_OUT], _dummy_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_MOUSE_WHEEL], _mouse_wheel_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_MULTI_DOWN], _multi_event_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_MULTI_UP], _multi_event_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_MULTI_MOVE], _multi_move_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_KEY_DOWN], _key_down_up_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_KEY_UP], _key_down_up_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_CLICK_ON], _click_on_desc_make()); - EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, - _mapping[EXACTNESS_ACTION_STABILIZE], _dummy_desc_make()); - - EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d); - - /* Exactness_Unit */ - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit); - unit_d = eet_data_descriptor_stream_new(&eddc); - EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "actions", actions, action_d); - EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "objs", objs, objs_d); - EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit, "codes", codes, code_d); - EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "fonts_path", fonts_path, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit, "nb_shots", nb_shots, EET_T_UINT); - } - - return unit_d; -} -/* END Event struct descriptors */ - -EAPI Exactness_Unit * -exactness_unit_file_read(const char *filename) -{ - int i; - Eina_List *itr, *itr2; - Exactness_Objects *e_objs; - Exactness_Object *e_obj, *e_parent; - Exactness_Unit *unit = NULL; - Eet_File *file; - eet_init(); - file = eet_open(filename, EET_FILE_MODE_READ); - if (!file) - { - fprintf(stderr, "Impossible to extract EET from %s\n", filename); - return NULL; - } - unit = eet_data_read(file, _unit_desc_make(), "cache"); - for (i = 0; i < unit->nb_shots; i++) - { - char entry[32]; - Exactness_Image *ex_img = malloc(sizeof(*ex_img)); - sprintf(entry, "images/%d", i + 1); - ex_img->pixels = eet_data_image_read(file, entry, - &ex_img->w, &ex_img->h, NULL, - NULL, NULL, NULL); - unit->imgs = eina_list_append(unit->imgs, ex_img); - } - EINA_LIST_FOREACH(unit->objs, itr, e_objs) - { - Eina_Hash *hash = eina_hash_pointer_new(NULL); - EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) - { - eina_hash_set(hash, &(e_obj->id), e_obj); - } - EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj) - { - if (!e_obj->parent_id) - e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj); - else - { - e_parent = eina_hash_find(hash, &(e_obj->parent_id)); - if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj); - } - } - eina_hash_free(hash); - } - eet_close(file); - eet_shutdown(); - return unit; -} - -EAPI Eina_Bool -exactness_unit_file_write(Exactness_Unit *unit, const char *filename) -{ - Eina_List *itr; - Exactness_Image *ex_img; - Eet_File *file; - int i = 1; - eet_init(); - file = eet_open(filename, EET_FILE_MODE_WRITE); - eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE); - EINA_LIST_FOREACH(unit->imgs, itr, ex_img) - { - char entry[32]; - sprintf(entry, "images/%d", i++); - eet_data_image_write(file, entry, - ex_img->pixels, ex_img->w, ex_img->h, 0xFF, - 0, 100, EET_IMAGE_LOSSLESS); - } - eet_close(file); - eet_shutdown(); - return EINA_TRUE; -} - -EAPI Eina_Bool -exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **imgO) -{ - unsigned int w, h; - int *pxs1, *pxs2, *pxsO = NULL; - unsigned int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0; - unsigned int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0; - unsigned int wO = MAX(w1, w2); - unsigned int hO = MAX(h1, h2); - Eina_Bool ret = EINA_FALSE; - if (imgO) *imgO = NULL; - if (!wO || !hO) return EINA_FALSE; - - pxs1 = img1 ? img1->pixels : NULL; - pxs2 = img2 ? img2->pixels : NULL; - if (imgO) pxsO = malloc(wO * hO * 4); - - for (w = 0; w < wO; w++) - { - for (h = 0; h < hO; h++) - { - Eina_Bool valid1 = img1 ? w < w1 && h < h1 : EINA_FALSE; - Eina_Bool valid2 = img2 ? w < w2 && h < h2 : EINA_FALSE; - int px1 = valid1 ? pxs1[h * w1 + w] : 0; - int px2 = valid2 ? pxs2[h * w2 + w] : 0; - int r1 = (px1 & 0x00FF0000) >> 16; - int r2 = (px2 & 0x00FF0000) >> 16; - int g1 = (px1 & 0x0000FF00) >> 8; - int g2 = (px2 & 0x0000FF00) >> 8; - int b1 = (px1 & 0x000000FF); - int b2 = (px2 & 0x000000FF); - int new_r, new_g, new_b; - if (valid1 || valid2) - { - if (px1 != px2) - { - new_r = 0xFF; - new_g = ((g1 + g2) >> 1) >> 2; - new_b = ((b1 + b2) >> 1) >> 2; - ret = EINA_TRUE; - } - else - { - new_r = (((r1 + r2) >> 1) >> 2) + 0xC0; - new_g = (((g1 + g2) >> 1) >> 2) + 0xC0; - new_b = (((b1 + b2) >> 1) >> 2) + 0xC0; - } - } - else - { - new_r = new_g = new_b = 0x0; - } - if (pxsO) pxsO[h * wO + w] = 0xFF000000 | new_r << 16 | new_g << 8 | new_b; - } - } - if (imgO) - { - Exactness_Image *imgR = calloc(1, sizeof(Exactness_Image)); - *imgO = imgR; - imgR->w = wO; - imgR->h = hO; - imgR->pixels = pxsO; - } - return ret; -} - -EAPI void exactness_image_free(Exactness_Image *img) -{ - if (!img) return; - free(img->pixels); - free(img); -}