summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2017-12-05 08:26:24 +0000
committerRostislav Pehlivanov <atomnuker@gmail.com>2017-12-05 08:26:24 +0000
commita743fef837bcab206b1e576db7e7a64b02890449 (patch)
tree875105fee109e9e6604af5d117c84e8e883c9375 /video/out/wayland_common.c
parent713668b99a201a3ca33780d64bd4072ed966f406 (diff)
downloadmpv-a743fef837bcab206b1e576db7e7a64b02890449.tar.bz2
mpv-a743fef837bcab206b1e576db7e7a64b02890449.tar.xz
vo: add support for externally driven renderloop and make wayland use it
Fixes display-sync (though if you change virtual desktops you'll need to seek to re-enable display-sync) partially under wayland. As an advantage, rendering is completely disabled if you change desktops or alt+tab so you lose no performance if you leave mpv running elsewhere as long as it isn't visible. This could also be ported to other VOs which supports it.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r--video/out/wayland_common.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index a0e734703b..19adf01df0 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -767,6 +767,9 @@ static void frame_callback(void *data, struct wl_callback *callback, uint32_t ti
wl->frame_callback = wl_surface_frame(wl->surface);
wl_callback_add_listener(wl->frame_callback, &frame_listener, wl);
+
+ if (!vo_render_frame_external(wl->vo))
+ wl_surface_commit(wl->surface);
}
static const struct wl_callback_listener frame_listener = {
@@ -785,6 +788,7 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id
wl->surface = wl_compositor_create_surface(wl->compositor);
wl->cursor_surface = wl_compositor_create_surface(wl->compositor);
wl_surface_add_listener(wl->surface, &surface_listener, wl);
+ vo_enable_external_renderloop(wl->vo);
wl->frame_callback = wl_surface_frame(wl->surface);
wl_callback_add_listener(wl->frame_callback, &frame_listener, wl);
}
@@ -1295,6 +1299,17 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
*(char ***)arg = get_displays_spanned(wl);
return VO_TRUE;
}
+ case VOCTRL_PAUSE: {
+ wl_callback_destroy(wl->frame_callback);
+ wl->frame_callback = NULL;
+ vo_disable_external_renderloop(wl->vo);
+ return VO_TRUE;
+ }
+ case VOCTRL_RESUME: {
+ vo_enable_external_renderloop(wl->vo);
+ frame_callback(wl, NULL, 0);
+ return VO_TRUE;
+ }
case VOCTRL_GET_UNFS_WINDOW_SIZE: {
int *s = arg;
s[0] = mp_rect_w(wl->geometry)*wl->scaling;