monitor: Make function to calculate fractional scale factor public

We'll need this function for migrating from PHYSICAL layout mode to LOGICAL
layout mode soon, so make it public.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
This commit is contained in:
Jonas Dreßler 2024-02-19 01:58:05 +01:00 committed by Marge Bot
parent 0d23eb1da8
commit 078d95cc15
2 changed files with 14 additions and 8 deletions

View File

@ -1994,11 +1994,11 @@ meta_monitor_mode_should_be_advertised (MetaMonitorMode *monitor_mode)
monitor_mode->spec.height);
}
static float
get_closest_scale_factor_for_resolution (float width,
float height,
float scale,
float threshold)
float
meta_get_closest_monitor_scale_factor_for_resolution (float width,
float height,
float scale,
float threshold)
{
unsigned int i, j;
float scaled_h;
@ -2095,9 +2095,10 @@ meta_monitor_calculate_supported_scales (MetaMonitor *monitor,
float scale;
float scale_value = i + j * SCALE_FACTORS_STEPS;
scale = get_closest_scale_factor_for_resolution (width, height,
scale_value,
max_bound);
scale = meta_get_closest_monitor_scale_factor_for_resolution (width,
height,
scale_value,
max_bound);
if (scale > 0.0)
g_array_append_val (supported_scales, scale);
}

View File

@ -233,6 +233,11 @@ float meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
MetaMonitorScalesConstraint constraints);
float meta_get_closest_monitor_scale_factor_for_resolution (float width,
float height,
float scale,
float threshold);
META_EXPORT_TEST
float * meta_monitor_calculate_supported_scales (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,