cogl: Port Journal away from CoglObject

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui 2023-08-18 15:07:42 +02:00 committed by Marge Bot
parent 82ca43c3b6
commit 686081077a
3 changed files with 32 additions and 12 deletions

View File

@ -346,7 +346,7 @@ cogl_framebuffer_dispose (GObject *object)
g_clear_pointer (&priv->clip_stack, _cogl_clip_stack_unref);
g_clear_object (&priv->modelview_stack);
g_clear_object (&priv->projection_stack);
g_clear_pointer (&priv->journal, _cogl_journal_free);
g_clear_object (&priv->journal);
ctx->framebuffers = g_list_remove (ctx->framebuffers, framebuffer);

View File

@ -31,7 +31,6 @@
#pragma once
#include "cogl/cogl-texture.h"
#include "cogl/cogl-object-private.h"
#include "cogl/cogl-clip-stack.h"
#include "cogl/cogl-fence-private.h"
@ -39,6 +38,8 @@
typedef struct _CoglJournal
{
GObject parent_instance;
/* 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
@ -67,6 +68,15 @@ typedef struct _CoglJournal
} CoglJournal;
#define COGL_TYPE_JOURNAL (cogl_journal_get_type ())
COGL_EXPORT
G_DECLARE_FINAL_TYPE (CoglJournal,
cogl_journal,
COGL,
JOURNAL,
GObject)
/* To improve batching of geometry when submitting vertices to OpenGL we
* log the texture rectangles we want to draw to a journal, so when we
* later flush the journal we aim to batch data, and gl draw calls. */
@ -85,9 +95,6 @@ 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,
@ -116,6 +123,3 @@ _cogl_journal_try_read_pixel (CoglJournal *journal,
int y,
CoglBitmap *bitmap,
gboolean *found_intersection);
gboolean
_cogl_is_journal (void *object);

View File

@ -122,9 +122,12 @@ typedef void (*CoglJournalBatchCallback) (CoglJournalEntry *start,
typedef gboolean (*CoglJournalBatchTest) (CoglJournalEntry *entry0,
CoglJournalEntry *entry1);
void
_cogl_journal_free (CoglJournal *journal)
G_DEFINE_TYPE (CoglJournal, cogl_journal, G_TYPE_OBJECT);
static void
cogl_journal_dispose (GObject *object)
{
CoglJournal *journal = COGL_JOURNAL (object);
int i;
if (journal->entries)
@ -136,13 +139,26 @@ _cogl_journal_free (CoglJournal *journal)
if (journal->vbo_pool[i])
cogl_object_unref (journal->vbo_pool[i]);
g_free (journal);
G_OBJECT_CLASS (cogl_journal_parent_class)->dispose (object);
}
static void
cogl_journal_init (CoglJournal *journal)
{
}
static void
cogl_journal_class_init (CoglJournalClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = cogl_journal_dispose;
}
CoglJournal *
_cogl_journal_new (CoglFramebuffer *framebuffer)
{
CoglJournal *journal = g_new0 (CoglJournal, 1);
CoglJournal *journal = g_object_new (COGL_TYPE_JOURNAL, NULL);
journal->framebuffer = framebuffer;
journal->entries = g_array_new (FALSE, FALSE, sizeof (CoglJournalEntry));