output: Move MetaGpu field to instance private

Set during construction only, retrieved using helper.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
This commit is contained in:
Jonas Ådahl 2020-02-25 10:54:40 +01:00 committed by Georges Basile Stavracas Neto
parent 2ebd43cba9
commit f4fd92d8e8
8 changed files with 84 additions and 17 deletions

View File

@ -205,7 +205,9 @@ append_monitor (MetaMonitorManager *manager,
crtc->all_transforms = ALL_TRANSFORMS;
*crtcs = g_list_append (*crtcs, crtc);
output = g_object_new (META_TYPE_OUTPUT, NULL);
output = g_object_new (META_TYPE_OUTPUT,
"gpu", gpu,
NULL);
output_dummy = g_new0 (MetaOutputDummy, 1);
*output_dummy = (MetaOutputDummy) {
@ -214,7 +216,6 @@ append_monitor (MetaMonitorManager *manager,
number = g_list_length (*outputs) + 1;
output->gpu = gpu;
output->winsys_id = number;
output->name = g_strdup_printf ("LVDS%d", number);
output->vendor = g_strdup ("MetaProducts Inc.");
@ -319,9 +320,10 @@ append_tiled_monitor (MetaMonitorManager *manager,
preferred_mode = g_list_last (*modes)->data;
output = g_object_new (META_TYPE_OUTPUT, NULL);
output = g_object_new (META_TYPE_OUTPUT,
"gpu", gpu,
NULL);
output->gpu = gpu;
output->winsys_id = number;
output->name = g_strdup_printf ("LVDS%d", number);
output->vendor = g_strdup ("MetaProducts Inc.");

View File

@ -21,8 +21,21 @@
#include "backends/meta-output.h"
enum
{
PROP_0,
PROP_GPU,
N_PROPS
};
static GParamSpec *obj_props[N_PROPS];
typedef struct _MetaOutputPrivate
{
MetaGpu *gpu;
/* The CRTC driving this output, NULL if the output is not enabled */
MetaCrtc *crtc;
} MetaOutputPrivate;
@ -32,7 +45,9 @@ G_DEFINE_TYPE_WITH_PRIVATE (MetaOutput, meta_output, G_TYPE_OBJECT)
MetaGpu *
meta_output_get_gpu (MetaOutput *output)
{
return output->gpu;
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
return priv->gpu;
}
const char *
@ -91,6 +106,44 @@ meta_output_crtc_to_logical_transform (MetaOutput *output,
inverted_panel_orientation_transform);
}
static void
meta_output_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaOutput *output = META_OUTPUT (object);
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
switch (prop_id)
{
case PROP_GPU:
priv->gpu = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
meta_output_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaOutput *output = META_OUTPUT (object);
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
switch (prop_id)
{
case PROP_GPU:
g_value_set_object (value, priv->gpu);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
meta_output_dispose (GObject *object)
{
@ -131,6 +184,18 @@ meta_output_class_init (MetaOutputClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = meta_output_set_property;
object_class->get_property = meta_output_get_property;
object_class->dispose = meta_output_dispose;
object_class->finalize = meta_output_finalize;
obj_props[PROP_GPU] =
g_param_spec_object ("gpu",
"gpu",
"MetaGpu",
META_TYPE_GPU,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
}

View File

@ -64,8 +64,6 @@ struct _MetaOutput
{
GObject parent;
MetaGpu *gpu;
/* The low-level ID of this output, used to apply back configuration */
uint64_t winsys_id;
char *name;

View File

@ -302,13 +302,14 @@ meta_create_kms_output (MetaGpuKms *gpu_kms,
GList *l;
uint32_t gpu_id;
output = g_object_new (META_TYPE_OUTPUT, NULL);
output = g_object_new (META_TYPE_OUTPUT,
"gpu", gpu,
NULL);
output_kms = g_slice_new0 (MetaOutputKms);
output->driver_private = output_kms;
output->driver_notify = (GDestroyNotify) meta_output_destroy_notify;
output->gpu = gpu;
output->name = g_strdup (meta_kms_connector_get_name (kms_connector));
gpu_id = meta_gpu_kms_get_id (gpu_kms);

View File

@ -770,8 +770,9 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
GBytes *edid;
unsigned int i;
output = g_object_new (META_TYPE_OUTPUT, NULL);
output->gpu = META_GPU (gpu_xrandr);
output = g_object_new (META_TYPE_OUTPUT,
"gpu", gpu_xrandr,
NULL);
output->winsys_id = output_id;
output->name = g_strdup (xrandr_output->name);

View File

@ -151,7 +151,9 @@ meta_test_headless_monitor_connect (void)
possible_crtcs = g_new0 (MetaCrtc *, 1);
possible_crtcs[0] = g_list_first (test_setup->crtcs)->data;
output = g_object_new (META_TYPE_OUTPUT, NULL);
output = g_object_new (META_TYPE_OUTPUT,
"gpu", gpu,
NULL);
output->winsys_id = 1;
output->name = g_strdup ("DP-1");
output->vendor = g_strdup ("MetaProduct's Inc.");

View File

@ -88,13 +88,9 @@ meta_monitor_manager_test_read_current (MetaMonitorManager *manager)
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaBackendTest *backend_test = META_BACKEND_TEST (backend);
MetaGpu *gpu = meta_backend_test_get_gpu (backend_test);
GList *l;
g_assert (manager_test->test_setup);
for (l = manager_test->test_setup->outputs; l; l = l->next)
META_OUTPUT (l->data)->gpu = gpu;
meta_gpu_take_modes (gpu, manager_test->test_setup->modes);
meta_gpu_take_crtcs (gpu, manager_test->test_setup->crtcs);
meta_gpu_take_outputs (gpu, manager_test->test_setup->outputs);

View File

@ -649,7 +649,9 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
if (!serial)
serial = "0x123456";
output = g_object_new (META_TYPE_OUTPUT, NULL);
output = g_object_new (META_TYPE_OUTPUT,
"gpu", test_get_gpu (),
NULL);
if (crtc)
meta_output_assign_crtc (output, crtc);