wayland/dma-buf: Make manager object a GObject

Will make certain operations easier, i.e. setting up a GQuark.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
This commit is contained in:
Jonas Ådahl 2021-08-06 15:23:15 +02:00 committed by Marge Bot
parent 90076cf268
commit 9c942a43d6
3 changed files with 40 additions and 17 deletions

View File

@ -98,6 +98,8 @@ typedef struct _MetaWaylandDmaBufFeedback
struct _MetaWaylandDmaBufManager struct _MetaWaylandDmaBufManager
{ {
GObject parent;
MetaWaylandCompositor *compositor; MetaWaylandCompositor *compositor;
dev_t main_device_id; dev_t main_device_id;
@ -122,6 +124,9 @@ struct _MetaWaylandDmaBufBuffer
G_DEFINE_TYPE (MetaWaylandDmaBufBuffer, meta_wayland_dma_buf_buffer, G_TYPE_OBJECT); G_DEFINE_TYPE (MetaWaylandDmaBufBuffer, meta_wayland_dma_buf_buffer, G_TYPE_OBJECT);
G_DEFINE_TYPE (MetaWaylandDmaBufManager, meta_wayland_dma_buf_manager,
G_TYPE_OBJECT)
static MetaWaylandDmaBufTranche * static MetaWaylandDmaBufTranche *
meta_wayland_dma_buf_tranche_new (dev_t device_id, meta_wayland_dma_buf_tranche_new (dev_t device_id,
GArray *formats, GArray *formats,
@ -1084,7 +1089,7 @@ meta_wayland_dma_buf_manager_new (MetaWaylandCompositor *compositor,
EGLDeviceEXT egl_device; EGLDeviceEXT egl_device;
EGLAttrib attrib; EGLAttrib attrib;
g_autoptr (GError) local_error = NULL; g_autoptr (GError) local_error = NULL;
g_autofree MetaWaylandDmaBufManager *dma_buf_manager = NULL; g_autoptr (MetaWaylandDmaBufManager) dma_buf_manager = NULL;
const char *device_path = NULL; const char *device_path = NULL;
struct stat device_stat; struct stat device_stat;
@ -1159,7 +1164,7 @@ meta_wayland_dma_buf_manager_new (MetaWaylandCompositor *compositor,
initialize: initialize:
dma_buf_manager = g_new0 (MetaWaylandDmaBufManager, 1); dma_buf_manager = g_object_new (META_TYPE_WAYLAND_DMA_BUF_MANAGER, NULL);
if (!wl_global_create (compositor->wayland_display, if (!wl_global_create (compositor->wayland_display,
&zwp_linux_dmabuf_v1_interface, &zwp_linux_dmabuf_v1_interface,
@ -1181,17 +1186,6 @@ initialize:
return g_steal_pointer (&dma_buf_manager); return g_steal_pointer (&dma_buf_manager);
} }
void
meta_wayland_dma_buf_manager_free (MetaWaylandDmaBufManager *dma_buf_manager)
{
g_clear_pointer (&dma_buf_manager->format_table_file,
meta_anonymous_file_free);
g_clear_pointer (&dma_buf_manager->formats, g_array_unref);
g_clear_pointer (&dma_buf_manager->default_feedback,
meta_wayland_dma_buf_feedback_free);
g_free (dma_buf_manager);
}
static void static void
meta_wayland_dma_buf_buffer_finalize (GObject *object) meta_wayland_dma_buf_buffer_finalize (GObject *object)
{ {
@ -1225,3 +1219,31 @@ meta_wayland_dma_buf_buffer_class_init (MetaWaylandDmaBufBufferClass *klass)
object_class->finalize = meta_wayland_dma_buf_buffer_finalize; object_class->finalize = meta_wayland_dma_buf_buffer_finalize;
} }
static void
meta_wayland_dma_buf_manager_finalize (GObject *object)
{
MetaWaylandDmaBufManager *dma_buf_manager =
META_WAYLAND_DMA_BUF_MANAGER (object);
g_clear_pointer (&dma_buf_manager->format_table_file,
meta_anonymous_file_free);
g_clear_pointer (&dma_buf_manager->formats, g_array_unref);
g_clear_pointer (&dma_buf_manager->default_feedback,
meta_wayland_dma_buf_feedback_free);
G_OBJECT_CLASS (meta_wayland_dma_buf_manager_parent_class)->finalize (object);
}
static void
meta_wayland_dma_buf_manager_class_init (MetaWaylandDmaBufManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_wayland_dma_buf_manager_finalize;
}
static void
meta_wayland_dma_buf_manager_init (MetaWaylandDmaBufManager *dma_buf)
{
}

View File

@ -37,13 +37,15 @@
G_DECLARE_FINAL_TYPE (MetaWaylandDmaBufBuffer, meta_wayland_dma_buf_buffer, G_DECLARE_FINAL_TYPE (MetaWaylandDmaBufBuffer, meta_wayland_dma_buf_buffer,
META, WAYLAND_DMA_BUF_BUFFER, GObject); META, WAYLAND_DMA_BUF_BUFFER, GObject);
#define META_TYPE_WAYLAND_DMA_BUF_MANAGER (meta_wayland_dma_buf_manager_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandDmaBufManager, meta_wayland_dma_buf_manager,
META, WAYLAND_DMA_BUF_MANAGER, GObject)
typedef struct _MetaWaylandDmaBufBuffer MetaWaylandDmaBufBuffer; typedef struct _MetaWaylandDmaBufBuffer MetaWaylandDmaBufBuffer;
MetaWaylandDmaBufManager * meta_wayland_dma_buf_manager_new (MetaWaylandCompositor *compositor, MetaWaylandDmaBufManager * meta_wayland_dma_buf_manager_new (MetaWaylandCompositor *compositor,
GError **error); GError **error);
void meta_wayland_dma_buf_manager_free (MetaWaylandDmaBufManager *dma_buf_manager);
gboolean gboolean
meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_dma_buf_buffer_attach (MetaWaylandBuffer *buffer,
CoglTexture **texture, CoglTexture **texture,

View File

@ -437,8 +437,7 @@ meta_wayland_compositor_finalize (GObject *object)
{ {
MetaWaylandCompositor *compositor = META_WAYLAND_COMPOSITOR (object); MetaWaylandCompositor *compositor = META_WAYLAND_COMPOSITOR (object);
g_clear_pointer (&compositor->dma_buf_manager, g_clear_object (&compositor->dma_buf_manager);
meta_wayland_dma_buf_manager_free);
g_clear_pointer (&compositor->seat, meta_wayland_seat_free); g_clear_pointer (&compositor->seat, meta_wayland_seat_free);