From a576265f0a8ce8ed76c29ab6aa5d81dbbad02d27 Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Sun, 21 Oct 2018 00:14:55 +0300 Subject: [PATCH] Player: add an option to wait for the frames to be stable before shots It can happen that some tests take more time on weaker machines, leading to wrong screenshots. By using this option, the player will wait before each shot for the application to be stabilized (no mode frames changes) and then take the shot. --- src/bin/exactness.c | 7 +++++-- src/bin/player.c | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/bin/exactness.c b/src/bin/exactness.c index 2c3455c..d14a532 100644 --- a/src/bin/exactness.c +++ b/src/bin/exactness.c @@ -38,7 +38,7 @@ static Eina_List *_base_dirs = NULL; static char *_dest_dir; static char *_wrap_command = NULL, *_fonts_dir = NULL; static int _verbose = 0; -static Eina_Bool _scan_objs = EINA_FALSE, _disable_screenshots = EINA_FALSE; +static Eina_Bool _scan_objs = EINA_FALSE, _disable_screenshots = EINA_FALSE, _stabilize_shots = EINA_FALSE; static Run_Mode _mode; static List_Entry *_next_test_to_run = NULL; @@ -228,13 +228,14 @@ _run_command_prepare(const List_Entry *ent, char *buf) ok: sbuf = eina_strbuf_new(); eina_strbuf_append_printf(sbuf, - "%s %s exactness_play %s %s%s %s%.*s %s%s-t '%s' ", + "%s %s exactness_play %s %s%s %s%.*s %s%s%s-t '%s' ", CONFIG, _wrap_command ? _wrap_command : "", _mode == RUN_SIMULATION ? "-s" : "", _fonts_dir ? "-f " : "", _fonts_dir ? _fonts_dir : "", _verbose ? "-" : "", _verbose, "vvvvvvvvvv", _scan_objs ? "--scan-objects " : "", _disable_screenshots ? "--disable-screenshots " : "", + _stabilize_shots ? "--stabilize-shots " : "", scn_path ); if (is_exu) @@ -473,6 +474,7 @@ static const Ecore_Getopt optdesc = { ECORE_GETOPT_STORE_TRUE(0, "scan-objects", "Extract information of all the objects at every shot."), ECORE_GETOPT_STORE_TRUE(0, "disable-screenshots", "Disable screenshots."), ECORE_GETOPT_STORE_STR('f', "fonts-dir", "Specify a directory of the fonts that should be used."), + ECORE_GETOPT_STORE_TRUE(0, "stabilize-shots", "Wait for the frames to be stable before taking the shots."), ECORE_GETOPT_COUNT('v', "verbose", "Turn verbose messages on."), ECORE_GETOPT_LICENSE('L', "license"), @@ -506,6 +508,7 @@ main(int argc, char *argv[]) ECORE_GETOPT_VALUE_BOOL(scan_objs), ECORE_GETOPT_VALUE_BOOL(_disable_screenshots), ECORE_GETOPT_VALUE_STR(_fonts_dir), + ECORE_GETOPT_VALUE_BOOL(_stabilize_shots), ECORE_GETOPT_VALUE_INT(_verbose), ECORE_GETOPT_VALUE_BOOL(want_quit), diff --git a/src/bin/player.c b/src/bin/player.c index c1fc6ed..e69a713 100644 --- a/src/bin/player.c +++ b/src/bin/player.c @@ -136,7 +136,7 @@ static Eina_List *_cur_event_list = NULL; static int _cur_shot_id = 0; static Eina_Bool _shot_needed = EINA_FALSE; -static Eina_Bool _scan_objects = EINA_FALSE, _disable_shots = 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; @@ -567,11 +567,11 @@ _stabilization_timer_cb(void *data EINA_UNUSED) static int need_more = STAB_MAX; EINA_LIST_FOREACH(_evas_list, itr, e) { - Exactness_Image *last_img = efl_key_data_get(e, "_last_shot"); + Exactness_Image *last_img = efl_key_data_get(e, "_last_stab_shot"); Exactness_Image *cur_img = _snapshot_shot_get(e); if (!last_img || exactness_image_compare(last_img, cur_img, NULL)) need_more = STAB_MAX; exactness_image_free(last_img); - efl_key_data_set(e, "_last_shot", cur_img); + efl_key_data_set(e, "_last_stab_shot", cur_img); } EINA_LIST_FOREACH(_evas_list, itr, e) { @@ -814,6 +814,18 @@ _src_open() if (act->type == EXACTNESS_ACTION_TAKE_SHOT) break; _src_unit->actions = eina_list_remove(_src_unit->actions, act); } + if (_stabilize_shots) + { + EINA_LIST_FOREACH_SAFE(_src_unit->actions, itr, itr2, act) + { + if (act->type == EXACTNESS_ACTION_TAKE_SHOT) + { + Exactness_Action *act2 = calloc(1, sizeof(*act2)); + act2->type = EXACTNESS_ACTION_STABILIZE; + _src_unit->actions = eina_list_prepend_relative(_src_unit->actions, act2, act); + } + } + } } else { @@ -965,6 +977,7 @@ static const Ecore_Getopt optdesc = { ECORE_GETOPT_STORE_TRUE(0, "external-injection", "Expect events injection via Eina debug channel."), ECORE_GETOPT_STORE_TRUE(0, "disable-screenshots", "Disable screenshots."), ECORE_GETOPT_STORE_STR('f', "fonts-dir", "Specify a directory of the fonts that should be used."), + ECORE_GETOPT_STORE_TRUE(0, "stabilize-shots", "Wait for the frames to be stable before taking the shots."), ECORE_GETOPT_COUNT('v', "verbose", "Turn verbose messages on."), ECORE_GETOPT_LICENSE('L', "license"), @@ -992,6 +1005,7 @@ int main(int argc, char **argv) ECORE_GETOPT_VALUE_BOOL(external_injection), ECORE_GETOPT_VALUE_BOOL(_disable_shots), ECORE_GETOPT_VALUE_STR(fonts_dir), + ECORE_GETOPT_VALUE_BOOL(_stabilize_shots), ECORE_GETOPT_VALUE_INT(_verbose), ECORE_GETOPT_VALUE_BOOL(want_quit),