output: expose wlr_output_state_finish()

Same as the original function, but check for the bitfield before
calling pixman_region32_fini(), because that function expects an
initialized region.
Simon Ser 2 years ago committed by Isaac Freund
parent d25ab03326
commit 4629d0ef40

@ -543,6 +543,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor); void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
void wlr_output_state_finish(struct wlr_output_state *state);
void wlr_output_state_set_enabled(struct wlr_output_state *state, void wlr_output_state_set_enabled(struct wlr_output_state *state,
bool enabled); bool enabled);
void wlr_output_state_set_mode(struct wlr_output_state *state, void wlr_output_state_set_mode(struct wlr_output_state *state,

@ -324,16 +324,6 @@ static void output_state_init(struct wlr_output_state *state) {
pixman_region32_init(&state->damage); pixman_region32_init(&state->damage);
} }
static void output_state_finish(struct wlr_output_state *state) {
wlr_buffer_unlock(state->buffer);
// struct wlr_buffer is ref'counted, so the pointer may remain valid after
// wlr_buffer_unlock(). Reset the field to NULL to ensure nobody mistakenly
// reads it after output_state_finish().
state->buffer = NULL;
pixman_region32_fini(&state->damage);
free(state->gamma_lut);
}
static void output_state_move(struct wlr_output_state *dst, static void output_state_move(struct wlr_output_state *dst,
struct wlr_output_state *src) { struct wlr_output_state *src) {
*dst = *src; *dst = *src;
@ -425,7 +415,7 @@ void wlr_output_destroy(struct wlr_output *output) {
free(output->model); free(output->model);
free(output->serial); free(output->serial);
output_state_finish(&output->pending); wlr_output_state_finish(&output->pending);
if (output->impl && output->impl->destroy) { if (output->impl && output->impl->destroy) {
output->impl->destroy(output); output->impl->destroy(output);
@ -887,7 +877,7 @@ bool wlr_output_commit(struct wlr_output *output) {
} }
bool ok = wlr_output_commit_state(output, &state); bool ok = wlr_output_commit_state(output, &state);
output_state_finish(&state); wlr_output_state_finish(&state);
return ok; return ok;
} }

@ -1,5 +1,18 @@
#include <stdlib.h>
#include "types/wlr_output.h" #include "types/wlr_output.h"
void wlr_output_state_finish(struct wlr_output_state *state) {
wlr_buffer_unlock(state->buffer);
// struct wlr_buffer is ref'counted, so the pointer may remain valid after
// wlr_buffer_unlock(). Reset the field to NULL to ensure nobody mistakenly
// reads it after output_state_finish().
state->buffer = NULL;
if (state->committed & WLR_OUTPUT_STATE_DAMAGE) {
pixman_region32_fini(&state->damage);
}
free(state->gamma_lut);
}
void wlr_output_state_set_enabled(struct wlr_output_state *state, void wlr_output_state_set_enabled(struct wlr_output_state *state,
bool enabled) { bool enabled) {
state->committed |= WLR_OUTPUT_STATE_ENABLED; state->committed |= WLR_OUTPUT_STATE_ENABLED;

Loading…
Cancel
Save