From 673943d730a5800c033af119a98dff0112e9ed0e Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Fri, 31 Dec 2021 15:49:34 +0100 Subject: [PATCH] libweston/compositor: Cache buffer damage for synced subsurfaces The spec states: > Because buffer transformation changes and damage requests may be > interleaved in the protocol stream, it is impossible to determine > the actual mapping between surface and buffer damage until > wl_surface.commit time. Therefore, compositors wishing to take both > kinds of damage into account will have to accumulate damage from the > two requests separately and only transform from one to the other after > receiving the wl_surface.commit. For subsurfaces in sync mode, arguably the same is the case until the cached state gets applied eventually. Thus, in order to keep complexity to a sane level, just accumulate buffer damage and convert it only when the cached state gets applied. This mirrors how other compositors like Mutter implement cached damage and what the spec arguably should demand. Closes https://gitlab.freedesktop.org/wayland/weston/-/issues/446 Signed-off-by: Robert Mader (cherry picked from commit 933290e6eadb37a984dba78562f1e499a5f41679) --- libweston/compositor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index 1670c500..452d32f7 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4211,6 +4211,11 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub) &surface->pending.damage_surface); pixman_region32_clear(&surface->pending.damage_surface); + pixman_region32_union(&sub->cached.damage_buffer, + &sub->cached.damage_buffer, + &surface->pending.damage_buffer); + pixman_region32_clear(&surface->pending.damage_buffer); + if (surface->pending.newly_attached) { sub->cached.newly_attached = 1; weston_surface_state_set_buffer(&sub->cached, @@ -4233,8 +4238,6 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub) sub->cached.sx += surface->pending.sx; sub->cached.sy += surface->pending.sy; - apply_damage_buffer(&sub->cached.damage_surface, surface, &surface->pending); - sub->cached.buffer_viewport.changed |= surface->pending.buffer_viewport.changed; sub->cached.buffer_viewport.buffer =