From f1a4758ce2ba01d53edc0b97a39c2d907b73decb Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Thu, 14 Mar 2024 18:28:20 +0100 Subject: [PATCH] window-actor/wayland: Access single pixel buffer object directly Using `meta_wayland_single_pixel_buffer_from_buffer()` can fail if the buffer resource is already gone. Given that we release the buffer immediately, that is actually expected - but the client this was tested with did/does not do so. This made the single pixel black bar optimization fail for GstWaylandsink, while working for the mpv Wayland backend. Access the object directly, which is both faster and works as long as the buffer is alive. Fixes: ed50cbbfe4 (window-actor/wayland: Update scanout candidate check) Part-of: --- src/compositor/meta-window-actor-wayland.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/compositor/meta-window-actor-wayland.c b/src/compositor/meta-window-actor-wayland.c index a943b98e5..24597bbf7 100644 --- a/src/compositor/meta-window-actor-wayland.c +++ b/src/compositor/meta-window-actor-wayland.c @@ -388,6 +388,7 @@ meta_window_actor_wayland_get_scanout_candidate (MetaWindowActor *actor) MetaSurfaceActorWayland *bg_surface_actor = NULL; MetaWaylandSurface *bg_surface; MetaWaylandBuffer *buffer; + MetaWaylandSinglePixelBuffer *sp_buffer; clutter_actor_iter_init (&iter, surface_container); while (clutter_actor_iter_next (&iter, &child_actor)) @@ -402,15 +403,11 @@ meta_window_actor_wayland_get_scanout_candidate (MetaWindowActor *actor) bg_surface = meta_surface_actor_wayland_get_surface (bg_surface_actor); buffer = meta_wayland_surface_get_buffer (bg_surface); - if (buffer->type == META_WAYLAND_BUFFER_TYPE_SINGLE_PIXEL) - { - MetaWaylandSinglePixelBuffer *sp_buffer; - sp_buffer = meta_wayland_single_pixel_buffer_from_buffer (buffer); - if (sp_buffer && - meta_wayland_single_pixel_buffer_is_opaque_black (sp_buffer)) - return topmost_surface_actor; - } + sp_buffer = buffer->single_pixel.single_pixel_buffer; + if (sp_buffer && + meta_wayland_single_pixel_buffer_is_opaque_black (sp_buffer)) + return topmost_surface_actor; } if (meta_surface_actor_is_opaque (topmost_surface_actor) &&