Player: support screenshots disabling

master
Daniel Zaoui 4 years ago
parent 7c47c57383
commit 6489ac6142
  1. 9
      src/bin/inspect.c
  2. 80
      src/bin/player.c

@ -229,8 +229,8 @@ _pixels_compare(Exactness_Image *img1, Exactness_Image *img2, Eina_Bool *has_dif
{
for (h = 0; h < imgO->h; h++)
{
Eina_Bool valid1 = w <= w1 && h <= h1;
Eina_Bool valid2 = w <= w2 && h <= h2;
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;
@ -578,6 +578,11 @@ _img_content_get(void *data, Evas_Object *gl, const char *part)
}
else
{
if (!data)
{
efl_del(img);
return NULL;
}
Exactness_Image *ex_img = data;
evas_object_image_size_set(evas_img, ex_img->w, ex_img->h);
evas_object_image_data_set(evas_img, ex_img->pixels);

@ -123,7 +123,7 @@ static Eina_List *_evas_list = NULL;
static Eina_List *_cur_event_list = NULL;
static int _cur_shot_id = 0;
static Eina_Bool _scan_objects = EINA_FALSE;
static Eina_Bool _scan_objects = EINA_FALSE, _disable_shots = EINA_FALSE;
static Eina_Bool _stabilization_needed = EINA_FALSE;
static Ecore_Timer *_stabilization_timer = NULL;
@ -162,46 +162,52 @@ _shot_do(Evas *e)
if (_dest_type == FTYPE_DIR)
{
int dir_name_len;
char *filename;
Evas_Object *o;
Ecore_Evas *ee;
_ignore_evas_creation++;
ee = ecore_evas_buffer_new(1, 1);
_ignore_evas_creation--;
o = evas_object_image_add(ecore_evas_get(ee));
evas_object_image_alpha_set(o, alpha);
evas_object_image_size_set(o, w, h);
evas_object_image_data_set(o, pixels);
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);
_printf(1, "Shot taken (%s).\n", filename);
if (!evas_object_image_save(o, filename, NULL, NULL))
if (!_disable_shots)
{
printf("Cannot save widget to <%s>\n", filename);
int dir_name_len;
char *filename;
Evas_Object *o;
Ecore_Evas *ee;
_ignore_evas_creation++;
ee = ecore_evas_buffer_new(1, 1);
_ignore_evas_creation--;
o = evas_object_image_add(ecore_evas_get(ee));
evas_object_image_alpha_set(o, alpha);
evas_object_image_size_set(o, w, h);
evas_object_image_data_set(o, pixels);
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);
_printf(1, "Shot taken (%s).\n", filename);
if (!evas_object_image_save(o, filename, NULL, NULL))
{
printf("Cannot save widget to <%s>\n", filename);
}
free(filename);
ecore_evas_free(ee);
}
free(filename);
ecore_evas_free(ee);
}
else if (_dest_type == FTYPE_EXU)
{
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
int nb_bytes = w * h * 4;
ex_img->w = w;
ex_img->h = h;
ex_img->alpha = alpha;
ex_img->pixels = malloc(nb_bytes);
memcpy(ex_img->pixels, pixels, nb_bytes);
_dest_unit->imgs = eina_list_append(_dest_unit->imgs, ex_img);
_dest_unit->nb_shots++;
_printf(1, "Shot taken (in %s).\n", _dest);
if (!_disable_shots)
{
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
int nb_bytes = w * h * 4;
ex_img->w = w;
ex_img->h = h;
ex_img->alpha = alpha;
ex_img->pixels = malloc(nb_bytes);
memcpy(ex_img->pixels, pixels, nb_bytes);
_dest_unit->imgs = eina_list_append(_dest_unit->imgs, ex_img);
_dest_unit->nb_shots++;
_printf(1, "Shot taken (in %s).\n", _dest);
}
if (_scan_objects)
{
@ -844,6 +850,7 @@ static const Ecore_Getopt optdesc = {
ECORE_GETOPT_STORE_TRUE('s', "show-on-screen", "Show on screen."),
ECORE_GETOPT_STORE_TRUE(0, "scan-objects", "Extract information of all the objects at every shot."),
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_COUNT('v', "verbose", "Turn verbose messages on."),
ECORE_GETOPT_LICENSE('L', "license"),
@ -867,6 +874,7 @@ int main(int argc, char **argv)
ECORE_GETOPT_VALUE_BOOL(show_on_screen),
ECORE_GETOPT_VALUE_BOOL(_scan_objects),
ECORE_GETOPT_VALUE_BOOL(external_injection),
ECORE_GETOPT_VALUE_BOOL(_disable_shots),
ECORE_GETOPT_VALUE_INT(_verbose),
ECORE_GETOPT_VALUE_BOOL(want_quit),

Loading…
Cancel
Save