From 20404ed8bb3ccad39e8c1458d9b1468741c0bc72 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 11 Aug 2021 15:26:38 +0200 Subject: [PATCH] surface: drop surface_state_copy This function was weird because it copied some fields but not all. --- types/wlr_surface.c | 51 +++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 2ac70921..620a5256 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -259,7 +259,10 @@ static void surface_update_damage(pixman_region32_t *buffer_damage, } } -static void surface_state_copy(struct wlr_surface_state *state, +/** + * Append pending state to current state and clear pending state. + */ +static void surface_state_move(struct wlr_surface_state *state, struct wlr_surface_state *next) { state->width = next->width; state->height = next->height; @@ -275,16 +278,29 @@ static void surface_state_copy(struct wlr_surface_state *state, if (next->committed & WLR_SURFACE_STATE_BUFFER) { state->dx = next->dx; state->dy = next->dy; + next->dx = next->dy = 0; + + surface_state_set_buffer(state, next->buffer_resource); + surface_state_reset_buffer(next); + + if (next->buffer) { + wlr_buffer_unlock(state->buffer); + state->buffer = wlr_buffer_lock(next->buffer); + } + wlr_buffer_unlock(next->buffer); + next->buffer = NULL; } else { state->dx = state->dy = 0; } if (next->committed & WLR_SURFACE_STATE_SURFACE_DAMAGE) { pixman_region32_copy(&state->surface_damage, &next->surface_damage); + pixman_region32_clear(&next->surface_damage); } else { pixman_region32_clear(&state->surface_damage); } if (next->committed & WLR_SURFACE_STATE_BUFFER_DAMAGE) { pixman_region32_copy(&state->buffer_damage, &next->buffer_damage); + pixman_region32_clear(&next->buffer_damage); } else { pixman_region32_clear(&state->buffer_damage); } @@ -299,36 +315,11 @@ static void surface_state_copy(struct wlr_surface_state *state, } state->committed |= next->committed; - state->seq = next->seq; - state->cached_state_locks = next->cached_state_locks; -} - -/** - * Append pending state to current state and clear pending state. - */ -static void surface_state_move(struct wlr_surface_state *state, - struct wlr_surface_state *next) { - surface_state_copy(state, next); - - if (next->committed & WLR_SURFACE_STATE_BUFFER) { - if (next->buffer) { - wlr_buffer_unlock(state->buffer); - state->buffer = wlr_buffer_lock(next->buffer); - } - surface_state_set_buffer(state, next->buffer_resource); - surface_state_reset_buffer(next); - next->dx = next->dy = 0; - wlr_buffer_unlock(next->buffer); - next->buffer = NULL; - } - if (next->committed & WLR_SURFACE_STATE_SURFACE_DAMAGE) { - pixman_region32_clear(&next->surface_damage); - } - if (next->committed & WLR_SURFACE_STATE_BUFFER_DAMAGE) { - pixman_region32_clear(&next->buffer_damage); - } - next->committed = 0; + + state->seq = next->seq; + + state->cached_state_locks = next->cached_state_locks; next->cached_state_locks = 0; }