cogl: Port Display away from CoglObject

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui 2023-08-17 11:40:09 +02:00 committed by Marge Bot
parent 748c1fb9f4
commit 0f54700101
6 changed files with 41 additions and 45 deletions

View File

@ -261,7 +261,7 @@ clutter_backend_do_real_create_context (ClutterBackend *backend,
error:
if (backend->cogl_display != NULL)
{
cogl_object_unref (backend->cogl_display);
g_object_unref (backend->cogl_display);
backend->cogl_display = NULL;
}

View File

@ -155,11 +155,11 @@ cogl_context_new (CoglDisplay *display,
cogl_object_unref(renderer);
}
else
cogl_object_ref (display);
g_object_ref (display);
if (!cogl_display_setup (display, error))
{
cogl_object_unref (display);
g_object_unref (display);
g_free (context);
return NULL;
}
@ -182,14 +182,14 @@ cogl_context_new (CoglDisplay *display,
winsys = _cogl_context_get_winsys (context);
if (!winsys->context_init (context, error))
{
cogl_object_unref (display);
g_object_unref (display);
g_free (context);
return NULL;
}
if (!context->driver_vtable->context_init (context))
{
cogl_object_unref (display);
g_object_unref (display);
g_free (context);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Failed to initialize context");
@ -302,7 +302,7 @@ cogl_context_new (CoglDisplay *display,
&local_error);
if (!context->default_gl_texture_2d_tex)
{
cogl_object_unref (display);
g_object_unref (display);
g_free (context);
g_propagate_prefixed_error (error, local_error,
"Failed to create 1x1 fallback texture: ");
@ -392,7 +392,7 @@ _cogl_context_free (CoglContext *context)
driver->context_deinit (context);
cogl_object_unref (context->display);
g_object_unref (context->display);
g_hash_table_remove_all (context->named_pipelines);
g_hash_table_destroy (context->named_pipelines);

View File

@ -30,14 +30,13 @@
#pragma once
#include "cogl/cogl-object-private.h"
#include "cogl/cogl-display.h"
#include "cogl/cogl-renderer.h"
#include "cogl/cogl-onscreen-template.h"
struct _CoglDisplay
{
CoglObject _parent;
GObjectClass parnet_class;
gboolean setup;
CoglRenderer *renderer;

View File

@ -34,17 +34,13 @@
#include <string.h>
#include "cogl/cogl-private.h"
#include "cogl/cogl-object.h"
#include "cogl/cogl-display-private.h"
#include "cogl/cogl-renderer-private.h"
#include "cogl/cogl-gtype-private.h"
#include "cogl/winsys/cogl-winsys-private.h"
static void _cogl_display_free (CoglDisplay *display);
COGL_OBJECT_DEFINE (Display, display);
COGL_GTYPE_DEFINE_CLASS (Display, display);
G_DEFINE_TYPE (CoglDisplay, cogl_display, G_TYPE_OBJECT);
static const CoglWinsysVtable *
_cogl_display_get_winsys (CoglDisplay *display)
@ -53,8 +49,10 @@ _cogl_display_get_winsys (CoglDisplay *display)
}
static void
_cogl_display_free (CoglDisplay *display)
cogl_display_dispose (GObject *object)
{
CoglDisplay *display = COGL_DISPLAY (object);
const CoglWinsysVtable *winsys;
if (display->setup)
@ -76,14 +74,27 @@ _cogl_display_free (CoglDisplay *display)
display->onscreen_template = NULL;
}
g_free (display);
G_OBJECT_CLASS (cogl_display_parent_class)->dispose (object);
}
static void
cogl_display_init (CoglDisplay *display)
{
}
static void
cogl_display_class_init (CoglDisplayClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = cogl_display_dispose;
}
CoglDisplay *
cogl_display_new (CoglRenderer *renderer,
cogl_display_new (CoglRenderer *renderer,
CoglOnscreenTemplate *onscreen_template)
{
CoglDisplay *display = g_new0 (CoglDisplay, 1);
CoglDisplay *display = g_object_new (COGL_TYPE_DISPLAY, NULL);
GError *error = NULL;
_cogl_init ();
@ -99,8 +110,6 @@ cogl_display_new (CoglRenderer *renderer,
display->setup = FALSE;
display = _cogl_display_object_new (display);
cogl_display_set_onscreen_template (display, onscreen_template);
return display;

View File

@ -44,8 +44,9 @@
G_BEGIN_DECLS
/**
* SECTION:cogl-display
* @short_description: Common aspects of a display pipeline
* CoglDisplay:
*
* Common aspects of a display pipeline
*
* The basic intention for this object is to let the application
* configure common display preferences before creating a context, and
@ -65,17 +66,16 @@ G_BEGIN_DECLS
* create a GLContext.
*/
typedef struct _CoglDisplay CoglDisplay;
typedef struct _CoglDisplay CoglDisplay;
#define COGL_DISPLAY(OBJECT) ((CoglDisplay *)OBJECT)
#define COGL_TYPE_DISPLAY (cogl_display_get_type ())
/**
* cogl_display_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
COGL_EXPORT
GType cogl_display_get_gtype (void);
G_DECLARE_FINAL_TYPE (CoglDisplay,
cogl_display,
COGL,
DISPLAY,
GObject)
/**
* cogl_display_new:
@ -179,18 +179,6 @@ cogl_display_set_onscreen_template (CoglDisplay *display,
*/
COGL_EXPORT gboolean
cogl_display_setup (CoglDisplay *display,
GError **error);
/**
* cogl_is_display:
* @object: A #CoglObject pointer
*
* Gets whether the given object references a #CoglDisplay.
*
* Return value: %TRUE if the object references a #CoglDisplay
* and %FALSE otherwise.
*/
COGL_EXPORT gboolean
cogl_is_display (void *object);
GError **error);
G_END_DECLS

View File

@ -249,11 +249,11 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
display = cogl_display_new (renderer, onscreen_template);
if (!cogl_display_setup (display, error))
{
cogl_object_unref (display);
g_object_unref (display);
return FALSE;
}
cogl_object_unref (display);
g_object_unref (display);
return TRUE;
}