[Mesa-dev] [PATCH v5 06/10] egl/tizen: add tizen specific implementations for BindWaylandDisplayWL/UnbindWaylandDisplayWL/QueryWaylandBufferWL (v2)

Gwan-gyeong Mun elongbug at gmail.com
Wed Oct 25 16:50:59 UTC 2017


Tizen platform (actually WL_TBM protocol) internally processes similiar actions
such as mesa's BindWaylandDisplayWL/UnbindWaylandDisplayWL/QueryWaylandBufferWL.
So the platform_tizen.c needs to implemment BindWaylandDisplayWL,
UnbindWaylandDisplayWL and QueryWaylandBufferWL apart from mesa's.

  - tizen's enlightenment wayland display server calls wayland_tbm_server_init()
    which processes described tasks.

  - section TPL-EGL and Wayland Server and Client
    from https://wiki.tizen.org/3.0_Porting_Guide/Graphics_and_UI/OpenGL

    "Tizen uses the wl_tbm protocol instead of wl_drm. The wl_tbm protocol is
     born for sharing the buffer(tbm_surface) between the wayland_client and
     wayland_server. Although the wayland_tbm_server_init and wayland_tbm_client_init
     pair is a role for the eglBindWaylandDisplayWL, the EGL driver is required
     to implement the entrypoints for the eglBindWaylandDisplayWL and
     eglUnbindWaylandDisplayWL as dummy."

v2: Fixes from Emil's review:
   a) Remove unneeded compiler pragma
   b) Add and use get_texture_format() helper
   c) Add switch's default case on tizen_query_wayland_buffer_wl()

referenced materials:
[1] https://wiki.tizen.org/3.0_Porting_Guide/Graphics_and_UI/OpenGL
[2] repository: git://git.tizen.org/platform/core/uifw/wayland-tbm (branch: tizen)

Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
---
 src/egl/drivers/dri2/platform_tizen.c | 92 +++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/src/egl/drivers/dri2/platform_tizen.c b/src/egl/drivers/dri2/platform_tizen.c
index addb7c8862..1b3b105fa3 100644
--- a/src/egl/drivers/dri2/platform_tizen.c
+++ b/src/egl/drivers/dri2/platform_tizen.c
@@ -64,6 +64,21 @@ static int get_format_bpp(tbm_format format)
    }
 }
 
+static EGLBoolean get_texture_format(tbm_format format, EGLint *value)
+{
+   switch (format) {
+   case TBM_FORMAT_ARGB8888:
+      *value = EGL_TEXTURE_RGBA;
+      return EGL_TRUE;
+   case TBM_FORMAT_XRGB8888:
+   case TBM_FORMAT_RGB565:
+      *value = EGL_TEXTURE_RGB;
+      return EGL_TRUE;
+   default:
+      return EGL_FALSE;
+   }
+}
+
 static int get_stride(tbm_surface_h tbm_surface)
 {
    tbm_surface_info_s surf_info;
@@ -734,6 +749,78 @@ static const __DRIextension *tizen_swrast_loader_extensions[] = {
    NULL,
 };
 
+static EGLBoolean
+tizen_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
+                              struct wl_display *wl_dpy)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+
+   (void) drv;
+   (void) wl_dpy;
+
+   if (!dri2_dpy->tpl_display)
+      return EGL_FALSE;
+
+   if (!tpl_display_get_native_handle(dri2_dpy->tpl_display))
+      return EGL_FALSE;
+
+   return EGL_TRUE;
+}
+
+static EGLBoolean
+tizen_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
+                                struct wl_display *wl_dpy)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+
+   (void) drv;
+   (void) wl_dpy;
+
+   if (!dri2_dpy->tpl_display)
+      return EGL_FALSE;
+
+   if (!tpl_display_get_native_handle(dri2_dpy->tpl_display))
+      return EGL_FALSE;
+
+   return EGL_TRUE;
+}
+
+static EGLBoolean
+tizen_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
+                              struct wl_resource *buffer_resource,
+                              EGLint attribute, EGLint *value)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   tbm_format tbm_format = 0;
+   int width = 0, height = 0;
+   tpl_result_t res;
+
+   if (!dri2_dpy->tpl_display)
+      return EGL_FALSE;
+
+   if (!tpl_display_get_native_handle(dri2_dpy->tpl_display))
+      return EGL_FALSE;
+
+   res = tpl_display_get_native_pixmap_info(dri2_dpy->tpl_display,
+                                            (tpl_handle_t)buffer_resource,
+                                            &width, &height, &tbm_format);
+   if (res != TPL_ERROR_NONE)
+      return EGL_FALSE;
+
+   switch (attribute) {
+   case EGL_TEXTURE_FORMAT:
+      return get_texture_format(tbm_format, value);
+   case EGL_WIDTH:
+      *value = width;
+      return EGL_TRUE;
+   case EGL_HEIGHT:
+      *value = height;
+      return EGL_TRUE;
+   default:
+      return EGL_FALSE;
+   }
+}
+
 EGLBoolean
 dri2_initialize_tizen(_EGLDriver *drv, _EGLDisplay *dpy)
 {
@@ -864,6 +951,11 @@ dri2_initialize_tizen(_EGLDriver *drv, _EGLDisplay *dpy)
 
    dpy->Extensions.EXT_buffer_age = EGL_TRUE;
    dpy->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
+   dpy->Extensions.WL_bind_wayland_display = EGL_TRUE;
+
+   drv->API.BindWaylandDisplayWL = tizen_bind_wayland_display_wl;
+   drv->API.UnbindWaylandDisplayWL = tizen_unbind_wayland_display_wl;
+   drv->API.QueryWaylandBufferWL = tizen_query_wayland_buffer_wl;
 
    return EGL_TRUE;
 
-- 
2.14.2



More information about the mesa-dev mailing list