From 2bb75a3c97b9d6f57b08b1a6e731aaa996025358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 28 Nov 2023 16:59:24 +0100 Subject: [PATCH] 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: --- src/backends/meta-crtc.c | 28 +++++++++++-------- src/backends/meta-crtc.h | 11 +++++--- src/backends/meta-monitor-manager-dummy.c | 9 +++--- .../native/meta-monitor-manager-native.c | 9 +++--- src/backends/x11/meta-crtc-xrandr.c | 17 ++++++----- .../x11/meta-monitor-manager-xrandr.c | 9 +++--- src/tests/meta-monitor-manager-test.c | 9 +++--- 7 files changed, 54 insertions(+), 38 deletions(-) diff --git a/src/backends/meta-crtc.c b/src/backends/meta-crtc.c index ebbfbc3a6..8d27d204e 100644 --- a/src/backends/meta-crtc.c +++ b/src/backends/meta-crtc.c @@ -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; +} diff --git a/src/backends/meta-crtc.h b/src/backends/meta-crtc.h index 0dbd90ced..b39c23b93 100644 --- a/src/backends/meta-crtc.h +++ b/src/backends/meta-crtc.h @@ -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) diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c index 315117e5c..28f34f945 100644 --- a/src/backends/meta-monitor-manager-dummy.c +++ b/src/backends/meta-monitor-manager-dummy.c @@ -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++) { diff --git a/src/backends/native/meta-monitor-manager-native.c b/src/backends/native/meta-monitor-manager-native.c index 85234ce0d..df0a4b5ed 100644 --- a/src/backends/native/meta-monitor-manager-native.c +++ b/src/backends/native/meta-monitor-manager-native.c @@ -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++) { diff --git a/src/backends/x11/meta-crtc-xrandr.c b/src/backends/x11/meta-crtc-xrandr.c index d580a39b9..19e7b942d 100644 --- a/src/backends/x11/meta-crtc-xrandr.c +++ b/src/backends/x11/meta-crtc-xrandr.c @@ -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; diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index 97ba112e8..2d8fd4d9c 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -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); } } diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c index 1fedf2aae..aa98b0600 100644 --- a/src/tests/meta-monitor-manager-test.c +++ b/src/tests/meta-monitor-manager-test.c @@ -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++) {