From be050979684ae8779a56e4b0166cfb21d1935d35 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 22 Jun 2023 15:48:35 +0200 Subject: output: add wlr_output_state_init() This changes the semantics of wlr_output_state. Instead of having fields with uninitialized memory when missing from the committed bitflag, all fields are always initialized (and maybe NULL/empty), just like we do in wlr_surface_state. This reduces the chances of footguns when reading a field, and removes the need to check for the committed bitfield everywhere. A new wlr_output_state_init() function takes care of initializing the Pixman region. --- include/wlr/types/wlr_output.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index ad034982..aa3d7a18 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -88,10 +88,8 @@ struct wlr_output_state { uint32_t render_format; enum wl_output_subpixel subpixel; - // only valid if WLR_OUTPUT_STATE_BUFFER struct wlr_buffer *buffer; - // only valid if WLR_OUTPUT_STATE_MODE enum wlr_output_state_mode_type mode_type; struct wlr_output_mode *mode; struct { @@ -99,11 +97,9 @@ struct wlr_output_state { int32_t refresh; // mHz, may be zero } custom_mode; - // only valid if WLR_OUTPUT_STATE_GAMMA_LUT uint16_t *gamma_lut; size_t gamma_lut_size; - // only valid if WLR_OUTPUT_STATE_LAYERS struct wlr_output_layer_state *layers; size_t layers_len; }; @@ -567,6 +563,10 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, double x, double y); void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor); +/** + * Initialize an output state. + */ +void wlr_output_state_init(struct wlr_output_state *state); /** * Releases all resources associated with an output state. */ -- cgit v1.2.3