From c3fc6025b17eda210c5ad172dad229c929a34a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 26 Feb 2020 10:14:52 +0100 Subject: [PATCH] crtc: Move all_transforms field into instance private Now set as a property during construction. Only actually set by the Xrandr backend, as it's the only one currently not supporting all transforms, which is the default. While at it, move the 'ALL_TRANFORMS' macro to meta-monitor-tranforms.h. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287 --- src/backends/meta-crtc.c | 30 +++++++++++++++++++ src/backends/meta-crtc.h | 4 +-- src/backends/meta-monitor-manager-dummy.c | 4 --- src/backends/meta-monitor-manager.c | 6 ++-- src/backends/meta-monitor-transform.h | 1 + src/backends/native/meta-crtc-kms.c | 1 - src/backends/x11/meta-crtc-xrandr.c | 11 ++++--- .../x11/meta-monitor-manager-xrandr.c | 3 +- src/tests/headless-start-test.c | 2 -- src/tests/monitor-test-utils.c | 1 - src/tests/monitor-test-utils.h | 2 -- 11 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/backends/meta-crtc.c b/src/backends/meta-crtc.c index d06334fe6..815823b14 100644 --- a/src/backends/meta-crtc.c +++ b/src/backends/meta-crtc.c @@ -29,6 +29,7 @@ enum PROP_ID, PROP_GPU, + PROP_ALL_TRANSFORMS, N_PROPS }; @@ -40,6 +41,8 @@ typedef struct _MetaCrtcPrivate uint64_t id; MetaGpu *gpu; + + MetaMonitorTransform all_transforms; } MetaCrtcPrivate; G_DEFINE_TYPE_WITH_PRIVATE (MetaCrtc, meta_crtc, G_TYPE_OBJECT) @@ -62,6 +65,14 @@ meta_crtc_get_gpu (MetaCrtc *crtc) return priv->gpu; } +MetaMonitorTransform +meta_crtc_get_all_transforms (MetaCrtc *crtc) +{ + MetaCrtcPrivate *priv = meta_crtc_get_instance_private (crtc); + + return priv->all_transforms; +} + void meta_crtc_set_config (MetaCrtc *crtc, graphene_rect_t *layout, @@ -103,6 +114,9 @@ meta_crtc_set_property (GObject *object, case PROP_GPU: priv->gpu = g_value_get_object (value); break; + case PROP_ALL_TRANSFORMS: + priv->all_transforms = g_value_get_uint (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -125,6 +139,9 @@ meta_crtc_get_property (GObject *object, case PROP_GPU: g_value_set_object (value, priv->gpu); break; + case PROP_ALL_TRANSFORMS: + g_value_set_uint (value, priv->all_transforms); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -146,6 +163,9 @@ meta_crtc_finalize (GObject *object) static void meta_crtc_init (MetaCrtc *crtc) { + MetaCrtcPrivate *priv = meta_crtc_get_instance_private (crtc); + + priv->all_transforms = META_MONITOR_ALL_TRANSFORMS; } static void @@ -173,6 +193,16 @@ meta_crtc_class_init (MetaCrtcClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_props[PROP_ALL_TRANSFORMS] = + g_param_spec_uint ("all-transforms", + "all-transforms", + "All transforms", + 0, + META_MONITOR_ALL_TRANSFORMS, + META_MONITOR_ALL_TRANSFORMS, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, N_PROPS, obj_props); } diff --git a/src/backends/meta-crtc.h b/src/backends/meta-crtc.h index 12c46951c..e5737c446 100644 --- a/src/backends/meta-crtc.h +++ b/src/backends/meta-crtc.h @@ -60,8 +60,6 @@ struct _MetaCrtc { GObject parent; - unsigned int all_transforms; - MetaCrtcConfig *config; gpointer driver_private; @@ -97,6 +95,8 @@ uint64_t meta_crtc_get_id (MetaCrtc *crtc); META_EXPORT_TEST MetaGpu * meta_crtc_get_gpu (MetaCrtc *crtc); +MetaMonitorTransform meta_crtc_get_all_transforms (MetaCrtc *crtc); + META_EXPORT_TEST void meta_crtc_set_config (MetaCrtc *crtc, graphene_rect_t *layout, diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c index 6547f9dcd..3c59f6860 100644 --- a/src/backends/meta-monitor-manager-dummy.c +++ b/src/backends/meta-monitor-manager-dummy.c @@ -36,8 +36,6 @@ #include "backends/meta-output.h" #include "meta/util.h" -#define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1) - #define MAX_MONITORS 5 #define MAX_OUTPUTS (MAX_MONITORS * 2) #define MAX_CRTCS (MAX_MONITORS * 2) @@ -203,7 +201,6 @@ append_monitor (MetaMonitorManager *manager, "id", g_list_length (*crtcs) + 1, "gpu", gpu, NULL); - crtc->all_transforms = ALL_TRANSFORMS; *crtcs = g_list_append (*crtcs, crtc); number = g_list_length (*outputs) + 1; @@ -298,7 +295,6 @@ append_tiled_monitor (MetaMonitorManager *manager, "id", g_list_length (*crtcs) + i + 1, "gpu", gpu, NULL); - crtc->all_transforms = ALL_TRANSFORMS; new_crtcs = g_list_append (new_crtcs, crtc); } *crtcs = g_list_concat (*crtcs, new_crtcs); diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index d76e4348b..ebe763cb3 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1021,8 +1021,10 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton, g_variant_builder_init (&transforms, G_VARIANT_TYPE ("au")); for (j = 0; j <= META_MONITOR_TRANSFORM_FLIPPED_270; j++) - if (crtc->all_transforms & (1 << j)) - g_variant_builder_add (&transforms, "u", j); + { + if (meta_crtc_get_all_transforms (crtc) & (1 << j)) + g_variant_builder_add (&transforms, "u", j); + } crtc_config = crtc->config; diff --git a/src/backends/meta-monitor-transform.h b/src/backends/meta-monitor-transform.h index c49e29e81..6113f3a5a 100644 --- a/src/backends/meta-monitor-transform.h +++ b/src/backends/meta-monitor-transform.h @@ -36,6 +36,7 @@ enum _MetaMonitorTransform META_MONITOR_TRANSFORM_FLIPPED_270, }; #define META_MONITOR_N_TRANSFORMS (META_MONITOR_TRANSFORM_FLIPPED_270 + 1) +#define META_MONITOR_ALL_TRANSFORMS ((1 << META_MONITOR_N_TRANSFORMS) - 1) /* Returns true if transform causes width and height to be inverted This is true for the odd transforms in the enum */ diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c index 372a4dac4..f8be55736 100644 --- a/src/backends/native/meta-crtc-kms.c +++ b/src/backends/native/meta-crtc-kms.c @@ -302,7 +302,6 @@ meta_create_kms_crtc (MetaGpuKms *gpu_kms, "id", meta_kms_crtc_get_id (kms_crtc), "gpu", gpu, NULL); - crtc->all_transforms = ALL_TRANSFORMS_MASK; crtc_kms = g_new0 (MetaCrtcKms, 1); crtc_kms->kms_crtc = kms_crtc; diff --git a/src/backends/x11/meta-crtc-xrandr.c b/src/backends/x11/meta-crtc-xrandr.c index 0b68a9003..77621b9d5 100644 --- a/src/backends/x11/meta-crtc-xrandr.c +++ b/src/backends/x11/meta-crtc-xrandr.c @@ -46,8 +46,6 @@ #include "backends/x11/meta-gpu-xrandr.h" #include "backends/x11/meta-monitor-manager-xrandr.h" -#define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1) - typedef struct _MetaCrtcXrandr { MetaRectangle rect; @@ -161,7 +159,7 @@ meta_monitor_transform_from_xrandr_all (Rotation rotation) /* All rotations and one reflection -> all of them by composition */ if ((rotation & ALL_ROTATIONS) && ((rotation & RR_Reflect_X) || (rotation & RR_Reflect_Y))) - return ALL_TRANSFORMS; + return META_MONITOR_ALL_TRANSFORMS; ret = 1 << META_MONITOR_TRANSFORM_NORMAL; if (rotation & RR_Rotate_90) @@ -242,15 +240,19 @@ meta_create_xrandr_crtc (MetaGpuXrandr *gpu_xrandr, META_MONITOR_MANAGER_XRANDR (monitor_manager); Display *xdisplay = meta_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr); + MetaMonitorTransform all_transforms; MetaCrtc *crtc; MetaCrtcXrandr *crtc_xrandr; XRRPanning *panning; unsigned int i; GList *modes; + all_transforms = + meta_monitor_transform_from_xrandr_all (xrandr_crtc->rotations); crtc = g_object_new (META_TYPE_CRTC, "id", crtc_id, "gpu", gpu, + "all-transforms", all_transforms, NULL); crtc_xrandr = g_new0 (MetaCrtcXrandr, 1); @@ -280,9 +282,6 @@ meta_create_xrandr_crtc (MetaGpuXrandr *gpu_xrandr, }; } - crtc->all_transforms = - meta_monitor_transform_from_xrandr_all (xrandr_crtc->rotations); - modes = meta_gpu_get_modes (gpu); for (i = 0; i < (unsigned int) resources->nmode; i++) { diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index cccc07fe4..b4873aa30 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -857,7 +857,8 @@ meta_monitor_manager_xrandr_is_transform_handled (MetaMonitorManager *manager, MetaCrtc *crtc, MetaMonitorTransform transform) { - g_warn_if_fail ((crtc->all_transforms & transform) == transform); + g_warn_if_fail ((meta_crtc_get_all_transforms (crtc) & transform) == + transform); return TRUE; } diff --git a/src/tests/headless-start-test.c b/src/tests/headless-start-test.c index 223ef1a49..388f387ea 100644 --- a/src/tests/headless-start-test.c +++ b/src/tests/headless-start-test.c @@ -31,7 +31,6 @@ #include "tests/test-utils.h" #include "wayland/meta-wayland.h" -#define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1) #define FRAME_WARNING "Frame has assigned frame counter but no frame drawn time" static gboolean @@ -143,7 +142,6 @@ meta_test_headless_monitor_connect (void) "id", 1, "gpu", gpu, NULL); - crtc->all_transforms = ALL_TRANSFORMS; test_setup->crtcs = g_list_append (NULL, crtc); modes = g_new0 (MetaCrtcMode *, 1); diff --git a/src/tests/monitor-test-utils.c b/src/tests/monitor-test-utils.c index 484ec1f19..3253a04c0 100644 --- a/src/tests/monitor-test-utils.c +++ b/src/tests/monitor-test-utils.c @@ -576,7 +576,6 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup, "id", i + 1, "gpu", test_get_gpu (), NULL); - crtc->all_transforms = ALL_TRANSFORMS; test_setup->crtcs = g_list_append (test_setup->crtcs, crtc); } diff --git a/src/tests/monitor-test-utils.h b/src/tests/monitor-test-utils.h index db6be98f3..3ebf1ff79 100644 --- a/src/tests/monitor-test-utils.h +++ b/src/tests/monitor-test-utils.h @@ -26,8 +26,6 @@ #include "backends/meta-crtc.h" #include "backends/meta-output.h" -#define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1) - #define MAX_N_MODES 10 #define MAX_N_OUTPUTS 10 #define MAX_N_CRTCS 10