[Mesa-dev] [PATCH 18/25] egl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not driver

Chad Versace chad.versace at linux.intel.com
Sun Feb 9 13:37:54 PST 2014


Add dri2_egl_display_vtbl::create_wayland_buffer_from_image, set it for
each platform, and let egl_dri2 dispatch
eglCreateWaylandBufferFromImageWL to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c           |  9 +++++++++
 src/egl/drivers/dri2/egl_dri2.h           |  6 ++++++
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 10 ++++++++++
 src/egl/drivers/dri2/platform_android.c   |  1 +
 src/egl/drivers/dri2/platform_drm.c       |  1 +
 src/egl/drivers/dri2/platform_wayland.c   | 10 ++++------
 src/egl/drivers/dri2/platform_x11.c       |  2 ++
 7 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d1b15f7..e0d4b6c 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1486,6 +1486,14 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx,
    return &dri2_img->base;
 }
 
+static struct wl_buffer*
+dri2_create_wayland_buffer_from_image(_EGLDriver *drv, _EGLDisplay *dpy,
+                                      _EGLImage *img)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->create_wayland_buffer_from_image(drv, dpy, img);
+}
+
 #ifdef HAVE_DRM_PLATFORM
 static EGLBoolean
 dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
@@ -2150,6 +2158,7 @@ _eglBuiltInDriverDRI2(const char *args)
    dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
    dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
    dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
+   dri2_drv->base.API.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
 #ifdef HAVE_DRM_PLATFORM
    dri2_drv->base.API.CreateDRMImageMESA = dri2_create_drm_image_mesa;
    dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 250d209..8f3ed9d 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -75,6 +75,8 @@
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
+struct wl_buffer;
+
 struct dri2_egl_driver
 {
    _EGLDriver base;
@@ -131,6 +133,10 @@ struct dri2_egl_display_vtbl {
 
    EGLint
    (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
+
+   struct wl_buffer*
+   (*create_wayland_buffer_from_image)(_EGLDriver *drv, _EGLDisplay *dpy,
+                                       _EGLImage *img);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index 00e955a..80ed26d 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -26,6 +26,8 @@
 
 #include "egltypedefs.h"
 
+struct wl_buffer;
+
 static inline _EGLSurface *
 dri2_fallback_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
                                     _EGLConfig *conf,
@@ -88,3 +90,11 @@ dri2_fallback_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy,
 {
    return 0;
 }
+
+static inline struct wl_buffer*
+dri2_fallback_create_wayland_buffer_from_image(_EGLDriver *drv,
+                                               _EGLDisplay *dpy,
+                                               _EGLImage *img)
+{
+   return NULL;
+}
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index eddf33c..0aa0fa4 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -652,6 +652,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
    .post_sub_buffer = dri2_fallback_post_sub_buffer,
    .copy_buffers = dri2_fallback_copy_buffers,
    .query_buffer_age = dri2_fallback_query_buffer_age,
+   .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 18eca19..89222bf 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -454,6 +454,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
    .post_sub_buffer = dri2_fallback_post_sub_buffer,
    .copy_buffers = dri2_fallback_copy_buffers,
    .query_buffer_age = dri2_drm_query_buffer_age,
+   .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image,
 };
 
 EGLBoolean
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 8dc2893..a875656 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -685,9 +685,9 @@ dri2_wl_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
 }
 
 static struct wl_buffer *
-dri2_wl_create_wayland_buffer_from_image_wl(_EGLDriver *drv,
-                                            _EGLDisplay *disp,
-                                            _EGLImage *img)
+dri2_wl_create_wayland_buffer_from_image(_EGLDriver *drv,
+                                          _EGLDisplay *disp,
+                                          _EGLImage *img)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_image *dri2_img = dri2_egl_image(img);
@@ -944,6 +944,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
    .post_sub_buffer = dri2_fallback_post_sub_buffer,
    .copy_buffers = dri2_fallback_copy_buffers,
    .query_buffer_age = dri2_wl_query_buffer_age,
+   .create_wayland_buffer_from_image = dri2_wl_create_wayland_buffer_from_image,
 };
 
 EGLBoolean
@@ -960,9 +961,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
 
    loader_set_logger(_eglLog);
 
-   drv->API.CreateWaylandBufferFromImageWL =
-      dri2_wl_create_wayland_buffer_from_image_wl;
-
    dri2_dpy = calloc(1, sizeof *dri2_dpy);
    if (!dri2_dpy)
       return _eglError(EGL_BAD_ALLOC, "eglInitialize");
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index f6378f4..e41758b 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1005,6 +1005,7 @@ static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = {
    .post_sub_buffer = dri2_fallback_post_sub_buffer,
    .copy_buffers = dri2_x11_copy_buffers,
    .query_buffer_age = dri2_fallback_query_buffer_age,
+   .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image,
 };
 
 static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
@@ -1020,6 +1021,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
    .post_sub_buffer = dri2_x11_post_sub_buffer,
    .copy_buffers = dri2_x11_copy_buffers,
    .query_buffer_age = dri2_fallback_query_buffer_age,
+   .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image,
 };
 
 static EGLBoolean
-- 
1.8.5.3



More information about the mesa-dev mailing list