egl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not driver
authorChad Versace <chad.versace@linux.intel.com>
Wed, 29 Jan 2014 01:03:03 +0000 (17:03 -0800)
committerChad Versace <chad.versace@linux.intel.com>
Mon, 17 Mar 2014 22:39:22 +0000 (15:39 -0700)
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@linux.intel.com>
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/egl_dri2_fallbacks.h
src/egl/drivers/dri2/platform_android.c
src/egl/drivers/dri2/platform_drm.c
src/egl/drivers/dri2/platform_wayland.c
src/egl/drivers/dri2/platform_x11.c

index 9e5b956bc82de32082cf678294607efece60abb7..722131cb9343e3cf4bf916eca726a96d1d4a7dd6 100644 (file)
@@ -1487,6 +1487,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)
@@ -2151,6 +2159,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;
index f43a08bb830b9522c5464f51d33d76534052c409..104b86593f9c6bfad87976ff78c7606dd6075246 100644 (file)
@@ -75,6 +75,8 @@
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
+struct wl_buffer;
+
 struct dri2_egl_driver
 {
    _EGLDriver base;
@@ -128,6 +130,9 @@ 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
index 00e955a5e966014ddbeae80c10bb0b2c8f4fa185..80ed26d2fe5ff82a57db17be20fd4d98f74514ae 100644 (file)
@@ -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;
+}
index 5ff80d018e845c868d8a76fcd85efc47e4e29118..e21ba137f440e9b73cbb8ee0875c518de0e60c6a 100644 (file)
@@ -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
index b4e472d9142f1d28c6d4b4ec1875ad29d83416f5..1459e68d48c6094ada2b87a93dde1ea16f60a3f4 100644 (file)
@@ -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
index c6031f0fd1b1ee70929a2acf23ee2ee8234785aa..78a3ae0e94c327f365773efb3f4203916e68a097 100644 (file)
@@ -686,9 +686,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);
@@ -945,6 +945,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
@@ -961,9 +962,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");
index f6378f47ebf885e7940a8a20c1a8dfb35d79e018..e41758b644d73bdde105e63a568da29ad4555a12 100644 (file)
@@ -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