[Mesa-dev] [PATCH v4 01/10] egl: add a treatment of tizen platform on egl display (v2)

Gwan-gyeong Mun elongbug at gmail.com
Fri Oct 6 22:03:18 UTC 2017


It adds a _EGL_PLATFORM_TIZEN enum value to _EGLPlatformType for tizen platform.

It adds a detecting routine of tizen platform to _eglNativePlatformDetectNativeDisplay()
and _eglGetNativePlatform().

  - As tizen platform internally distinguishes native displays of tbm, drm/gbm
    and wayland client, when EGL_PLATFORM_WAYLAND_EXT or EGL_PLATFORM_GBM_MESA
    come from eglGetPlatformDisplayEXT(), it have call _eglGetTizenDisplay().

    Tizen supports various display protocols (tbm / gbm / wayland-egl) and each
    implementation is different from mesa's. Because of tizen specific scanout-buffer
    management for hardware overlay compositing and optimization. And also tizen
    has its own gbm implementation for tizen specific implementation.
    (gbm_create_device function pointer is differ from mesa's implementation.)

    Therefore tizen provides libtpl-egl(Tizen Porting Layer for EGL) which is
    an abstraction layer for the surface and buffer management on Tizen platform
    aimed to implement the EGL porting layer of the OpenGLES driver over the
    various display protocols.
    As the libtpl-egl detects native display, if mesa send native display to
    the libtpl-egl then it  distinguishes tbm/gbm/wayland-egl native display
    and loads appropriate backend.

  - If tizen platform is enabled at the configuration, _eglGetNativePlatform()
    always detects _EGL_PLATFORM_TIZEN as a detected_platform.

v2:
 - Fixes from Emil's review:
   a) Add commit messages in detail for a needing of a separated tizen backend.
   b) Remove unneeded ifndef blocks.
   c) Add comments in detail.
   d) Remove an wrong detection routine on _eglGetNativePlatform()

 - Add a detection routine of Tizen platform on _eglGetNativePlatformFromEnv()

Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
---
 src/egl/main/eglapi.c     | 13 +++++++++++++
 src/egl/main/egldisplay.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 src/egl/main/egldisplay.h |  7 +++++++
 3 files changed, 66 insertions(+)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 4a9b3fe392..f3257eef4b 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -402,6 +402,19 @@ _eglGetPlatformDisplayCommon(EGLenum platform, void *native_display,
    case EGL_PLATFORM_SURFACELESS_MESA:
       dpy = _eglGetSurfacelessDisplay(native_display, attrib_list);
       break;
+#endif
+#ifdef HAVE_TIZEN_PLATFORM
+/* Tizen supports various display protocols (tbm / gbm / wayland-egl) and
+ * each implementation is different from mesa's.
+ * (Tizen has its own gbm implementation for tizen specific implementation.)
+ *  Therefore, when Tizen platform is enabled, it has call _eglGetTizenDisplay().
+ */
+    case EGL_PLATFORM_GBM_MESA:
+       dpy = _eglGetTizenDisplay(native_display, attrib_list);
+       break;
+    case EGL_PLATFORM_WAYLAND_EXT:
+       dpy = _eglGetTizenDisplay(native_display, attrib_list);
+       break;
 #endif
    default:
       RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, NULL);
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 690728d2f7..43e2d73e73 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -70,6 +70,7 @@ static const struct {
    { _EGL_PLATFORM_ANDROID, "android" },
    { _EGL_PLATFORM_HAIKU, "haiku" },
    { _EGL_PLATFORM_SURFACELESS, "surfaceless" },
+   { _EGL_PLATFORM_TIZEN, "tizen" },
 };
 
 
@@ -92,7 +93,20 @@ _eglGetNativePlatformFromEnv(void)
 
    for (i = 0; i < _EGL_NUM_PLATFORMS; i++) {
       if (strcmp(egl_platforms[i].name, plat_name) == 0) {
+#ifdef HAVE_TIZEN_PLATFORM
+         /* Some widget library (ex. efl) can set EGL_DISPLAY environment
+          * variable as wayland or drm. But when TIZEN platform is enabled,
+          * we should ignore this variable in mesa. Becasue libtpl-egl detects
+          * this enviromnet variable and loads appropriate backend for that.
+          */
+         if ((egl_platforms[i].platform == _EGL_PLATFORM_WAYLAND) ||
+             (egl_platforms[i].platform == _EGL_PLATFORM_DRM))
+            plat = _EGL_PLATFORM_TIZEN;
+         else
+            plat = egl_platforms[i].platform;
+#else
          plat = egl_platforms[i].platform;
+#endif
          break;
       }
    }
@@ -115,6 +129,23 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
 
       (void) first_pointer; /* silence unused var warning */
 
+#ifdef HAVE_TIZEN_PLATFORM
+      /* Tizen supports various display protocols (tbm / gbm / wayland-egl)
+       * and each implementation is different from mesa's. Because of tizen
+       * specific scanout-buffer management for hardware overlay compositing
+       * and optimization. And also tizen has its own gbm implementation for
+       * tizen specific implementation. (gbm_create_device function pointer
+       * is differ from mesa's implementation.)
+       * Therefore tizen provides libtpl-egl(Tizen Porting Layer for EGL) which
+       * is an abstraction layer for the surface and buffer management on Tizen
+       * platform aimed to implement the EGL porting layer of the OpenGLES driver
+       * over the various display protocols. As the libtpl-egl detects native
+       * display, if mesa send native display to libtpl-egl then it distinguishes
+       * tbm / gbm / wayland-egl native display and loads appropriate backend.
+       */
+      return _EGL_PLATFORM_TIZEN;
+#endif
+
 #ifdef HAVE_WAYLAND_PLATFORM
       /* wl_display is a wl_proxy, which is a wl_object.
        * wl_object's first element points to the interfacetype. */
@@ -541,3 +572,18 @@ _eglGetSurfacelessDisplay(void *native_display,
    return _eglFindDisplay(_EGL_PLATFORM_SURFACELESS, native_display);
 }
 #endif /* HAVE_SURFACELESS_PLATFORM */
+
+#ifdef HAVE_TIZEN_PLATFORM
+_EGLDisplay*
+_eglGetTizenDisplay(void *native_display,
+                    const EGLint *attrib_list)
+{
+   /* EGL_EXT_platform_wayland recognizes no attributes. */
+   if (attrib_list != NULL && attrib_list[0] != EGL_NONE) {
+      _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
+      return NULL;
+   }
+
+   return _eglFindDisplay(_EGL_PLATFORM_TIZEN, native_display);
+}
+#endif /* HAVE_TIZEN_PLATFORM */
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 9a0b9b672a..c009462b82 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -50,6 +50,7 @@ enum _egl_platform_type {
    _EGL_PLATFORM_ANDROID,
    _EGL_PLATFORM_HAIKU,
    _EGL_PLATFORM_SURFACELESS,
+   _EGL_PLATFORM_TIZEN,
 
    _EGL_NUM_PLATFORMS,
    _EGL_INVALID_PLATFORM = -1
@@ -285,6 +286,12 @@ _eglGetSurfacelessDisplay(void *native_display,
                           const EGLint *attrib_list);
 #endif
 
+#ifdef HAVE_TIZEN_PLATFORM
+_EGLDisplay*
+_eglGetTizenDisplay(void *native_display,
+                    const EGLint *attrib_list);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.14.2



More information about the mesa-dev mailing list