wayland/surface: Move committed buffer size check out of if (buffer)

A surface commit may change the buffer scale but not attach a new
buffer. In that case, the size of the previously attached buffer needs
to be consistent with the new buffer scale.

Fixes: 7649e2f3ab ("wayland/surface: Move buffer size check to meta_wayland_surface_commit")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3466>
This commit is contained in:
Michel Dänzer 2023-12-19 11:53:26 +01:00 committed by Michel Dänzer
parent 17640d9c98
commit 14d84707fc

View File

@ -895,8 +895,6 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface)
if (buffer) if (buffer)
{ {
int committed_scale = surface->committed_state.scale;
MetaMultiTexture *committed_texture;
g_autoptr (GError) error = NULL; g_autoptr (GError) error = NULL;
g_clear_signal_handler (&pending->buffer_destroy_handler_id, g_clear_signal_handler (&pending->buffer_destroy_handler_id,
@ -918,7 +916,21 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface)
return; return;
} }
committed_texture = surface->committed_state.texture; pending->texture = g_object_ref (surface->committed_state.texture);
g_object_ref (buffer);
meta_wayland_buffer_inc_use_count (buffer);
}
else if (pending->newly_attached)
{
g_clear_object (&surface->committed_state.texture);
}
if (surface->committed_state.texture)
{
MetaMultiTexture *committed_texture = surface->committed_state.texture;
int committed_scale = surface->committed_state.scale;
if ((meta_multi_texture_get_width (committed_texture) % committed_scale != 0) || if ((meta_multi_texture_get_width (committed_texture) % committed_scale != 0) ||
(meta_multi_texture_get_height (committed_texture) % committed_scale != 0)) (meta_multi_texture_get_height (committed_texture) % committed_scale != 0))
{ {
@ -948,15 +960,6 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface)
committed_scale); committed_scale);
} }
} }
pending->texture = g_object_ref (committed_texture);
g_object_ref (buffer);
meta_wayland_buffer_inc_use_count (buffer);
}
else if (pending->newly_attached)
{
g_clear_object (&surface->committed_state.texture);
} }
if (meta_wayland_surface_is_synchronized (surface)) if (meta_wayland_surface_is_synchronized (surface))