cogl: Port SwapChain away from CoglObject

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
Bilal Elmoussaoui 2023-08-18 08:08:48 +02:00 committed by Marge Bot
parent 312d5c367e
commit 9d71949b26
6 changed files with 20 additions and 27 deletions

View File

@ -254,7 +254,7 @@ clutter_backend_do_real_create_context (ClutterBackend *backend,
/* the display owns the renderer and the swap chain */ /* the display owns the renderer and the swap chain */
cogl_object_unref (backend->cogl_renderer); cogl_object_unref (backend->cogl_renderer);
cogl_object_unref (swap_chain); g_object_unref (swap_chain);
return TRUE; return TRUE;
@ -272,7 +272,7 @@ error:
} }
if (swap_chain != NULL) if (swap_chain != NULL)
cogl_object_unref (swap_chain); g_object_unref (swap_chain);
return FALSE; return FALSE;
} }

View File

@ -323,7 +323,7 @@ cogl_framebuffer_init_config (CoglFramebuffer *framebuffer,
cogl_framebuffer_get_instance_private (framebuffer); cogl_framebuffer_get_instance_private (framebuffer);
priv->config = *config; priv->config = *config;
cogl_object_ref (priv->config.swap_chain); g_object_ref (priv->config.swap_chain);
} }
static void static void

View File

@ -58,7 +58,7 @@ cogl_onscreen_template_new (CoglSwapChain *swap_chain)
onscreen_template->config.swap_chain = swap_chain; onscreen_template->config.swap_chain = swap_chain;
if (swap_chain) if (swap_chain)
cogl_object_ref (swap_chain); g_object_ref (swap_chain);
else else
onscreen_template->config.swap_chain = cogl_swap_chain_new (); onscreen_template->config.swap_chain = cogl_swap_chain_new ();

View File

@ -30,11 +30,11 @@
#pragma once #pragma once
#include "cogl/cogl-object-private.h" #include <glib-object.h>
struct _CoglSwapChain struct _CoglSwapChain
{ {
CoglObject _parent; GObject parent_instance;
int length; int length;
}; };

View File

@ -31,32 +31,29 @@
#include "cogl-config.h" #include "cogl-config.h"
#include "cogl/cogl-object.h"
#include "cogl/cogl-swap-chain-private.h" #include "cogl/cogl-swap-chain-private.h"
#include "cogl/cogl-swap-chain.h" #include "cogl/cogl-swap-chain.h"
#include "cogl/cogl-gtype-private.h"
static void _cogl_swap_chain_free (CoglSwapChain *swap_chain);
COGL_OBJECT_DEFINE (SwapChain, swap_chain);
COGL_GTYPE_DEFINE_CLASS (SwapChain, swap_chain);
G_DEFINE_TYPE (CoglSwapChain, cogl_swap_chain, G_TYPE_OBJECT);
static void static void
_cogl_swap_chain_free (CoglSwapChain *swap_chain) cogl_swap_chain_init (CoglSwapChain *swap_chain)
{
}
static void
cogl_swap_chain_class_init (CoglSwapChainClass *class)
{ {
g_free (swap_chain);
} }
CoglSwapChain * CoglSwapChain *
cogl_swap_chain_new (void) cogl_swap_chain_new (void)
{ {
CoglSwapChain *swap_chain = g_new0 (CoglSwapChain, 1); CoglSwapChain *swap_chain = g_object_new (COGL_TYPE_SWAP_CHAIN, NULL);
swap_chain->length = -1; /* no preference */ swap_chain->length = -1; /* no preference */
return _cogl_swap_chain_object_new (swap_chain); return swap_chain;
} }
void void

View File

@ -40,13 +40,12 @@ G_BEGIN_DECLS
typedef struct _CoglSwapChain CoglSwapChain; typedef struct _CoglSwapChain CoglSwapChain;
/** #define COGL_TYPE_SWAP_CHAIN (cogl_swap_chain_get_type ())
* cogl_swap_chain_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
COGL_EXPORT COGL_EXPORT
GType cogl_swap_chain_get_gtype (void); G_DECLARE_FINAL_TYPE (CoglSwapChain, cogl_swap_chain,
COGL, SWAP_CHAIN, GObject)
COGL_EXPORT CoglSwapChain * COGL_EXPORT CoglSwapChain *
cogl_swap_chain_new (void); cogl_swap_chain_new (void);
@ -59,7 +58,4 @@ COGL_EXPORT void
cogl_swap_chain_set_length (CoglSwapChain *swap_chain, cogl_swap_chain_set_length (CoglSwapChain *swap_chain,
int length); int length);
COGL_EXPORT gboolean
cogl_is_swap_chain (void *object);
G_END_DECLS G_END_DECLS