Exactness: add the stabilize action to the scenario

This action is needed when the time for the frames to be stable is not
known.
This commit is contained in:
Daniel Zaoui 2018-04-01 20:04:56 +03:00
parent ca185b925a
commit 8f9e553d20
5 changed files with 65 additions and 3 deletions

View File

@ -111,6 +111,7 @@ static int _key_down_op = EINA_DEBUG_OPCODE_INVALID;
static int _key_up_op = EINA_DEBUG_OPCODE_INVALID; static int _key_up_op = EINA_DEBUG_OPCODE_INVALID;
static int _take_shot_op = EINA_DEBUG_OPCODE_INVALID; static int _take_shot_op = EINA_DEBUG_OPCODE_INVALID;
static int _efl_event_op = EINA_DEBUG_OPCODE_INVALID; static int _efl_event_op = EINA_DEBUG_OPCODE_INVALID;
static int _stabilize_op = EINA_DEBUG_OPCODE_INVALID;
static int _finish_op = EINA_DEBUG_OPCODE_INVALID; static int _finish_op = EINA_DEBUG_OPCODE_INVALID;
static Eina_Bool _all_apps_get_cb(Eina_Debug_Session *, int , void *, int); static Eina_Bool _all_apps_get_cb(Eina_Debug_Session *, int , void *, int);
@ -128,6 +129,7 @@ EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
{"Exactness/Actions/Key Up", &_key_up_op, NULL}, {"Exactness/Actions/Key Up", &_key_up_op, NULL},
{"Exactness/Actions/Take Shot", &_take_shot_op, NULL}, {"Exactness/Actions/Take Shot", &_take_shot_op, NULL},
{"Exactness/Actions/EFL Event", &_efl_event_op, NULL}, {"Exactness/Actions/EFL Event", &_efl_event_op, NULL},
{"Exactness/Actions/Stabilize", &_stabilize_op, NULL},
{"Exactness/Actions/Finish", &_finish_op, NULL}, {"Exactness/Actions/Finish", &_finish_op, NULL},
{NULL, NULL, NULL} {NULL, NULL, NULL}
); );
@ -265,6 +267,12 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
eina_debug_session_send(_session, _cid, _efl_event_op, buf, len); eina_debug_session_send(_session, _cid, _efl_event_op, buf, len);
break; break;
} }
case EXACTNESS_ACTION_STABILIZE:
{
_printf(2, "%s stabilize\n", __func__);
eina_debug_session_send(_session, _cid, _stabilize_op, NULL, 0);
break;
}
default: /* All non-input events are not handeled */ default: /* All non-input events are not handeled */
break; break;
} }

View File

@ -63,6 +63,7 @@ _action_name_get(Exactness_Action *act)
case EXACTNESS_ACTION_KEY_UP: return "Key Up"; case EXACTNESS_ACTION_KEY_UP: return "Key Up";
case EXACTNESS_ACTION_TAKE_SHOT: return "Take shot"; case EXACTNESS_ACTION_TAKE_SHOT: return "Take shot";
case EXACTNESS_ACTION_EFL_EVENT: return "EFL Event"; case EXACTNESS_ACTION_EFL_EVENT: return "EFL Event";
case EXACTNESS_ACTION_STABILIZE: return "Stabilize";
default: return NULL; default: return NULL;
} }
} }

View File

@ -125,6 +125,10 @@ static Eina_List *_cur_event_list = NULL;
static int _cur_shot_id = 0; static int _cur_shot_id = 0;
static Eina_Bool _scan_objects = EINA_FALSE; static Eina_Bool _scan_objects = EINA_FALSE;
static Eina_Bool _stabilization_needed = EINA_FALSE;
static Ecore_Timer *_stabilization_timer = NULL;
static Eina_Bool _stabilization_timer_cb(void *);
static void static void
_printf(int verbose, const char *fmt, ...) _printf(int verbose, const char *fmt, ...)
{ {
@ -426,6 +430,14 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
if (!found) fprintf(stderr, "Failed finding %s.\n", t->wdg_name); if (!found) fprintf(stderr, "Failed finding %s.\n", t->wdg_name);
break; break;
} }
case EXACTNESS_ACTION_STABILIZE:
{
_printf(2, "%s stabilize\n", __func__);
if (rect) evas_object_color_set(rect, 255, 165, 0, 255);
_stabilization_needed = EINA_TRUE;
_stabilization_timer = ecore_timer_add(1.0, _stabilization_timer_cb, NULL);
break;
}
default: /* All non-input events are not handeled */ default: /* All non-input events are not handeled */
break; break;
} }
@ -438,19 +450,47 @@ _feed_event_timer_cb(void *data EINA_UNUSED)
_feed_event(act->type, act->n_evas, act->data); _feed_event(act->type, act->n_evas, act->data);
_cur_event_list = eina_list_next(_cur_event_list); _cur_event_list = eina_list_next(_cur_event_list);
if (!_cur_event_list) if (!_cur_event_list)
{ /* Finished reading all events */ { /* Finished reading all events */
ecore_main_loop_quit(); ecore_main_loop_quit();
} }
else else
{ {
if (act->type != EXACTNESS_ACTION_STABILIZE)
{
act = eina_list_data_get(_cur_event_list);
_printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0);
ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
}
}
return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool
_stabilization_timer_cb(void *data EINA_UNUSED)
{
if (!_stabilization_needed) return ECORE_CALLBACK_CANCEL;
_stabilization_needed = EINA_FALSE;
if (_src_type != FTYPE_REMOTE)
{
Exactness_Action *act = eina_list_data_get(_cur_event_list);
_printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0); _printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0);
ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL); ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
} }
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
static void
_evas_render_post_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
if (_stabilization_needed)
{
_printf(2, "Not stable yet...\n");
ecore_timer_del(_stabilization_timer);
_stabilization_timer = ecore_timer_add(1.0, _stabilization_timer_cb, NULL);
}
}
static void static void
_main_loop_mouse_in_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED) _main_loop_mouse_in_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED)
{ {
@ -585,6 +625,12 @@ _main_loop_efl_event_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_
_feed_event(EXACTNESS_ACTION_EFL_EVENT, 0, &t); _feed_event(EXACTNESS_ACTION_EFL_EVENT, 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 static void
_main_loop_finish_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED) _main_loop_finish_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer EINA_UNUSED, int size EINA_UNUSED)
{ {
@ -601,6 +647,7 @@ WRAPPER_TO_XFER_MAIN_LOOP(_key_down_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_key_up_cb) WRAPPER_TO_XFER_MAIN_LOOP(_key_up_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_take_shot_cb) WRAPPER_TO_XFER_MAIN_LOOP(_take_shot_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_efl_event_cb) WRAPPER_TO_XFER_MAIN_LOOP(_efl_event_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_stabilize_cb)
WRAPPER_TO_XFER_MAIN_LOOP(_finish_cb) WRAPPER_TO_XFER_MAIN_LOOP(_finish_cb)
EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops, EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
@ -614,6 +661,7 @@ EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
{"Exactness/Actions/Key Up", NULL, &_key_up_cb}, {"Exactness/Actions/Key Up", NULL, &_key_up_cb},
{"Exactness/Actions/Take Shot", NULL, &_take_shot_cb}, {"Exactness/Actions/Take Shot", NULL, &_take_shot_cb},
{"Exactness/Actions/EFL Event", NULL, &_efl_event_cb}, {"Exactness/Actions/EFL Event", NULL, &_efl_event_cb},
{"Exactness/Actions/Stabilize", NULL, &_stabilize_cb},
{"Exactness/Actions/Finish", NULL, &_finish_cb}, {"Exactness/Actions/Finish", NULL, &_finish_cb},
{NULL, NULL, NULL} {NULL, NULL, NULL}
); );
@ -771,6 +819,7 @@ _my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
{ {
_printf(1, "New Evas\n"); _printf(1, "New Evas\n");
_evas_list = eina_list_append(_evas_list, e); _evas_list = eina_list_append(_evas_list, e);
efl_event_callback_add(e, EFL_CANVAS_SCENE_EVENT_RENDER_POST, _evas_render_post_cb, NULL);
} }
return e; return e;
} }

View File

@ -57,7 +57,8 @@ typedef enum
EXACTNESS_ACTION_KEY_UP, EXACTNESS_ACTION_KEY_UP,
EXACTNESS_ACTION_TAKE_SHOT, EXACTNESS_ACTION_TAKE_SHOT,
EXACTNESS_ACTION_EFL_EVENT, EXACTNESS_ACTION_EFL_EVENT,
EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_EFL_EVENT EXACTNESS_ACTION_STABILIZE,
EXACTNESS_ACTION_LAST = EXACTNESS_ACTION_STABILIZE
/* Add any supported actions here and update _LAST */ /* Add any supported actions here and update _LAST */
} Exactness_Action_Type; } Exactness_Action_Type;

View File

@ -134,7 +134,8 @@ static const char *_mapping[] =
"exactness_action_key_down", "exactness_action_key_down",
"exactness_action_key_up", "exactness_action_key_up",
"exactness_action_take_shot", "exactness_action_take_shot",
"exactness_action_efl_event" "exactness_action_efl_event",
"exactness_action_stabilize"
}; };
const char * const char *
@ -224,6 +225,8 @@ _unit_desc_make(void)
_mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make()); _mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make());
EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d, EET_DATA_DESCRIPTOR_ADD_MAPPING(action_variant_d,
_mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_desc_make()); _mapping[EXACTNESS_ACTION_EFL_EVENT], _efl_event_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, "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_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT);