mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
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.
This commit is contained in:
parent
8a5b5e6f28
commit
be05097968
19 changed files with 103 additions and 103 deletions
|
|
@ -89,7 +89,8 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
|
|||
int width, height;
|
||||
wlr_output_effective_resolution(output->wlr_output, &width, &height);
|
||||
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(output->wlr_output, &state, NULL,
|
||||
NULL);
|
||||
if (pass == NULL) {
|
||||
|
|
@ -166,7 +167,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
|
|||
};
|
||||
}
|
||||
|
||||
struct wlr_output_state output_state = {0};
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
wlr_output_state_set_layers(&output_state, layers_arr.data,
|
||||
layers_arr.size / sizeof(struct wlr_output_layer_state));
|
||||
|
||||
|
|
@ -175,7 +176,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
struct sample_state *sample = output->sample;
|
||||
struct wlr_output *wlr_output = output->output;
|
||||
|
||||
struct wlr_output_state output_state = {0};
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL);
|
||||
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
|
|
@ -178,7 +179,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
struct wlr_renderer *renderer = state->renderer;
|
||||
assert(renderer);
|
||||
|
||||
struct wlr_output_state output_state = {0};
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL);
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
.box = { .width = wlr_output->width, .height = wlr_output->height },
|
||||
|
|
@ -280,7 +281,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
int32_t width, height;
|
||||
wlr_output_effective_resolution(wlr_output, &width, &height);
|
||||
|
||||
struct wlr_output_state output_state = {0};
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL);
|
||||
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
|
|
@ -122,7 +123,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
sample_output->x_offs = sample_output->y_offs = 0;
|
||||
sample_output->x_vel = sample_output->y_vel = 128;
|
||||
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_transform(&state, sample->transform);
|
||||
|
||||
sample_output->output = output;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
sample->dec = inc;
|
||||
}
|
||||
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &state, NULL, NULL);
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
.box = { .width = wlr_output->width, .height = wlr_output->height },
|
||||
|
|
@ -107,7 +108,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(sample_output->output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
int32_t width, height;
|
||||
wlr_output_effective_resolution(wlr_output, &width, &height);
|
||||
|
||||
struct wlr_output_state output_state = {0};
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL);
|
||||
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
|
|
@ -285,7 +286,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
int32_t width, height;
|
||||
wlr_output_effective_resolution(wlr_output, &width, &height);
|
||||
|
||||
struct wlr_output_state output_state = {0};
|
||||
struct wlr_output_state output_state;
|
||||
wlr_output_state_init(&output_state);
|
||||
struct wlr_render_pass *pass = wlr_output_begin_render_pass(wlr_output, &output_state, NULL, NULL);
|
||||
wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
|
||||
.box = { .width = width, .height = height },
|
||||
|
|
@ -184,7 +185,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(output);
|
||||
if (mode != NULL) {
|
||||
struct wlr_output_state state = {0};
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_mode(&state, mode);
|
||||
wlr_output_commit_state(output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue