[Mesa-dev] [PATCH v2 6/9] egl/tizen: add tizen specific implementations for BindWaylandDisplayWL/UnbindWaylandDisplayWL/QueryWaylandBufferWL

Gwan-gyeong Mun elongbug at gmail.com
Sun Sep 17 18:01:04 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."

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 | 88 +++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/src/egl/drivers/dri2/platform_tizen.c b/src/egl/drivers/dri2/platform_tizen.c
index 77684d3c1a..19db84b553 100644
--- a/src/egl/drivers/dri2/platform_tizen.c
+++ b/src/egl/drivers/dri2/platform_tizen.c
@@ -746,6 +746,89 @@ 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:
+      switch (tbm_format) {
+      case TBM_FORMAT_ARGB8888:
+         *value = EGL_TEXTURE_RGBA;
+         return EGL_TRUE;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+      case TBM_FORMAT_XRGB8888:
+      case TBM_FORMAT_RGB565:
+#pragma GCC diagnostic pop
+         *value = EGL_TEXTURE_RGB;
+         return EGL_TRUE;
+      }
+   case EGL_WIDTH:
+      *value = width;
+      return EGL_TRUE;
+   case EGL_HEIGHT:
+      *value = height;
+      return EGL_TRUE;
+   }
+
+   return EGL_FALSE;
+}
+
 EGLBoolean
 dri2_initialize_tizen(_EGLDriver *drv, _EGLDisplay *dpy)
 {
@@ -879,6 +962,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.1



More information about the mesa-dev mailing list