monitor-manager: Rename *Info structs to *Assignment
MetaCrtcInfo and MetaOutputInfo did not represent information about MetaCrtc and MetaOutput, but the result of the monitor configuration assignment algorithm, thus rename it to MetaCrtcAssignment and MetaOutputAssignment. The purpose for this is to be able to introduce a struct that actually carries information about the CRTCs and outputs, as retrieved from the backend implementations. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
f71316c850
commit
b69111d8e6
@ -52,10 +52,10 @@ G_DEFINE_TYPE (MetaMonitorsConfig, meta_monitors_config,
|
||||
G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
meta_crtc_info_free (MetaCrtcInfo *info);
|
||||
meta_crtc_assignment_free (MetaCrtcAssignment *assignment);
|
||||
|
||||
static void
|
||||
meta_output_info_free (MetaOutputInfo *info);
|
||||
meta_output_assignment_free (MetaOutputAssignment *assignment);
|
||||
|
||||
MetaMonitorConfigManager *
|
||||
meta_monitor_config_manager_new (MetaMonitorManager *monitor_manager)
|
||||
@ -96,15 +96,16 @@ is_crtc_reserved (MetaCrtc *crtc,
|
||||
|
||||
static gboolean
|
||||
is_crtc_assigned (MetaCrtc *crtc,
|
||||
GPtrArray *crtc_infos)
|
||||
GPtrArray *crtc_assignments)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < crtc_infos->len; i++)
|
||||
for (i = 0; i < crtc_assignments->len; i++)
|
||||
{
|
||||
MetaCrtcInfo *assigned_crtc_info = g_ptr_array_index (crtc_infos, i);
|
||||
MetaCrtcAssignment *assigned_crtc_assignment =
|
||||
g_ptr_array_index (crtc_assignments, i);
|
||||
|
||||
if (assigned_crtc_info->crtc == crtc)
|
||||
if (assigned_crtc_assignment->crtc == crtc)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -113,14 +114,14 @@ is_crtc_assigned (MetaCrtc *crtc,
|
||||
|
||||
static MetaCrtc *
|
||||
find_unassigned_crtc (MetaOutput *output,
|
||||
GPtrArray *crtc_infos,
|
||||
GPtrArray *crtc_assignments,
|
||||
GArray *reserved_crtcs)
|
||||
{
|
||||
MetaCrtc *crtc;
|
||||
unsigned int i;
|
||||
|
||||
crtc = meta_output_get_assigned_crtc (output);
|
||||
if (crtc && !is_crtc_assigned (crtc, crtc_infos))
|
||||
if (crtc && !is_crtc_assigned (crtc, crtc_assignments))
|
||||
return crtc;
|
||||
|
||||
/* then try to assign a CRTC that wasn't used */
|
||||
@ -128,7 +129,7 @@ find_unassigned_crtc (MetaOutput *output,
|
||||
{
|
||||
crtc = output->possible_crtcs[i];
|
||||
|
||||
if (is_crtc_assigned (crtc, crtc_infos))
|
||||
if (is_crtc_assigned (crtc, crtc_assignments))
|
||||
continue;
|
||||
|
||||
if (is_crtc_reserved (crtc, reserved_crtcs))
|
||||
@ -142,7 +143,7 @@ find_unassigned_crtc (MetaOutput *output,
|
||||
{
|
||||
crtc = output->possible_crtcs[i];
|
||||
|
||||
if (is_crtc_assigned (crtc, crtc_infos))
|
||||
if (is_crtc_assigned (crtc, crtc_assignments))
|
||||
continue;
|
||||
|
||||
return crtc;
|
||||
@ -157,8 +158,8 @@ typedef struct
|
||||
MetaMonitorsConfig *config;
|
||||
MetaLogicalMonitorConfig *logical_monitor_config;
|
||||
MetaMonitorConfig *monitor_config;
|
||||
GPtrArray *crtc_infos;
|
||||
GPtrArray *output_infos;
|
||||
GPtrArray *crtc_assignments;
|
||||
GPtrArray *output_assignments;
|
||||
GArray *reserved_crtcs;
|
||||
} MonitorAssignmentData;
|
||||
|
||||
@ -181,15 +182,17 @@ assign_monitor_crtc (MetaMonitor *monitor,
|
||||
float width, height;
|
||||
MetaCrtcMode *crtc_mode;
|
||||
graphene_rect_t crtc_layout;
|
||||
MetaCrtcInfo *crtc_info;
|
||||
MetaOutputInfo *output_info;
|
||||
MetaCrtcAssignment *crtc_assignment;
|
||||
MetaOutputAssignment *output_assignment;
|
||||
MetaMonitorConfig *first_monitor_config;
|
||||
gboolean assign_output_as_primary;
|
||||
gboolean assign_output_as_presentation;
|
||||
|
||||
output = monitor_crtc_mode->output;
|
||||
|
||||
crtc = find_unassigned_crtc (output, data->crtc_infos, data->reserved_crtcs);
|
||||
crtc = find_unassigned_crtc (output,
|
||||
data->crtc_assignments,
|
||||
data->reserved_crtcs);
|
||||
|
||||
if (!crtc)
|
||||
{
|
||||
@ -244,15 +247,15 @@ assign_monitor_crtc (MetaMonitor *monitor,
|
||||
width,
|
||||
height);
|
||||
|
||||
crtc_info = g_slice_new0 (MetaCrtcInfo);
|
||||
*crtc_info = (MetaCrtcInfo) {
|
||||
crtc_assignment = g_slice_new0 (MetaCrtcAssignment);
|
||||
*crtc_assignment = (MetaCrtcAssignment) {
|
||||
.crtc = crtc,
|
||||
.mode = crtc_mode,
|
||||
.layout = crtc_layout,
|
||||
.transform = crtc_hw_transform,
|
||||
.outputs = g_ptr_array_new ()
|
||||
};
|
||||
g_ptr_array_add (crtc_info->outputs, output);
|
||||
g_ptr_array_add (crtc_assignment->outputs, output);
|
||||
|
||||
/*
|
||||
* Only one output can be marked as primary (due to Xrandr limitation),
|
||||
@ -272,16 +275,16 @@ assign_monitor_crtc (MetaMonitor *monitor,
|
||||
else
|
||||
assign_output_as_presentation = FALSE;
|
||||
|
||||
output_info = g_slice_new0 (MetaOutputInfo);
|
||||
*output_info = (MetaOutputInfo) {
|
||||
output_assignment = g_slice_new0 (MetaOutputAssignment);
|
||||
*output_assignment = (MetaOutputAssignment) {
|
||||
.output = output,
|
||||
.is_primary = assign_output_as_primary,
|
||||
.is_presentation = assign_output_as_presentation,
|
||||
.is_underscanning = data->monitor_config->enable_underscanning
|
||||
};
|
||||
|
||||
g_ptr_array_add (data->crtc_infos, crtc_info);
|
||||
g_ptr_array_add (data->output_infos, output_info);
|
||||
g_ptr_array_add (data->crtc_assignments, crtc_assignment);
|
||||
g_ptr_array_add (data->output_assignments, output_assignment);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -291,8 +294,8 @@ assign_monitor_crtcs (MetaMonitorManager *manager,
|
||||
MetaMonitorsConfig *config,
|
||||
MetaLogicalMonitorConfig *logical_monitor_config,
|
||||
MetaMonitorConfig *monitor_config,
|
||||
GPtrArray *crtc_infos,
|
||||
GPtrArray *output_infos,
|
||||
GPtrArray *crtc_assignments,
|
||||
GPtrArray *output_assignments,
|
||||
GArray *reserved_crtcs,
|
||||
GError **error)
|
||||
{
|
||||
@ -327,8 +330,8 @@ assign_monitor_crtcs (MetaMonitorManager *manager,
|
||||
.config = config,
|
||||
.logical_monitor_config = logical_monitor_config,
|
||||
.monitor_config = monitor_config,
|
||||
.crtc_infos = crtc_infos,
|
||||
.output_infos = output_infos,
|
||||
.crtc_assignments = crtc_assignments,
|
||||
.output_assignments = output_assignments,
|
||||
.reserved_crtcs = reserved_crtcs
|
||||
};
|
||||
if (!meta_monitor_mode_foreach_crtc (monitor, monitor_mode,
|
||||
@ -344,8 +347,8 @@ static gboolean
|
||||
assign_logical_monitor_crtcs (MetaMonitorManager *manager,
|
||||
MetaMonitorsConfig *config,
|
||||
MetaLogicalMonitorConfig *logical_monitor_config,
|
||||
GPtrArray *crtc_infos,
|
||||
GPtrArray *output_infos,
|
||||
GPtrArray *crtc_assignments,
|
||||
GPtrArray *output_assignments,
|
||||
GArray *reserved_crtcs,
|
||||
GError **error)
|
||||
{
|
||||
@ -359,7 +362,7 @@ assign_logical_monitor_crtcs (MetaMonitorManager *manager,
|
||||
config,
|
||||
logical_monitor_config,
|
||||
monitor_config,
|
||||
crtc_infos, output_infos,
|
||||
crtc_assignments, output_assignments,
|
||||
reserved_crtcs, error))
|
||||
return FALSE;
|
||||
}
|
||||
@ -370,19 +373,19 @@ assign_logical_monitor_crtcs (MetaMonitorManager *manager,
|
||||
gboolean
|
||||
meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
||||
MetaMonitorsConfig *config,
|
||||
GPtrArray **out_crtc_infos,
|
||||
GPtrArray **out_output_infos,
|
||||
GPtrArray **out_crtc_assignments,
|
||||
GPtrArray **out_output_assignments,
|
||||
GError **error)
|
||||
{
|
||||
GPtrArray *crtc_infos;
|
||||
GPtrArray *output_infos;
|
||||
GPtrArray *crtc_assignments;
|
||||
GPtrArray *output_assignments;
|
||||
GArray *reserved_crtcs;
|
||||
GList *l;
|
||||
|
||||
crtc_infos =
|
||||
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_crtc_info_free);
|
||||
output_infos =
|
||||
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_output_info_free);
|
||||
crtc_assignments =
|
||||
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_crtc_assignment_free);
|
||||
output_assignments =
|
||||
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_output_assignment_free);
|
||||
reserved_crtcs = g_array_new (FALSE, FALSE, sizeof (uint64_t));
|
||||
|
||||
for (l = config->logical_monitor_configs; l; l = l->next)
|
||||
@ -421,11 +424,11 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
||||
|
||||
if (!assign_logical_monitor_crtcs (manager,
|
||||
config, logical_monitor_config,
|
||||
crtc_infos, output_infos,
|
||||
crtc_assignments, output_assignments,
|
||||
reserved_crtcs, error))
|
||||
{
|
||||
g_ptr_array_free (crtc_infos, TRUE);
|
||||
g_ptr_array_free (output_infos, TRUE);
|
||||
g_ptr_array_free (crtc_assignments, TRUE);
|
||||
g_ptr_array_free (output_assignments, TRUE);
|
||||
g_array_free (reserved_crtcs, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -433,8 +436,8 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
|
||||
|
||||
g_array_free (reserved_crtcs, TRUE);
|
||||
|
||||
*out_crtc_infos = crtc_infos;
|
||||
*out_output_infos = output_infos;
|
||||
*out_crtc_assignments = crtc_assignments;
|
||||
*out_output_assignments = output_assignments;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1563,16 +1566,16 @@ meta_monitors_config_class_init (MetaMonitorsConfigClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
meta_crtc_info_free (MetaCrtcInfo *info)
|
||||
meta_crtc_assignment_free (MetaCrtcAssignment *assignment)
|
||||
{
|
||||
g_ptr_array_free (info->outputs, TRUE);
|
||||
g_slice_free (MetaCrtcInfo, info);
|
||||
g_ptr_array_free (assignment->outputs, TRUE);
|
||||
g_slice_free (MetaCrtcAssignment, assignment);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_output_info_free (MetaOutputInfo *info)
|
||||
meta_output_assignment_free (MetaOutputAssignment *assignment)
|
||||
{
|
||||
g_slice_free (MetaOutputInfo, info);
|
||||
g_slice_free (MetaOutputAssignment, assignment);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
Reference in New Issue
Block a user