From 56b3397f13363bcbb13bd6d7f82e672997ca6733 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Fri, 19 May 2017 16:07:20 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Added an API to check whether native handle is wl_display. - Added API tpl_bool_t twe_check_native_handle_is_wl_display(tpl_handle_t) Change-Id: Icf1a67368724ca98cec80bcc21d57af1debf22b7 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 23 +++++++++++++++++++++++ src/tpl_wayland_egl_thread.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 5f122dc..80ee554 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1333,6 +1333,29 @@ twe_surface_set_damage_region(tbm_surface_h tbm_surface, } tpl_result_t +twe_check_native_handle_is_wl_display(tpl_handle_t display) +{ + struct wl_interface *wl_egl_native_dpy = *(void **) display; + + if (!wl_egl_native_dpy) { + TPL_ERR("Invalid parameter. native_display(%p)", wl_egl_native_dpy); + return TPL_FALSE; + } + + /* MAGIC CHECK: A native display handle is a wl_display if the de-referenced first value + is a memory address pointing the structure of wl_display_interface. */ + if (wl_egl_native_dpy == &wl_display_interface) + return TPL_TRUE; + + if (strncmp(wl_egl_native_dpy->name, wl_display_interface.name, + strlen(wl_display_interface.name)) == 0) { + return TPL_TRUE; + } + + return TPL_FALSE; +} + +tpl_result_t twe_get_native_window_info(tpl_handle_t window, int *width, int *height) { struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)window; diff --git a/src/tpl_wayland_egl_thread.h b/src/tpl_wayland_egl_thread.h index 4819939..6b7f3c0 100644 --- a/src/tpl_wayland_egl_thread.h +++ b/src/tpl_wayland_egl_thread.h @@ -45,6 +45,9 @@ twe_surface_set_damage_region(tbm_surface_h tbm_surface, int num_rects, const int *rects); tpl_result_t +twe_check_native_handle_is_wl_display(tpl_handle_t display); + +tpl_result_t twe_get_native_window_info(tpl_handle_t window, int *width, int *height); tbm_surface_h -- 2.7.4