From 631056bf496161d05c46b166197a8074649cd524 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 31 Mar 2022 14:01:00 -0300 Subject: [PATCH] cogl/journal: Make CoglJournal a free-form struct There is no need to make CoglJournal a CoglObject, nor any kind of object for that matter, since it doesn't require refcounting at all. CoglJournal is entirely private to, and managed by, CoglFramebuffer, and it only needs to create and destroy it. Make CoglJournal a free-form struct, and adjust CoglFramebuffer to call _cogl_journal_free() instead of cogl_object_unref(). Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2087 Part-of: --- cogl/cogl/cogl-framebuffer.c | 2 +- cogl/cogl/cogl-journal-private.h | 5 +++-- cogl/cogl/cogl-journal.c | 8 ++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index 6f24b2e42..d8ffbcd1c 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -346,7 +346,7 @@ cogl_framebuffer_dispose (GObject *object) g_clear_pointer (&priv->clip_stack, _cogl_clip_stack_unref); cogl_clear_object (&priv->modelview_stack); cogl_clear_object (&priv->projection_stack); - cogl_clear_object (&priv->journal); + g_clear_pointer (&priv->journal, _cogl_journal_free); ctx->framebuffers = g_list_remove (ctx->framebuffers, framebuffer); diff --git a/cogl/cogl/cogl-journal-private.h b/cogl/cogl/cogl-journal-private.h index d38c3df1a..21214a6d0 100644 --- a/cogl/cogl/cogl-journal-private.h +++ b/cogl/cogl/cogl-journal-private.h @@ -40,8 +40,6 @@ typedef struct _CoglJournal { - CoglObject _parent; - /* A pointer the framebuffer that is using this journal. This is only valid when the journal is not empty. It *does* take a reference on the framebuffer. Although this creates a circular @@ -88,6 +86,9 @@ typedef struct _CoglJournalEntry CoglJournal * _cogl_journal_new (CoglFramebuffer *framebuffer); +void +_cogl_journal_free (CoglJournal *journal); + void _cogl_journal_log_quad (CoglJournal *journal, const float *position, diff --git a/cogl/cogl/cogl-journal.c b/cogl/cogl/cogl-journal.c index 26edb4ebf..4ed508a7f 100644 --- a/cogl/cogl/cogl-journal.c +++ b/cogl/cogl/cogl-journal.c @@ -122,11 +122,7 @@ typedef void (*CoglJournalBatchCallback) (CoglJournalEntry *start, typedef gboolean (*CoglJournalBatchTest) (CoglJournalEntry *entry0, CoglJournalEntry *entry1); -static void _cogl_journal_free (CoglJournal *journal); - -COGL_OBJECT_INTERNAL_DEFINE (Journal, journal); - -static void +void _cogl_journal_free (CoglJournal *journal) { int i; @@ -154,7 +150,7 @@ _cogl_journal_new (CoglFramebuffer *framebuffer) _cogl_list_init (&journal->pending_fences); - return _cogl_journal_object_new (journal); + return journal; } static void