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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3662>
This commit is contained in:
Robert Mader 2024-03-14 18:28:20 +01:00 committed by Marge Bot
parent f62e30b761
commit f1a4758ce2

View File

@ -388,6 +388,7 @@ meta_window_actor_wayland_get_scanout_candidate (MetaWindowActor *actor)
MetaSurfaceActorWayland *bg_surface_actor = NULL; MetaSurfaceActorWayland *bg_surface_actor = NULL;
MetaWaylandSurface *bg_surface; MetaWaylandSurface *bg_surface;
MetaWaylandBuffer *buffer; MetaWaylandBuffer *buffer;
MetaWaylandSinglePixelBuffer *sp_buffer;
clutter_actor_iter_init (&iter, surface_container); clutter_actor_iter_init (&iter, surface_container);
while (clutter_actor_iter_next (&iter, &child_actor)) while (clutter_actor_iter_next (&iter, &child_actor))
@ -402,16 +403,12 @@ meta_window_actor_wayland_get_scanout_candidate (MetaWindowActor *actor)
bg_surface = meta_surface_actor_wayland_get_surface (bg_surface_actor); bg_surface = meta_surface_actor_wayland_get_surface (bg_surface_actor);
buffer = meta_wayland_surface_get_buffer (bg_surface); 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); sp_buffer = buffer->single_pixel.single_pixel_buffer;
if (sp_buffer && if (sp_buffer &&
meta_wayland_single_pixel_buffer_is_opaque_black (sp_buffer)) meta_wayland_single_pixel_buffer_is_opaque_black (sp_buffer))
return topmost_surface_actor; return topmost_surface_actor;
} }
}
if (meta_surface_actor_is_opaque (topmost_surface_actor) && if (meta_surface_actor_is_opaque (topmost_surface_actor) &&
clutter_actor_get_paint_box (CLUTTER_ACTOR (actor), &window_box) && clutter_actor_get_paint_box (CLUTTER_ACTOR (actor), &window_box) &&