kms/impl: Manage a list of impl devices

Accessing the device list directly from MetaKms might not be safe if we
introduce threads, so keep a list completely within the impl context.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
Jonas Ådahl 2020-07-16 23:29:31 +02:00 committed by Marge Bot
parent eb78b62515
commit a8d724d058
4 changed files with 36 additions and 0 deletions

View File

@ -270,6 +270,8 @@ create_impl_device_in_impl (MetaKmsImpl *impl,
if (!impl_device)
return FALSE;
meta_kms_impl_add_impl_device (impl, impl_device);
data->out_impl_device = impl_device;
data->out_crtcs = meta_kms_impl_device_copy_crtcs (impl_device);
data->out_connectors = meta_kms_impl_device_copy_connectors (impl_device);

View File

@ -703,6 +703,8 @@ meta_kms_impl_device_finalize (GObject *object)
MetaKmsImplDevicePrivate *priv =
meta_kms_impl_device_get_instance_private (impl_device);
meta_kms_impl_remove_impl_device (priv->impl, impl_device);
g_list_free_full (priv->planes, g_object_unref);
g_list_free_full (priv->crtcs, g_object_unref);
g_list_free_full (priv->connectors, g_object_unref);

View File

@ -22,6 +22,8 @@
#include "backends/native/meta-kms-impl.h"
#include "backends/native/meta-kms-private.h"
enum
{
PROP_0,
@ -32,6 +34,8 @@ enum
typedef struct _MetaKmsImplPrivate
{
MetaKms *kms;
GList *impl_devices;
} MetaKmsImplPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaKmsImpl, meta_kms_impl, G_TYPE_OBJECT)
@ -44,6 +48,28 @@ meta_kms_impl_get_kms (MetaKmsImpl *impl)
return priv->kms;
}
void
meta_kms_impl_add_impl_device (MetaKmsImpl *impl,
MetaKmsImplDevice *impl_device)
{
MetaKmsImplPrivate *priv = meta_kms_impl_get_instance_private (impl);
meta_assert_in_kms_impl (priv->kms);
priv->impl_devices = g_list_append (priv->impl_devices, impl_device);
}
void
meta_kms_impl_remove_impl_device (MetaKmsImpl *impl,
MetaKmsImplDevice *impl_device)
{
MetaKmsImplPrivate *priv = meta_kms_impl_get_instance_private (impl);
meta_assert_in_kms_impl (priv->kms);
priv->impl_devices = g_list_remove (priv->impl_devices, impl_device);
}
MetaKmsFeedback *
meta_kms_impl_process_update (MetaKmsImpl *impl,
MetaKmsUpdate *update)

View File

@ -47,6 +47,12 @@ MetaKms * meta_kms_impl_get_kms (MetaKmsImpl *impl);
MetaKmsFeedback * meta_kms_impl_process_update (MetaKmsImpl *impl,
MetaKmsUpdate *update);
void meta_kms_impl_add_impl_device (MetaKmsImpl *impl,
MetaKmsImplDevice *impl_device);
void meta_kms_impl_remove_impl_device (MetaKmsImpl *impl,
MetaKmsImplDevice *impl_device);
void meta_kms_impl_handle_page_flip_callback (MetaKmsImpl *impl,
MetaKmsPageFlipData *page_flip_data);