From 14d84707fc8361481ee52249133ab9a813cbf00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 19 Dec 2023 11:53:26 +0100 Subject: [PATCH] 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: 7649e2f3abd5 ("wayland/surface: Move buffer size check to meta_wayland_surface_commit") Part-of: --- src/wayland/meta-wayland-surface.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index b6126c4a2..75004a686 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -895,8 +895,6 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface) if (buffer) { - int committed_scale = surface->committed_state.scale; - MetaMultiTexture *committed_texture; g_autoptr (GError) error = NULL; g_clear_signal_handler (&pending->buffer_destroy_handler_id, @@ -918,7 +916,21 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface) 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) || (meta_multi_texture_get_height (committed_texture) % committed_scale != 0)) { @@ -948,15 +960,6 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface) 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))