crtc: Make the caller allocate the config struct

This will make it more convenient to offload some part of the
configuring the backend by passing the config forward.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3428>
This commit is contained in:
Jonas Ådahl 2023-11-28 16:59:24 +01:00 committed by Marge Bot
parent c87fc36804
commit 2bb75a3c97
7 changed files with 54 additions and 38 deletions

View File

@ -111,21 +111,12 @@ meta_crtc_get_all_transforms (MetaCrtc *crtc)
}
void
meta_crtc_set_config (MetaCrtc *crtc,
graphene_rect_t *layout,
MetaCrtcMode *mode,
MetaMonitorTransform transform)
meta_crtc_set_config (MetaCrtc *crtc,
MetaCrtcConfig *config)
{
MetaCrtcPrivate *priv = meta_crtc_get_instance_private (crtc);
MetaCrtcConfig *config;
meta_crtc_unset_config (crtc);
config = g_new0 (MetaCrtcConfig, 1);
config->layout = *layout;
config->mode = mode;
config->transform = transform;
priv->config = config;
}
@ -402,3 +393,18 @@ meta_crtc_class_init (MetaCrtcClass *klass)
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
}
MetaCrtcConfig *
meta_crtc_config_new (graphene_rect_t *layout,
MetaCrtcMode *mode,
MetaMonitorTransform transform)
{
MetaCrtcConfig *config;
config = g_new0 (MetaCrtcConfig, 1);
config->layout = *layout;
config->mode = mode;
config->transform = transform;
return config;
}

View File

@ -70,10 +70,8 @@ void meta_crtc_unassign_output (MetaCrtc *crtc,
MetaMonitorTransform meta_crtc_get_all_transforms (MetaCrtc *crtc);
META_EXPORT_TEST
void meta_crtc_set_config (MetaCrtc *crtc,
graphene_rect_t *layout,
MetaCrtcMode *mode,
MetaMonitorTransform transform);
void meta_crtc_set_config (MetaCrtc *crtc,
MetaCrtcConfig *config);
META_EXPORT_TEST
void meta_crtc_unset_config (MetaCrtc *crtc);
@ -109,4 +107,9 @@ META_EXPORT_TEST
gboolean meta_gamma_lut_equal (const MetaGammaLut *gamma,
const MetaGammaLut *other_gamma);
META_EXPORT_TEST
MetaCrtcConfig * meta_crtc_config_new (graphene_rect_t *layout,
MetaCrtcMode *mode,
MetaMonitorTransform transform);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaGammaLut, meta_gamma_lut_free)

View File

@ -516,12 +516,13 @@ apply_crtc_assignments (MetaMonitorManager *manager,
}
else
{
MetaCrtcConfig *crtc_config;
unsigned int j;
meta_crtc_set_config (crtc,
&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config);
for (j = 0; j < crtc_assignment->outputs->len; j++)
{

View File

@ -214,12 +214,13 @@ apply_crtc_assignments (MetaMonitorManager *manager,
}
else
{
MetaCrtcConfig *crtc_config;
unsigned int j;
meta_crtc_set_config (crtc,
&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config);
for (j = 0; j < crtc_assignment->outputs->len; j++)
{

View File

@ -284,13 +284,16 @@ meta_crtc_xrandr_new (MetaGpuXrandr *gpu_xrandr,
if (crtc_xrandr->current_mode)
{
meta_crtc_set_config (META_CRTC (crtc_xrandr),
&GRAPHENE_RECT_INIT (crtc_xrandr->rect.x,
crtc_xrandr->rect.y,
crtc_xrandr->rect.width,
crtc_xrandr->rect.height),
crtc_xrandr->current_mode,
crtc_xrandr->transform);
MetaCrtcConfig *crtc_config;
crtc_config =
meta_crtc_config_new (&GRAPHENE_RECT_INIT (crtc_xrandr->rect.x,
crtc_xrandr->rect.y,
crtc_xrandr->rect.width,
crtc_xrandr->rect.height),
crtc_xrandr->current_mode,
crtc_xrandr->transform);
meta_crtc_set_config (META_CRTC (crtc_xrandr), crtc_config);
}
return crtc_xrandr;

View File

@ -502,6 +502,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
int x, y;
xcb_randr_rotation_t rotation;
xcb_randr_mode_t mode;
MetaCrtcConfig *crtc_config;
crtc_mode = crtc_assignment->mode;
@ -556,10 +557,10 @@ apply_crtc_assignments (MetaMonitorManager *manager,
continue;
}
meta_crtc_set_config (crtc,
&crtc_assignment->layout,
crtc_mode,
crtc_assignment->transform);
crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_mode,
crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config);
}
}

View File

@ -178,12 +178,13 @@ apply_crtc_assignments (MetaMonitorManager *manager,
}
else
{
MetaCrtcConfig *crtc_config;
unsigned int j;
meta_crtc_set_config (crtc,
&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_assignment->mode,
crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config);
for (j = 0; j < crtc_assignment->outputs->len; j++)
{