diff options
author | Robert Mader <robert.mader@collabora.com> | 2023-08-24 21:36:42 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-08-28 18:16:10 +0000 |
commit | 5a690a168adc964f7454cb2c25b3916be21b1e72 (patch) | |
tree | 82b340f1e55860b0261881fcd415d8d9073354d2 /video | |
parent | 3e612c07f46d97399447e090399c382d227d6079 (diff) | |
download | mpv-5a690a168adc964f7454cb2c25b3916be21b1e72.tar.bz2 mpv-5a690a168adc964f7454cb2c25b3916be21b1e72.tar.xz |
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
Diffstat (limited to 'video')
-rw-r--r-- | video/out/vo_dmabuf_wayland.c | 10 |
1 files changed, 9 insertions, 1 deletions
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; } } } |