From 75d398ed9309c0cb8179380bd317d8f935618df7 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Tue, 28 Jan 2014 17:03:03 -0800 Subject: [PATCH] egl/dri2: Dispatch eglSwapBuffersRegionNOK by display, not driver Add dri2_egl_display_vtbl::swap_buffers_region, set it for each platform, and let egl_dri2 dispatch eglSwapBuffersRegionNOK to that. This prepares for the EGL platform extensions. Reviewed-by: Ian Romanick Signed-off-by: Chad Versace --- src/egl/drivers/dri2/egl_dri2.c | 9 +++++++++ src/egl/drivers/dri2/egl_dri2.h | 4 ++++ 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 | 4 ++-- 7 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 3bf96ba111c..f52e68e600a 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1073,6 +1073,14 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *dpy, rects, n_rects); } +static EGLBoolean +dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, + EGLint numRects, const EGLint *rects) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); + return dri2_dpy->vtbl->swap_buffers_region(drv, dpy, surf, numRects, rects); +} + static EGLBoolean dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLNativePixmapType target) @@ -2118,6 +2126,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.SwapBuffersRegionNOK = dri2_swap_buffers_region; 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; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index a835f8ed320..167dd4e9d23 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -114,6 +114,10 @@ struct dri2_egl_display_vtbl { _EGLSurface *surface, const EGLint *rects, EGLint n_rects); + EGLBoolean (*swap_buffers_region)(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, EGLint numRects, + const EGLint *rects); + EGLBoolean (*copy_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLNativePixmapType target); diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h index f9f1a551bdb..b5eb5b73ad3 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_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, + EGLint numRects, const EGLint *rects) +{ + return EGL_FALSE; +} + static inline EGLBoolean dri2_fallback_copy_buffers(_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 4aac5f6c391..1fd60652832 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, + .swap_buffers_region = dri2_fallback_swap_buffers_region, .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 22832f498f5..b73e14055af 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, + .swap_buffers_region = dri2_fallback_swap_buffers_region, .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 bad696eae4e..06de900d0cc 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -966,6 +966,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, + .swap_buffers_region = dri2_fallback_swap_buffers_region, .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 200d888461c..7bf2c78742e 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, + .swap_buffers_region = dri2_fallback_swap_buffers_region, .copy_buffers = dri2_x11_copy_buffers, .query_buffer_age = dri2_fallback_query_buffer_age, }; @@ -1013,6 +1014,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, + .swap_buffers_region = dri2_x11_swap_buffers_region, .copy_buffers = dri2_x11_copy_buffers, .query_buffer_age = dri2_fallback_query_buffer_age, }; @@ -1022,7 +1024,6 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; - drv->API.SwapBuffersRegionNOK = NULL; drv->API.CreateImageKHR = NULL; drv->API.DestroyImageKHR = NULL; drv->API.CreateDRMImageMESA = NULL; @@ -1142,7 +1143,6 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) struct dri2_egl_display *dri2_dpy; drv->API.CreateImageKHR = dri2_x11_create_image_khr; - drv->API.SwapBuffersRegionNOK = dri2_x11_swap_buffers_region; drv->API.PostSubBufferNV = dri2_x11_post_sub_buffer; dri2_dpy = calloc(1, sizeof *dri2_dpy); -- 2.30.2