Registers gtypes for all public objects and structs

This adds much more comprehensive support for gobject-introspection
based bindings by registering all objects as fundamental types that
inherit from CoglObject, and all structs as boxed types.

Co-Author: Robert Bragg <robert@linux.intel.com>

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Lionel Landwerlin 2013-09-02 16:02:42 +01:00 committed by Neil Roberts
parent bb10532f4b
commit 1b2dd815b4
79 changed files with 1099 additions and 42 deletions

View File

@ -68,3 +68,40 @@ pkgconfig_DATA = $(pc_files)
EXTRA_DIST += cogl-gst.pc.in
DISTCLEANFILES += $(pc_files)
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
if HAVE_INTROSPECTION
INTROSPECTION_COMPILER_ARGS=--includedir=$(top_builddir)/cogl
CoglGst-2.0.gir: libcogl-gst.la Makefile
CoglGst_2_0_gir_NAMESPACE = CoglGst
CoglGst_2_0_gir_VERSION = 2.0
CoglGst_2_0_gir_LIBS = $(top_builddir)/cogl/libcogl.la libcogl-gst.la
CoglGst_2_0_gir_FILES = $(source_h) $(source_c)
CoglGst_2_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_GST_DEP_CFLAGS)
CoglGst_2_0_gir_INCLUDES = GObject-2.0 Gst-1.0 GstBase-1.0
CoglGst_2_0_gir_EXPORT_PACKAGES = cogl-gst-2.0-experimental
CoglGst_2_0_gir_SCANNERFLAGS = \
--warn-all \
--identifier-prefix=CoglGst \
--symbol-prefix=cogl_gst \
--c-include='cogl-gst/cogl-gst.h' \
--c-include="gst/gst.h" \
--include-uninstalled=$(top_builddir)/cogl/Cogl-2.0.gir \
--pkg gstreamer-1.0 \
--add-init-section="gst_init(NULL, NULL);"
INTROSPECTION_GIRS += CoglGst-2.0.gir
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)
typelibdir = $(libdir)/girepository-1.0
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif

View File

@ -35,6 +35,8 @@
#include <gst/riff/riff-ids.h>
#include <string.h>
#include "cogl-gtype-private.h"
/* We just need the public Cogl api for cogl-gst but we first need to
* undef COGL_COMPILATION to avoid getting an error that normally
* checks cogl.h isn't used internally. */
@ -171,6 +173,34 @@ struct _CoglGstVideoSinkPrivate
GstVideoInfo info;
};
/* GTypes */
static gpointer
cogl_gst_rectangle_copy (gpointer src)
{
if (G_LIKELY (src))
{
CoglGstRectangle *new = g_slice_new (CoglGstRectangle);
memcpy (new, src, sizeof (CoglGstRectangle));
return new;
}
else
return NULL;
}
static void
cogl_gst_rectangle_free (gpointer ptr)
{
g_slice_free (CoglGstRectangle, ptr);
}
COGL_GTYPE_DEFINE_BOXED (GstRectangle,
gst_rectangle,
cogl_gst_rectangle_copy,
cogl_gst_rectangle_free);
/**/
static void
cogl_gst_source_finalize (GSource *source)
{

View File

@ -87,6 +87,10 @@
G_BEGIN_DECLS
#define COGL_GST_GTYPE_DECLARE_TYPE(name) \
GType cogl_gst_ ## name ## _get_gtype (void)
#define COGL_GST_TYPE_VIDEO_SINK cogl_gst_video_sink_get_type()
#define COGL_GST_VIDEO_SINK(obj) \
@ -500,6 +504,8 @@ typedef struct _CoglGstRectangle
float height;
} CoglGstRectangle;
COGL_GST_GTYPE_DECLARE_TYPE (rectangle);
/**
* cogl_gst_video_sink_fit_size:
* @sink: A #CoglGstVideoSink

View File

@ -116,7 +116,23 @@ CoglPango_1_0_gir_SCANNERFLAGS = \
--c-include='cogl-pango/cogl-pango.h' \
--include-uninstalled=$(top_builddir)/cogl/Cogl-1.0.gir
INTROSPECTION_GIRS += CoglPango-1.0.gir
CoglPango-2.0.gir: libcogl-pango.la Makefile
CoglPango_2_0_gir_NAMESPACE = CoglPango
CoglPango_2_0_gir_VERSION = 2.0
CoglPango_2_0_gir_LIBS = $(top_builddir)/cogl/libcogl.la libcogl-pango.la
CoglPango_2_0_gir_FILES = $(source_h) $(source_c)
CoglPango_2_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) $(COGL_PANGO_DEP_CFLAGS)
CoglPango_2_0_gir_INCLUDES = Pango-1.0 PangoCairo-1.0
CoglPango_2_0_gir_EXPORT_PACKAGES = cogl-pango-2.0-experimental
CoglPango_2_0_gir_SCANNERFLAGS = \
--warn-all \
--identifier-prefix=CoglPango \
--symbol-prefix=cogl_pango \
--c-include='cogl-pango/cogl-pango.h' \
--include-uninstalled=$(top_builddir)/cogl/Cogl-2.0.gir
INTROSPECTION_GIRS += CoglPango-1.0.gir CoglPango-2.0.gir
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)

View File

@ -50,6 +50,7 @@
#include "cogl-path/cogl-path.h"
#include "cogl-path-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
#include <math.h>
@ -63,6 +64,7 @@ static CoglPrimitive *_cogl_path_get_fill_primitive (CoglPath *path);
static void _cogl_path_build_stroke_attribute_buffer (CoglPath *path);
COGL_OBJECT_DEFINE (Path, path);
COGL_GTYPE_DEFINE_CLASS (Path, path);
static void
_cogl_path_data_clear_vbos (CoglPathData *data)

View File

@ -41,9 +41,21 @@
#else
#include <cogl/cogl.h>
#endif
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_path_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_path_get_gtype (void);
#endif
#define cogl_path_new cogl2_path_new
/**
* cogl_path_new:
@ -70,7 +82,7 @@ cogl_path_new (void);
* Internally the path will share the data until one of the paths is
* modified so copying paths should be relatively cheap.
*
* Return value: a copy of the path in @path.
* Return value: (transfer full): a copy of the path in @path.
*
* Since: 2.0
*/

View File

@ -143,6 +143,15 @@ cogl_experimental_h = \
$(srcdir)/cogl-error.h \
$(NULL)
cogl_additional_experimental_h = \
$(srcdir)/cogl-bitmap.h \
$(srcdir)/cogl-color.h \
$(srcdir)/cogl-matrix.h \
$(srcdir)/cogl-texture.h \
$(srcdir)/cogl-types.h \
$(srcdir)/cogl-gtype-private.h \
$(NULL)
cogl_nodist_experimental_h = \
$(NULL)
@ -357,6 +366,7 @@ cogl_sources_c = \
$(srcdir)/cogl-flags.h \
$(srcdir)/cogl-bitmask.h \
$(srcdir)/cogl-bitmask.c \
$(srcdir)/cogl-gtype.c \
$(srcdir)/cogl-gtype-private.h \
$(srcdir)/cogl-point-in-poly-private.h \
$(srcdir)/cogl-point-in-poly.c \
@ -668,12 +678,28 @@ if UNIT_TESTS
Cogl_1_0_gir_LIBS += $(top_builddir)/test-fixtures/libtest-fixtures.la
endif
Cogl_1_0_gir_FILES = $(cogl_1_public_h) cogl-enum-types.h
Cogl-2.0.gir: libcogl.la Makefile
Cogl_2_0_gir_NAMESPACE = Cogl
Cogl_2_0_gir_VERSION = 2.0
Cogl_2_0_gir_LIBS = libcogl.la
if UNIT_TESTS
Cogl_2_0_gir_LIBS += $(top_builddir)/test-fixtures/libtest-fixtures.la
endif
Cogl_2_0_gir_FILES = $(cogl_experimental_h) $(cogl_additional_experimental_h) cogl-enum-types.h
Cogl_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -UCOGL_ENABLE_EXPERIMENTAL_API -UCOGL_ENABLE_EXPERIMENTAL_2_0_API -UCOGL_COMPILATION -D__COGL_H_INSIDE__ -D__COGL_XLIB_H_INSIDE__ -D__COGL_EGL_H_INSIDE__ -D__COGL_GLX_H_INSIDE__ -DCOGL_GIR_SCANNING
Cogl_1_0_gir_INCLUDES = GL-1.0 GObject-2.0
Cogl_1_0_gir_EXPORT_PACKAGES = cogl-1.0
Cogl_1_0_gir_SCANNERFLAGS = --warn-all --c-include='cogl/cogl.h'
INTROSPECTION_GIRS += Cogl-1.0.gir
Cogl_2_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -DCOGL_ENABLE_EXPERIMENTAL_API=1 -UCOGL_COMPILATION -D__COGL_H_INSIDE__ -D__COGL_XLIB_H_INSIDE__ -DCOGL_GIR_SCANNING
Cogl_2_0_gir_INCLUDES = GL-1.0 GObject-2.0
Cogl_2_0_gir_EXPORT_PACKAGES = cogl-2.0-experimental
Cogl_2_0_gir_SCANNERFLAGS = --warn-all --c-include='cogl/cogl.h' --symbol-prefix=cogl --symbol-prefix=cogl2
INTROSPECTION_GIRS += Cogl-1.0.gir Cogl-2.0.gir
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)

View File

@ -52,12 +52,14 @@
#include "cogl-sub-texture.h"
#include "cogl-error-private.h"
#include "cogl-texture-gl-private.h"
#include "cogl-gtype-private.h"
#include <stdlib.h>
static void _cogl_atlas_texture_free (CoglAtlasTexture *sub_tex);
COGL_TEXTURE_DEFINE (AtlasTexture, atlas_texture);
COGL_GTYPE_DEFINE_CLASS (AtlasTexture, atlas_texture);
static const CoglTextureVtable cogl_atlas_texture_vtable;

View File

@ -37,6 +37,10 @@
#include <cogl/cogl-context.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -67,6 +71,14 @@ COGL_BEGIN_DECLS
typedef struct _CoglAtlasTexture CoglAtlasTexture;
#define COGL_ATLAS_TEXTURE(tex) ((CoglAtlasTexture *) tex)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_atlas_texture_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_atlas_texture_get_gtype (void);
#endif
/**
* cogl_atlas_texture_new_with_size:

View File

@ -39,10 +39,12 @@
#include "cogl-attribute-buffer.h"
#include "cogl-attribute-buffer-private.h"
#include "cogl-context-private.h"
#include "cogl-gtype-private.h"
static void _cogl_attribute_buffer_free (CoglAttributeBuffer *array);
COGL_BUFFER_DEFINE (AttributeBuffer, attribute_buffer);
COGL_GTYPE_DEFINE_CLASS (AttributeBuffer, attribute_buffer);
CoglAttributeBuffer *
cogl_attribute_buffer_new_with_size (CoglContext *context,

View File

@ -45,6 +45,10 @@ typedef struct _CoglAttributeBuffer CoglAttributeBuffer;
#include <cogl/cogl-context.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -57,6 +61,15 @@ COGL_BEGIN_DECLS
#define COGL_ATTRIBUTE_BUFFER(buffer) ((CoglAttributeBuffer *)(buffer))
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_attribute_buffer_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_attribute_buffer_get_gtype (void);
#endif
/**
* cogl_attribute_buffer_new_with_size:
* @context: A #CoglContext

View File

@ -51,6 +51,7 @@
#include "cogl-pipeline-progend-glsl-private.h"
#endif
#include "cogl-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
#include <stdio.h>
@ -64,6 +65,7 @@
static void _cogl_attribute_free (CoglAttribute *attribute);
COGL_OBJECT_DEFINE (Attribute, attribute);
COGL_GTYPE_DEFINE_CLASS (Attribute, attribute);
static CoglBool
validate_cogl_attribute_name (const char *name,

View File

@ -46,6 +46,10 @@ typedef struct _CoglAttribute CoglAttribute;
#include <cogl/cogl-attribute-buffer.h>
#include <cogl/cogl-indices.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -56,6 +60,15 @@ COGL_BEGIN_DECLS
* FIXME
*/
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_attribute_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_attribute_get_gtype (void);
#endif
/**
* cogl_attribute_new: (constructor)
* @attribute_buffer: The #CoglAttributeBuffer containing the actual

View File

@ -41,12 +41,14 @@
#include "cogl-context-private.h"
#include "cogl-buffer-gl-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
static void _cogl_bitmap_free (CoglBitmap *bmp);
COGL_OBJECT_DEFINE (Bitmap, bitmap);
COGL_GTYPE_DEFINE_CLASS (Bitmap, bitmap);
static void
_cogl_bitmap_free (CoglBitmap *bmp)

View File

@ -44,12 +44,25 @@ typedef struct _CoglBitmap CoglBitmap;
#include <cogl/cogl-context.h>
#include <cogl/cogl-pixel-buffer.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
#ifdef COGL_HAS_ANDROID_SUPPORT
#include <android/asset_manager.h>
#endif
COGL_BEGIN_DECLS
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_bitmap_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_bitmap_get_gtype (void);
#endif
/**
* SECTION:cogl-bitmap
* @short_description: Functions for loading images

View File

@ -119,7 +119,7 @@ void
_cogl_buffer_register_buffer_type (const CoglObjectClass *klass);
#define COGL_BUFFER_DEFINE(TypeName, type_name) \
COGL_OBJECT_DEFINE_WITH_CODE \
COGL_OBJECT_DEFINE_WITH_CODE_GTYPE \
(TypeName, type_name, \
_cogl_buffer_register_buffer_type (&_cogl_##type_name##_class))

View File

@ -38,6 +38,9 @@
#include "cogl-color.h"
#include "cogl-fixed.h"
#include "cogl-color-private.h"
#include "cogl-gtype-private.h"
COGL_GTYPE_DEFINE_BOXED (Color, color, cogl_color_copy, cogl_color_free);
CoglColor *
cogl_color_new (void)

View File

@ -48,8 +48,21 @@
#include <cogl/cogl-types.h>
#include <cogl/cogl-macros.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_color_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_color_get_gtype (void);
#endif
/**
* cogl_color_new:
*

View File

@ -56,6 +56,7 @@
#include "cogl-gpu-info-private.h"
#include "cogl-config-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "cogl/deprecated/cogl-framebuffer-deprecated.h"
@ -78,6 +79,7 @@
static void _cogl_context_free (CoglContext *context);
COGL_OBJECT_DEFINE (Context, context);
COGL_GTYPE_DEFINE_CLASS (Context, context);
extern void
_cogl_create_context_driver (CoglContext *context);

View File

@ -45,6 +45,10 @@ typedef struct _CoglContext CoglContext;
#include <cogl/cogl-defines.h>
#include <cogl/cogl-display.h>
#include <cogl/cogl-primitive.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
#ifdef COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT
#include <android/native_window.h>
#endif
@ -97,6 +101,15 @@ COGL_BEGIN_DECLS
#define COGL_CONTEXT(OBJECT) ((CoglContext *)OBJECT)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_context_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_context_get_gtype (void);
#endif
/**
* cogl_context_new: (constructor)
* @display: (allow-none): A #CoglDisplay pointer

View File

@ -44,10 +44,12 @@
#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT
#include "cogl-wayland-server.h"
#endif
#include "cogl-gtype-private.h"
static void _cogl_display_free (CoglDisplay *display);
COGL_OBJECT_DEFINE (Display, display);
COGL_GTYPE_DEFINE_CLASS (Display, display);
static const CoglWinsysVtable *
_cogl_display_get_winsys (CoglDisplay *display)

View File

@ -40,6 +40,10 @@
#include <cogl/cogl-renderer.h>
#include <cogl/cogl-onscreen-template.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
@ -72,6 +76,15 @@ typedef struct _CoglDisplay CoglDisplay;
#define COGL_DISPLAY(OBJECT) ((CoglDisplay *)OBJECT)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_display_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_display_get_gtype (void);
#endif
/**
* cogl_display_new:
* @renderer: A #CoglRenderer

View File

@ -36,10 +36,15 @@
#include <cogl-util.h>
#include <cogl-euler.h>
#include <cogl-matrix.h>
#include "cogl-gtype-private.h"
#include <math.h>
#include <string.h>
COGL_GTYPE_DEFINE_BOXED (Euler, euler,
cogl_euler_copy,
cogl_euler_free);
void
cogl_euler_init (CoglEuler *euler,
float heading,

View File

@ -38,6 +38,10 @@
#include <cogl/cogl-types.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -162,6 +166,15 @@ struct _CoglEuler
};
COGL_STRUCT_SIZE_ASSERT (CoglEuler, 32);
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_euler_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_euler_get_gtype (void);
#endif
/**
* cogl_euler_init:
* @euler: The #CoglEuler angle to initialize

View File

@ -33,10 +33,12 @@
#endif
#include "cogl-frame-info-private.h"
#include "cogl-gtype-private.h"
static void _cogl_frame_info_free (CoglFrameInfo *info);
COGL_OBJECT_DEFINE (FrameInfo, frame_info);
COGL_GTYPE_DEFINE_CLASS (FrameInfo, frame_info);
CoglFrameInfo *
_cogl_frame_info_new (void)

View File

@ -39,6 +39,10 @@
#include <cogl/cogl-types.h>
#include <cogl/cogl-output.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
#include <glib.h>
G_BEGIN_DECLS
@ -46,6 +50,15 @@ G_BEGIN_DECLS
typedef struct _CoglFrameInfo CoglFrameInfo;
#define COGL_FRAME_INFO(X) ((CoglFrameInfo *)(X))
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_frame_info_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_frame_info_get_gtype (void);
#endif
/**
* cogl_is_frame_info:
* @object: A #CoglObject pointer

View File

@ -55,6 +55,7 @@
#include "cogl-primitives-private.h"
#include "cogl-error-private.h"
#include "cogl-texture-gl-private.h"
#include "cogl-gtype-private.h"
extern CoglObjectClass _cogl_onscreen_class;
@ -67,7 +68,9 @@ static void _cogl_offscreen_free (CoglOffscreen *offscreen);
COGL_OBJECT_DEFINE_WITH_CODE (Offscreen, offscreen,
_cogl_offscreen_class.virt_unref =
_cogl_framebuffer_unref);
COGL_GTYPE_DEFINE_CLASS (Offscreen, offscreen);
COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (offscreen);
COGL_GTYPE_DEFINE_INTERFACE (Framebuffer, framebuffer);
/* XXX:
* The CoglObject macros don't support any form of inheritance, so for

View File

@ -59,6 +59,9 @@ typedef struct _CoglFramebuffer CoglFramebuffer;
#include <cogl/cogl-euler.h>
#include <cogl/cogl-texture.h>
#endif
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
@ -102,6 +105,15 @@ COGL_BEGIN_DECLS
#ifdef COGL_ENABLE_EXPERIMENTAL_API
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_framebuffer_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_framebuffer_get_gtype (void);
#endif
/**
* cogl_framebuffer_allocate:
* @framebuffer: A #CoglFramebuffer
@ -1804,4 +1816,3 @@ cogl_is_framebuffer (void *object);
COGL_END_DECLS
#endif /* __COGL_FRAMEBUFFER_H */

View File

@ -53,10 +53,12 @@
#include "cogl-texture-2d-private.h"
#include "cogl-pipeline-opengl-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
static void _cogl_gles2_context_free (CoglGLES2Context *gles2_context);
COGL_OBJECT_DEFINE (GLES2Context, gles2_context);
COGL_GTYPE_DEFINE_CLASS (GLES2Context, gles2_context);
static CoglGLES2Context *current_gles2_context;

View File

@ -142,11 +142,24 @@ struct _CoglGLES2Vtable
#include <cogl/gl-prototypes/cogl-gles2-functions.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
#undef COGL_EXT_BEGIN
#undef COGL_EXT_FUNCTION
#undef COGL_EXT_END
};
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_gles2_context_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_gles2_context_get_gtype (void);
#endif
uint32_t
_cogl_gles2_context_error_quark (void);

View File

@ -28,21 +28,47 @@
*
*/
#include <glib.h>
#include <glib-object.h>
#ifndef __COGL_GTYPE_PRIVATE_H__
#define __COGL_GTYPE_PRIVATE_H__
#define COGL_GTYPE_DEFINE_BOXED(Name, underscore_name, copy_func, free_func) \
#include "config.h"
#include <glib.h>
#include <glib-object.h>
#include "cogl-object-private.h"
/* Move this to public headers? */
typedef struct _CoglGtypeObject CoglGtypeObject;
typedef struct _CoglGtypeClass CoglGtypeClass;
struct _CoglGtypeObject
{
GTypeInstance parent_instance;
guint dummy;
};
struct _CoglGtypeClass
{
GTypeClass base_class;
guint dummy;
};
#define I_(str) (g_intern_static_string ((str)))
/**/
#define COGL_GTYPE_DEFINE_BOXED(Name,underscore_name,copy_func,free_func) \
GType \
cogl_gtype_ ## underscore_name ## _get_type (void) \
cogl_##underscore_name##_get_gtype (void) \
{ \
static volatile size_t type_volatile = 0; \
if (g_once_init_enter (&type_volatile)) \
{ \
GType type = \
g_boxed_type_register_static (g_intern_static_string ("Cogl" Name), \
g_boxed_type_register_static (g_intern_static_string (I_("Cogl" # Name)), \
(GBoxedCopyFunc)copy_func, \
(GBoxedFreeFunc)free_func); \
g_once_init_leave (&type_volatile, type); \
@ -50,5 +76,198 @@ cogl_gtype_ ## underscore_name ## _get_type (void) \
return type_volatile; \
}
#endif /* __COGL_GTYPE_PRIVATE_H__ */
#define COGL_GTYPE_IMPLEMENT_INTERFACE(name) { \
const GInterfaceInfo g_implement_interface_info = { \
(GInterfaceInitFunc) _cogl_gtype_dummy_iface_init, NULL, NULL \
}; \
g_type_add_interface_static (fundamental_type_id, \
cogl_##name##_get_gtype(), \
&g_implement_interface_info); \
}
#define _COGL_GTYPE_DEFINE_BASE_CLASS_BEGIN(Name,name) \
GType \
cogl_##name##_get_gtype (void) \
{ \
static volatile gsize type_id__volatile = 0; \
if (g_once_init_enter (&type_id__volatile)) \
{ \
static const GTypeFundamentalInfo finfo = { \
(G_TYPE_FLAG_CLASSED | \
G_TYPE_FLAG_INSTANTIATABLE | \
G_TYPE_FLAG_DERIVABLE | \
G_TYPE_FLAG_DEEP_DERIVABLE), \
}; \
static const GTypeValueTable value_table = { \
_cogl_gtype_object_init_value, \
_cogl_gtype_object_free_value, \
_cogl_gtype_object_copy_value, \
_cogl_gtype_object_peek_pointer, \
"p", \
_cogl_gtype_object_collect_value, \
"p", \
_cogl_gtype_object_lcopy_value, \
}; \
const GTypeInfo node_info = { \
sizeof (CoglObjectClass), \
(GBaseInitFunc) _cogl_gtype_object_class_base_init, \
(GBaseFinalizeFunc) _cogl_gtype_object_class_base_finalize, \
(GClassInitFunc) _cogl_gtype_object_class_init, \
(GClassFinalizeFunc) NULL, \
NULL, \
sizeof (CoglObject), \
0, \
(GInstanceInitFunc) _cogl_gtype_object_init, \
&value_table, \
}; \
GType fundamental_type_id = \
g_type_register_fundamental (g_type_fundamental_next (), \
I_("Cogl" # Name), \
&node_info, &finfo, \
G_TYPE_FLAG_ABSTRACT); \
g_once_init_leave (&type_id__volatile, \
fundamental_type_id);
#define _COGL_GTYPE_DEFINE_BASE_CLASS_END() \
} \
return type_id__volatile; \
}
#define COGL_GTYPE_DEFINE_BASE_CLASS(Name,name,interfaces...) \
_COGL_GTYPE_DEFINE_BASE_CLASS_BEGIN(Name,name) \
{interfaces;} \
_COGL_GTYPE_DEFINE_BASE_CLASS_END()
#define _COGL_GTYPE_DEFINE_INTERFACE_EXTENDED_BEGIN(Name,name) \
\
static void name##_default_init (Name##Interface *klass); \
GType \
name##_get_gtype (void) \
{ \
static volatile gsize type_id__volatile = 0; \
if (g_once_init_enter (&type_id__volatile)) \
{ \
GType fundamental_type_id = \
g_type_register_static_simple (G_TYPE_INTERFACE, \
g_intern_static_string (#Name), \
sizeof (Name##Interface), \
(GClassInitFunc)name##_default_init, \
0, \
(GInstanceInitFunc)NULL, \
(GTypeFlags) 0); \
g_type_interface_add_prerequisite (fundamental_type_id, \
cogl_object_get_gtype()); \
{ /* custom code follows */
#define _COGL_GTYPE_DEFINE_INTERFACE_EXTENDED_END() \
/* following custom code */ \
} \
g_once_init_leave (&type_id__volatile, \
fundamental_type_id); \
} \
return type_id__volatile; \
} /* closes name##_get_type() */
#define COGL_GTYPE_DEFINE_INTERFACE(Name,name) \
typedef struct _Cogl##Name##Iface Cogl##Name##Iface; \
typedef Cogl##Name##Iface Cogl##Name##Interface; \
struct _Cogl##Name##Iface \
{ \
/*< private >*/ \
GTypeInterface g_iface; \
}; \
_COGL_GTYPE_DEFINE_INTERFACE_EXTENDED_BEGIN (Cogl##Name, cogl_##name) \
_COGL_GTYPE_DEFINE_INTERFACE_EXTENDED_END () \
static void \
cogl_##name##_default_init (Cogl##Name##Interface *iface) \
{ \
}
#define _COGL_GTYPE_DEFINE_TYPE_EXTENDED_BEGIN(Name,name,parent,flags) \
\
static void name##_init (Name *self); \
static void name##_class_init (Name##Class *klass); \
static gpointer name##_parent_class = NULL; \
static gint Name##_private_offset; \
\
_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(Name, name) \
\
static inline gpointer \
name##_get_instance_private (Name *self) \
{ \
return (G_STRUCT_MEMBER_P (self, Name ##_private_offset)); \
} \
\
GType \
name##_get_gtype (void) \
{ \
static volatile gsize type_id__volatile = 0; \
if (g_once_init_enter (&type_id__volatile)) \
{ \
GType fundamental_type_id = \
g_type_register_static_simple (parent, \
g_intern_static_string (#Name), \
sizeof (Name##Class), \
(GClassInitFunc) name##_class_intern_init, \
sizeof (Name), \
(GInstanceInitFunc) name##_init, \
(GTypeFlags) flags); \
{ /* custom code follows */
#define _COGL_GTYPE_DEFINE_TYPE_EXTENDED_END() \
/* following custom code */ \
} \
g_once_init_leave (&type_id__volatile, \
fundamental_type_id); \
} \
return type_id__volatile; \
} /* closes name##_get_type() */
#define COGL_GTYPE_DEFINE_CLASS(Name,name,interfaces...) \
typedef struct _Cogl##Name##Class Cogl##Name##Class; \
struct _Cogl##Name##Class { \
CoglObjectClass parent_class; \
}; \
_COGL_GTYPE_DEFINE_TYPE_EXTENDED_BEGIN(Cogl##Name, \
cogl_##name, \
cogl_object_get_gtype(), \
0) \
{interfaces;} \
_COGL_GTYPE_DEFINE_TYPE_EXTENDED_END() \
static void \
cogl_##name##_init (Cogl##Name *instance) \
{ \
} \
static void \
cogl_##name##_class_init (Cogl##Name##Class *klass) \
{ \
}
void _cogl_gtype_object_init_value (GValue *value);
void _cogl_gtype_object_free_value (GValue *value);
void _cogl_gtype_object_copy_value (const GValue *src,
GValue *dst);
gpointer _cogl_gtype_object_peek_pointer (const GValue *value);
gchar *_cogl_gtype_object_collect_value (GValue *value,
guint n_collect_values,
GTypeCValue *collect_values,
guint collect_flags);
gchar *_cogl_gtype_object_lcopy_value (const GValue *value,
guint n_collect_values,
GTypeCValue *collect_values,
guint collect_flags);
void _cogl_gtype_object_class_base_init (CoglObjectClass *klass);
void _cogl_gtype_object_class_base_finalize (CoglObjectClass *klass);
void _cogl_gtype_object_class_init (CoglObjectClass *klass);
void _cogl_gtype_object_init (CoglObject *object);
void cogl_object_value_set_object (GValue *value,
gpointer object);
gpointer cogl_object_value_get_object (const GValue *value);
void _cogl_gtype_dummy_iface_init (gpointer iface);
#endif /* __COGL_GTYPE_PRIVATE_H__ */

153
cogl/cogl-gtype.c Normal file
View File

@ -0,0 +1,153 @@
#include "cogl-gtype-private.h"
#include <gobject/gvaluecollector.h>
void
_cogl_gtype_object_init_value (GValue *value)
{
value->data[0].v_pointer = NULL;
}
void
_cogl_gtype_object_free_value (GValue *value)
{
if (value->data[0].v_pointer != NULL)
cogl_object_unref (value->data[0].v_pointer);
}
void
_cogl_gtype_object_copy_value (const GValue *src,
GValue *dst)
{
if (src->data[0].v_pointer != NULL)
dst->data[0].v_pointer = cogl_object_ref (src->data[0].v_pointer);
else
dst->data[0].v_pointer = NULL;
}
gpointer
_cogl_gtype_object_peek_pointer (const GValue *value)
{
return value->data[0].v_pointer;
}
gchar *
_cogl_gtype_object_collect_value (GValue *value,
guint n_collect_values,
GTypeCValue *collect_values,
guint collect_flags)
{
CoglObject *object;
object = collect_values[0].v_pointer;
if (object == NULL)
{
value->data[0].v_pointer = NULL;
return NULL;
}
if (object->klass == NULL)
return g_strconcat ("invalid unclassed CoglObject pointer for "
"value type '",
G_VALUE_TYPE_NAME (value),
"'",
NULL);
value->data[0].v_pointer = cogl_object_ref (object);
return NULL;
}
gchar *
_cogl_gtype_object_lcopy_value (const GValue *value,
guint n_collect_values,
GTypeCValue *collect_values,
guint collect_flags)
{
CoglObject **object_p = collect_values[0].v_pointer;
if (object_p == NULL)
return g_strconcat ("value location for '",
G_VALUE_TYPE_NAME (value),
"' passed as NULL",
NULL);
if (value->data[0].v_pointer == NULL)
*object_p = NULL;
else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
*object_p = value->data[0].v_pointer;
else
*object_p = cogl_object_ref (value->data[0].v_pointer);
return NULL;
}
void
_cogl_gtype_object_class_base_init (CoglObjectClass *klass)
{
}
void
_cogl_gtype_object_class_base_finalize (CoglObjectClass *klass)
{
}
void
_cogl_gtype_object_class_init (CoglObjectClass *klass)
{
}
void
_cogl_gtype_object_init (CoglObject *object)
{
}
void
_cogl_gtype_dummy_iface_init (gpointer iface)
{
}
/**
* cogl_object_value_set_object:
* @value: a #GValue initialized with %COGL_GTYPE_TYPE_OBJECT
* @object: (type Cogl.GtypeObject) (allow-none): a #CoglGtypeObject, or %NULL
*
* Sets the contents of a #GValue initialized with %COGL_GTYPE_TYPE_OBJECT.
*
*/
void
cogl_object_value_set_object (GValue *value,
gpointer object)
{
CoglObject *old_object;
old_object = value->data[0].v_pointer;
if (object != NULL)
{
/* take over ownership */
value->data[0].v_pointer = object;
}
else
value->data[0].v_pointer = NULL;
if (old_object != NULL)
cogl_object_unref (old_object);
}
/**
* cogl_object_value_get_object:
* @value: a #GValue initialized with %COGL_GTYPE_TYPE_OBJECT
*
* Retrieves a pointer to the #CoglGtypeObject contained inside
* the passed #GValue.
*
* Return value: (transfer none) (type Cogl.GtypeObject): a pointer to
* a #CoglGtypeObject, or %NULL
*/
gpointer
cogl_object_value_get_object (const GValue *value)
{
return value->data[0].v_pointer;
}

View File

@ -39,10 +39,12 @@
#include "cogl-indices.h"
#include "cogl-indices-private.h"
#include "cogl-context-private.h"
#include "cogl-gtype-private.h"
static void _cogl_index_buffer_free (CoglIndexBuffer *indices);
COGL_BUFFER_DEFINE (IndexBuffer, index_buffer);
COGL_GTYPE_DEFINE_CLASS (IndexBuffer, index_buffer);
/* XXX: Unlike the wiki design this just takes a size. A single
* indices buffer should be able to contain multiple ranges of indices

View File

@ -40,6 +40,10 @@
#include <cogl/cogl-context.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -54,6 +58,15 @@ COGL_BEGIN_DECLS
typedef struct _CoglIndexBuffer CoglIndexBuffer;
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_index_buffer_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_index_buffer_get_gtype (void);
#endif
/**
* cogl_index_buffer_new:
* @context: A #CoglContext

View File

@ -42,12 +42,14 @@
#include "cogl-indices.h"
#include "cogl-indices-private.h"
#include "cogl-index-buffer.h"
#include "cogl-gtype-private.h"
#include <stdarg.h>
static void _cogl_indices_free (CoglIndices *indices);
COGL_OBJECT_DEFINE (Indices, indices);
COGL_GTYPE_DEFINE_CLASS (Indices, indices);
static size_t
sizeof_indices_type (CoglIndicesType type)

View File

@ -45,6 +45,10 @@ typedef struct _CoglIndices CoglIndices;
#include <cogl/cogl-index-buffer.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -105,6 +109,15 @@ COGL_BEGIN_DECLS
* for drawing quads as above.
*/
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_indices_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_indices_get_gtype (void);
#endif
CoglIndices *
cogl_indices_new (CoglContext *context,
CoglIndicesType type,

View File

@ -43,10 +43,15 @@
#include "cogl-offscreen.h"
#include "cogl-matrix-private.h"
#include "cogl-magazine-private.h"
#include "cogl-gtype-private.h"
static void _cogl_matrix_stack_free (CoglMatrixStack *stack);
COGL_OBJECT_DEFINE (MatrixStack, matrix_stack);
COGL_GTYPE_DEFINE_CLASS (MatrixStack, matrix_stack);
COGL_GTYPE_DEFINE_BOXED (MatrixEntry, matrix_entry,
cogl_matrix_entry_ref,
cogl_matrix_entry_unref);
static CoglMagazine *cogl_matrix_stack_magazine;
static CoglMagazine *cogl_matrix_stack_matrices_magazine;

View File

@ -134,6 +134,15 @@
*/
typedef struct _CoglMatrixStack CoglMatrixStack;
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_matrix_stack_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_matrix_stack_get_gtype (void);
#endif
/**
* CoglMatrixEntry:
*
@ -170,6 +179,16 @@ typedef struct _CoglMatrixStack CoglMatrixStack;
*/
typedef struct _CoglMatrixEntry CoglMatrixEntry;
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_matrix_entry_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_matrix_entry_get_gtype (void);
#endif
/**
* cogl_matrix_stack_new:
* @ctx: A #CoglContext

View File

@ -85,12 +85,10 @@
#include <math.h>
#include <string.h>
#ifdef _COGL_SUPPORTS_GTYPE_INTEGRATION
#include <cogl-gtype-private.h>
COGL_GTYPE_DEFINE_BOXED ("Matrix", matrix,
COGL_GTYPE_DEFINE_BOXED (Matrix, matrix,
cogl_matrix_copy,
cogl_matrix_free);
#endif
/*
* Symbolic names to some of the entries in the matrix
@ -2305,3 +2303,11 @@ cogl_matrix_transpose (CoglMatrix *matrix)
cogl_matrix_init_from_array (matrix, new_values);
}
#ifdef COGL_HAS_GTYPE_SUPPORT
GType
cogl_gtype_matrix_get_type (void)
{
return cogl_matrix_get_gtype ();
}
#endif

View File

@ -46,6 +46,9 @@
#ifdef COGL_ENABLE_EXPERIMENTAL_API
#include <cogl/cogl-quaternion.h>
#endif
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
@ -123,6 +126,7 @@ struct _CoglMatrix
};
COGL_STRUCT_SIZE_ASSERT (CoglMatrix, 128 + sizeof (unsigned long) * 3);
/**
* cogl_matrix_init_identity:
* @matrix: A 4x4 transformation matrix
@ -787,9 +791,16 @@ cogl_matrix_transpose (CoglMatrix *matrix);
void
cogl_debug_matrix_print (const CoglMatrix *matrix);
#ifdef _COGL_SUPPORTS_GTYPE_INTEGRATION
#ifdef COGL_HAS_GTYPE_SUPPORT
#define COGL_GTYPE_TYPE_MATRIX (cogl_gtype_matrix_get_type ())
#define COGL_GTYPE_TYPE_MATRIX (cogl_matrix_get_gtype ())
/**
* cogl_matrix_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_matrix_get_gtype (void);
/**
* cogl_gtype_matrix_get_type:
@ -797,13 +808,14 @@ cogl_debug_matrix_print (const CoglMatrix *matrix);
* Returns: the GType for the registered "CoglMatrix" boxed type. This
* can be used for example to define GObject properties that accept a
* #CoglMatrix value.
*
* Deprecated: 1.18: Use cogl_matrix_get_gtype() instead.
*/
GType
cogl_gtype_matrix_get_type (void);
#endif /* _COGL_SUPPORTS_GTYPE_INTEGRATION */
#endif /* COGL_HAS_GTYPE_SUPPORT*/
COGL_END_DECLS
#endif /* __COGL_MATRIX_H */

View File

@ -57,6 +57,9 @@ typedef void (*CoglUserDataDestroyInternalCallback) (void *user_data,
typedef struct _CoglObjectClass
{
#ifdef COGL_HAS_GTYPE_SUPPORT
GTypeClass base_class;
#endif
const char *name;
void *virt_free;
void *virt_unref;
@ -80,7 +83,7 @@ typedef struct
*/
struct _CoglObject
{
CoglObjectClass *klass;
CoglObjectClass *klass; /* equivalent to GTypeInstance */
CoglUserDataEntry user_data_entry[
COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES];
@ -124,6 +127,14 @@ struct _CoglObject
#endif /* COGL_OBJECT_DEBUG */
#ifdef COGL_HAS_GTYPE_SUPPORT
#define _COGL_GTYPE_INIT_CLASS(type_name) do { \
_cogl_##type_name##_class.base_class.g_type = cogl_##type_name##_get_gtype (); \
} while (0)
#else
#define _COGL_GTYPE_INIT_CLASS(type_name)
#endif
#define COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \
\
CoglObjectClass _cogl_##type_name##_class; \
@ -148,6 +159,28 @@ _cogl_object_##type_name##_indirect_free (CoglObject *obj) \
_cogl_object_##type_name##_dec (); \
} \
\
static void \
_cogl_object_##type_name##_class_init (void) \
{ \
_cogl_object_##type_name##_count = 0; \
\
if (_cogl_debug_instances == NULL) \
_cogl_debug_instances = \
g_hash_table_new (g_str_hash, g_str_equal); \
\
_cogl_##type_name##_class.virt_free = \
_cogl_object_##type_name##_indirect_free; \
_cogl_##type_name##_class.virt_unref = \
_cogl_object_default_unref; \
_cogl_##type_name##_class.name = "Cogl"#TypeName; \
\
g_hash_table_insert (_cogl_debug_instances, \
(void *) _cogl_##type_name##_class.name, \
&_cogl_object_##type_name##_count); \
\
{ code; } \
} \
\
static Cogl##TypeName * \
_cogl_##type_name##_object_new (Cogl##TypeName *new_obj) \
{ \
@ -160,23 +193,7 @@ _cogl_##type_name##_object_new (Cogl##TypeName *new_obj) \
obj->klass = &_cogl_##type_name##_class; \
if (!obj->klass->virt_free) \
{ \
_cogl_object_##type_name##_count = 0; \
\
if (_cogl_debug_instances == NULL) \
_cogl_debug_instances = \
g_hash_table_new (g_str_hash, g_str_equal); \
\
obj->klass->virt_free = \
_cogl_object_##type_name##_indirect_free; \
obj->klass->virt_unref = \
_cogl_object_default_unref; \
obj->klass->name = "Cogl"#TypeName, \
\
g_hash_table_insert (_cogl_debug_instances, \
(void *) obj->klass->name, \
&_cogl_object_##type_name##_count); \
\
{ code; } \
_cogl_object_##type_name##_class_init (); \
} \
\
_cogl_object_##type_name##_inc (); \
@ -184,9 +201,29 @@ _cogl_##type_name##_object_new (Cogl##TypeName *new_obj) \
return new_obj; \
}
#define COGL_OBJECT_DEFINE_WITH_CODE_GTYPE(TypeName, type_name, code) \
\
COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, \
type_name, \
do { code; } while (0); \
_COGL_GTYPE_INIT_CLASS (type_name)) \
\
CoglBool \
cogl_is_##type_name (void *object) \
{ \
CoglObject *obj = object; \
\
if (object == NULL) \
return FALSE; \
\
return obj->klass == &_cogl_##type_name##_class; \
}
#define COGL_OBJECT_DEFINE_WITH_CODE(TypeName, type_name, code) \
\
COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \
COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, \
type_name, \
do { code; } while (0);) \
\
CoglBool \
cogl_is_##type_name (void *object) \
@ -246,7 +283,7 @@ cogl_##type_name##_unref (void *object) \
}
#define COGL_OBJECT_DEFINE(TypeName, type_name) \
COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
COGL_OBJECT_DEFINE_WITH_CODE_GTYPE (TypeName, type_name, (void) 0)
#define COGL_OBJECT_INTERNAL_DEFINE(TypeName, type_name) \
COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)

View File

@ -39,6 +39,9 @@
#include "cogl-util.h"
#include "cogl-types.h"
#include "cogl-object-private.h"
#include "cogl-gtype-private.h"
COGL_GTYPE_DEFINE_BASE_CLASS (Object, object);
void *
cogl_object_ref (void *object)

View File

@ -33,12 +33,34 @@
#include <cogl/cogl-types.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
typedef struct _CoglObject CoglObject;
#define COGL_OBJECT(X) ((CoglObject *)X)
/**
* CoglObject:
*
* Ref Func: cogl_object_ref
* Unref Func: cogl_object_unref
* Set Value Func: cogl_object_value_set_object
* Get Value Func: cogl_object_value_get_object
*/
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_object_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_object_get_gtype (void);
#endif
/**
* cogl_object_ref: (skip)
* @object: a #CoglObject

View File

@ -38,6 +38,10 @@
#include <cogl/cogl-types.h>
#include <cogl/cogl-texture.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -52,6 +56,15 @@ typedef struct _CoglOffscreen CoglOffscreen;
#define COGL_OFFSCREEN(X) ((CoglOffscreen *)X)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_offscreen_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_offscreen_get_gtype (void);
#endif
/* Offscreen api */
/**

View File

@ -37,12 +37,14 @@
#include "cogl-framebuffer-private.h"
#include "cogl-onscreen-template-private.h"
#include "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);
static void
_cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template)

View File

@ -39,12 +39,25 @@
#include <cogl/cogl-swap-chain.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
typedef struct _CoglOnscreenTemplate CoglOnscreenTemplate;
#define COGL_ONSCREEN_TEMPLATE(OBJECT) ((CoglOnscreenTemplate *)OBJECT)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_onscreen_template_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_onscreen_template_get_gtype (void);
#endif
CoglOnscreenTemplate *
cogl_onscreen_template_new (CoglSwapChain *swap_chain);

View File

@ -42,12 +42,15 @@
#include "cogl1-context.h"
#include "cogl-closure-list-private.h"
#include "cogl-poll-private.h"
#include "cogl-gtype-private.h"
static void _cogl_onscreen_free (CoglOnscreen *onscreen);
COGL_OBJECT_DEFINE_WITH_CODE (Onscreen, onscreen,
_cogl_onscreen_class.virt_unref =
_cogl_framebuffer_unref);
COGL_GTYPE_DEFINE_CLASS (Onscreen, onscreen,
COGL_GTYPE_IMPLEMENT_INTERFACE (framebuffer));
static void
_cogl_onscreen_init_from_template (CoglOnscreen *onscreen,

View File

@ -43,11 +43,24 @@
#include <cogl/cogl-frame-info.h>
#include <cogl/cogl-object.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
typedef struct _CoglOnscreen CoglOnscreen;
#define COGL_ONSCREEN(X) ((CoglOnscreen *)(X))
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_onscreen_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_onscreen_get_gtype (void);
#endif
/**
* cogl_onscreen_new: (constructor)
* @context: A #CoglContext

View File

@ -33,12 +33,14 @@
#endif
#include "cogl-output-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
static void _cogl_output_free (CoglOutput *output);
COGL_OBJECT_DEFINE (Output, output);
COGL_GTYPE_DEFINE_CLASS (Output, output);
CoglOutput *
_cogl_output_new (const char *name)

View File

@ -39,6 +39,10 @@
#include <cogl/cogl-types.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -66,6 +70,15 @@ COGL_BEGIN_DECLS
typedef struct _CoglOutput CoglOutput;
#define COGL_OUTPUT(X) ((CoglOutput *)(X))
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_output_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_output_get_gtype (void);
#endif
/**
* CoglSubpixelOrder:
* @COGL_SUBPIXEL_ORDER_UNKNOWN: the layout of subpixel

View File

@ -51,6 +51,7 @@
#include "cogl-profile.h"
#include "cogl-depth-state-private.h"
#include "cogl1-context.h"
#include "cogl-gtype-private.h"
#include <glib.h>
#include <glib/gprintf.h>
@ -95,6 +96,7 @@ _cogl_pipeline_progends[MAX (COGL_PIPELINE_N_PROGENDS, 1)];
#endif
COGL_OBJECT_DEFINE (Pipeline, pipeline);
COGL_GTYPE_DEFINE_CLASS (Pipeline, pipeline);
/*
* This initializes the first pipeline owned by the Cogl context. All

View File

@ -44,6 +44,10 @@ typedef struct _CoglPipeline CoglPipeline;
#include <cogl/cogl-context.h>
#include <cogl/cogl-snippet.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
#ifdef COGL_ENABLE_EXPERIMENTAL_API
@ -64,6 +68,15 @@ COGL_BEGIN_DECLS
#define COGL_PIPELINE(OBJECT) ((CoglPipeline *)OBJECT)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_pipeline_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_pipeline_get_gtype (void);
#endif
/**
* cogl_pipeline_new:
* @context: a #CoglContext

View File

@ -51,6 +51,7 @@
#include "cogl-object.h"
#include "cogl-pixel-buffer-private.h"
#include "cogl-pixel-buffer.h"
#include "cogl-gtype-private.h"
/*
* GL/GLES compatibility defines for the buffer API:
@ -72,6 +73,7 @@ static void
_cogl_pixel_buffer_free (CoglPixelBuffer *buffer);
COGL_BUFFER_DEFINE (PixelBuffer, pixel_buffer)
COGL_GTYPE_DEFINE_CLASS (PixelBuffer, pixel_buffer)
static CoglPixelBuffer *
_cogl_pixel_buffer_new (CoglContext *context,

View File

@ -46,10 +46,23 @@ typedef struct _CoglPixelBuffer CoglPixelBuffer;
#include <cogl/cogl-types.h>
#include <cogl/cogl-context.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
#define COGL_PIXEL_BUFFER(buffer) ((CoglPixelBuffer *)(buffer))
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_pixel_buffer_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_pixel_buffer_get_gtype (void);
#endif
/**
* cogl_pixel_buffer_new:
* @context: A #CoglContext

View File

@ -41,6 +41,7 @@
#include "cogl-primitive-private.h"
#include "cogl-attribute-private.h"
#include "cogl-framebuffer-private.h"
#include "cogl-gtype-private.h"
#include <stdarg.h>
#include <string.h>
@ -48,6 +49,7 @@
static void _cogl_primitive_free (CoglPrimitive *primitive);
COGL_OBJECT_DEFINE (Primitive, primitive);
COGL_GTYPE_DEFINE_CLASS (Primitive, primitive);
CoglPrimitive *
cogl_primitive_new_with_attributes (CoglVerticesMode mode,

View File

@ -47,6 +47,10 @@ typedef struct _CoglPrimitive CoglPrimitive;
#include <cogl/cogl-attribute.h>
#include <cogl/cogl-framebuffer.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -57,6 +61,15 @@ COGL_BEGIN_DECLS
* FIXME
*/
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_primitive_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_primitive_get_gtype (void);
#endif
/**
* CoglVertexP2:
* @x: The x component of a position attribute
@ -272,7 +285,6 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode,
* @mode: A #CoglVerticesMode defining how to draw the vertices
* @n_vertices: The number of vertices to read from @data and also
* the number of vertices to read when later drawing.
* @data: (array length=n_vertices): (type Cogl.VertexP2): An array
* of #CoglVertexP2 vertices
*

View File

@ -49,12 +49,17 @@
#include <cogl-matrix.h>
#include <cogl-vector.h>
#include <cogl-euler.h>
#include "cogl-gtype-private.h"
#include <string.h>
#include <math.h>
#define FLOAT_EPSILON 1e-03
COGL_GTYPE_DEFINE_BOXED (Quaternion, quaternion,
cogl_quaternion_copy,
cogl_quaternion_free);
static CoglQuaternion zero_quaternion =
{
0.0, 0.0, 0.0, 0.0,

View File

@ -59,6 +59,10 @@ COGL_BEGIN_DECLS
#include <cogl/cogl-vector.h>
#include <cogl/cogl-euler.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
/**
* CoglQuaternion:
* @w: based on the angle of rotation it is cos(𝜃/2)
@ -128,6 +132,7 @@ COGL_BEGIN_DECLS
*/
struct _CoglQuaternion
{
/*< public >*/
float w;
float x;
@ -142,6 +147,15 @@ struct _CoglQuaternion
};
COGL_STRUCT_SIZE_ASSERT (CoglQuaternion, 32);
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_quaternion_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_quaternion_get_gtype (void);
#endif
/**
* cogl_quaternion_init:
* @quaternion: An uninitialized #CoglQuaternion

View File

@ -49,6 +49,7 @@
#include "cogl-winsys-stub-private.h"
#include "cogl-config-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
#include "cogl-winsys-egl-x11-private.h"
@ -227,6 +228,7 @@ static CoglWinsysVtableGetter _cogl_winsys_vtable_getters[] =
static void _cogl_renderer_free (CoglRenderer *renderer);
COGL_OBJECT_DEFINE (Renderer, renderer);
COGL_GTYPE_DEFINE_CLASS (Renderer, renderer);
typedef struct _CoglNativeFilterClosure
{

View File

@ -38,6 +38,10 @@
#include <cogl/cogl-error.h>
#include <cogl/cogl-output.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -85,6 +89,15 @@ cogl_renderer_error_quark (void);
typedef struct _CoglRenderer CoglRenderer;
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_renderer_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_renderer_get_gtype (void);
#endif
/**
* cogl_is_renderer:
* @object: A #CoglObject pointer

View File

@ -38,11 +38,13 @@
#include "cogl-types.h"
#include "cogl-snippet-private.h"
#include "cogl-util.h"
#include "cogl-gtype-private.h"
static void
_cogl_snippet_free (CoglSnippet *snippet);
COGL_OBJECT_DEFINE (Snippet, snippet);
COGL_GTYPE_DEFINE_CLASS (Snippet, snippet);
CoglSnippet *
cogl_snippet_new (CoglSnippetHook hook,

View File

@ -341,6 +341,15 @@ typedef struct _CoglSnippet CoglSnippet;
#define COGL_SNIPPET(OBJECT) ((CoglSnippet *)OBJECT)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_snippet_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_snippet_get_gtype (void);
#endif
/* Enumeration of all the hook points that a snippet can be attached
to within a pipeline. */
/**

View File

@ -45,6 +45,7 @@
#include "cogl-texture-rectangle-private.h"
#include "cogl-texture-2d.h"
#include "cogl-texture-gl-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
#include <math.h>
@ -52,6 +53,7 @@
static void _cogl_sub_texture_free (CoglSubTexture *sub_tex);
COGL_TEXTURE_DEFINE (SubTexture, sub_texture);
COGL_GTYPE_DEFINE_CLASS (SubTexture, sub_texture);
static const CoglTextureVtable cogl_sub_texture_vtable;

View File

@ -52,6 +52,15 @@ COGL_BEGIN_DECLS
#define COGL_SUB_TEXTURE(tex) ((CoglSubTexture *) tex)
typedef struct _CoglSubTexture CoglSubTexture;
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_sub_texture_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_sub_texture_get_gtype (void);
#endif
/**
* cogl_sub_texture_new:
* @ctx: A #CoglContext pointer

View File

@ -37,10 +37,13 @@
#include "cogl-swap-chain-private.h"
#include "cogl-swap-chain.h"
#include "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);
static void
_cogl_swap_chain_free (CoglSwapChain *swap_chain)

View File

@ -33,10 +33,25 @@
#ifndef __COGL_SWAP_CHAIN_H__
#define __COGL_SWAP_CHAIN_H__
#include <cogl/cogl-types.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
typedef struct _CoglSwapChain CoglSwapChain;
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_swap_chain_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_swap_chain_get_gtype (void);
#endif
CoglSwapChain *
cogl_swap_chain_new (void);

View File

@ -56,6 +56,7 @@
#include "cogl-primitive-texture.h"
#include "cogl-error-private.h"
#include "cogl-texture-gl-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
#include <stdlib.h>
@ -64,6 +65,8 @@
static void _cogl_texture_2d_sliced_free (CoglTexture2DSliced *tex_2ds);
COGL_TEXTURE_DEFINE (Texture2DSliced, texture_2d_sliced);
COGL_GTYPE_DEFINE_CLASS (Texture2DSliced, texture_2d_sliced,
COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
static const CoglTextureVtable cogl_texture_2d_sliced_vtable;

View File

@ -70,6 +70,15 @@
typedef struct _CoglTexture2DSliced CoglTexture2DSliced;
#define COGL_TEXTURE_2D_SLICED(X) ((CoglTexture2DSliced *)X)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_texture_2d_sliced_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_2d_sliced_get_gtype (void);
#endif
/**
* cogl_texture_2d_sliced_new_with_size:
* @ctx: A #CoglContext

View File

@ -50,6 +50,7 @@
#ifdef COGL_HAS_EGL_SUPPORT
#include "cogl-winsys-egl-private.h"
#endif
#include "cogl-gtype-private.h"
#include <string.h>
#include <math.h>
@ -61,6 +62,8 @@
static void _cogl_texture_2d_free (CoglTexture2D *tex_2d);
COGL_TEXTURE_DEFINE (Texture2D, texture_2d);
COGL_GTYPE_DEFINE_CLASS (Texture2D, texture_2d,
COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
static const CoglTextureVtable cogl_texture_2d_vtable;

View File

@ -61,6 +61,15 @@ COGL_BEGIN_DECLS
typedef struct _CoglTexture2D CoglTexture2D;
#define COGL_TEXTURE_2D(X) ((CoglTexture2D *)X)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_texture_2d_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_2d_get_gtype (void);
#endif
/**
* cogl_is_texture_2d:
* @object: A #CoglObject

View File

@ -47,6 +47,7 @@
#include "cogl-pipeline-opengl-private.h"
#include "cogl-error-private.h"
#include "cogl-util-gl-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
#include <math.h>
@ -62,6 +63,8 @@
static void _cogl_texture_3d_free (CoglTexture3D *tex_3d);
COGL_TEXTURE_DEFINE (Texture3D, texture_3d);
COGL_GTYPE_DEFINE_CLASS (Texture3D, texture_3d,
COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
static const CoglTextureVtable cogl_texture_3d_vtable;

View File

@ -52,6 +52,15 @@ typedef struct _CoglTexture3D CoglTexture3D;
#define COGL_TEXTURE_3D(X) ((CoglTexture3D *)X)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_texture_3d_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_3d_get_gtype (void);
#endif
/**
* cogl_texture_3d_new_with_size:
* @context: a #CoglContext

View File

@ -254,7 +254,7 @@ void
_cogl_texture_register_texture_type (const CoglObjectClass *klass);
#define COGL_TEXTURE_DEFINE(TypeName, type_name) \
COGL_OBJECT_DEFINE_WITH_CODE \
COGL_OBJECT_DEFINE_WITH_CODE_GTYPE \
(TypeName, type_name, \
_cogl_texture_register_texture_type (&_cogl_##type_name##_class))

View File

@ -46,6 +46,7 @@
#include "cogl-pipeline-opengl-private.h"
#include "cogl-error-private.h"
#include "cogl-util-gl-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
#include <math.h>
@ -64,6 +65,8 @@
static void _cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect);
COGL_TEXTURE_DEFINE (TextureRectangle, texture_rectangle);
COGL_GTYPE_DEFINE_CLASS (TextureRectangle, texture_rectangle,
COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
static const CoglTextureVtable cogl_texture_rectangle_vtable;

View File

@ -69,6 +69,15 @@ COGL_BEGIN_DECLS
typedef struct _CoglTextureRectangle CoglTextureRectangle;
#define COGL_TEXTURE_RECTANGLE(X) ((CoglTextureRectangle *)X)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_texture_rectangle_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_rectangle_get_gtype (void);
#endif
/**
* cogl_is_texture_rectangle:
* @object: A #CoglObject

View File

@ -63,6 +63,7 @@
#include "cogl-sub-texture.h"
#include "cogl-primitive-texture.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include <string.h>
#include <stdlib.h>
@ -73,6 +74,8 @@
#define GL_RED 0x1903
#endif
COGL_GTYPE_DEFINE_INTERFACE (Texture, texture);
uint32_t
cogl_texture_error_quark (void)
{

View File

@ -56,6 +56,10 @@ typedef struct _CoglTexture CoglTexture;
#endif
#include <cogl/cogl-bitmap.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
/**
@ -69,6 +73,15 @@ COGL_BEGIN_DECLS
#define COGL_TEXTURE_MAX_WASTE 127
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_texture_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_get_gtype (void);
#endif
/**
* COGL_TEXTURE_ERROR:
*
@ -79,7 +92,6 @@ COGL_BEGIN_DECLS
*/
#define COGL_TEXTURE_ERROR (cogl_texture_error_quark ())
/**
* CoglTextureError:
* @COGL_TEXTURE_ERROR_SIZE: Unsupported size

View File

@ -57,6 +57,7 @@
#include "cogl-error-private.h"
#include "cogl-texture-gl-private.h"
#include "cogl-private.h"
#include "cogl-gtype-private.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -71,6 +72,7 @@
static void _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap);
COGL_TEXTURE_DEFINE (TexturePixmapX11, texture_pixmap_x11);
COGL_GTYPE_DEFINE_CLASS (TexturePixmapX11, texture_pixmap_x11);
static const CoglTextureVtable cogl_texture_pixmap_x11_vtable;

View File

@ -50,6 +50,10 @@
#include <cogl/cogl-context.h>
#ifdef COGL_HAS_GTYPE_SUPPORT
#include <glib-object.h>
#endif
COGL_BEGIN_DECLS
#ifdef COGL_ENABLE_EXPERIMENTAL_API
@ -68,6 +72,15 @@ typedef struct _CoglTexturePixmapX11 CoglTexturePixmapX11;
#define COGL_TEXTURE_PIXMAP_X11(X) ((CoglTexturePixmapX11 *)X)
#ifdef COGL_HAS_GTYPE_SUPPORT
/**
* cogl_texture_pixmap_x11_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_pixmap_x11_get_gtype (void);
#endif
typedef enum
{
COGL_TEXTURE_PIXMAP_X11_DAMAGE_RAW_RECTANGLES,