From 0a4f50a0725e78bef23591e205bbe34795be8e87 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 12 Jul 2024 11:43:50 -0500 Subject: [PATCH] libweston: Remove output->scale We've got output->scale, output->current_scale, output->original_scale and output->native_scale. output->scale is apparently just a weird temporary variable, and has led to some confusing bugs. Remove it entirely. Signed-off-by: Derek Foreman --- include/libweston/libweston.h | 1 - libweston/backend-headless/headless.c | 6 +++--- libweston/backend-wayland/wayland.c | 10 +++++----- libweston/backend-x11/x11.c | 10 +++++----- libweston/compositor.c | 25 ++++++++++++------------- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index af97afcf..6cfcde75 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -655,7 +655,6 @@ struct weston_output { uint16_t *b); bool enabled; /**< is in the output_list, not pending list */ - int scale; struct weston_color_profile *color_profile; bool from_blend_to_output_by_backend; diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index 057962a5..9fe66041 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -405,7 +405,7 @@ headless_output_set_size(struct weston_output *base, assert(!output->base.current_mode); /* Make sure we have scale set. */ - assert(output->base.scale); + assert(output->base.current_scale); wl_list_for_each(head, &output->base.head_list, output_link) { weston_head_set_monitor_strings(head, "weston", "headless", @@ -415,8 +415,8 @@ headless_output_set_size(struct weston_output *base, weston_head_set_physical_size(head, width, height); } - output_width = width * output->base.scale; - output_height = height * output->base.scale; + output_width = width * output->base.current_scale; + output_height = height * output->base.current_scale; output->mode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index d79bad21..8b5d9619 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -1521,7 +1521,7 @@ wayland_output_set_size(struct weston_output *base, int width, int height) assert(!output->base.current_mode); /* Make sure we have scale set. */ - assert(output->base.scale); + assert(output->base.current_scale); if (width < 1) { weston_log("Invalid width \"%d\" for output %s\n", @@ -1542,8 +1542,8 @@ wayland_output_set_size(struct weston_output *base, int width, int height) weston_head_set_physical_size(head, width, height); } - output_width = width * output->base.scale; - output_height = height * output->base.scale; + output_width = width * output->base.current_scale; + output_height = height * output->base.current_scale; output->mode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; @@ -1576,7 +1576,7 @@ wayland_output_setup_for_parent_output(struct wayland_output *output, return -1; } - output->base.scale = 1; + output->base.current_scale = 1; output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL; output->parent.output = poutput->global; @@ -1600,7 +1600,7 @@ wayland_output_setup_fullscreen(struct wayland_output *output, struct wayland_backend *b = output->backend; int width = 0, height = 0; - output->base.scale = 1; + output->base.current_scale = 1; output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL; if (wayland_backend_create_output_surface(output) < 0) diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index ead6a8ac..48d3ab99 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -1147,7 +1147,7 @@ x11_output_set_size(struct weston_output *base, int width, int height) assert(!output->base.current_mode); /* Make sure we have scale set. */ - assert(output->base.scale); + assert(output->base.current_scale); if (width < WINDOW_MIN_WIDTH) { weston_log("Invalid width \"%d\" for output %s\n", @@ -1168,8 +1168,8 @@ x11_output_set_size(struct weston_output *base, int width, int height) height * scrn->height_in_millimeters / scrn->height_in_pixels); } - output_width = width * output->base.scale; - output_height = height * output->base.scale; + output_width = width * output->base.current_scale; + output_height = height * output->base.current_scale; output->mode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; @@ -1178,12 +1178,12 @@ x11_output_set_size(struct weston_output *base, int width, int height) output->mode.height = output_height; output->mode.refresh = 60000; output->native = output->mode; - output->scale = output->base.scale; + output->scale = output->base.current_scale; wl_list_insert(&output->base.mode_list, &output->mode.link); output->base.current_mode = &output->mode; output->base.native_mode = &output->native; - output->base.native_scale = output->base.scale; + output->base.native_scale = output->base.current_scale; return 0; } diff --git a/libweston/compositor.c b/libweston/compositor.c index 289db0b8..93c6dfe7 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -7256,7 +7256,7 @@ weston_output_transform_scale_init(struct weston_output *output, uint32_t transf { output->transform = transform; output->native_scale = scale; - output->current_scale = scale; + assert(output->current_scale > 0); convert_size_by_transform_scale(&output->width, &output->height, output->current_mode->width, @@ -7629,24 +7629,21 @@ weston_compositor_remove_output(struct weston_output *output) compositor->output_id_pool &= ~(1u << output->id); output->id = 0xffffffff; /* invalid */ } - /** Sets the output scale for a given output. * * \param output The weston_output object that the scale is set for. * \param scale Scale factor for the given output. * - * It only supports setting scale for an output that - * is not enabled and it can only be ran once. - * * \ingroup output */ WL_EXPORT void weston_output_set_scale(struct weston_output *output, int32_t scale) { - output->scale = scale; - if (!output->enabled) + if (!output->enabled) { + output->current_scale = scale; return; + } if (output->current_scale == scale) return; @@ -7684,7 +7681,8 @@ weston_output_set_transform(struct weston_output *output, return; } - weston_output_transform_scale_init(output, transform, output->scale); + weston_output_transform_scale_init(output, transform, + output->current_scale); pixman_region32_init(&old_region); pixman_region32_copy(&old_region, &output->region); @@ -8046,7 +8044,7 @@ weston_output_init(struct weston_output *output, /* Add some (in)sane defaults which can be used * for checking if an output was properly configured */ - output->scale = 0; + output->current_scale = 0; /* Can't use -1 on uint32_t and 0 is valid enum value */ output->transform = UINT32_MAX; @@ -8175,17 +8173,18 @@ weston_output_enable(struct weston_output *output) } /* Make sure the scale is set up */ - assert(output->scale); + assert(output->current_scale); /* Make sure we have a transform set */ assert(output->transform != UINT32_MAX); - output->original_scale = output->scale; + output->original_scale = output->current_scale; wl_signal_init(&output->frame_signal); wl_signal_init(&output->destroy_signal); - weston_output_transform_scale_init(output, output->transform, output->scale); + weston_output_transform_scale_init(output, output->transform, + output->current_scale); weston_output_init_geometry(output, output->pos); @@ -9332,7 +9331,7 @@ weston_compositor_print_scene_graph(struct weston_compositor *ec) output->current_mode->width, output->current_mode->height, output->current_mode->refresh / 1000.0); - fprintf(fp, "\tscale: %d\n", output->scale); + fprintf(fp, "\tscale: %d\n", output->current_scale); fprintf(fp, "\trepaint status: %s\n", output_repaint_status_text(output));