meta-monitor-config: Look at an output's modes directly when assigning

Going through the global mode pool and then checking if the mode is
available for a given output is pointless work since we can look at
the output's available modes directly.

This implicitly changes how we choose the default mode since, instead
of relying on the sort order of the global modes array, we now rely on
the sort order of the output modes array. Still not ideal, but at
least it makes more sense since the global array is essentially
unsorted.

https://bugzilla.gnome.org/show_bug.cgi?id=772176
This commit is contained in:
Rui Matos 2016-10-06 16:04:49 +02:00
parent 04b75c45f8
commit 5261638bfd

View File

@ -1801,19 +1801,6 @@ crtc_can_drive_output (MetaCRTC *crtc,
return FALSE;
}
static gboolean
output_supports_mode (MetaOutput *output,
MetaMonitorMode *mode)
{
unsigned int i;
for (i = 0; i < output->n_modes; i++)
if (output->modes[i] == mode)
return TRUE;
return FALSE;
}
static gboolean
crtc_assignment_assign (CrtcAssignment *assign,
MetaCRTC *crtc,
@ -1828,9 +1815,6 @@ crtc_assignment_assign (CrtcAssignment *assign,
if (!crtc_can_drive_output (crtc, output))
return FALSE;
if (!output_supports_mode (output, mode))
return FALSE;
if ((crtc->all_transforms & (1 << transform)) == 0)
return FALSE;
@ -1917,10 +1901,9 @@ static gboolean
real_assign_crtcs (CrtcAssignment *assignment,
unsigned int output_num)
{
MetaMonitorMode *modes;
MetaCRTC *crtcs;
MetaOutput *outputs;
unsigned int n_crtcs, n_modes, n_outputs;
unsigned int n_crtcs, n_outputs;
MetaOutputKey *output_key;
MetaOutputConfig *output_config;
unsigned int i;
@ -1936,7 +1919,7 @@ real_assign_crtcs (CrtcAssignment *assignment,
return real_assign_crtcs (assignment, output_num + 1);
meta_monitor_manager_get_resources (assignment->manager,
&modes, &n_modes,
NULL, NULL,
&crtcs, &n_crtcs,
&outputs, &n_outputs);
@ -1953,9 +1936,9 @@ real_assign_crtcs (CrtcAssignment *assignment,
MetaOutput *output = find_output_by_key (outputs, n_outputs, output_key);
unsigned int j;
for (j = 0; j < n_modes; j++)
for (j = 0; j < output->n_modes; j++)
{
MetaMonitorMode *mode = &modes[j];
MetaMonitorMode *mode = output->modes[j];
int width, height;
if (meta_monitor_transform_is_rotated (output_config->transform))
@ -1980,7 +1963,7 @@ real_assign_crtcs (CrtcAssignment *assignment,
output_config->transform,
pass);
if (crtc_assignment_assign (assignment, crtc, &modes[j],
if (crtc_assignment_assign (assignment, crtc, mode,
output_config->rect.x, output_config->rect.y,
output_config->transform,
output))