diff options
author | Emil Velikov <[email protected]> | 2017-08-05 00:25:46 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-08-10 19:23:31 +0100 |
commit | 47b06f5821551375e98699ca8ea41d06dc4ba0e9 (patch) | |
tree | c222901e59d22e1af94f0495413837515c43e5a1 /src/egl/drivers/dri2/egl_dri2.c | |
parent | 4d9b0dcccb81ad10113d9aef52b4c84496e879f1 (diff) |
egl: add dri2_setup_swap_interval helper
The current two implementations - X11 and Wayland were identical,
barrind the upper limit.
Instead of having same code twice - introduce a helper and pass the
limit as an argument.
Thus as Android/DRM/others get support - they only need to call the
function ;-)
v2: Rebase on top of keeping ::swap_available
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]> (v1)
Diffstat (limited to 'src/egl/drivers/dri2/egl_dri2.c')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index f0d1ded4083..f584740751a 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -729,6 +729,41 @@ dri2_setup_screen(_EGLDisplay *disp) } } +void +dri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; + + /* Allow driconf to override applications.*/ + if (dri2_dpy->config) + dri2_dpy->config->configQueryi(dri2_dpy->dri_screen, + "vblank_mode", &vblank_mode); + switch (vblank_mode) { + case DRI_CONF_VBLANK_NEVER: + dri2_dpy->min_swap_interval = 0; + dri2_dpy->max_swap_interval = 0; + dri2_dpy->default_swap_interval = 0; + break; + case DRI_CONF_VBLANK_ALWAYS_SYNC: + dri2_dpy->min_swap_interval = 1; + dri2_dpy->max_swap_interval = max_swap_interval; + dri2_dpy->default_swap_interval = 1; + break; + case DRI_CONF_VBLANK_DEF_INTERVAL_0: + dri2_dpy->min_swap_interval = 0; + dri2_dpy->max_swap_interval = max_swap_interval; + dri2_dpy->default_swap_interval = 0; + break; + default: + case DRI_CONF_VBLANK_DEF_INTERVAL_1: + dri2_dpy->min_swap_interval = 0; + dri2_dpy->max_swap_interval = max_swap_interval; + dri2_dpy->default_swap_interval = 1; + break; + } +} + /* All platforms but DRM call this function to create the screen and populate * the driver_configs. DRM inherits that information from its display - GBM. */ |