From b8ea50b3e0b5ce8250e8e5d441b6357d9f21dbf8 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 16 Sep 2015 16:57:07 +0900 Subject: [PATCH] replace 'tizen_buffer_pool' interface with 'wayland-tbm' library Change-Id: I2c154cd84176dacdba4da9b675d052f03e73a036 --- CMakeLists.txt | 2 +- packaging/capi-ui-efl-util.spec | 1 + src/efl_util.c | 41 ++++++++++++----------------------------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a669279..5b915ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ ENDIF (WITH_X11) IF (WITH_WAYLAND) ADD_DEFINITIONS("-DWAYLAND") - SET(dependents "${dependents} ecore-wayland wayland-client screenshooter-client tizen-extension-client") + SET(dependents "${dependents} ecore-wayland wayland-client wayland-tbm-client screenshooter-client tizen-extension-client") ENDIF (WITH_WAYLAND) INCLUDE(FindPkgConfig) diff --git a/packaging/capi-ui-efl-util.spec b/packaging/capi-ui-efl-util.spec index d15e9c3..8d02d9f 100644 --- a/packaging/capi-ui-efl-util.spec +++ b/packaging/capi-ui-efl-util.spec @@ -24,6 +24,7 @@ BuildRequires: pkgconfig(xdamage) %endif %if %{with wayland} BuildRequires: pkgconfig(wayland-client) +BuildRequires: pkgconfig(wayland-tbm-client) BuildRequires: pkgconfig(screenshooter-client) BuildRequires: pkgconfig(tizen-extension-client) BuildRequires: pkgconfig(ecore-wayland) diff --git a/src/efl_util.c b/src/efl_util.c index a65ab0c..901178b 100644 --- a/src/efl_util.c +++ b/src/efl_util.c @@ -44,6 +44,7 @@ #if WAYLAND #include #include +#include #include #include #endif /* end of WAYLAND */ @@ -113,7 +114,7 @@ typedef struct _Efl_Util_Data struct { struct screenshooter *screenshooter; - struct tizen_buffer_pool *buffer_pool; + struct wayland_tbm_client *tbm_client; Eina_List *output_list; } shot; } wl; @@ -478,10 +479,6 @@ _cb_wl_reg_global(void *data, output->output = wl_registry_bind(reg, name, &wl_output_interface, version); wl_output_add_listener(output->output, &output_listener, output); } - else if (strcmp(interface, "tizen_buffer_pool") == 0) - { - _eflutil.wl.shot.buffer_pool = wl_registry_bind(reg, name, &tizen_buffer_pool_interface, 1); - } else if (strcmp(interface, "screenshooter") == 0) { _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version); @@ -1432,9 +1429,11 @@ API efl_util_screenshot_h efl_util_screenshot_initialize(int width, int height) int ret = 0; _wl_init(); while (!_eflutil.wl.shot.screenshooter && ret != -1) - ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue); EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init); - EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.buffer_pool, fail_init); + + _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy); + EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init); } EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param); @@ -1457,7 +1456,7 @@ API efl_util_screenshot_h efl_util_screenshot_initialize(int width, int height) screenshot->width = width; screenshot->height = height; - screenshot->bufmgr = tbm_bufmgr_init(-1); + screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client); EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init); g_screenshot = screenshot; @@ -1539,9 +1538,6 @@ API int efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot) if (!screenshot) return EFL_UTIL_ERROR_NONE; - if (screenshot->bufmgr) - tbm_bufmgr_deinit(screenshot->bufmgr); - free(screenshot); g_screenshot = NULL; @@ -1689,10 +1685,8 @@ fail: #endif #if WAYLAND - tbm_bo t_bo = NULL; tbm_surface_h t_surface = NULL; struct wl_buffer *buffer = NULL; - tbm_surface_info_s info; Efl_Util_Wl_Output_Info *output; int ret = 0; @@ -1716,21 +1710,7 @@ fail: goto fail; } - t_bo = tbm_surface_internal_get_bo(t_surface, 0); - if (!t_bo) - { - fprintf(stderr, "[screenshot] fail: no tbm_bo for screenshot\n"); - goto fail; - } - - tbm_surface_get_info(t_surface, &info); - - buffer = - tizen_buffer_pool_create_buffer(_eflutil.wl.shot.buffer_pool, - tbm_bo_export(t_bo), - info.width, info.height, - info.planes[0].stride, - TIZEN_BUFFER_POOL_FORMAT_XRGB8888); + buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface); if (!buffer) { fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); @@ -1741,7 +1721,7 @@ fail: screenshot->shot_done = EINA_FALSE; while (!screenshot->shot_done && ret != -1) - ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue); if (ret == -1) { @@ -1751,6 +1731,9 @@ fail: wl_buffer_destroy(buffer); + /* reset shot_done for next screenshot */ + screenshot->shot_done = EINA_FALSE; + return t_surface; fail: -- 2.7.4