Compare commits

...

3 Commits

Author SHA1 Message Date
Stefan Schmidt 2c75dd609a TESTING 2020-06-08 14:13:00 +02:00
Stefan Schmidt 7bdad2c85a exactness: remove deprecated FTYPE_DIR and re-factor code
We no longer support scenarios in the old rec/dir format. Remove all the
ifdef handling for it and re-factor the code to take EXU as default.
2020-06-08 14:10:23 +02:00
Stefan Schmidt 2a3554f885 exactness: remove remote and unknow FTYPE's
The debug mode has not been used for a long time and we do not even know
if it still works. Simplify the player code by dropping it.
2020-06-08 14:03:17 +02:00
2 changed files with 22 additions and 340 deletions

View File

@ -76,7 +76,6 @@ jobs:
if: type = cron
env: DISTRO=Fedora32 CI_BUILD_TYPE=asan
- os: linux
if: type = cron
env: DISTRO=Fedora32-exactness CI_BUILD_TYPE=exactness
- os: linux
if: type = cron
@ -144,14 +143,3 @@ before_cache:
mv $HOME/Library/Caches/Homebrew $HOME/cachedir/Homebrew
fi
notifications:
irc:
channels:
- "chat.freenode.net#edevelop"
on_success: change
on_failure: always
template:
- "TravisCI build %{build_number} in branch %{branch}: %{result} - %{message} (%{elapsed_time})"
- "Commit: %{commit_subject} (%{commit}) from %{author}"
- "Change view : %{compare_url}"
- "Build details : %{build_url}"

View File

@ -43,20 +43,9 @@
static int _log_domain = -1;
typedef enum
{
FTYPE_UNKNOWN,
FTYPE_DIR,
FTYPE_REC = FTYPE_DIR,
FTYPE_EXU,
FTYPE_REMOTE
} File_Type;
static File_Type _dest_type = FTYPE_UNKNOWN;
static Eina_Stringshare *_dest = NULL;
static Exactness_Unit *_dest_unit = NULL;
static File_Type _src_type = FTYPE_UNKNOWN;
static Eina_Stringshare *_src_filename = NULL;
static Exactness_Unit *_src_unit = NULL;
@ -71,10 +60,6 @@ static int _cur_shot_id = 0;
static Eina_Bool _shot_needed = EINA_FALSE;
static Eina_Bool _scan_objects = EINA_FALSE, _disable_shots = EINA_FALSE, _stabilize_shots = EINA_FALSE;
static Eina_Debug_Session *_last_debug_session = NULL;
static int _last_debug_src_cid = 0;
static int _take_shot_op = EINA_DEBUG_OPCODE_INVALID;
static Eina_Bool _stabilization_timer_cb(void *);
static double _speed = 1.0;
@ -140,36 +125,10 @@ _evas_render_post_cb(void *data EINA_UNUSED, const Efl_Event *event)
if (e_data)
{
if (_dest_type == FTYPE_DIR)
{
char *filename = e_data;
Eo *o = evas_object_image_add(event->object);
evas_object_image_size_set(o, ex_shot->w, ex_shot->h);
evas_object_image_data_set(o, ex_shot->pixels);
INF("Shot taken (%s).\n", filename);
if (!evas_object_image_save(o, filename, NULL, NULL))
{
printf("Cannot save widget to <%s>\n", filename);
}
free(filename);
}
else if (_dest_type == FTYPE_EXU)
{
Exactness_Image *ex_img = e_data;
memcpy(ex_img, ex_shot, sizeof(Exactness_Image));
ex_shot->pixels = NULL;
INF("Shot taken (in %s).\n", _dest);
}
else if (_dest_type == FTYPE_REMOTE)
{
int len = sizeof(int) + sizeof(int) + ex_shot->w * ex_shot->h * 4;
char *buf = alloca(len);
char *tmp = buf;
STORE_INT(tmp, ex_shot->w);
STORE_INT(tmp, ex_shot->h);
memcpy(tmp, ex_shot->pixels, ex_shot->w * ex_shot->h * 4);
eina_debug_session_send(_last_debug_session, _last_debug_src_cid, _take_shot_op, buf, len);
}
Exactness_Image *ex_img = e_data;
memcpy(ex_img, ex_shot, sizeof(Exactness_Image));
ex_shot->pixels = NULL;
INF("Shot taken (in %s).\n", _dest);
}
exactness_image_free(ex_shot);
efl_key_data_set(event->object, "_shot", NULL);
@ -190,30 +149,10 @@ _shot_do(Evas *e)
if (!_disable_shots)
{
if (_dest_type == FTYPE_DIR)
{
int dir_name_len;
char *filename;
dir_name_len = strlen(_dest) + 1; /* includes space of a '/' */
filename = malloc(strlen(_test_name) + strlen(IMAGE_FILENAME_EXT) +
dir_name_len + 8); /* also space for serial */
sprintf(filename, "%s/%s%c%03d%s", _dest, _test_name,
SHOT_DELIMITER, _cur_shot_id, IMAGE_FILENAME_EXT);
e_data = filename;
}
else if (_dest_type == FTYPE_EXU)
{
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
_dest_unit->imgs = eina_list_append(_dest_unit->imgs, ex_img);
_dest_unit->nb_shots++;
e_data = ex_img;
}
else if (_dest_type == FTYPE_REMOTE)
{
e_data = e;
}
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
_dest_unit->imgs = eina_list_append(_dest_unit->imgs, ex_img);
_dest_unit->nb_shots++;
e_data = ex_img;
}
efl_key_data_set(e, "_shot", e_data);
_shot_needed = EINA_TRUE;
@ -222,7 +161,7 @@ _shot_do(Evas *e)
ev.object = e;
_evas_render_post_cb(NULL, &ev);
if (_scan_objects && _dest_type == FTYPE_EXU)
if (_scan_objects)
{
Eina_Iterator *iter;
Eo *obj;
@ -396,7 +335,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
DBG("%s take shot n_evas=<%d>\n", __func__, n_evas);
if (rect) evas_object_color_set(rect, 0, 0, 255, 255);
_cur_shot_id++;
if (_dest_type != FTYPE_UNKNOWN && e) _shot_do(e);
if (e) _shot_do(e);
break;
}
case EXACTNESS_ACTION_EFL_EVENT:
@ -549,7 +488,7 @@ _stabilization_timer_cb(void *data EINA_UNUSED)
if (!need_more)
{
_playing_status = EINA_FALSE;
if (_src_type != FTYPE_REMOTE && !_pause_request)
if (!_pause_request)
{
Exactness_Action *act = eina_list_data_get(_cur_event_list);
if (act)
@ -565,194 +504,6 @@ _stabilization_timer_cb(void *data EINA_UNUSED)
return ECORE_CALLBACK_RENEW;
}
static void
_main_loop_mouse_in_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
int n_evas = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_MOUSE_IN, n_evas, NULL);
}
static void
_main_loop_mouse_out_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
int n_evas = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_MOUSE_OUT, n_evas, NULL);
}
static void
_main_loop_mouse_wheel_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Mouse_Wheel t;
int n_evas = EXTRACT_INT(buf);
t.direction = EXTRACT_INT(buf);
t.z = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_MOUSE_WHEEL, n_evas, &t);
}
static void
_main_loop_multi_down_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Multi_Event t;
int n_evas = EXTRACT_INT(buf);
t.d = EXTRACT_INT(buf);
t.b = EXTRACT_INT(buf);
t.x = EXTRACT_INT(buf);
t.y = EXTRACT_INT(buf);
t.rad = EXTRACT_DOUBLE(buf);
t.radx = EXTRACT_DOUBLE(buf);
t.rady = EXTRACT_DOUBLE(buf);
t.pres = EXTRACT_DOUBLE(buf);
t.ang = EXTRACT_DOUBLE(buf);
t.fx = EXTRACT_DOUBLE(buf);
t.fy = EXTRACT_DOUBLE(buf);
t.flags = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_MULTI_DOWN, n_evas, &t);
}
static void
_main_loop_multi_up_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Multi_Event t;
int n_evas = EXTRACT_INT(buf);
t.d = EXTRACT_INT(buf);
t.b = EXTRACT_INT(buf);
t.x = EXTRACT_INT(buf);
t.y = EXTRACT_INT(buf);
t.rad = EXTRACT_DOUBLE(buf);
t.radx = EXTRACT_DOUBLE(buf);
t.rady = EXTRACT_DOUBLE(buf);
t.pres = EXTRACT_DOUBLE(buf);
t.ang = EXTRACT_DOUBLE(buf);
t.fx = EXTRACT_DOUBLE(buf);
t.fy = EXTRACT_DOUBLE(buf);
t.flags = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_MULTI_UP, n_evas, &t);
}
static void
_main_loop_multi_move_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Multi_Move t;
int n_evas = EXTRACT_INT(buf);
t.d = EXTRACT_INT(buf);
t.x = EXTRACT_INT(buf);
t.y = EXTRACT_INT(buf);
t.rad = EXTRACT_DOUBLE(buf);
t.radx = EXTRACT_DOUBLE(buf);
t.rady = EXTRACT_DOUBLE(buf);
t.pres = EXTRACT_DOUBLE(buf);
t.ang = EXTRACT_DOUBLE(buf);
t.fx = EXTRACT_DOUBLE(buf);
t.fy = EXTRACT_DOUBLE(buf);
_feed_event(EXACTNESS_ACTION_MULTI_MOVE, n_evas, &t);
}
static void
_main_loop_key_down_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Key_Down_Up t;
int n_evas = EXTRACT_INT(buf);
t.keyname = EXTRACT_STRING(buf);
t.key = EXTRACT_STRING(buf);
t.string = EXTRACT_STRING(buf);
t.compose = EXTRACT_STRING(buf);
t.keycode = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_KEY_DOWN, n_evas, &t);
}
static void
_main_loop_key_up_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Key_Down_Up t;
int n_evas = EXTRACT_INT(buf);
t.keyname = EXTRACT_STRING(buf);
t.key = EXTRACT_STRING(buf);
t.string = EXTRACT_STRING(buf);
t.compose = EXTRACT_STRING(buf);
t.keycode = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_KEY_UP, n_evas, &t);
}
static void
_main_loop_take_shot_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
int n_evas = EXTRACT_INT(buf);
_feed_event(EXACTNESS_ACTION_TAKE_SHOT, n_evas, NULL);
_last_debug_session = session;
_last_debug_src_cid = srcid;
}
static void
_main_loop_efl_event_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Efl_Event t;
t.wdg_name = EXTRACT_STRING(buf);
t.event_name = EXTRACT_STRING(buf);
_feed_event(EXACTNESS_ACTION_EFL_EVENT, 0, &t);
}
static void
_main_loop_click_on_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{
char *buf = buffer;
Exactness_Action_Click_On t;
t.wdg_name = EXTRACT_STRING(buf);
_feed_event(EXACTNESS_ACTION_CLICK_ON, 0, &t);
}
static void
_main_loop_stabilize_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED)
{
_feed_event(EXACTNESS_ACTION_STABILIZE, 0, NULL);
}
static void
_main_loop_finish_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED)
{
ecore_main_loop_quit();
}
WRAPPER_TO_XFER_MAIN_LOOP(_mouse_in_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_mouse_out_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_mouse_wheel_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_multi_down_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_multi_up_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_multi_move_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_key_down_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_key_up_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_take_shot_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_efl_event_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_click_on_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_stabilize_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_finish_cb)
EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
{"Exactness/Actions/Mouse In", NULL, &_mouse_in_cb},
{"Exactness/Actions/Mouse Out", NULL, &_mouse_out_cb},
{"Exactness/Actions/Mouse Wheel", NULL, &_mouse_wheel_cb},
{"Exactness/Actions/Multi Down", NULL, &_multi_down_cb},
{"Exactness/Actions/Multi Up", NULL, &_multi_up_cb},
{"Exactness/Actions/Multi Move", NULL, &_multi_move_cb},
{"Exactness/Actions/Key Down", NULL, &_key_down_cb},
{"Exactness/Actions/Key Up", NULL, &_key_up_cb},
{"Exactness/Actions/Take Shot", &_take_shot_op, &_take_shot_cb},
{"Exactness/Actions/EFL Event", NULL, &_efl_event_cb},
{"Exactness/Actions/Click On", NULL, &_click_on_cb},
{"Exactness/Actions/Stabilize", NULL, &_stabilize_cb},
{"Exactness/Actions/Finish", NULL, &_finish_cb},
{NULL, NULL, NULL}
);
static Eina_Bool
_src_feed(void *data EINA_UNUSED)
{
@ -775,16 +526,14 @@ _src_feed(void *data EINA_UNUSED)
static Eina_Bool
_src_open()
{
if (_src_type != FTYPE_REMOTE)
if (1)
{
Eina_List *itr, *itr2;
Exactness_Action *act;
DBG("<%s> Source file is <%s>\n", __func__, _src_filename);
if (_src_type == FTYPE_EXU)
{
_src_unit = exactness_unit_file_read(_src_filename);
_ready_to_write = EINA_TRUE;
}
_src_unit = exactness_unit_file_read(_src_filename);
_ready_to_write = EINA_TRUE;
if (!_src_unit) return EINA_FALSE;
if (_stabilize_shots)
{
@ -807,31 +556,9 @@ _src_open()
act->delay_ms /= _speed;
}
}
else
{
eina_debug_opcodes_register(NULL, _debug_ops(), NULL, NULL);
}
return EINA_TRUE;
}
static void
_old_shots_rm_cb(const char *name, const char *path, void *data)
{
const char *prefix = data;
unsigned int len = strlen(prefix);
if (!strncmp(name, prefix, len) && (strlen(name) > len) && (name[len] == SHOT_DELIMITER))
{
unsigned int length = strlen(path) + strlen(name) + 2;
char *buf = alloca(length);
snprintf(buf, length, "%s/%s", path, name);
if (unlink(buf))
{
printf("Failed deleting '%s/%s': ", path, name);
perror("");
}
}
}
static void
_evas_del_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
@ -881,14 +608,13 @@ _my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
}
static Eina_Bool
_setup_dest_type(const char *dest, Eina_Bool external_injection)
_setup_dest_type(const char *dest)
{
if (dest)
{
_dest = eina_stringshare_add(dest);
if (!strcmp(_dest + strlen(_dest) - 4,".exu"))
{
_dest_type = FTYPE_EXU;
char *path = ecore_file_dir_get(dest);
if (!ecore_file_mkpath(path))
@ -899,20 +625,6 @@ _setup_dest_type(const char *dest, Eina_Bool external_injection)
}
free(path);
}
else
{
_dest_type = FTYPE_DIR;
if (!ecore_file_mkpath(_dest))
{
fprintf(stderr, "Directory %s cannot be created\n", _dest);
return EINA_FALSE;
}
}
}
if (external_injection)
{
_src_type = FTYPE_REMOTE;
if (_dest_type == FTYPE_UNKNOWN) _dest_type = FTYPE_REMOTE;
}
return EINA_TRUE;
}
@ -925,12 +637,7 @@ _setup_names(const char *src)
_src_filename = eina_stringshare_add(src);
if (!strcmp(_src_filename + strlen(_src_filename) - 4,".exu"))
{
_src_type = FTYPE_EXU;
if (_dest_type == FTYPE_UNKNOWN)
{
_dest_type = FTYPE_EXU;
_dest = "./output.exu";
}
_dest = "./output.exu";
}
char *slash = strrchr(_src_filename, '/');
if (slash) _test_name = strdup(slash + 1);
@ -943,17 +650,10 @@ _setup_names(const char *src)
static void
_setup_dest_unit(void)
{
if (_dest_type == FTYPE_EXU) _dest_unit = calloc(1, sizeof(*_dest_unit));
_dest_unit = calloc(1, sizeof(*_dest_unit));
}
static void
_remove_old_shots(void)
{
if (_dest_type == FTYPE_DIR && _test_name)
eina_file_dir_list(_dest, 0, _old_shots_rm_cb, (void *)_test_name);
}
static Eina_Bool
_setup_font_settings(const char *fonts_dir)
{
@ -1008,8 +708,7 @@ static void
_setup_ee_creation(void)
{
ecore_evas_callback_new_set(_my_evas_new);
if (_src_type != FTYPE_REMOTE)
ecore_idler_add(_src_feed, NULL);
ecore_idler_add(_src_feed, NULL);
}
static void
@ -1020,11 +719,8 @@ _write_unit_file(void)
Exactness_Unit *tmp = NULL;
EINA_SAFETY_ON_NULL_RETURN(_src_unit);
if (_src_type == FTYPE_EXU)
{
tmp = exactness_unit_file_read(_src_filename);
_dest_unit->actions = tmp->actions;
}
tmp = exactness_unit_file_read(_src_filename);
_dest_unit->actions = tmp->actions;
exactness_unit_file_write(_dest_unit, _dest);
}
}
@ -1054,7 +750,6 @@ eina_init(void)
if (original_return == 1)
{
const char *dest = getenv("EXACTNESS_DEST");
const char *external_injection = getenv("EXACTNESS_EXTERNAL_INJECTION");
const char *src = getenv("EXACTNESS_SRC");
const char *fonts_dir = getenv("EXACTNESS_FONTS_DIR");
const char *speed = getenv("EXACTNESS_SPEED");
@ -1067,11 +762,10 @@ eina_init(void)
_speed = atof(speed);
_log_domain = eina_log_domain_register("exactness_player", NULL);
if (!_setup_dest_type(dest, !!external_injection))
if (!_setup_dest_type(dest))
return 0;
_setup_names(src);
_setup_dest_unit();
_remove_old_shots();
if (!_src_open())
{