From 5a690a168adc964f7454cb2c25b3916be21b1e72 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Thu, 24 Aug 2023 21:36:42 +0200 Subject: vo_dmabuf_wayland: unmap osd surface when not needed Attaching a NULL buffer unmaps the surface, allowing compositors to skip blending the empty buffer. Closes #12236 --- video/out/vo_dmabuf_wayland.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'video') diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index 43c94882f2..18555e75f5 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -94,6 +94,8 @@ struct priv { int osd_shm_width; int osd_shm_stride; int osd_shm_height; + bool osd_surface_is_mapped; + bool osd_surface_has_contents; struct osd_buffer *osd_buffer; struct mp_draw_sub_cache *osd_cache; @@ -553,6 +555,8 @@ static bool draw_osd(struct vo *vo, struct mp_image *cur, double pts) MP_ARRAY_SIZE(act_rc), &num_act_rc, mod_rc, MP_ARRAY_SIZE(mod_rc), &num_mod_rc); + p->osd_surface_has_contents = num_act_rc > 0; + if (!osd || !num_mod_rc) goto done; @@ -599,10 +603,14 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) buf->image->h); if (osd_buf && osd_buf->buffer) { - if (draw_osd(vo, &osd_buf->image, pts)) { + if (draw_osd(vo, &osd_buf->image, pts) && p->osd_surface_has_contents) { wl_surface_attach(wl->osd_surface, osd_buf->buffer, 0, 0); wl_surface_damage_buffer(wl->osd_surface, 0, 0, osd_buf->image.w, osd_buf->image.h); + p->osd_surface_is_mapped = true; + } else if (!p->osd_surface_has_contents && p->osd_surface_is_mapped) { + wl_surface_attach(wl->osd_surface, NULL, 0, 0); + p->osd_surface_is_mapped = false; } } } -- cgit v1.2.3