[Mesa-dev] [PATCH v5 08/10] egl/tizen: add EGL_NATIVE_SURFACE_TIZEN target of eglCreateImageKHR()

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


It adds TIZEN_image_native_surface extension string to _EGLExtensions.
And it adds a routine of creating an EGLImage from a tbm_surface.

  - section overview
    from https://www.khronos.org/registry/EGL/extensions/TIZEN/EGL_TIZEN_image_native_surface.txt

    "Tizen Buffer Manager (TBM) is a user space, generic memory management
     framework to create and share memory buffers between different system
     components. This extension enables using a Tizen Buffer Manager (TBM)
     surface object (struct tbm_surface_h) as an EGLImage source."

Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
---
 src/egl/drivers/dri2/platform_tizen.c | 18 ++++++++++++++++++
 src/egl/main/eglapi.c                 |  2 ++
 src/egl/main/egldisplay.h             |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/src/egl/drivers/dri2/platform_tizen.c b/src/egl/drivers/dri2/platform_tizen.c
index af6fb52205..16a0c7c00d 100644
--- a/src/egl/drivers/dri2/platform_tizen.c
+++ b/src/egl/drivers/dri2/platform_tizen.c
@@ -677,6 +677,20 @@ tizen_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
    return _eglQuerySurface(drv, dpy, surf, attribute, value);
 }
 
+static _EGLImage *
+dri2_create_image_tizen_native_buffer(_EGLDisplay *disp,
+                                      _EGLContext *ctx,
+                                      tbm_surface_h tbm_surface)
+{
+   int fd;
+
+   fd = get_native_buffer_fd(tbm_surface);
+   if (fd >= 0)
+      return tizen_create_image_from_prime_fd(disp, ctx, tbm_surface, fd);
+
+   return tizen_create_image_from_name(disp, ctx, tbm_surface);
+}
+
 static _EGLImage *
 dri2_create_image_tizen_wl_buffer(_EGLDisplay *disp,
                                   _EGLContext *ctx,
@@ -704,6 +718,9 @@ tizen_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
                        EGLClientBuffer buffer, const EGLint *attr_list)
 {
    switch (target) {
+   case EGL_NATIVE_SURFACE_TIZEN:
+      return dri2_create_image_tizen_native_buffer(disp, ctx,
+                                                   (tbm_surface_h)buffer);
    case EGL_WAYLAND_BUFFER_WL:
       return dri2_create_image_tizen_wl_buffer(disp, ctx, (tpl_handle_t)buffer);
    default:
@@ -1248,6 +1265,7 @@ 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.TIZEN_image_native_surface = EGL_TRUE;
    dpy->Extensions.WL_bind_wayland_display = EGL_TRUE;
 
    drv->API.BindWaylandDisplayWL = tizen_bind_wayland_display_wl;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 75790477e2..80c95c523d 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -538,6 +538,8 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
 
    _EGL_CHECK_EXTENSION(NV_post_sub_buffer);
 
+   _EGL_CHECK_EXTENSION(TIZEN_image_native_surface);
+
    _EGL_CHECK_EXTENSION(WL_bind_wayland_display);
    _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image);
 
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 869c6601a1..f1b286c31c 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -138,6 +138,8 @@ struct _egl_extensions
 
    EGLBoolean NV_post_sub_buffer;
 
+   EGLBoolean TIZEN_image_native_surface;
+
    EGLBoolean WL_bind_wayland_display;
    EGLBoolean WL_create_wayland_buffer_from_image;
 };
-- 
2.14.2



More information about the mesa-dev mailing list