From 3f9e4f7a447daa0c53c010c78dff7f8143b9268f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 11 Aug 2021 15:19:26 +0200 Subject: [PATCH] surface: kill wlr_surface.previous This wlr_surface_state field was a special case because we don't want to save the whole current state: for instance, the wlr_buffer must not be saved or else wouldn't get released soon enough. Let's just inline the state fields we need instead. --- include/wlr/types/wlr_surface.h | 16 ++++++++++++---- types/wlr_surface.c | 10 +++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index cdf42222..a9859d7b 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -124,10 +124,9 @@ struct wlr_surface { /** * `current` contains the current, committed surface state. `pending` * accumulates state changes from the client between commits and shouldn't - * be accessed by the compositor directly. `previous` contains the state of - * the previous commit. + * be accessed by the compositor directly. */ - struct wlr_surface_state current, pending, previous; + struct wlr_surface_state current, pending; struct wl_list cached; // wlr_surface_state.cached_link @@ -150,9 +149,18 @@ struct wlr_surface { struct wl_list current_outputs; // wlr_surface_output::link + void *data; + + // private state + struct wl_listener renderer_destroy; - void *data; + struct { + int32_t scale; + enum wl_output_transform transform; + int width, height; + int buffer_width, buffer_height; + } previous; }; struct wlr_subsurface_state { diff --git a/types/wlr_surface.c b/types/wlr_surface.c index e9979bb1..2ac70921 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -444,7 +444,13 @@ static void surface_commit_state(struct wlr_surface *surface, surface->sy += next->dy; surface_update_damage(&surface->buffer_damage, &surface->current, next); - surface_state_copy(&surface->previous, &surface->current); + surface->previous.scale = surface->current.scale; + surface->previous.transform = surface->current.transform; + surface->previous.width = surface->current.width; + surface->previous.height = surface->current.height; + surface->previous.buffer_width = surface->current.buffer_width; + surface->previous.buffer_height = surface->current.buffer_height; + surface_state_move(&surface->current, next); if (invalid_buffer) { @@ -726,7 +732,6 @@ static void surface_handle_resource_destroy(struct wl_resource *resource) { wl_list_remove(&surface->renderer_destroy.link); surface_state_finish(&surface->pending); surface_state_finish(&surface->current); - surface_state_finish(&surface->previous); pixman_region32_fini(&surface->buffer_damage); pixman_region32_fini(&surface->opaque_region); pixman_region32_fini(&surface->input_region); @@ -766,7 +771,6 @@ struct wlr_surface *surface_create(struct wl_client *client, surface_state_init(&surface->current); surface_state_init(&surface->pending); - surface_state_init(&surface->previous); surface->pending.seq = 1; wl_signal_init(&surface->events.commit);