[cogl/wip/rib/introspection-1.18: 2/2] Registers gtypes for all public objects and structs



commit 5affebf8c7549bd73348e4f6ed797337bbb5ba69
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>

 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 31891ea..f70a01e 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -39,6 +39,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. */
@@ -175,6 +177,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 fc73792..95fabb3 100644
--- a/cogl-gst/cogl-gst-video-sink.h
+++ b/cogl-gst/cogl-gst-video-sink.h
@@ -91,6 +91,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) \
@@ -433,6 +437,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 aeceda2..f974480 100644
--- a/cogl-path/cogl-path.c
+++ b/cogl-path/cogl-path.c
@@ -44,6 +44,7 @@
 
 #include "cogl-path/cogl-path.h"
 #include "cogl-path-private.h"
+#include "cogl-gtype-private.h"
 
 #include <string.h>
 #include <math.h>
@@ -57,6 +58,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 dae0809..dabb117 100644
--- a/cogl-path/cogl2-path-functions.h
+++ b/cogl-path/cogl2-path-functions.h
@@ -35,9 +35,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:
@@ -64,7 +76,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 dffec07..76db8f0 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                  \
@@ -666,12 +676,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__ 
-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 c412a70..81efc0a 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -45,12 +45,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 e4fc594..ea90972 100644
--- a/cogl/cogl-atlas-texture.h
+++ b/cogl/cogl-atlas-texture.h
@@ -31,6 +31,10 @@
 
 #include <cogl/cogl-context.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -61,6 +65,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 20c093d..40c5fc6 100644
--- a/cogl/cogl-attribute-buffer.c
+++ b/cogl/cogl-attribute-buffer.c
@@ -33,10 +33,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 caa4c5e..8ccc885 100644
--- a/cogl/cogl-attribute-buffer.h
+++ b/cogl/cogl-attribute-buffer.h
@@ -38,6 +38,10 @@ typedef struct _CoglAttributeBuffer CoglAttributeBuffer;
 
 #include <cogl/cogl-context.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -50,6 +54,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 1bd6b42..ea7da6d 100644
--- a/cogl/cogl-attribute.c
+++ b/cogl/cogl-attribute.c
@@ -45,6 +45,7 @@
 #include "cogl-pipeline-progend-glsl-private.h"
 #endif
 #include "cogl-private.h"
+#include "cogl-gtype-private.h"
 
 #include <string.h>
 #include <stdio.h>
@@ -58,6 +59,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 019e6c9..d2ecc3e 100644
--- a/cogl/cogl-attribute.h
+++ b/cogl/cogl-attribute.h
@@ -39,6 +39,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
 
 /**
@@ -49,6 +53,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 9b51a30..ad72b64 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -34,12 +34,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 a175a3a..a335a9f 100644
--- a/cogl/cogl-bitmap.h
+++ b/cogl/cogl-bitmap.h
@@ -37,12 +37,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 014eae9..09749f2 100644
--- a/cogl/cogl-buffer-private.h
+++ b/cogl/cogl-buffer-private.h
@@ -112,7 +112,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 7d5db0f..b625073 100644
--- a/cogl/cogl-color.c
+++ b/cogl/cogl-color.c
@@ -31,6 +31,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 2896505..3a155c2 100644
--- a/cogl/cogl-color.h
+++ b/cogl/cogl-color.h
@@ -41,8 +41,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 75cfdb3..8bf9c89 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -49,6 +49,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"
 
@@ -71,6 +72,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 c38b863..da26f08 100644
--- a/cogl/cogl-context.h
+++ b/cogl/cogl-context.h
@@ -39,6 +39,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
@@ -91,6 +95,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 cedd68b..7a64b25 100644
--- a/cogl/cogl-display.c
+++ b/cogl/cogl-display.c
@@ -39,10 +39,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 0dfa2ab..971ddea 100644
--- a/cogl/cogl-display.h
+++ b/cogl/cogl-display.h
@@ -34,6 +34,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
@@ -66,6 +70,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 5931f89..73325f3 100644
--- a/cogl/cogl-euler.c
+++ b/cogl/cogl-euler.c
@@ -31,10 +31,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 bf526d7..1389194 100644
--- a/cogl/cogl-euler.h
+++ b/cogl/cogl-euler.h
@@ -33,6 +33,10 @@
 
 #include <cogl/cogl-types.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -157,6 +161,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 a64e728..d514392 100644
--- a/cogl/cogl-frame-info.c
+++ b/cogl/cogl-frame-info.c
@@ -26,10 +26,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 8d9c39b..a7d0b6c 100644
--- a/cogl/cogl-frame-info.h
+++ b/cogl/cogl-frame-info.h
@@ -33,6 +33,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
@@ -40,6 +44,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 cb55dbe..c9490cf 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -49,6 +49,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;
 
@@ -61,7 +62,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 f2a96c9..2f0c7c1 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -53,6 +53,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
 
@@ -96,6 +99,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
@@ -1798,4 +1810,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 ffaf1f0..ec77b75 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -47,10 +47,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 d3f628c..ef84e2b 100644
--- a/cogl/cogl-gles2.h
+++ b/cogl/cogl-gles2.h
@@ -136,11 +136,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 5715d01..63b5d32 100644
--- a/cogl/cogl-gtype-private.h
+++ b/cogl/cogl-gtype-private.h
@@ -22,21 +22,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); \
@@ -44,5 +70,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 a36c2d2..f34d2df 100644
--- a/cogl/cogl-index-buffer.c
+++ b/cogl/cogl-index-buffer.c
@@ -33,10 +33,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 e9fdda9..4074790 100644
--- a/cogl/cogl-index-buffer.h
+++ b/cogl/cogl-index-buffer.h
@@ -33,6 +33,10 @@
 
 #include <cogl/cogl-context.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -47,6 +51,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 ebdaccf..db8d75a 100644
--- a/cogl/cogl-indices.c
+++ b/cogl/cogl-indices.c
@@ -36,12 +36,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 483b137..8137850 100644
--- a/cogl/cogl-indices.h
+++ b/cogl/cogl-indices.h
@@ -38,6 +38,10 @@ typedef struct _CoglIndices CoglIndices;
 
 #include <cogl/cogl-index-buffer.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -98,6 +102,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 6438041..c71f5d9 100644
--- a/cogl/cogl-matrix-stack.c
+++ b/cogl/cogl-matrix-stack.c
@@ -37,10 +37,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 4498ec2..9b6cdbe 100644
--- a/cogl/cogl-matrix-stack.h
+++ b/cogl/cogl-matrix-stack.h
@@ -128,6 +128,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:
  *
@@ -164,6 +173,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 5c3cb67..bde9826 100644
--- a/cogl/cogl-matrix.c
+++ b/cogl/cogl-matrix.c
@@ -77,12 +77,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
@@ -2297,3 +2295,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 de6cba3..1bd3bb2 100644
--- a/cogl/cogl-matrix.h
+++ b/cogl/cogl-matrix.h
@@ -39,6 +39,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
 
@@ -116,6 +119,7 @@ struct _CoglMatrix
 };
 COGL_STRUCT_SIZE_ASSERT (CoglMatrix, 128 + sizeof (unsigned long) * 3);
 
+
 /**
  * cogl_matrix_init_identity:
  * @matrix: A 4x4 transformation matrix
@@ -780,9 +784,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:
@@ -790,13 +801,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 82fc06c..6019595 100644
--- a/cogl/cogl-object-private.h
+++ b/cogl/cogl-object-private.h
@@ -51,6 +51,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;
@@ -74,7 +77,7 @@ typedef struct
  */
 struct _CoglObject
 {
-  CoglObjectClass  *klass;
+  CoglObjectClass  *klass; /* equivalent to GTypeInstance */
 
   CoglUserDataEntry user_data_entry[
     COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES];
@@ -118,6 +121,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;                              \
@@ -142,6 +153,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)                \
 {                                                                       \
@@ -154,23 +187,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 ();                                    \
@@ -178,9 +195,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)                                      \
@@ -240,7 +277,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 9ae29f7..152f88a 100644
--- a/cogl/cogl-object.c
+++ b/cogl/cogl-object.c
@@ -33,6 +33,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 a557f80..19849fe 100644
--- a/cogl/cogl-object.h
+++ b/cogl/cogl-object.h
@@ -27,6 +27,10 @@
 
 #include <cogl/cogl-types.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 typedef struct _CoglObject      CoglObject;
@@ -34,6 +38,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 fcb9924..3a1d5f7 100644
--- a/cogl/cogl-offscreen.h
+++ b/cogl/cogl-offscreen.h
@@ -31,6 +31,10 @@
 #include <cogl/cogl-types.h>
 #include <cogl/cogl-texture.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -45,6 +49,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 5fa5b99..02f4678 100644
--- a/cogl/cogl-onscreen-template.c
+++ b/cogl/cogl-onscreen-template.c
@@ -32,12 +32,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 c105469..e89b0f0 100644
--- a/cogl/cogl-onscreen-template.h
+++ b/cogl/cogl-onscreen-template.h
@@ -33,12 +33,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 3c1fe3c..fd8eff1 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -35,12 +35,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 5f616e7..5bea318 100644
--- a/cogl/cogl-onscreen.h
+++ b/cogl/cogl-onscreen.h
@@ -37,11 +37,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 1f5e78f..793148d 100644
--- a/cogl/cogl-output.c
+++ b/cogl/cogl-output.c
@@ -26,12 +26,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 c0cc7cc..bebd8bf 100644
--- a/cogl/cogl-output.h
+++ b/cogl/cogl-output.h
@@ -33,6 +33,10 @@
 
 #include <cogl/cogl-types.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -60,6 +64,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 350cbf3..0fb0ff7 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -45,6 +45,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>
@@ -89,6 +90,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 8e90d19..f0558d2 100644
--- a/cogl/cogl-pipeline.h
+++ b/cogl/cogl-pipeline.h
@@ -37,6 +37,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
@@ -57,6 +61,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 b664ddc..0f97683 100644
--- a/cogl/cogl-pixel-buffer.c
+++ b/cogl/cogl-pixel-buffer.c
@@ -44,6 +44,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:
@@ -65,6 +66,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 b618efd..3a665d4 100644
--- a/cogl/cogl-pixel-buffer.h
+++ b/cogl/cogl-pixel-buffer.h
@@ -39,10 +39,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 580f4b8..4d7f1d4 100644
--- a/cogl/cogl-primitive.c
+++ b/cogl/cogl-primitive.c
@@ -35,6 +35,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>
@@ -42,6 +43,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 1266fd2..9f2fdc3 100644
--- a/cogl/cogl-primitive.h
+++ b/cogl/cogl-primitive.h
@@ -40,6 +40,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
 
 /**
@@ -50,6 +54,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
@@ -265,7 +278,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 8a918c6..e56ef8d 100644
--- a/cogl/cogl-quaternion.c
+++ b/cogl/cogl-quaternion.c
@@ -44,12 +44,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 b5848c1..ef623db 100644
--- a/cogl/cogl-quaternion.h
+++ b/cogl/cogl-quaternion.h
@@ -54,6 +54,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)
@@ -123,6 +127,7 @@ COGL_BEGIN_DECLS
  */
 struct _CoglQuaternion
 {
+  /*< public >*/
   float w;
 
   float x;
@@ -137,6 +142,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 d2042fc..caa8f4f 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -44,6 +44,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"
@@ -222,6 +223,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 19c1195..42a79e1 100644
--- a/cogl/cogl-renderer.h
+++ b/cogl/cogl-renderer.h
@@ -33,6 +33,10 @@
 #include <cogl/cogl-error.h>
 #include <cogl/cogl-output.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -80,6 +84,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 25c1a0a..7a16d1e 100644
--- a/cogl/cogl-snippet.c
+++ b/cogl/cogl-snippet.c
@@ -32,11 +32,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 120a9be..7bc118d 100644
--- a/cogl/cogl-snippet.h
+++ b/cogl/cogl-snippet.h
@@ -335,6 +335,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 8f18229..e39518d 100644
--- a/cogl/cogl-sub-texture.c
+++ b/cogl/cogl-sub-texture.c
@@ -38,6 +38,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>
@@ -45,6 +46,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 1130b83..5f38545 100644
--- a/cogl/cogl-sub-texture.h
+++ b/cogl/cogl-sub-texture.h
@@ -47,6 +47,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 7a5b342..61981eb 100644
--- a/cogl/cogl-swap-chain.c
+++ b/cogl/cogl-swap-chain.c
@@ -32,10 +32,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 05596a8..2e3cdda 100644
--- a/cogl/cogl-swap-chain.h
+++ b/cogl/cogl-swap-chain.h
@@ -28,10 +28,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 33d0cc3..e1923c5 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -49,6 +49,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>
@@ -57,6 +58,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 94fdf22..1db481f 100644
--- a/cogl/cogl-texture-2d-sliced.h
+++ b/cogl/cogl-texture-2d-sliced.h
@@ -64,6 +64,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 62b8956..1617ee0 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -43,6 +43,7 @@
 #ifdef COGL_HAS_EGL_SUPPORT
 #include "cogl-winsys-egl-private.h"
 #endif
+#include "cogl-gtype-private.h"
 
 #include <string.h>
 #include <math.h>
@@ -54,6 +55,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 ae30b15..6abecab 100644
--- a/cogl/cogl-texture-2d.h
+++ b/cogl/cogl-texture-2d.h
@@ -55,6 +55,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 9ebfe2d..756e942 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -40,6 +40,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>
@@ -55,6 +56,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 091812a..4f59d26 100644
--- a/cogl/cogl-texture-3d.h
+++ b/cogl/cogl-texture-3d.h
@@ -47,6 +47,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 5c422cf..bbb7f31 100644
--- a/cogl/cogl-texture-private.h
+++ b/cogl/cogl-texture-private.h
@@ -247,7 +247,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 02bdb5f..f86812d 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -39,6 +39,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>
@@ -57,6 +58,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 421e331..c982705 100644
--- a/cogl/cogl-texture-rectangle.h
+++ b/cogl/cogl-texture-rectangle.h
@@ -63,6 +63,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 e2abde6..c964346 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -56,6 +56,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>
@@ -66,6 +67,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 d4e40c5..2c864e1 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -49,6 +49,10 @@ typedef struct _CoglTexture CoglTexture;
 #endif
 #include <cogl/cogl-bitmap.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 /**
@@ -62,6 +66,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:
  *
@@ -72,7 +85,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 ee34a51..e1b1b9d 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -50,6 +50,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>
@@ -64,6 +65,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 babf596..9fc38b0 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.h
+++ b/cogl/winsys/cogl-texture-pixmap-x11.h
@@ -43,6 +43,10 @@
 
 #include <cogl/cogl-context.h>
 
+#ifdef COGL_HAS_GTYPE_SUPPORT
+#include <glib-object.h>
+#endif
+
 COGL_BEGIN_DECLS
 
 #ifdef COGL_ENABLE_EXPERIMENTAL_API
@@ -61,6 +65,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]