struct wl_registry *reg = NULL;
int ret = 0;
- EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
- EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
+ if (width <= 0 || height <= 0)
+ {
+ set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
_screenshot_mutex_lock();
+ if (!g_screenshot)
+ {
+ screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
+ EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
+ }
+
if (!_eflutil.wl.shot.screenshooter)
{
ret = _wl_init();
g_screenshot->width = width;
g_screenshot->height = height;
}
+ set_last_result(EFL_UTIL_ERROR_NONE);
_screenshot_mutex_unlock();
return g_screenshot;
}
- screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
- EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
-
screenshot->width = width;
screenshot->height = height;
screenshot->auto_rotation = EINA_TRUE;
return g_screenshot;
-fail_param:
- set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
- return NULL;
-fail_memory:
/* LCOV_EXCL_START */
+fail_memory:
if (display_wrapper)
wl_proxy_wrapper_destroy(display_wrapper);
set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
+ _screenshot_mutex_unlock();
return NULL;
+
fail_init:
if (reg)
wl_registry_destroy(reg);
if (screenshot)
- efl_util_screenshot_deinitialize(screenshot);
- _screenshot_mutex_unlock();
+ {
+ _screenshot_mutex_unlock();
+ efl_util_screenshot_deinitialize(screenshot);
+ }
set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
return NULL;
/* LCOV_EXCL_STOP */
free(screenshot);
g_screenshot = NULL;
+ if (_eflutil.wl.shot.tbm_client)
+ {
+ wayland_tbm_client_deinit(_eflutil.wl.shot.tbm_client);
+ _eflutil.wl.shot.tbm_client = NULL;
+ }
+
if (_eflutil.wl.shot.screenshooter)
{
screenshooter_destroy(_eflutil.wl.shot.screenshooter);
goto fail;
}
- wl_buffer_destroy(buffer);
+ wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
/* reset shot_done for next screenshot */
screenshot->shot_done = EINA_FALSE;
if (t_surface)
tbm_surface_destroy(t_surface);
if (buffer)
- wl_buffer_destroy(buffer);
+ wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);