egl/dri2: Dispatch eglSwapInterval by display, not driver
authorChad Versace <chad.versace@linux.intel.com>
Tue, 28 Jan 2014 20:34:19 +0000 (12:34 -0800)
committerChad Versace <chad.versace@linux.intel.com>
Mon, 17 Mar 2014 22:36:03 +0000 (15:36 -0700)
Add dri2_egl_display_vtbl::swap_interval, set it for each platform, and
let egl_dri2 dispatch eglSwapInterval to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
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 [new file with mode: 0644]
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 7e5fdc0f9a9e36f14ae961b06f0315ec1eabe2bd..e1a8e1e449068cf35b7ee8adcd262bbc23805408 100644 (file)
@@ -1013,6 +1013,14 @@ dri2_get_proc_address(_EGLDriver *drv, const char *procname)
    return dri2_drv->get_proc_address(procname);
 }
 
+static EGLBoolean
+dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+                   EGLint interval)
+{
+   struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+   return dri2_dpy->vtbl->swap_interval(drv, dpy, surf, interval);
+}
+
 static EGLBoolean
 dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
 {
@@ -2036,6 +2044,7 @@ _eglBuiltInDriverDRI2(const char *args)
    dri2_drv->base.API.WaitNative = dri2_wait_native;
    dri2_drv->base.API.BindTexImage = dri2_bind_tex_image;
    dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
+   dri2_drv->base.API.SwapInterval = dri2_swap_interval;
    dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
    dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
 #ifdef HAVE_DRM_PLATFORM
index 4da0c5b34666be09ebf76e4212750938f0d1e854..9f785c1c9505fb3920ad7de897fed69f43cf2bc3 100644 (file)
@@ -86,6 +86,9 @@ struct dri2_egl_driver
 
 struct dri2_egl_display_vtbl {
    int (*authenticate)(_EGLDisplay *disp, uint32_t id);
+
+   EGLBoolean (*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy,
+                               _EGLSurface *surf, EGLint interval);
 };
 
 struct dri2_egl_display
diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h
new file mode 100644 (file)
index 0000000..e09a3b8
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#pragma once
+
+#include "egltypedefs.h"
+
+static inline EGLBoolean
+dri2_fallback_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
+                            _EGLSurface *surf, EGLint interval)
+{
+   return EGL_FALSE;
+}
index 3a8f6bbe8d7382c2ca00730dc1576b3e1820cfb2..c2786b0561729cac7f60208520d3b9be0e849a8e 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "loader.h"
 #include "egl_dri2.h"
+#include "egl_dri2_fallbacks.h"
 #include "gralloc_drm.h"
 
 static int
@@ -654,6 +655,7 @@ droid_log(EGLint level, const char *msg)
 
 static struct dri2_egl_display_vtbl droid_display_vtbl = {
    .authenticate = NULL,
+   .swap_interval = dri2_fallback_swap_interval,
 };
 
 EGLBoolean
index 9d3158ce72f1b015aece801e6a00a4217a2f0d67..45f8ae6f630bd8d2755559d565cfcd49cbcd796c 100644 (file)
@@ -36,6 +36,7 @@
 #include <unistd.h>
 
 #include "egl_dri2.h"
+#include "egl_dri2_fallbacks.h"
 #include "loader.h"
 
 static struct gbm_bo *
@@ -442,6 +443,7 @@ dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id)
 
 static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
    .authenticate = dri2_drm_authenticate,
+   .swap_interval = dri2_fallback_swap_interval,
 };
 
 EGLBoolean
index 6a75355b587ad37f0b8af474931b50a862d7e082..518d0232adddfd47209907dbda5a42c1cdc28634 100644 (file)
@@ -36,6 +36,7 @@
 #include <xf86drm.h>
 
 #include "egl_dri2.h"
+#include "egl_dri2_fallbacks.h"
 #include "loader.h"
 
 #include <wayland-client.h>
@@ -958,6 +959,7 @@ dri2_wl_setup_swap_interval(struct dri2_egl_display *dri2_dpy)
 
 static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
    .authenticate = dri2_wl_authenticate,
+   .swap_interval = dri2_wl_swap_interval,
 };
 
 EGLBoolean
@@ -978,7 +980,6 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
    drv->API.DestroySurface = dri2_wl_destroy_surface;
    drv->API.SwapBuffers = dri2_wl_swap_buffers;
    drv->API.SwapBuffersWithDamageEXT = dri2_wl_swap_buffers_with_damage;
-   drv->API.SwapInterval = dri2_wl_swap_interval;
    drv->API.Terminate = dri2_wl_terminate;
    drv->API.QueryBufferAge = dri2_wl_query_buffer_age;
 
index ea871fd810cc9e3a521c9e3b1940694a8f70aaab..9bc2afba830bb7c2c9605ef04ed7c365b0f8b017 100644 (file)
@@ -40,6 +40,7 @@
 #include <sys/stat.h>
 
 #include "egl_dri2.h"
+#include "egl_dri2_fallbacks.h"
 
 static EGLBoolean
 dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
@@ -993,10 +994,12 @@ dri2_x11_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
 
 static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = {
    .authenticate = NULL,
+   .swap_interval = dri2_fallback_swap_interval,
 };
 
 static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
    .authenticate = dri2_x11_authenticate,
+   .swap_interval = dri2_x11_swap_interval,
 };
 
 static EGLBoolean
@@ -1139,7 +1142,6 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
    drv->API.CreateImageKHR = dri2_x11_create_image_khr;
    drv->API.SwapBuffersRegionNOK = dri2_x11_swap_buffers_region;
    drv->API.PostSubBufferNV = dri2_x11_post_sub_buffer;
-   drv->API.SwapInterval = dri2_x11_swap_interval;
 
    dri2_dpy = calloc(1, sizeof *dri2_dpy);
    if (!dri2_dpy)