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 <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2024-07-12 11:43:50 -05:00
parent d500dbd4e2
commit 0a4f50a072
5 changed files with 25 additions and 27 deletions

View File

@ -655,7 +655,6 @@ struct weston_output {
uint16_t *b); uint16_t *b);
bool enabled; /**< is in the output_list, not pending list */ bool enabled; /**< is in the output_list, not pending list */
int scale;
struct weston_color_profile *color_profile; struct weston_color_profile *color_profile;
bool from_blend_to_output_by_backend; bool from_blend_to_output_by_backend;

View File

@ -405,7 +405,7 @@ headless_output_set_size(struct weston_output *base,
assert(!output->base.current_mode); assert(!output->base.current_mode);
/* Make sure we have scale set. */ /* 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) { wl_list_for_each(head, &output->base.head_list, output_link) {
weston_head_set_monitor_strings(head, "weston", "headless", 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); weston_head_set_physical_size(head, width, height);
} }
output_width = width * output->base.scale; output_width = width * output->base.current_scale;
output_height = height * output->base.scale; output_height = height * output->base.current_scale;
output->mode.flags = output->mode.flags =
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;

View File

@ -1521,7 +1521,7 @@ wayland_output_set_size(struct weston_output *base, int width, int height)
assert(!output->base.current_mode); assert(!output->base.current_mode);
/* Make sure we have scale set. */ /* Make sure we have scale set. */
assert(output->base.scale); assert(output->base.current_scale);
if (width < 1) { if (width < 1) {
weston_log("Invalid width \"%d\" for output %s\n", 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); weston_head_set_physical_size(head, width, height);
} }
output_width = width * output->base.scale; output_width = width * output->base.current_scale;
output_height = height * output->base.scale; output_height = height * output->base.current_scale;
output->mode.flags = output->mode.flags =
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
@ -1576,7 +1576,7 @@ wayland_output_setup_for_parent_output(struct wayland_output *output,
return -1; return -1;
} }
output->base.scale = 1; output->base.current_scale = 1;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL; output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
output->parent.output = poutput->global; output->parent.output = poutput->global;
@ -1600,7 +1600,7 @@ wayland_output_setup_fullscreen(struct wayland_output *output,
struct wayland_backend *b = output->backend; struct wayland_backend *b = output->backend;
int width = 0, height = 0; int width = 0, height = 0;
output->base.scale = 1; output->base.current_scale = 1;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL; output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
if (wayland_backend_create_output_surface(output) < 0) if (wayland_backend_create_output_surface(output) < 0)

View File

@ -1147,7 +1147,7 @@ x11_output_set_size(struct weston_output *base, int width, int height)
assert(!output->base.current_mode); assert(!output->base.current_mode);
/* Make sure we have scale set. */ /* Make sure we have scale set. */
assert(output->base.scale); assert(output->base.current_scale);
if (width < WINDOW_MIN_WIDTH) { if (width < WINDOW_MIN_WIDTH) {
weston_log("Invalid width \"%d\" for output %s\n", 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); height * scrn->height_in_millimeters / scrn->height_in_pixels);
} }
output_width = width * output->base.scale; output_width = width * output->base.current_scale;
output_height = height * output->base.scale; output_height = height * output->base.current_scale;
output->mode.flags = output->mode.flags =
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; 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.height = output_height;
output->mode.refresh = 60000; output->mode.refresh = 60000;
output->native = output->mode; 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); wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode; output->base.current_mode = &output->mode;
output->base.native_mode = &output->native; output->base.native_mode = &output->native;
output->base.native_scale = output->base.scale; output->base.native_scale = output->base.current_scale;
return 0; return 0;
} }

View File

@ -7256,7 +7256,7 @@ weston_output_transform_scale_init(struct weston_output *output, uint32_t transf
{ {
output->transform = transform; output->transform = transform;
output->native_scale = scale; output->native_scale = scale;
output->current_scale = scale; assert(output->current_scale > 0);
convert_size_by_transform_scale(&output->width, &output->height, convert_size_by_transform_scale(&output->width, &output->height,
output->current_mode->width, output->current_mode->width,
@ -7629,24 +7629,21 @@ weston_compositor_remove_output(struct weston_output *output)
compositor->output_id_pool &= ~(1u << output->id); compositor->output_id_pool &= ~(1u << output->id);
output->id = 0xffffffff; /* invalid */ output->id = 0xffffffff; /* invalid */
} }
/** Sets the output scale for a given output. /** Sets the output scale for a given output.
* *
* \param output The weston_output object that the scale is set for. * \param output The weston_output object that the scale is set for.
* \param scale Scale factor for the given output. * \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 * \ingroup output
*/ */
WL_EXPORT void WL_EXPORT void
weston_output_set_scale(struct weston_output *output, weston_output_set_scale(struct weston_output *output,
int32_t scale) int32_t scale)
{ {
output->scale = scale; if (!output->enabled) {
if (!output->enabled) output->current_scale = scale;
return; return;
}
if (output->current_scale == scale) if (output->current_scale == scale)
return; return;
@ -7684,7 +7681,8 @@ weston_output_set_transform(struct weston_output *output,
return; 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_init(&old_region);
pixman_region32_copy(&old_region, &output->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 /* Add some (in)sane defaults which can be used
* for checking if an output was properly configured * 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 */ /* Can't use -1 on uint32_t and 0 is valid enum value */
output->transform = UINT32_MAX; output->transform = UINT32_MAX;
@ -8175,17 +8173,18 @@ weston_output_enable(struct weston_output *output)
} }
/* Make sure the scale is set up */ /* Make sure the scale is set up */
assert(output->scale); assert(output->current_scale);
/* Make sure we have a transform set */ /* Make sure we have a transform set */
assert(output->transform != UINT32_MAX); 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->frame_signal);
wl_signal_init(&output->destroy_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); 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->width,
output->current_mode->height, output->current_mode->height,
output->current_mode->refresh / 1000.0); 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", fprintf(fp, "\trepaint status: %s\n",
output_repaint_status_text(output)); output_repaint_status_text(output));