[cogl/cogl-1.18] Registers gtypes for all public objects and structs



commit 1b2dd815b4a81048f445890b91d12237a8a06a8b
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Mon Sep 2 16:02:42 2013 +0100

    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>

 cogl-gst/Makefile.am                  |   37 ++++++
 cogl-gst/cogl-gst-video-sink.c        |   30 +++++
 cogl-gst/cogl-gst-video-sink.h        |    6 +
 cogl-pango/Makefile.am                |   18 +++-
 cogl-path/cogl-path.c                 |    2 +
 cogl-path/cogl2-path-functions.h      |   14 ++-
 cogl/Makefile.am                      |   28 ++++-
 cogl/cogl-atlas-texture.c             |    2 +
 cogl/cogl-atlas-texture.h             |   12 ++
 cogl/cogl-attribute-buffer.c          |    2 +
 cogl/cogl-attribute-buffer.h          |   13 ++
 cogl/cogl-attribute.c                 |    2 +
 cogl/cogl-attribute.h                 |   13 ++
 cogl/cogl-bitmap.c                    |    2 +
 cogl/cogl-bitmap.h                    |   13 ++
 cogl/cogl-buffer-private.h            |    2 +-
 cogl/cogl-color.c                     |    3 +
 cogl/cogl-color.h                     |   13 ++
 cogl/cogl-context.c                   |    2 +
 cogl/cogl-context.h                   |   13 ++
 cogl/cogl-display.c                   |    2 +
 cogl/cogl-display.h                   |   13 ++
 cogl/cogl-euler.c                     |    5 +
 cogl/cogl-euler.h                     |   13 ++
 cogl/cogl-frame-info.c                |    2 +
 cogl/cogl-frame-info.h                |   13 ++
 cogl/cogl-framebuffer.c               |    3 +
 cogl/cogl-framebuffer.h               |   13 ++-
 cogl/cogl-gles2-context.c             |    2 +
 cogl/cogl-gles2.h                     |   13 ++
 cogl/cogl-gtype-private.h             |  231 ++++++++++++++++++++++++++++++++-
 cogl/cogl-gtype.c                     |  153 ++++++++++++++++++++++
 cogl/cogl-index-buffer.c              |    2 +
 cogl/cogl-index-buffer.h              |   13 ++
 cogl/cogl-indices.c                   |    2 +
 cogl/cogl-indices.h                   |   13 ++
 cogl/cogl-matrix-stack.c              |    5 +
 cogl/cogl-matrix-stack.h              |   19 +++
 cogl/cogl-matrix.c                    |   12 ++-
 cogl/cogl-matrix.h                    |   20 +++-
 cogl/cogl-object-private.h            |   77 ++++++++---
 cogl/cogl-object.c                    |    3 +
 cogl/cogl-object.h                    |   22 +++
 cogl/cogl-offscreen.h                 |   13 ++
 cogl/cogl-onscreen-template.c         |    2 +
 cogl/cogl-onscreen-template.h         |   13 ++
 cogl/cogl-onscreen.c                  |    3 +
 cogl/cogl-onscreen.h                  |   13 ++
 cogl/cogl-output.c                    |    2 +
 cogl/cogl-output.h                    |   13 ++
 cogl/cogl-pipeline.c                  |    2 +
 cogl/cogl-pipeline.h                  |   13 ++
 cogl/cogl-pixel-buffer.c              |    2 +
 cogl/cogl-pixel-buffer.h              |   13 ++
 cogl/cogl-primitive.c                 |    2 +
 cogl/cogl-primitive.h                 |   14 ++-
 cogl/cogl-quaternion.c                |    5 +
 cogl/cogl-quaternion.h                |   14 ++
 cogl/cogl-renderer.c                  |    2 +
 cogl/cogl-renderer.h                  |   13 ++
 cogl/cogl-snippet.c                   |    2 +
 cogl/cogl-snippet.h                   |    9 ++
 cogl/cogl-sub-texture.c               |    2 +
 cogl/cogl-sub-texture.h               |    9 ++
 cogl/cogl-swap-chain.c                |    3 +
 cogl/cogl-swap-chain.h                |   15 ++
 cogl/cogl-texture-2d-sliced.c         |    3 +
 cogl/cogl-texture-2d-sliced.h         |    9 ++
 cogl/cogl-texture-2d.c                |    3 +
 cogl/cogl-texture-2d.h                |    9 ++
 cogl/cogl-texture-3d.c                |    3 +
 cogl/cogl-texture-3d.h                |    9 ++
 cogl/cogl-texture-private.h           |    2 +-
 cogl/cogl-texture-rectangle.c         |    3 +
 cogl/cogl-texture-rectangle.h         |    9 ++
 cogl/cogl-texture.c                   |    3 +
 cogl/cogl-texture.h                   |   14 ++-
 cogl/winsys/cogl-texture-pixmap-x11.c |    2 +
 cogl/winsys/cogl-texture-pixmap-x11.h |   13 ++
 79 files changed, 1098 insertions(+), 41 deletions(-)
---
diff --git a/cogl-gst/Makefile.am b/cogl-gst/Makefile.am
index 49c68ad..ba0c3d8 100644
--- a/cogl-gst/Makefile.am
+++ b/cogl-gst/Makefile.am
@@ -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
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 42b50a9..1461083 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -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)
 {
diff --git a/cogl-gst/cogl-gst-video-sink.h b/cogl-gst/cogl-gst-video-sink.h
index 71718c2..12a6480 100644
--- a/cogl-gst/cogl-gst-video-sink.h
+++ b/cogl-gst/cogl-gst-video-sink.h
@@ -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
diff --git a/cogl-pango/Makefile.am b/cogl-pango/Makefile.am
index 2f86cb7..64d9771 100644
--- a/cogl-pango/Makefile.am
+++ b/cogl-pango/Makefile.am
@@ -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)
diff --git a/cogl-path/cogl-path.c b/cogl-path/cogl-path.c
index fd74131..2b4b3c6 100644
--- a/cogl-path/cogl-path.c
+++ b/cogl-path/cogl-path.c
@@ -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)
diff --git a/cogl-path/cogl2-path-functions.h b/cogl-path/cogl2-path-functions.h
index 61f8f65..72c1fc8 100644
--- a/cogl-path/cogl2-path-functions.h
+++ b/cogl-path/cogl2-path-functions.h
@@ -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
  */
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index 9c01227..62d3762 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -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)
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index fcdd064..beaaf24 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -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;
 
diff --git a/cogl/cogl-atlas-texture.h b/cogl/cogl-atlas-texture.h
index 081df6e..79c15b9 100644
--- a/cogl/cogl-atlas-texture.h
+++ b/cogl/cogl-atlas-texture.h
@@ -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:
diff --git a/cogl/cogl-attribute-buffer.c b/cogl/cogl-attribute-buffer.c
index 0e8b417..8d92d29 100644
--- a/cogl/cogl-attribute-buffer.c
+++ b/cogl/cogl-attribute-buffer.c
@@ -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,
diff --git a/cogl/cogl-attribute-buffer.h b/cogl/cogl-attribute-buffer.h
index a713439..189d81e 100644
--- a/cogl/cogl-attribute-buffer.h
+++ b/cogl/cogl-attribute-buffer.h
@@ -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
diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c
index 6264f09..bcfbf78 100644
--- a/cogl/cogl-attribute.c
+++ b/cogl/cogl-attribute.c
@@ -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,
diff --git a/cogl/cogl-attribute.h b/cogl/cogl-attribute.h
index f974893..736b0c6 100644
--- a/cogl/cogl-attribute.h
+++ b/cogl/cogl-attribute.h
@@ -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
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c
index 27565d7..5b2aa8e 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -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)
diff --git a/cogl/cogl-bitmap.h b/cogl/cogl-bitmap.h
index fd4f292..13b5cd2 100644
--- a/cogl/cogl-bitmap.h
+++ b/cogl/cogl-bitmap.h
@@ -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
diff --git a/cogl/cogl-buffer-private.h b/cogl/cogl-buffer-private.h
index eab81fd..0402abb 100644
--- a/cogl/cogl-buffer-private.h
+++ b/cogl/cogl-buffer-private.h
@@ -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))
 
diff --git a/cogl/cogl-color.c b/cogl/cogl-color.c
index c26a2b8..02e501d 100644
--- a/cogl/cogl-color.c
+++ b/cogl/cogl-color.c
@@ -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)
diff --git a/cogl/cogl-color.h b/cogl/cogl-color.h
index e52e92a..bdb0bfa 100644
--- a/cogl/cogl-color.h
+++ b/cogl/cogl-color.h
@@ -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:
  *
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 2c00579..a7eed29 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -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);
diff --git a/cogl/cogl-context.h b/cogl/cogl-context.h
index f7cd2e8..07badeb 100644
--- a/cogl/cogl-context.h
+++ b/cogl/cogl-context.h
@@ -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
diff --git a/cogl/cogl-display.c b/cogl/cogl-display.c
index 54852d6..ced922f 100644
--- a/cogl/cogl-display.c
+++ b/cogl/cogl-display.c
@@ -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)
diff --git a/cogl/cogl-display.h b/cogl/cogl-display.h
index 68e9616..ae3f3c9 100644
--- a/cogl/cogl-display.h
+++ b/cogl/cogl-display.h
@@ -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
diff --git a/cogl/cogl-euler.c b/cogl/cogl-euler.c
index fce6b49..f877bbc 100644
--- a/cogl/cogl-euler.c
+++ b/cogl/cogl-euler.c
@@ -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,
diff --git a/cogl/cogl-euler.h b/cogl/cogl-euler.h
index 62d4b82..4ccbb2a 100644
--- a/cogl/cogl-euler.h
+++ b/cogl/cogl-euler.h
@@ -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
diff --git a/cogl/cogl-frame-info.c b/cogl/cogl-frame-info.c
index 0f7ddda..2114a64 100644
--- a/cogl/cogl-frame-info.c
+++ b/cogl/cogl-frame-info.c
@@ -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)
diff --git a/cogl/cogl-frame-info.h b/cogl/cogl-frame-info.h
index ceb57c9..7304c53 100644
--- a/cogl/cogl-frame-info.h
+++ b/cogl/cogl-frame-info.h
@@ -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
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index e14c72a..3245d61 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -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
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index 3c93e0d..347284f 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -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 */
-
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index 516339e..33c4387 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -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;
 
diff --git a/cogl/cogl-gles2.h b/cogl/cogl-gles2.h
index 49de955..84c9ba1 100644
--- a/cogl/cogl-gles2.h
+++ b/cogl/cogl-gles2.h
@@ -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);
 
diff --git a/cogl/cogl-gtype-private.h b/cogl/cogl-gtype-private.h
index 4889e7e..21590da 100644
--- a/cogl/cogl-gtype-private.h
+++ b/cogl/cogl-gtype-private.h
@@ -28,21 +28,47 @@
  *
  */
 
+#ifndef __COGL_GTYPE_PRIVATE_H__
+#define __COGL_GTYPE_PRIVATE_H__
+
+#include "config.h"
+
 #include <glib.h>
 #include <glib-object.h>
 
-#ifndef __COGL_GTYPE_PRIVATE_H__
-#define __COGL_GTYPE_PRIVATE_H__
+#include "cogl-object-private.h"
+
+/* Move this to public headers? */
+typedef struct _CoglGtypeObject CoglGtypeObject;
+typedef struct _CoglGtypeClass  CoglGtypeClass;
+
+struct _CoglGtypeObject
+{
+  GTypeInstance parent_instance;
 
-#define COGL_GTYPE_DEFINE_BOXED(Name, underscore_name, copy_func, free_func) \
+  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__ */
diff --git a/cogl/cogl-gtype.c b/cogl/cogl-gtype.c
new file mode 100644
index 0000000..314d8e4
--- /dev/null
+++ b/cogl/cogl-gtype.c
@@ -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;
+}
diff --git a/cogl/cogl-index-buffer.c b/cogl/cogl-index-buffer.c
index 33190d2..cddaf47 100644
--- a/cogl/cogl-index-buffer.c
+++ b/cogl/cogl-index-buffer.c
@@ -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
diff --git a/cogl/cogl-index-buffer.h b/cogl/cogl-index-buffer.h
index 2eef2aa..204c858 100644
--- a/cogl/cogl-index-buffer.h
+++ b/cogl/cogl-index-buffer.h
@@ -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
diff --git a/cogl/cogl-indices.c b/cogl/cogl-indices.c
index 581a4c2..2256830 100644
--- a/cogl/cogl-indices.c
+++ b/cogl/cogl-indices.c
@@ -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)
diff --git a/cogl/cogl-indices.h b/cogl/cogl-indices.h
index 636f9a1..3cc9239 100644
--- a/cogl/cogl-indices.h
+++ b/cogl/cogl-indices.h
@@ -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,
diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c
index 62ef30d..400855f 100644
--- a/cogl/cogl-matrix-stack.c
+++ b/cogl/cogl-matrix-stack.c
@@ -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;
diff --git a/cogl/cogl-matrix-stack.h b/cogl/cogl-matrix-stack.h
index cd09d4b..6ea323a 100644
--- a/cogl/cogl-matrix-stack.h
+++ b/cogl/cogl-matrix-stack.h
@@ -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
diff --git a/cogl/cogl-matrix.c b/cogl/cogl-matrix.c
index 6a8cef5..fd0f6af 100644
--- a/cogl/cogl-matrix.c
+++ b/cogl/cogl-matrix.c
@@ -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
diff --git a/cogl/cogl-matrix.h b/cogl/cogl-matrix.h
index 5b3ba37..58ec5c7 100644
--- a/cogl/cogl-matrix.h
+++ b/cogl/cogl-matrix.h
@@ -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 */
-
diff --git a/cogl/cogl-object-private.h b/cogl/cogl-object-private.h
index cf5d189..61ada8f 100644
--- a/cogl/cogl-object-private.h
+++ b/cogl/cogl-object-private.h
@@ -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)
diff --git a/cogl/cogl-object.c b/cogl/cogl-object.c
index fe9a279..452f625 100644
--- a/cogl/cogl-object.c
+++ b/cogl/cogl-object.c
@@ -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)
diff --git a/cogl/cogl-object.h b/cogl/cogl-object.h
index e07a923..a0bed88 100644
--- a/cogl/cogl-object.h
+++ b/cogl/cogl-object.h
@@ -33,6 +33,10 @@
 
 #include <cogl/cogl-types.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 typedef struct _CoglObject      CoglObject;
@@ -40,6 +44,24 @@ 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
  *
diff --git a/cogl/cogl-offscreen.h b/cogl/cogl-offscreen.h
index 7de4bd7..9c84442 100644
--- a/cogl/cogl-offscreen.h
+++ b/cogl/cogl-offscreen.h
@@ -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 */
 
 /**
diff --git a/cogl/cogl-onscreen-template.c b/cogl/cogl-onscreen-template.c
index ce94587..5a5e54c 100644
--- a/cogl/cogl-onscreen-template.c
+++ b/cogl/cogl-onscreen-template.c
@@ -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)
diff --git a/cogl/cogl-onscreen-template.h b/cogl/cogl-onscreen-template.h
index 7b22b77..cd1d853 100644
--- a/cogl/cogl-onscreen-template.h
+++ b/cogl/cogl-onscreen-template.h
@@ -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);
 
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
index bc20f54..8ca9770 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -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,
diff --git a/cogl/cogl-onscreen.h b/cogl/cogl-onscreen.h
index 867d6f4..fd24e12 100644
--- a/cogl/cogl-onscreen.h
+++ b/cogl/cogl-onscreen.h
@@ -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
diff --git a/cogl/cogl-output.c b/cogl/cogl-output.c
index 56f1e4c..ae85605 100644
--- a/cogl/cogl-output.c
+++ b/cogl/cogl-output.c
@@ -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)
diff --git a/cogl/cogl-output.h b/cogl/cogl-output.h
index dea3166..6eec10e 100644
--- a/cogl/cogl-output.h
+++ b/cogl/cogl-output.h
@@ -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
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 6d60a6f..b2fee10 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -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
diff --git a/cogl/cogl-pipeline.h b/cogl/cogl-pipeline.h
index 9d2c4db..08ae3f6 100644
--- a/cogl/cogl-pipeline.h
+++ b/cogl/cogl-pipeline.h
@@ -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
diff --git a/cogl/cogl-pixel-buffer.c b/cogl/cogl-pixel-buffer.c
index 1960b90..e2d6565 100644
--- a/cogl/cogl-pixel-buffer.c
+++ b/cogl/cogl-pixel-buffer.c
@@ -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,
diff --git a/cogl/cogl-pixel-buffer.h b/cogl/cogl-pixel-buffer.h
index e53eb51..8ae6164 100644
--- a/cogl/cogl-pixel-buffer.h
+++ b/cogl/cogl-pixel-buffer.h
@@ -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
diff --git a/cogl/cogl-primitive.c b/cogl/cogl-primitive.c
index 6c2866d..b31a25a 100644
--- a/cogl/cogl-primitive.c
+++ b/cogl/cogl-primitive.c
@@ -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,
diff --git a/cogl/cogl-primitive.h b/cogl/cogl-primitive.h
index a3549d4..0f20bb5 100644
--- a/cogl/cogl-primitive.h
+++ b/cogl/cogl-primitive.h
@@ -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
  *
diff --git a/cogl/cogl-quaternion.c b/cogl/cogl-quaternion.c
index 0c47adc..9567443 100644
--- a/cogl/cogl-quaternion.c
+++ b/cogl/cogl-quaternion.c
@@ -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,
diff --git a/cogl/cogl-quaternion.h b/cogl/cogl-quaternion.h
index a4a4704..c70ecca 100644
--- a/cogl/cogl-quaternion.h
+++ b/cogl/cogl-quaternion.h
@@ -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
diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c
index 9672f7c..ef6e900 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -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
 {
diff --git a/cogl/cogl-renderer.h b/cogl/cogl-renderer.h
index 012706f..78cb25d 100644
--- a/cogl/cogl-renderer.h
+++ b/cogl/cogl-renderer.h
@@ -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
diff --git a/cogl/cogl-snippet.c b/cogl/cogl-snippet.c
index 3e1bf8a..a3f5d6c 100644
--- a/cogl/cogl-snippet.c
+++ b/cogl/cogl-snippet.c
@@ -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,
diff --git a/cogl/cogl-snippet.h b/cogl/cogl-snippet.h
index 41e0d88..b8d9efd 100644
--- a/cogl/cogl-snippet.h
+++ b/cogl/cogl-snippet.h
@@ -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. */
 /**
diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c
index 26aebef..7baf95e 100644
--- a/cogl/cogl-sub-texture.c
+++ b/cogl/cogl-sub-texture.c
@@ -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;
 
diff --git a/cogl/cogl-sub-texture.h b/cogl/cogl-sub-texture.h
index 1db67df..ced2677 100644
--- a/cogl/cogl-sub-texture.h
+++ b/cogl/cogl-sub-texture.h
@@ -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
diff --git a/cogl/cogl-swap-chain.c b/cogl/cogl-swap-chain.c
index 1f8a4ba..e5dd2f4 100644
--- a/cogl/cogl-swap-chain.c
+++ b/cogl/cogl-swap-chain.c
@@ -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)
diff --git a/cogl/cogl-swap-chain.h b/cogl/cogl-swap-chain.h
index a153a2d..d048867 100644
--- a/cogl/cogl-swap-chain.h
+++ b/cogl/cogl-swap-chain.h
@@ -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);
 
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index 46500f6..e76bef6 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -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;
 
diff --git a/cogl/cogl-texture-2d-sliced.h b/cogl/cogl-texture-2d-sliced.h
index 538dd19..ec959a9 100644
--- a/cogl/cogl-texture-2d-sliced.h
+++ b/cogl/cogl-texture-2d-sliced.h
@@ -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
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index a65e847..cc28cd9 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -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;
 
diff --git a/cogl/cogl-texture-2d.h b/cogl/cogl-texture-2d.h
index db71a52..c806ced 100644
--- a/cogl/cogl-texture-2d.h
+++ b/cogl/cogl-texture-2d.h
@@ -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
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index 2205b25..8e2ff08 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -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;
 
diff --git a/cogl/cogl-texture-3d.h b/cogl/cogl-texture-3d.h
index 17a71e0..b3b038a 100644
--- a/cogl/cogl-texture-3d.h
+++ b/cogl/cogl-texture-3d.h
@@ -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
diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h
index 0d2f568..472c41d 100644
--- a/cogl/cogl-texture-private.h
+++ b/cogl/cogl-texture-private.h
@@ -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))
 
diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c
index 368588f..65d2f06 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -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;
 
diff --git a/cogl/cogl-texture-rectangle.h b/cogl/cogl-texture-rectangle.h
index 0b86215..7619686 100644
--- a/cogl/cogl-texture-rectangle.h
+++ b/cogl/cogl-texture-rectangle.h
@@ -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
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index a890692..d93db22 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -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)
 {
diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h
index 7ea6e9e..2718830 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -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
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 896fdba..6c1edeb 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -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;
 
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.h b/cogl/winsys/cogl-texture-pixmap-x11.h
index 12dd416..35155cd 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.h
+++ b/cogl/winsys/cogl-texture-pixmap-x11.h
@@ -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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]