[Mesa-dev] [PATCH 1/3] st/egl: Hook up eglSwapInterval
Fredrik Höglund
fredrik at kde.org
Thu Mar 8 13:22:34 PST 2012
---
.../state_trackers/egl/common/egl_g3d_api.c | 21 ++++++++++++++++++++
src/gallium/state_trackers/egl/common/native.h | 5 ++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
index 58e772f..0d45bec 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -308,6 +308,10 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
return NULL;
}
+ /* Initialize the swap interval */
+ if (nsurf->swap_interval)
+ nsurf->swap_interval(nsurf, gsurf->base.SwapInterval);
+
nsurf->user_data = &gsurf->base;
gsurf->native = nsurf;
@@ -655,6 +659,22 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
}
static EGLBoolean
+egl_g3d_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval)
+{
+ interval = CLAMP(interval, surf->Config->MinSwapInterval, surf->Config->MaxSwapInterval);
+
+ if (surf->SwapInterval != interval) {
+ struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+ surf->SwapInterval = interval;
+
+ if (gsurf->native && gsurf->native->swap_interval)
+ return gsurf->native->swap_interval(gsurf->native, interval);
+ }
+
+ return EGL_TRUE;
+}
+
+static EGLBoolean
egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
@@ -892,6 +912,7 @@ egl_g3d_init_driver_api(_EGLDriver *drv)
drv->API.MakeCurrent = egl_g3d_make_current;
drv->API.SwapBuffers = egl_g3d_swap_buffers;
drv->API.CopyBuffers = egl_g3d_copy_buffers;
+ drv->API.SwapInterval = egl_g3d_swap_interval;
drv->API.WaitClient = egl_g3d_wait_client;
drv->API.WaitNative = egl_g3d_wait_native;
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 312b079..2f7f2e2 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -146,6 +146,11 @@ struct native_surface {
* Wait until all native commands affecting the surface has been executed.
*/
void (*wait)(struct native_surface *nsurf);
+
+ /**
+ * Set the surface swap interval.
+ */
+ boolean (*swap_interval)(struct native_surface *nsurf, int interval);
};
/**
--
1.7.7.3
More information about the mesa-dev
mailing list