From eadd5e0c0a3c4b24c25e6368ea0a8352a8fd0701 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Tue, 28 Jan 2014 17:03:03 -0800 Subject: [PATCH] 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 --- src/egl/drivers/dri2/egl_dri2.c | 9 +++++++++ src/egl/drivers/dri2/egl_dri2.h | 5 +++++ 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, 32 insertions(+), 6 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 9e5b956bc82..722131cb934 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -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; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index f43a08bb830..104b86593f9 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 @@ 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 00e955a5e96..80ed26d2fe5 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 5ff80d018e8..e21ba137f44 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 b4e472d9142..1459e68d48c 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 c6031f0fd1b..78a3ae0e94c 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -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"); diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index f6378f47ebf..e41758b644d 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 -- 2.30.2