mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 23:46:33 -05:00
monitor: Define scale_steps globally
No need to compute the scale steps multiple times, since it's just a defined value, so let's use a define for this avoiding to pass around. https://bugzilla.gnome.org/show_bug.cgi?id=782742
This commit is contained in:
parent
c67b0bd7e2
commit
f76b3edf9c
@ -31,6 +31,7 @@
|
||||
#include "backends/meta-output.h"
|
||||
|
||||
#define SCALE_FACTORS_PER_INTEGER 4
|
||||
#define SCALE_FACTORS_STEPS (1.0 / (float) SCALE_FACTORS_PER_INTEGER)
|
||||
#define MINIMUM_SCALE_FACTOR 1.0f
|
||||
#define MAXIMUM_SCALE_FACTOR 4.0f
|
||||
#define MINIMUM_LOGICAL_WIDTH 800
|
||||
@ -1579,8 +1580,7 @@ meta_monitor_mode_should_be_advertised (MetaMonitorMode *monitor_mode)
|
||||
static float
|
||||
get_closest_scale_factor_for_resolution (float width,
|
||||
float height,
|
||||
float scale,
|
||||
float scale_step)
|
||||
float scale)
|
||||
{
|
||||
unsigned int i, j;
|
||||
float scaled_h;
|
||||
@ -1609,7 +1609,6 @@ get_closest_scale_factor_for_resolution (float width,
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
float current_scale;
|
||||
@ -1619,13 +1618,12 @@ get_closest_scale_factor_for_resolution (float width,
|
||||
current_scale = width / scaled_w;
|
||||
scaled_h = height / current_scale;
|
||||
|
||||
if (current_scale >= scale + scale_step ||
|
||||
current_scale <= scale - scale_step ||
|
||||
if (current_scale >= scale + SCALE_FACTORS_STEPS ||
|
||||
current_scale <= scale - SCALE_FACTORS_STEPS ||
|
||||
current_scale < MINIMUM_SCALE_FACTOR ||
|
||||
current_scale > MAXIMUM_SCALE_FACTOR)
|
||||
{
|
||||
limit_exceeded = TRUE;
|
||||
continue;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (floorf (scaled_h) == scaled_h)
|
||||
@ -1653,10 +1651,8 @@ meta_monitor_calculate_supported_scales (MetaMonitor *monitor,
|
||||
{
|
||||
unsigned int i, j;
|
||||
int width, height;
|
||||
float scale_steps;
|
||||
GArray *supported_scales;
|
||||
|
||||
scale_steps = 1.0 / (float) SCALE_FACTORS_PER_INTEGER;
|
||||
supported_scales = g_array_new (FALSE, FALSE, sizeof (float));
|
||||
|
||||
meta_monitor_mode_get_resolution (monitor_mode, &width, &height);
|
||||
@ -1668,7 +1664,7 @@ meta_monitor_calculate_supported_scales (MetaMonitor *monitor,
|
||||
for (j = 0; j < SCALE_FACTORS_PER_INTEGER; j++)
|
||||
{
|
||||
float scale;
|
||||
float scale_value = i + j * scale_steps;
|
||||
float scale_value = i + j * SCALE_FACTORS_STEPS;
|
||||
|
||||
if ((constraints & META_MONITOR_SCALES_CONSTRAINT_NO_FRAC) &&
|
||||
fmodf (scale_value, 1.0) != 0.0)
|
||||
@ -1678,8 +1674,7 @@ meta_monitor_calculate_supported_scales (MetaMonitor *monitor,
|
||||
|
||||
scale = get_closest_scale_factor_for_resolution (width,
|
||||
height,
|
||||
scale_value,
|
||||
scale_steps);
|
||||
scale_value);
|
||||
|
||||
if (scale > 0.0f)
|
||||
g_array_append_val (supported_scales, scale);
|
||||
|
Loading…
Reference in New Issue
Block a user