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

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


Add dri2_egl_display_vtbl::copy_buffers, set it for each
platform, and let egl_dri2 dispatch eglCopyBuffers 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           | 5 +++++
 src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 ++++++++
 src/egl/drivers/dri2/platform_android.c   | 1 +
 src/egl/drivers/dri2/platform_drm.c       | 1 +
 src/egl/drivers/dri2/platform_wayland.c   | 1 +
 src/egl/drivers/dri2/platform_x11.c       | 5 ++---
 7 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index f6fd94b..1874db3 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1072,6 +1072,14 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *dpy,
                                                    rects, n_rects);
 }
 
+static EGLBoolean
+dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+                  EGLNativePixmapType target)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->copy_buffers(drv, dpy, surf, target);
+}
+
 static EGLint
 dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
 {
@@ -2109,6 +2117,7 @@ _eglBuiltInDriverDRI2(const char *args)
    dri2_drv->base.API.SwapInterval = dri2_swap_interval;
    dri2_drv->base.API.SwapBuffers = dri2_swap_buffers;
    dri2_drv->base.API.SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
+   dri2_drv->base.API.CopyBuffers = dri2_copy_buffers,
    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;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 2adb862..3140b29 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -116,6 +116,11 @@ struct dri2_egl_display_vtbl {
    (*swap_buffers_with_damage)(_EGLDriver *drv, _EGLDisplay *dpy,
                                _EGLSurface *surface,
                                const EGLint *rects, EGLint n_rects);
+
+   EGLBoolean
+   (*copy_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+                   EGLNativePixmapType target);
+
    EGLint
    (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf);
 };
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
index f903998..f9f1a55 100644
--- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h
+++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
@@ -58,6 +58,14 @@ dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *dpy,
    return EGL_FALSE;
 }
 
+static inline EGLBoolean
+dri2_fallback_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy,
+                           _EGLSurface *surf,
+                           EGLNativePixmapType target)
+{
+   return EGL_FALSE;
+}
+
 static inline EGLint
 dri2_fallback_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy,
                                _EGLSurface *surf)
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index d60e54e..8b8cd11 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -648,6 +648,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
    .swap_interval = dri2_fallback_swap_interval,
    .swap_buffers = droid_swap_buffers,
    .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .copy_buffers = dri2_fallback_copy_buffers,
    .query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 45c856b..5f52332 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -450,6 +450,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
    .swap_interval = dri2_fallback_swap_interval,
    .swap_buffers = dri2_drm_swap_buffers,
    .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .copy_buffers = dri2_fallback_copy_buffers,
    .query_buffer_age = dri2_drm_query_buffer_age,
 };
 
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index c2b39d6..0a7e628 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -965,6 +965,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
    .swap_interval = dri2_wl_swap_interval,
    .swap_buffers = dri2_wl_swap_buffers,
    .swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
+   .copy_buffers = dri2_fallback_copy_buffers,
    .query_buffer_age = dri2_wl_query_buffer_age,
 };
 
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 2427d6a..200d888 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1000,6 +1000,7 @@ static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = {
    .destroy_surface = dri2_x11_destroy_surface,
    .swap_interval = dri2_fallback_swap_interval,
    .swap_buffers = dri2_x11_swap_buffers,
+   .copy_buffers = dri2_x11_copy_buffers,
    .query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
@@ -1012,6 +1013,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
    .swap_interval = dri2_x11_swap_interval,
    .swap_buffers = dri2_x11_swap_buffers,
    .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
+   .copy_buffers = dri2_x11_copy_buffers,
    .query_buffer_age = dri2_fallback_query_buffer_age,
 };
 
@@ -1020,8 +1022,6 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp)
 {
    struct dri2_egl_display *dri2_dpy;
 
-   drv->API.CopyBuffers = dri2_x11_copy_buffers;
-
    drv->API.SwapBuffersRegionNOK = NULL;
    drv->API.CreateImageKHR  = NULL;
    drv->API.DestroyImageKHR = NULL;
@@ -1141,7 +1141,6 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
 {
    struct dri2_egl_display *dri2_dpy;
 
-   drv->API.CopyBuffers = dri2_x11_copy_buffers;
    drv->API.CreateImageKHR = dri2_x11_create_image_khr;
    drv->API.SwapBuffersRegionNOK = dri2_x11_swap_buffers_region;
    drv->API.PostSubBufferNV = dri2_x11_post_sub_buffer;
-- 
1.8.5.3



More information about the mesa-dev mailing list