diff options
author | Dudemanguy <random342@airmail.cc> | 2022-04-06 23:01:21 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2022-04-11 18:14:22 +0000 |
commit | 2c2a856f2512843d12931a1f6f5b15ea76db8502 (patch) | |
tree | 075f6fd3e2d1b44b01b86861bc03f4a56ae90137 /video/out/opengl/context_wayland.c | |
parent | 5edc49adc96b45479383483a0d53db7f48d1e362 (diff) | |
download | mpv-2c2a856f2512843d12931a1f6f5b15ea76db8502.tar.bz2 mpv-2c2a856f2512843d12931a1f6f5b15ea76db8502.tar.xz |
wayland: unify visibility checking code
A bit of a personal pet peeve. vulkan, opengl, and wlshm all had
different methods for doing wayland's "check for visibility before
drawing" thing. The specific backend doesn't matter in this case and the
logic should all be shared. Additionally, the external swapchain that
the opengl code on wayland uses is done away with and it instead copies
vulkan by using a param. This keeps things looking more uniform across
backends and also makes it easier to extend to other platforms (see the
next couple of commits).
Diffstat (limited to 'video/out/opengl/context_wayland.c')
-rw-r--r-- | video/out/opengl/context_wayland.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c index a7a8f4f3b4..98d702c386 100644 --- a/video/out/opengl/context_wayland.c +++ b/video/out/opengl/context_wayland.c @@ -54,19 +54,13 @@ static void resize(struct ra_ctx *ctx) wl->vo->dheight = height; } -static bool wayland_egl_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo) +static bool wayland_egl_check_visible(struct ra_ctx *ctx) { - struct ra_ctx *ctx = sw->ctx; - struct vo_wayland_state *wl = ctx->vo->wl; - bool render = !wl->hidden || wl->opts->disable_vsync; - wl->frame_wait = true; - - return render ? ra_gl_ctx_start_frame(sw, out_fbo) : false; + return vo_wayland_check_visible(ctx->vo); } -static void wayland_egl_swap_buffers(struct ra_swapchain *sw) +static void wayland_egl_swap_buffers(struct ra_ctx *ctx) { - struct ra_ctx *ctx = sw->ctx; struct priv *p = ctx->priv; struct vo_wayland_state *wl = ctx->vo->wl; @@ -79,11 +73,6 @@ static void wayland_egl_swap_buffers(struct ra_swapchain *sw) vo_wayland_sync_swap(wl); } -static const struct ra_swapchain_fns wayland_egl_swapchain = { - .start_frame = wayland_egl_start_frame, - .swap_buffers = wayland_egl_swap_buffers, -}; - static void wayland_egl_get_vsync(struct ra_ctx *ctx, struct vo_vsync_info *info) { struct vo_wayland_state *wl = ctx->vo->wl; @@ -116,8 +105,9 @@ static bool egl_create_context(struct ra_ctx *ctx) mpegl_load_functions(&p->gl, wl->log); struct ra_gl_ctx_params params = { - .external_swapchain = &wayland_egl_swapchain, - .get_vsync = &wayland_egl_get_vsync, + .check_visible = wayland_egl_check_visible, + .swap_buffers = wayland_egl_swap_buffers, + .get_vsync = wayland_egl_get_vsync, }; if (!ra_gl_ctx_init(ctx, &p->gl, params)) |