cogl: Port OnscreenTemplate away from CoglObject

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui 2023-08-18 10:15:33 +02:00 committed by Marge Bot
parent df8ae83040
commit d71fe5c55e
6 changed files with 21 additions and 39 deletions

View File

@ -237,7 +237,7 @@ clutter_backend_do_real_create_context (ClutterBackend *backend,
backend->cogl_display = cogl_display_new (backend->cogl_renderer, tmpl);
/* the display owns the template */
cogl_object_unref (tmpl);
g_object_unref (tmpl);
}
if (backend->cogl_display == NULL)

View File

@ -70,7 +70,7 @@ cogl_display_dispose (GObject *object)
if (display->onscreen_template)
{
cogl_object_unref (display->onscreen_template);
g_object_unref (display->onscreen_template);
display->onscreen_template = NULL;
}
@ -128,10 +128,10 @@ cogl_display_set_onscreen_template (CoglDisplay *display,
g_return_if_fail (display->setup == FALSE);
if (onscreen_template)
cogl_object_ref (onscreen_template);
g_object_ref (onscreen_template);
if (display->onscreen_template)
cogl_object_unref (display->onscreen_template);
g_object_unref (display->onscreen_template);
display->onscreen_template = onscreen_template;

View File

@ -30,13 +30,12 @@
#pragma once
#include "cogl/cogl-object-private.h"
#include "cogl/cogl-swap-chain.h"
#include "cogl/cogl-framebuffer-private.h"
struct _CoglOnscreenTemplate
{
CoglObject _parent;
GObject parent_instance;
CoglFramebufferConfig config;
};

View File

@ -31,29 +31,27 @@
#include "cogl-config.h"
#include "cogl/cogl-object.h"
#include "cogl/cogl-framebuffer-private.h"
#include "cogl/cogl-onscreen-template-private.h"
#include "cogl/cogl-gtype-private.h"
#include <stdlib.h>
static void _cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template);
COGL_OBJECT_DEFINE (OnscreenTemplate, onscreen_template);
COGL_GTYPE_DEFINE_CLASS (OnscreenTemplate, onscreen_template);
G_DEFINE_TYPE (CoglOnscreenTemplate, cogl_onscreen_template, G_TYPE_OBJECT);
static void
_cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template)
cogl_onscreen_template_init (CoglOnscreenTemplate *onscreen_template)
{
}
static void
cogl_onscreen_template_class_init (CoglOnscreenTemplateClass *class)
{
g_free (onscreen_template);
}
CoglOnscreenTemplate *
cogl_onscreen_template_new (CoglSwapChain *swap_chain)
{
CoglOnscreenTemplate *onscreen_template = g_new0 (CoglOnscreenTemplate, 1);
CoglOnscreenTemplate *onscreen_template = g_object_new (COGL_TYPE_ONSCREEN_TEMPLATE, NULL);
char *user_config;
onscreen_template->config.swap_chain = swap_chain;
@ -74,7 +72,7 @@ cogl_onscreen_template_new (CoglSwapChain *swap_chain)
samples_per_pixel;
}
return _cogl_onscreen_template_object_new (onscreen_template);
return onscreen_template;
}
void

View File

@ -42,17 +42,13 @@
G_BEGIN_DECLS
typedef struct _CoglOnscreenTemplate CoglOnscreenTemplate;
typedef struct _CoglOnscreenTemplate CoglOnscreenTemplate;
#define COGL_ONSCREEN_TEMPLATE(OBJECT) ((CoglOnscreenTemplate *)OBJECT)
#define COGL_TYPE_ONSCREEN_TEMPLATE (cogl_onscreen_template_get_type ())
/**
* cogl_onscreen_template_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
COGL_EXPORT
GType cogl_onscreen_template_get_gtype (void);
G_DECLARE_FINAL_TYPE (CoglOnscreenTemplate, cogl_onscreen_template,
COGL, ONSCREEN_TEMPLATE, GObject)
COGL_EXPORT CoglOnscreenTemplate *
cogl_onscreen_template_new (CoglSwapChain *swap_chain);
@ -95,18 +91,7 @@ cogl_onscreen_template_set_samples_per_pixel (
*/
COGL_EXPORT void
cogl_onscreen_template_set_stereo_enabled (
CoglOnscreenTemplate *onscreen_template,
gboolean enabled);
/**
* cogl_is_onscreen_template:
* @object: A #CoglObject pointer
*
* Gets whether the given object references a #CoglOnscreenTemplate.
*
* Return value: %TRUE if the object references a #CoglOnscreenTemplate
* and %FALSE otherwise.
*/
COGL_EXPORT gboolean
cogl_is_onscreen_template (void *object);
CoglOnscreenTemplate *onscreen_template,
gboolean enabled);
G_END_DECLS

View File

@ -164,7 +164,7 @@ meta_clutter_backend_x11_get_display (ClutterBackend *clutter_backend,
if (res)
display = cogl_display_new (renderer, onscreen_template);
cogl_object_unref (onscreen_template);
g_object_unref (onscreen_template);
return display;
}