summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/out/opengl/context_wayland.c36
-rw-r--r--video/out/vo_wlshm.c6
-rw-r--r--video/out/vulkan/context_wayland.c36
-rw-r--r--video/out/wayland_common.c14
-rw-r--r--video/out/wayland_common.h1
5 files changed, 54 insertions, 39 deletions
diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
index 2456de1b90..95ea9f65e0 100644
--- a/video/out/opengl/context_wayland.c
+++ b/video/out/opengl/context_wayland.c
@@ -119,16 +119,10 @@ static void resize(struct ra_ctx *ctx)
MP_VERBOSE(wl, "Handling resize on the egl side\n");
- const int32_t width = wl->scaling*mp_rect_w(wl->geometry);
- const int32_t height = wl->scaling*mp_rect_h(wl->geometry);
-
- if (!ctx->opts.want_alpha) {
- struct wl_region *region = wl_compositor_create_region(wl->compositor);
- wl_region_add(region, 0, 0, width, height);
- wl_surface_set_opaque_region(wl->surface, region);
- wl_region_destroy(region);
- }
+ const int32_t width = wl->scaling * mp_rect_w(wl->geometry);
+ const int32_t height = wl->scaling * mp_rect_h(wl->geometry);
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
if (p->egl_window)
@@ -296,6 +290,13 @@ static void wayland_egl_wait_events(struct ra_ctx *ctx, int64_t until_time_us)
vo_wayland_wait_events(ctx->vo, until_time_us);
}
+static void wayland_egl_update_render_opts(struct ra_ctx *ctx)
+{
+ struct vo_wayland_state *wl = ctx->vo->wl;
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
+ wl_surface_commit(wl->surface);
+}
+
static bool wayland_egl_init(struct ra_ctx *ctx)
{
if (!vo_wayland_init(ctx->vo)) {
@@ -307,12 +308,13 @@ static bool wayland_egl_init(struct ra_ctx *ctx)
}
const struct ra_ctx_fns ra_ctx_wayland_egl = {
- .type = "opengl",
- .name = "wayland",
- .reconfig = wayland_egl_reconfig,
- .control = wayland_egl_control,
- .wakeup = wayland_egl_wakeup,
- .wait_events = wayland_egl_wait_events,
- .init = wayland_egl_init,
- .uninit = wayland_egl_uninit,
+ .type = "opengl",
+ .name = "wayland",
+ .reconfig = wayland_egl_reconfig,
+ .control = wayland_egl_control,
+ .wakeup = wayland_egl_wakeup,
+ .wait_events = wayland_egl_wait_events,
+ .update_render_opts = wayland_egl_update_render_opts,
+ .init = wayland_egl_init,
+ .uninit = wayland_egl_uninit,
};
diff --git a/video/out/vo_wlshm.c b/video/out/vo_wlshm.c
index a517d0f09d..dbfa386789 100644
--- a/video/out/vo_wlshm.c
+++ b/video/out/vo_wlshm.c
@@ -201,11 +201,7 @@ static int resize(struct vo *vo)
const int32_t height = wl->scaling * mp_rect_h(wl->geometry);
struct buffer *buf;
- struct wl_region *region = wl_compositor_create_region(wl->compositor);
- wl_region_add(region, 0, 0, width, height);
- wl_surface_set_opaque_region(wl->surface, region);
- wl_region_destroy(region);
-
+ vo_wayland_set_opaque_region(wl, 0);
vo->want_redraw = true;
vo->dwidth = width;
vo->dheight = height;
diff --git a/video/out/vulkan/context_wayland.c b/video/out/vulkan/context_wayland.c
index 4af0e795ef..7e6beb3bdd 100644
--- a/video/out/vulkan/context_wayland.c
+++ b/video/out/vulkan/context_wayland.c
@@ -205,16 +205,10 @@ static bool resize(struct ra_ctx *ctx)
MP_VERBOSE(wl, "Handling resize on the vk side\n");
- const int32_t width = wl->scaling*mp_rect_w(wl->geometry);
- const int32_t height = wl->scaling*mp_rect_h(wl->geometry);
-
- if (!ctx->opts.want_alpha) {
- struct wl_region *region = wl_compositor_create_region(wl->compositor);
- wl_region_add(region, 0, 0, width, height);
- wl_surface_set_opaque_region(wl->surface, region);
- wl_region_destroy(region);
- }
+ const int32_t width = wl->scaling * mp_rect_w(wl->geometry);
+ const int32_t height = wl->scaling * mp_rect_h(wl->geometry);
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
bool ok = ra_vk_ctx_resize(ctx, width, height);
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
@@ -250,13 +244,21 @@ static void wayland_vk_wait_events(struct ra_ctx *ctx, int64_t until_time_us)
vo_wayland_wait_events(ctx->vo, until_time_us);
}
+static void wayland_vk_update_render_opts(struct ra_ctx *ctx)
+{
+ struct vo_wayland_state *wl = ctx->vo->wl;
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
+ wl_surface_commit(wl->surface);
+}
+
const struct ra_ctx_fns ra_ctx_vulkan_wayland = {
- .type = "vulkan",
- .name = "waylandvk",
- .reconfig = wayland_vk_reconfig,
- .control = wayland_vk_control,
- .wakeup = wayland_vk_wakeup,
- .wait_events = wayland_vk_wait_events,
- .init = wayland_vk_init,
- .uninit = wayland_vk_uninit,
+ .type = "vulkan",
+ .name = "waylandvk",
+ .reconfig = wayland_vk_reconfig,
+ .control = wayland_vk_control,
+ .wakeup = wayland_vk_wakeup,
+ .wait_events = wayland_vk_wait_events,
+ .update_render_opts = wayland_vk_update_render_opts,
+ .init = wayland_vk_init,
+ .uninit = wayland_vk_uninit,
};
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index ecea6fedeb..2d9e63a17d 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1612,6 +1612,20 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
return VO_NOTIMPL;
}
+void vo_wayland_set_opaque_region(struct vo_wayland_state *wl, int alpha)
+{
+ const int32_t width = wl->scaling * mp_rect_w(wl->geometry);
+ const int32_t height = wl->scaling * mp_rect_h(wl->geometry);
+ if (!alpha) {
+ struct wl_region *region = wl_compositor_create_region(wl->compositor);
+ wl_region_add(region, 0, 0, width, height);
+ wl_surface_set_opaque_region(wl->surface, region);
+ wl_region_destroy(region);
+ } else {
+ wl_surface_set_opaque_region(wl->surface, NULL);
+ }
+}
+
void vo_wayland_sync_clear(struct vo_wayland_state *wl)
{
struct vo_wayland_sync sync = {0, 0, 0, 0};
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index e54e3ff447..f2c1a31f66 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -153,6 +153,7 @@ void vo_wayland_uninit(struct vo *vo);
void vo_wayland_wakeup(struct vo *vo);
void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us);
void vo_wayland_wait_frame(struct vo_wayland_state *wl);
+void vo_wayland_set_opaque_region(struct vo_wayland_state *wl, int alpha);
void vo_wayland_sync_clear(struct vo_wayland_state *wl);
void wayland_sync_swap(struct vo_wayland_state *wl);
void vo_wayland_sync_shift(struct vo_wayland_state *wl);