From: Changyeon Lee Date: Thu, 14 Jan 2016 04:49:34 +0000 (+0900) Subject: Remove window system dependent file and source X-Git-Tag: accepted/tizen/mobile/20160115.011030^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F70%2F56970%2F2;p=platform%2Fcore%2Fuifw%2Flibtbm.git Remove window system dependent file and source Change-Id: I1eaf94aff7ca6b3bc66fcb014fb1d45a9aeb9927 Signed-off-by: Changyeon Lee --- diff --git a/configure.ac b/configure.ac index 7343f5c..0144728 100644 --- a/configure.ac +++ b/configure.ac @@ -50,12 +50,6 @@ AC_ARG_WITH(bufmgr-module-path, AS_HELP_STRING([--with-bufmgr-module-path=PATH], [ BUFMGR_MODULE_PATH="$withval" ], [ BUFMGR_MODULE_PATH="${DEFAULT_BUFMGR_MODULE_PATH}" ]) -# set the window system platform where the bufmgr initializes -AC_ARG_WITH(tbm-platform, AS_HELP_STRING([--with-tbm-platform=WINSYS], [tbm platform (default: X11)]), - [ TBM_PLATFORM="$withval" ], - [ TBM_PLATFORM="X11" ]) -AC_SUBST(TBM_PLATFORM) - #AC_DEFINE(BUFMGR_MODULE_DIR, "${BUFMGR_MODULE_PATH}", [Directory for the modules of tbm_bufmgr]) AC_DEFINE_UNQUOTED(BUFMGR_MODULE_DIR, "${BUFMGR_MODULE_PATH}", [Directory for the modules of tbm_bufmgr]) @@ -65,23 +59,6 @@ AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=], AC_SUBST([CLOCK_LIB]) -if test "x$TBM_PLATFORM" = "xX11"; then - PKG_CHECK_MODULES(LIBDRI2, libdri2) - PKG_CHECK_MODULES(X11, x11) - LIBTBM_CFLAGS="$LIBDRI2_CFLAGS $X11_CFLAGS" - LIBTBM_LIBS="$LIBDRI2_LIBS $X11_LIBS" -fi - -if test "x$TBM_PLATFORM" = "xWAYLAND"; then - PKG_CHECK_MODULES(WAYLAND_CLIENT, wayland-client wayland-server) - LIBTBM_CFLAGS="$WAYLAND_CLIENT_CFLAGS" - LIBTBM_LIBS="$WAYLAND_CLIENT_LIBS" - - WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client wayland-server` - AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],, - [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH]) -fi - PKG_CHECK_MODULES(CAPI, [capi-base-common >= 0.1.1], [capi_0_1_1=yes], [capi_0_1_1=no]) if test x"$capi_0_1_1" = xyes; then AC_DEFINE(HAVE_CAPI_0_1_1,1,[The version of capi-base-common is over 0.1.1]) @@ -95,20 +72,12 @@ LIBTBM_LIBS+="$LIBTBM_LIBS $LIBDRM_LIBS $PTHREADSTUBS_LIBS $CAPI_LIBS" AC_SUBST(LIBTBM_CFLAGS) AC_SUBST(LIBTBM_LIBS) -if test "x$TBM_PLATFORM" = "xX11"; then - AC_DEFINE(HAVE_X11,1,[The window system is X11.]) -else - AC_DEFINE(HAVE_WAYLAND,1,[The window system is WAYLAND.]) -fi - HOST_CPU_X86_64=no case $host_cpu in x86_64*|amd64*) HOST_CPU_X86_64=yes esac -AM_CONDITIONAL(HAVE_TBM_PLATFORM_X11, test "x$TBM_PLATFORM" = "xX11") -AM_CONDITIONAL(HAVE_TBM_PLATFORM_WAYLAND, test "x$TBM_PLATFORM" = "xWAYLAND") AM_CONDITIONAL(HOST_CPU_X86_64, test "x$HOST_CPU_X86_64" = "xyes") AC_OUTPUT([ @@ -122,6 +91,5 @@ echo "LDFLAGS : $LDFLAGS" echo "LIBTBM_CFLAGS : $LIBTBM_CFLAGS" echo "LIBTBM_LIBS : $LIBTBM_LIBS" echo "BUFMGR_MODULE_DIR : $BUFMGR_MODULE_PATH" -echo "TBM_PLATFORM : $TBM_PLATFORM" echo "" diff --git a/packaging/libtbm.spec b/packaging/libtbm.spec index 0ee44a6..1bf2c3d 100644 --- a/packaging/libtbm.spec +++ b/packaging/libtbm.spec @@ -12,13 +12,6 @@ Source1001: %name.manifest BuildRequires: pkgconfig(libdrm) BuildRequires: pkgconfig(pthread-stubs) -%if %{with wayland} -BuildRequires: pkgconfig -BuildRequires: pkgconfig(wayland-client) -%else -BuildRequires: pkgconfig(x11) -BuildRequires: pkgconfig(libdri2) -%endif BuildRequires: pkgconfig(capi-base-common) %description diff --git a/src/Makefile.am b/src/Makefile.am index e14b4c1..cbe61dc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,19 +13,7 @@ libtbm_ladir = $(libdir) libtbm_la_LDFLAGS = -version-number 1:0:0 -no-undefined libtbm_la_LIBADD = @LIBTBM_LIBS@ @PTHREADSTUBS_LIBS@ @CLOCK_LIB@ -ldl -libtbm_la_SOURCES = - -if HAVE_TBM_PLATFORM_X11 - libtbm_la_SOURCES += \ - tbm_x11.c -endif - -if HAVE_TBM_PLATFORM_WAYLAND - libtbm_la_SOURCES += \ - tbm_wayland.c -endif - -libtbm_la_SOURCES += \ +libtbm_la_SOURCES = \ tbm_surface_internal.c \ tbm_surface.c \ tbm_surface_queue.c \ diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 11bbcf4..c337302 100755 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -838,18 +838,6 @@ tbm_bufmgr tbm_bufmgr_init(int fd) } if (fd < 0) { -#ifdef HAVE_X11 - fd = tbm_bufmgr_get_drm_fd_x11(); -#elif HAVE_WAYLAND - fd = tbm_bufmgr_get_drm_fd_wayland(); -#endif - if (fd < 0) { - _tbm_set_last_result(TBM_BO_ERROR_GET_FD_FAILED); - TBM_LOG("[libtbm:%d] Fail get drm fd\n", - getpid()); - pthread_mutex_unlock(&gLock); - return NULL; - } fd_flag = 1; } @@ -859,9 +847,6 @@ tbm_bufmgr tbm_bufmgr_init(int fd) gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr)); if (!gBufMgr) { _tbm_set_last_result(TBM_BO_ERROR_HEAP_ALLOC_FAILED); - if (fd_flag) - close(fd); - pthread_mutex_unlock(&gLock); return NULL; } @@ -869,7 +854,7 @@ tbm_bufmgr tbm_bufmgr_init(int fd) gBufMgr->fd_flag = fd_flag; if (fd_flag) { - gBufMgr->fd = fd; + gBufMgr->fd = -1; } else { gBufMgr->fd = dup(fd); if (gBufMgr->fd < 0) { @@ -889,7 +874,10 @@ tbm_bufmgr tbm_bufmgr_init(int fd) if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) { _tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED); TBM_LOG("[libtbm:%d] " "error : Fail to load bufmgr backend\n", getpid()); - close(gBufMgr->fd); + + if (gBufMgr->fd > 0) + close(gBufMgr->fd); + free(gBufMgr); gBufMgr = NULL; pthread_mutex_unlock(&gLock); @@ -925,7 +913,10 @@ tbm_bufmgr tbm_bufmgr_init(int fd) gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv); tbm_backend_free(gBufMgr->backend); dlclose(gBufMgr->module_data); - close(gBufMgr->fd); + + if (gBufMgr->fd > 0) + close(gBufMgr->fd); + free(gBufMgr); gBufMgr = NULL; pthread_mutex_unlock(&gLock); @@ -940,7 +931,10 @@ tbm_bufmgr tbm_bufmgr_init(int fd) tbm_backend_free(gBufMgr->backend); pthread_mutex_destroy(&gBufMgr->lock); dlclose(gBufMgr->module_data); - close(gBufMgr->fd); + + if (gBufMgr->fd > 0) + close(gBufMgr->fd); + free(gBufMgr); gBufMgr = NULL; pthread_mutex_unlock(&gLock); @@ -1039,7 +1033,8 @@ void tbm_bufmgr_deinit(tbm_bufmgr bufmgr) dlclose(bufmgr->module_data); - close(bufmgr->fd); + if (bufmgr->fd > 0) + close(bufmgr->fd); free(bufmgr); bufmgr = NULL; diff --git a/src/tbm_wayland.c b/src/tbm_wayland.c deleted file mode 100644 index 40c0685..0000000 --- a/src/tbm_wayland.c +++ /dev/null @@ -1,277 +0,0 @@ -/************************************************************************** - -libtbm - -Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: SooChan Lim , Sangjin Lee -Boram Park , Changyeon Lee - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -#include "config.h" - -#include "tbm_bufmgr_int.h" -#include - -#include -#include -#include - -#include "wayland-util.h" - -extern const struct wl_interface wl_buffer_interface; - -static const struct wl_interface *types[] = { - NULL, - NULL, - NULL, - &wl_buffer_interface, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &wl_buffer_interface, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, -}; - -static const struct wl_message wl_tbm_requests[] = { - {"create_buffer", "niiuiiiiiiiiiiuiuuu", types + 3}, - {"create_buffer_with_fd", "niiuiiiiiiiiiiuihhh", types + 22}, - {"get_authentication_info", "", types + 0}, -}; - -static const struct wl_message wl_tbm_events[] = { - {"authentication_info", "suh", types + 0}, -}; - -WL_EXPORT const struct wl_interface wl_tbm_interface = { - "wl_tbm", 1, - 3, wl_tbm_requests, - 1, wl_tbm_events, -}; - -struct wl_buffer; -struct wl_tbm; - -extern const struct wl_interface wl_tbm_interface; - -#ifndef WL_TBM_ERROR_ENUM -#define WL_TBM_ERROR_ENUM -enum wl_tbm_error { - WL_TBM_ERROR_AUTHENTICATE_FAIL = 0, - WL_TBM_ERROR_INVALID_FORMAT = 1, - WL_TBM_ERROR_INVALID_NAME = 2, -}; -#endif /* WL_TBM_ERROR_ENUM */ - -struct wl_tbm_listener { - /** - * authentication_info - (none) - * @device_name: (none) - * @capabilities: (none) - * @auth_fd: (none) - */ - void (*authentication_info) (void *data, struct wl_tbm * wl_tbm, const char *device_name, uint32_t capabilities, int32_t auth_fd); -}; - -static inline int wl_tbm_add_listener(struct wl_tbm *wl_tbm, const struct wl_tbm_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *)wl_tbm, (void (**)(void))listener, data); -} - -#define WL_TBM_CREATE_BUFFER 0 -#define WL_TBM_CREATE_BUFFER_WITH_FD 1 -#define WL_TBM_GET_AUTHENTICATION_INFO 2 - -static inline void wl_tbm_set_user_data(struct wl_tbm *wl_tbm, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *)wl_tbm, user_data); -} - -static inline void *wl_tbm_get_user_data(struct wl_tbm *wl_tbm) -{ - return wl_proxy_get_user_data((struct wl_proxy *)wl_tbm); -} - -static inline void wl_tbm_destroy(struct wl_tbm *wl_tbm) -{ - wl_proxy_destroy((struct wl_proxy *)wl_tbm); -} - -static inline void wl_tbm_get_authentication_info(struct wl_tbm *wl_tbm) -{ - wl_proxy_marshal((struct wl_proxy *)wl_tbm, WL_TBM_GET_AUTHENTICATION_INFO); -} - -struct wl_tbm_info { - struct wl_display *dpy; - struct wl_event_queue *wl_queue; - struct wl_tbm *wl_tbm; - - uint32_t capabilities; - char *device; - int32_t fd; -}; - -static void handle_tbm_authentication_info(void *data, struct wl_tbm *wl_tbm, const char *device_name, uint32_t capabilities, int32_t auth_fd) -{ - struct wl_tbm_info *info = (struct wl_tbm_info *)data; - - info->fd = auth_fd; - info->capabilities = capabilities; - if (device_name) - info->device = strndup(device_name, 256); -} - -static const struct wl_tbm_listener wl_tbm_client_listener = { - handle_tbm_authentication_info -}; - -static void wl_client_registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) -{ - struct wl_tbm_info *info = (struct wl_tbm_info *)data; - - if (!strcmp(interface, "wl_tbm")) { - info->wl_tbm = wl_registry_bind(registry, name, &wl_tbm_interface, version); - if (!info->wl_tbm) { - printf("Failed to bind wl_tbm\n"); - return; - } - - wl_tbm_add_listener(info->wl_tbm, &wl_tbm_client_listener, info); - wl_proxy_set_queue((struct wl_proxy *)info->wl_tbm, info->wl_queue); - } -} - -static int tbm_util_get_drm_fd(void *dpy, int *fd) -{ - struct wl_display *disp = NULL; - struct wl_registry *wl_registry; - struct wl_tbm_info info = { - .dpy = NULL, - .wl_queue = NULL, - .wl_tbm = NULL, - .capabilities = 0, - .device = NULL, - .fd = 0, - }; - - static const struct wl_registry_listener registry_listener = { - wl_client_registry_handle_global, - NULL - }; - - if (!fd) - return -1; - - if (!dpy) { - disp = wl_display_connect(NULL); - if (!disp) { - printf("Failed to create a new display connection\n"); - return -1; - } - dpy = disp; - } - - info.dpy = dpy; - info.wl_queue = wl_display_create_queue(dpy); - if (!info.wl_queue) { - printf("Failed to create a WL Queue\n"); - if (disp == dpy) - wl_display_disconnect(disp); - - return -1; - } - - wl_registry = wl_display_get_registry(dpy); - if (!wl_registry) { - printf("Failed to get registry\n"); - wl_event_queue_destroy(info.wl_queue); - if (disp == dpy) - wl_display_disconnect(disp); - - return -1; - } - wl_proxy_set_queue((struct wl_proxy *)wl_registry, info.wl_queue); - wl_registry_add_listener(wl_registry, ®istry_listener, &info); - wl_display_roundtrip_queue(dpy, info.wl_queue); - - wl_tbm_get_authentication_info(info.wl_tbm); - wl_display_roundtrip_queue(dpy, info.wl_queue); - - *fd = info.fd; - - wl_event_queue_destroy(info.wl_queue); - wl_registry_destroy(wl_registry); - - free(info.device); - wl_tbm_set_user_data(info.wl_tbm, NULL); - wl_tbm_destroy(info.wl_tbm); - - if (disp == dpy) - wl_display_disconnect(disp); - - return *fd >= 0 ? 0 : -1; -} - -int tbm_bufmgr_get_drm_fd_wayland() -{ - int fd = -1; - - if (tbm_util_get_drm_fd(NULL, &fd)) - printf("Failed to get drm_fd\n"); - - return fd; -} diff --git a/src/tbm_x11.c b/src/tbm_x11.c deleted file mode 100644 index ce09c9e..0000000 --- a/src/tbm_x11.c +++ /dev/null @@ -1,117 +0,0 @@ -/************************************************************************** - -libtbm - -Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: SooChan Lim , Sangjin Lee -Boram Park , Changyeon Lee - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -#include "config.h" - -#include "tbm_bufmgr.h" -#include "tbm_bufmgr_int.h" -#include -#include -#include - -int tbm_bufmgr_get_drm_fd_x11() -{ - int screen; - Display *display; - int dri2Major, dri2Minor; - int eventBase, errorBase; - drm_magic_t magic; - char *driver_name, *device_name; - int fd; - - display = XOpenDisplay(NULL); - if (!display) { - TBM_LOG("[libtbm:%d] Fail XOpenDisplay\n", getpid()); - return -1; - } - - screen = DefaultScreen(display); - - if (!DRI2QueryExtension(display, &eventBase, &errorBase)) { - TBM_LOG("[libtbm:%d] Fail DRI2QueryExtention\n", getpid()); - XCloseDisplay(display); - return -1; - } - - if (!DRI2QueryVersion(display, &dri2Major, &dri2Minor)) { - TBM_LOG("[libtbm:%d] Fail DRI2QueryVersion\n", getpid()); - XCloseDisplay(display); - return -1; - } - - if (!DRI2Connect(display, RootWindow(display, screen), &driver_name, &device_name)) { - TBM_LOG("[libtbm:%d] Fail DRI2Connect\n", getpid()); - XCloseDisplay(display); - return -1; - } - - fd = open(device_name, O_RDWR); - if (fd < 0) { - TBM_LOG("[libtbm:%d] cannot open drm device (%s)\n", getpid(), device_name); - free(driver_name); - free(device_name); - XCloseDisplay(display); - return -1; - } - - if (drmGetMagic(fd, &magic)) { - TBM_LOG("[libtbm:%d] Fail drmGetMagic\n", getpid()); - free(driver_name); - free(device_name); - close(fd); - XCloseDisplay(display); - return -1; - } - - if (!DRI2Authenticate(display, RootWindow(display, screen), magic)) { - TBM_LOG("[libtbm:%d] Fail DRI2Authenticate\n", getpid()); - free(driver_name); - free(device_name); - close(fd); - XCloseDisplay(display); - return -1; - } - - if (!drmAuthMagic(fd, magic)) { - TBM_LOG("[libtbm:%d] Fail drmAuthMagic\n", getpid()); - free(driver_name); - free(device_name); - close(fd); - XCloseDisplay(display); - return -1; - } - - free(driver_name); - free(device_name); - XCloseDisplay(display); - - return fd; -}