Commit 71d2ec4b authored by myfreeweb's avatar myfreeweb

libweston: add fractional scaling

parent 5e774479
Pipeline #13997 passed with stage
in 2 minutes and 52 seconds
......@@ -68,7 +68,7 @@
struct wet_output_config {
int width;
int height;
int32_t scale;
float scale;
uint32_t transform;
};
......@@ -550,7 +550,7 @@ wet_init_parsed_options(struct weston_compositor *ec)
config->width = 0;
config->height = 0;
config->scale = 0;
config->scale = 0.0;
config->transform = UINT32_MAX;
compositor->parsed_options = config;
......@@ -1181,13 +1181,13 @@ handle_exit(struct weston_compositor *c)
static void
wet_output_set_scale(struct weston_output *output,
struct weston_config_section *section,
int32_t default_scale,
int32_t parsed_scale)
float default_scale,
float parsed_scale)
{
int32_t scale = default_scale;
float scale = default_scale;
if (section)
weston_config_section_get_int(section, "scale", &scale, default_scale);
weston_config_section_get_float(section, "scale", &scale, default_scale);
if (parsed_scale)
scale = parsed_scale;
......@@ -1195,6 +1195,7 @@ wet_output_set_scale(struct weston_output *output,
weston_output_set_scale(output, scale);
}
/* UINT32_MAX is treated as invalid because 0 is a valid
* enumeration value and the parameter is unsigned
*/
......@@ -1521,7 +1522,7 @@ drm_backend_output_configure(struct weston_output *output,
}
free(modeline);
wet_output_set_scale(output, section, 1, 0);
wet_output_set_scale(output, section, 1.0, 0);
wet_output_set_transform(output, section, WL_OUTPUT_TRANSFORM_NORMAL, UINT32_MAX);
weston_config_section_get_string(section,
......@@ -2191,7 +2192,7 @@ headless_backend_output_configure(struct weston_output *output)
struct wet_output_config defaults = {
.width = 1024,
.height = 640,
.scale = 1,
.scale = 1.0,
.transform = WL_OUTPUT_TRANSFORM_NORMAL
};
......@@ -2395,7 +2396,7 @@ x11_backend_output_configure(struct weston_output *output)
struct wet_output_config defaults = {
.width = 1024,
.height = 600,
.scale = 1,
.scale = 1.0,
.transform = WL_OUTPUT_TRANSFORM_NORMAL
};
......@@ -2500,7 +2501,7 @@ wayland_backend_output_configure(struct weston_output *output)
struct wet_output_config defaults = {
.width = 1024,
.height = 640,
.scale = 1,
.scale = 1.0,
.transform = WL_OUTPUT_TRANSFORM_NORMAL
};
......
......@@ -152,7 +152,7 @@ struct wayland_parent_output {
int32_t x, y;
uint32_t transform;
uint32_t scale;
float scale;
struct wl_callback *sync_cb; /**< wl_output < 2 done replacement */
......@@ -1508,7 +1508,7 @@ wayland_output_setup_for_parent_output(struct wayland_output *output,
return -1;
}
output->base.scale = 1;
output->base.scale = 1.0;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
output->parent.output = poutput->global;
......@@ -1532,7 +1532,7 @@ wayland_output_setup_fullscreen(struct wayland_output *output,
struct wayland_backend *b = to_wayland_backend(output->base.compositor);
int width = 0, height = 0;
output->base.scale = 1;
output->base.scale = 1.0;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
if (wayland_backend_create_output_surface(output) < 0)
......
......@@ -134,7 +134,7 @@ struct x11_output {
int shm_id;
void *buf;
uint8_t depth;
int32_t scale;
float scale;
bool resize_pending;
bool window_resized;
};
......@@ -643,8 +643,8 @@ x11_output_wait_for_map(struct x11_backend *b, struct x11_output *output)
(xcb_configure_notify_event_t *) event;
if (configure_notify->width % output->scale != 0 ||
configure_notify->height % output->scale != 0)
if (configure_notify->width % (uint16_t)output->scale != 0 ||
configure_notify->height % (uint16_t)output->scale != 0)
weston_log("Resolution is not a multiple of screen size, rounding\n");
output->mode.width = configure_notify->width;
output->mode.height = configure_notify->height;
......
......@@ -75,7 +75,7 @@ weston_output_update_matrix(struct weston_output *output);
static void
weston_output_transform_scale_init(struct weston_output *output,
uint32_t transform, uint32_t scale);
uint32_t transform, float scale);
static void
weston_compositor_build_view_list(struct weston_compositor *compositor);
......@@ -108,7 +108,7 @@ weston_mode_switch_send_events(struct weston_head *head,
version = wl_resource_get_version(resource);
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION && scale_changed)
wl_output_send_scale(resource, output->current_scale);
wl_output_send_scale(resource, ceil(output->current_scale));
if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
wl_output_send_done(resource);
......@@ -180,7 +180,7 @@ weston_compositor_reflow_outputs(struct weston_compositor *compositor,
WL_EXPORT int
weston_output_mode_set_native(struct weston_output *output,
struct weston_mode *mode,
int32_t scale)
float scale)
{
int ret;
int mode_changed = 0, scale_changed = 0;
......@@ -251,7 +251,7 @@ weston_output_mode_switch_to_native(struct weston_output *output)
WL_EXPORT int
weston_output_mode_switch_to_temporary(struct weston_output *output,
struct weston_mode *mode,
int32_t scale)
float scale)
{
int ret;
......@@ -565,7 +565,7 @@ weston_view_to_global_float(struct weston_view *view,
WL_EXPORT void
weston_transformed_coord(int width, int height,
enum wl_output_transform transform,
int32_t scale,
float scale,
float sx, float sy, float *bx, float *by)
{
switch (transform) {
......@@ -611,7 +611,7 @@ weston_transformed_coord(int width, int height,
WL_EXPORT pixman_box32_t
weston_transformed_rect(int width, int height,
enum wl_output_transform transform,
int32_t scale,
float scale,
pixman_box32_t rect)
{
float x1, x2, y1, y2;
......@@ -701,13 +701,13 @@ weston_matrix_transform_region(pixman_region32_t *dest,
WL_EXPORT void
weston_transformed_region(int width, int height,
enum wl_output_transform transform,
int32_t scale,
float scale,
pixman_region32_t *src, pixman_region32_t *dest)
{
pixman_box32_t *src_rects, *dest_rects;
int nrects, i;
if (transform == WL_OUTPUT_TRANSFORM_NORMAL && scale == 1) {
if (transform == WL_OUTPUT_TRANSFORM_NORMAL && scale == 1.0) {
if (src != dest)
pixman_region32_copy(dest, src);
return;
......@@ -776,7 +776,7 @@ weston_transformed_region(int width, int height,
}
}
if (scale != 1) {
if (scale != 1.0) {
for (i = 0; i < nrects; i++) {
dest_rects[i].x1 *= scale;
dest_rects[i].x2 *= scale;
......@@ -1768,7 +1768,7 @@ static void
convert_size_by_transform_scale(int32_t *width_out, int32_t *height_out,
int32_t width, int32_t height,
uint32_t transform,
int32_t scale)
float scale)
{
assert(scale > 0);
......@@ -1777,15 +1777,15 @@ convert_size_by_transform_scale(int32_t *width_out, int32_t *height_out,
case WL_OUTPUT_TRANSFORM_180:
case WL_OUTPUT_TRANSFORM_FLIPPED:
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
*width_out = width / scale;
*height_out = height / scale;
*width_out = ceil(width / scale);
*height_out = ceil(height / scale);
break;
case WL_OUTPUT_TRANSFORM_90:
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
*width_out = height / scale;
*height_out = width / scale;
*width_out = ceil(height / scale);
*height_out = ceil(width / scale);
break;
default:
assert(0 && "invalid transform");
......@@ -4476,7 +4476,7 @@ bind_output(struct wl_client *client,
output->transform);
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
wl_output_send_scale(resource,
output->current_scale);
ceil(output->current_scale));
wl_list_for_each (mode, &output->mode_list, link) {
wl_output_send_mode(resource,
......@@ -5308,7 +5308,7 @@ weston_output_update_matrix(struct weston_output *output)
}
static void
weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale)
weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, float scale)
{
output->transform = transform;
output->native_scale = scale;
......@@ -5523,7 +5523,7 @@ weston_compositor_remove_output(struct weston_output *output)
*/
WL_EXPORT void
weston_output_set_scale(struct weston_output *output,
int32_t scale)
float scale)
{
/* We can only set scale on a disabled output */
assert(!output->enabled);
......@@ -6541,7 +6541,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: %.2f\n", output->scale);
fprintf(fp, "\trepaint status: %s\n",
output_repaint_status_text(output));
......
......@@ -258,9 +258,9 @@ struct weston_output {
struct wl_list feedback_list;
uint32_t transform;
int32_t native_scale;
int32_t current_scale;
int32_t original_scale;
float native_scale;
float current_scale;
float original_scale;
struct weston_mode *native_mode;
struct weston_mode *current_mode;
......@@ -292,7 +292,7 @@ struct weston_output {
struct weston_timeline_object timeline;
bool enabled; /**< is in the output_list, not pending list */
int scale;
float scale;
int (*enable)(struct weston_output *output);
int (*disable)(struct weston_output *output);
......@@ -2135,11 +2135,11 @@ weston_surface_destroy(struct weston_surface *surface);
int
weston_output_mode_set_native(struct weston_output *output,
struct weston_mode *mode,
int32_t scale);
float scale);
int
weston_output_mode_switch_to_temporary(struct weston_output *output,
struct weston_mode *mode,
int32_t scale);
float scale);
int
weston_output_mode_switch_to_native(struct weston_output *output);
......@@ -2158,12 +2158,12 @@ weston_module_init(struct weston_compositor *compositor);
void
weston_transformed_coord(int width, int height,
enum wl_output_transform transform,
int32_t scale,
float scale,
float sx, float sy, float *bx, float *by);
pixman_box32_t
weston_transformed_rect(int width, int height,
enum wl_output_transform transform,
int32_t scale,
float scale,
pixman_box32_t rect);
void
weston_matrix_transform_region(pixman_region32_t *dest,
......@@ -2172,7 +2172,7 @@ weston_matrix_transform_region(pixman_region32_t *dest,
void
weston_transformed_region(int width, int height,
enum wl_output_transform transform,
int32_t scale,
float scale,
pixman_region32_t *src, pixman_region32_t *dest);
void *
......@@ -2305,7 +2305,7 @@ weston_output_iterate_heads(struct weston_output *output,
void
weston_output_set_scale(struct weston_output *output,
int32_t scale);
float scale);
void
weston_output_set_transform(struct weston_output *output,
......
......@@ -458,7 +458,7 @@ they are not affected by this multiplier.
.RE
.RS
.PP
An integer, 1 by default, typically configured as 2 or higher when needed,
A number, 1 by default, typically configured as 1.25 or higher when needed,
denoting the scaling multiplier for the output.
.RE
.TP 7
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment