Skip to content
Snippets Groups Projects
Commit bb474016 authored by Alexandros Frantzis's avatar Alexandros Frantzis
Browse files

winewayland.drv: Support compositor-side scaling.


Introduce a mechanism to select whether we should use application-side
or composidor-side scaling. This is controlled by the "HiDPIScaling"
global or per-app driver option, either "Application" (the default) or
"Compositor".

With application-side scaling, which is the default, the application has
access to the full/native resolution of the outputs, and needs to manage
scaling manually (e.g., by using the Wine DPI options).

With compositor-side scaling, the application has access only to the
scaled resolution of the outputs, and the compositor automatically
scales the provided buffers.

Signed-off-by: default avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
parent 5b708b62
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@
*/
char *option_drm_device = NULL;
enum wayland_hidpi_scaling option_hidpi_scaling = WAYLAND_HIDPI_SCALING_APPLICATION;
BOOL option_use_system_cursors = TRUE;
/***********************************************************************
......@@ -95,6 +96,14 @@ void wayland_read_options_from_registry(void)
if (!get_config_key(hkey, appkey, "DRMDevice", REG_SZ, buffer, sizeof(buffer)))
option_drm_device = strdup(buffer);
if (!get_config_key(hkey, appkey, "HiDPIScaling", REG_SZ, buffer, sizeof(buffer)))
{
if (!strcasecmp(buffer, "Application"))
option_hidpi_scaling = WAYLAND_HIDPI_SCALING_APPLICATION;
else if (!strcasecmp(buffer, "Compositor"))
option_hidpi_scaling = WAYLAND_HIDPI_SCALING_COMPOSITOR;
}
if (!get_config_key(hkey, appkey, "UseSystemCursors", REG_SZ, buffer, sizeof(buffer)))
option_use_system_cursors = IS_OPTION_TRUE(buffer[0]);
......
......@@ -274,6 +274,11 @@ static void wayland_output_list_update_physical_coords(struct wl_list *output_li
cur->y = cur->logical_y;
}
/* When compositor scaling is used, we treat logical coordinates as
* physical. */
if (option_hidpi_scaling == WAYLAND_HIDPI_SCALING_COMPOSITOR)
return;
/* Sort and process the outputs from left to right. */
cur_p = sorted_x = wayland_output_list_sorted(output_list, wayland_output_cmp_x);
if (!sorted_x) return;
......@@ -338,6 +343,15 @@ static void wayland_output_update_scale(struct wayland_output *output)
{
double inferred_scale = 0.0;
/* When compositor scaling is used, we ignore the output scale, to
* allow the the compositor to scale us. */
if (option_hidpi_scaling == WAYLAND_HIDPI_SCALING_COMPOSITOR)
{
output->scale = 1.0;
TRACE("using scale=%.2f to enable compositor scaling\n", output->scale);
return;
}
if (output->logical_w != 0 && output->logical_h != 0 &&
output->current_mode)
{
......@@ -369,6 +383,17 @@ static void wayland_output_done(struct wayland_output *output)
TRACE("output->name=%s\n", output->name);
/* When compositor scaling is used, the current and only native mode
* corresponds to the logical width and height. */
if (option_hidpi_scaling == WAYLAND_HIDPI_SCALING_COMPOSITOR)
{
int32_t current_refresh =
output->current_mode ? output->current_mode->refresh : default_refresh;
wayland_output_clear_modes(output);
wayland_output_add_mode_all_bpp(output, output->logical_w, output->logical_h,
current_refresh, TRUE, TRUE);
}
wayland_output_add_default_modes(output);
wayland_output_list_update_physical_coords(&output->wayland->output_list);
wayland_output_update_scale(output);
......@@ -419,6 +444,12 @@ static void output_handle_mode(void *data, struct wl_output *wl_output,
{
struct wayland_output *output = data;
/* When compositor scaling is used, we don't use physical width/height
* for modes and the current mode will be set based on logical width
* and height (see wayland_output_done()). */
if (option_hidpi_scaling == WAYLAND_HIDPI_SCALING_COMPOSITOR)
return;
/* Windows apps don't expect a zero refresh rate, so use a default value. */
if (refresh == 0) refresh = default_refresh;
......
......@@ -59,6 +59,7 @@ extern struct wl_display *process_wl_display DECLSPEC_HIDDEN;
extern struct gbm_device *process_gbm_device DECLSPEC_HIDDEN;
extern const struct user_driver_funcs waylanddrv_funcs DECLSPEC_HIDDEN;
extern char *option_drm_device DECLSPEC_HIDDEN;
extern enum wayland_hidpi_scaling option_hidpi_scaling DECLSPEC_HIDDEN;
extern BOOL option_use_system_cursors DECLSPEC_HIDDEN;
/**********************************************************************
......@@ -129,6 +130,12 @@ enum wayland_pointer_locked_reason
WAYLAND_POINTER_LOCKED_REASON_CLIP = (1 << 1),
};
enum wayland_hidpi_scaling
{
WAYLAND_HIDPI_SCALING_APPLICATION,
WAYLAND_HIDPI_SCALING_COMPOSITOR,
};
/**********************************************************************
* Definitions for wayland types
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment