diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2015-03-22 02:47:27 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-23 21:53:32 +0100 |
commit | 3714430cdf0c1515da5dea9e3c098f02802a45ee (patch) | |
tree | d8b2c6071e959d3374cf4d1b68fc268dad14a161 /video/out/wayland_common.c | |
parent | dd08aa7364e061132b795f6e55aaeeb2e4854b8e (diff) | |
download | mpv-3714430cdf0c1515da5dea9e3c098f02802a45ee.tar.bz2 mpv-3714430cdf0c1515da5dea9e3c098f02802a45ee.tar.xz |
vo_wayland: share frame callbacks.
Define frame callback logic in wayland_common.c
As this should be used by opengl renderer as well.
Preferably drawing should be skipped entierly when no frame callbacks
are received. However, for now only swap buffers is skipped.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r-- | video/out/wayland_common.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 224a60d1e0..5ddd1ad54c 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -59,6 +59,8 @@ static void schedule_resize(struct vo_wayland_state *wl, static void vo_wayland_fullscreen (struct vo *vo); +static const struct wl_callback_listener frame_listener; + static const struct mp_keymap keymap[] = { // special keys {XKB_KEY_Pause, MP_KEY_PAUSE}, {XKB_KEY_Escape, MP_KEY_ESC}, @@ -795,6 +797,30 @@ static void schedule_resize(struct vo_wayland_state *wl, wl->vo->dheight = height; } +static void frame_callback(void *data, + struct wl_callback *callback, + uint32_t time) +{ + struct vo_wayland_state *wl = data; + + if (callback) + wl_callback_destroy(callback); + + wl->frame.callback = wl_surface_frame(wl->window.video_surface); + + if (!wl->frame.callback) { + MP_ERR(wl, "wl_surface_frame failed\n"); + return; + } + + wl_callback_add_listener(wl->frame.callback, &frame_listener, wl); + wl->frame.pending = true; +} + +static const struct wl_callback_listener frame_listener = { + frame_callback +}; + static bool create_display (struct vo_wayland_state *wl) { if (wl->vo->probing && !getenv("XDG_RUNTIME_DIR")) @@ -878,6 +904,7 @@ static bool create_window (struct vo_wayland_state *wl) wl_shell_surface_set_class(wl->window.shell_surface, "mpv"); } + frame_callback(wl, NULL, 0); return true; } @@ -888,6 +915,9 @@ static void destroy_window (struct vo_wayland_state *wl) if (wl->window.video_surface) wl_surface_destroy(wl->window.video_surface); + + if (wl->frame.callback) + wl_callback_destroy(wl->frame.callback); } static bool create_cursor (struct vo_wayland_state *wl) |