tpl_wayland_egl_thread: Added an API to check whether native handle is wl_display. 06/135106/5
authorjoonbum.ko <joonbum.ko@samsung.com>
Fri, 19 May 2017 07:07:20 +0000 (16:07 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 22 Jun 2017 08:53:36 +0000 (08:53 +0000)
 - Added API
 tpl_bool_t twe_check_native_handle_is_wl_display(tpl_handle_t)

Change-Id: Icf1a67368724ca98cec80bcc21d57af1debf22b7
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c
src/tpl_wayland_egl_thread.h

index 5f122dc..80ee554 100644 (file)
@@ -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;
index 4819939..6b7f3c0 100644 (file)
@@ -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