egl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not driver
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>
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 9e5b956..722131c 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1487,6 +1487,14 @@
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 @@
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 f43a08b..104b865 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;
@@ -128,6 +130,9 @@
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 @@
{
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 5ff80d0..e21ba13 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -652,6 +652,7 @@
.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 b4e472d..1459e68 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -454,6 +454,7 @@
.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 c6031f0..78a3ae0 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -686,9 +686,9 @@
}
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 @@
.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 @@
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 @@
.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 @@
.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