From b21c26a1c9b5f035eb69ede201980c82c256dabc Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 24 May 2022 20:41:22 +0200 Subject: output: add wlr_output_event_precommit.state --- include/wlr/types/wlr_output.h | 1 + types/output/output.c | 1 + types/wlr_output_damage.c | 4 +++- types/wlr_screencopy_v1.c | 13 ++++++++----- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 363df2bc..05275156 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -205,6 +205,7 @@ struct wlr_output_event_damage { struct wlr_output_event_precommit { struct wlr_output *output; struct timespec *when; + const struct wlr_output_state *state; }; struct wlr_output_event_commit { diff --git a/types/output/output.c b/types/output/output.c index 4bd4917a..a587edc1 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -703,6 +703,7 @@ bool wlr_output_commit(struct wlr_output *output) { struct wlr_output_event_precommit pre_event = { .output = output, .when = &now, + .state = &output->pending, }; wlr_signal_emit_safe(&output->events.precommit, &pre_event); diff --git a/types/wlr_output_damage.c b/types/wlr_output_damage.c index f9aabc31..0dfc30ca 100644 --- a/types/wlr_output_damage.c +++ b/types/wlr_output_damage.c @@ -47,9 +47,11 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { static void output_handle_precommit(struct wl_listener *listener, void *data) { struct wlr_output_damage *output_damage = wl_container_of(listener, output_damage, output_precommit); + const struct wlr_output_event_precommit *event = data; + const struct wlr_output_state *state = event->state; struct wlr_output *output = output_damage->output; - if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) { + if (state->committed & WLR_OUTPUT_STATE_BUFFER) { // TODO: find a better way to access this info without a precommit // handler output_damage->pending_attach_render = output->back_buffer != NULL; diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index c656a916..0b48fe3f 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -40,16 +40,18 @@ static struct screencopy_damage *screencopy_damage_find( return NULL; } -static void screencopy_damage_accumulate(struct screencopy_damage *damage) { +static void screencopy_damage_accumulate(struct screencopy_damage *damage, + const struct wlr_output_state *state) { struct pixman_region32 *region = &damage->damage; struct wlr_output *output = damage->output; - if (output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) { + if (state->committed & WLR_OUTPUT_STATE_DAMAGE) { // If the compositor submitted damage, copy it over - pixman_region32_union(region, region, &output->pending.damage); + pixman_region32_union(region, region, + (pixman_region32_t *) &state->damage); pixman_region32_intersect_rect(region, region, 0, 0, output->width, output->height); - } else if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) { + } else if (state->committed & WLR_OUTPUT_STATE_BUFFER) { // If the compositor did not submit damage but did submit a buffer // damage everything pixman_region32_union_rect(region, region, 0, 0, @@ -61,7 +63,8 @@ static void screencopy_damage_handle_output_precommit( struct wl_listener *listener, void *data) { struct screencopy_damage *damage = wl_container_of(listener, damage, output_precommit); - screencopy_damage_accumulate(damage); + const struct wlr_output_event_precommit *event = data; + screencopy_damage_accumulate(damage, event->state); } static void screencopy_damage_destroy(struct screencopy_damage *damage) { -- cgit v1.2.3