[Cogl] [PATCH] Declare interface types as void and remove cast macros

Robert Bragg robert at sixbynine.org
Tue Oct 29 00:51:58 CET 2013


From: Robert Bragg <robert at linux.intel.com>

This declares the interface types CoglFramebuffer, CoglBuffer,
CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when
including the public cogl.h header so that users don't have to use lots
of C type casts between instance types and interface types.

This also removes all of the COGL_XYZ() type cast macros since they do
nothing more than compile time type casting but it's less readable if
you haven't seen that coding pattern before.

Unlike with gobject based apis that use per-type macros for casting and
performing runtime type checking we instead prefer to do our runtime
type checking internally within the front-end public apis when objects
are passed into Cogl. This greatly reduces the verbosity for users of
the api and may help reduce the chance of excessive runtime type
checking that can sometimes be a problem.
---
 cogl-gst/cogl-gst-video-sink.c                     | 19 +++++-----
 cogl-gst/cogl-gst-video-sink.h                     | 10 ++++++
 cogl-pango/cogl-pango-display-list.c               |  1 -
 cogl-pango/cogl-pango-display-list.h               |  1 -
 cogl-pango/cogl-pango-glyph-cache.h                |  3 +-
 cogl-pango/cogl-pango-pipeline-cache.c             |  1 -
 cogl-pango/cogl-pango-pipeline-cache.h             |  3 +-
 cogl-pango/cogl-pango.h                            | 13 +++++++
 cogl-path/cogl-path.c                              |  2 --
 cogl-path/cogl-path.h                              |  7 ++--
 cogl/cogl-buffer.h                                 | 10 ++++--
 cogl/cogl-framebuffer.h                            | 10 ++++--
 cogl/cogl-gles2.h                                  |  9 +++++
 cogl/cogl-meta-texture.h                           |  7 ++++
 cogl/cogl-primitive-texture.h                      |  7 ++++
 cogl/cogl-texture.h                                | 10 ++++--
 cogl/cogl-wayland-client.h                         |  9 +++++
 cogl/cogl-wayland-server.h                         |  9 +++++
 cogl/cogl-xlib-renderer.h                          |  8 +++++
 cogl/cogl-xlib.h                                   |  8 +++++
 cogl/cogl.h                                        |  4 +++
 cogl/winsys/cogl-texture-pixmap-x11.h              |  8 +++++
 examples/cogl-basic-video-player.c                 |  2 +-
 examples/cogl-crate.c                              |  6 ++--
 examples/cogl-gles2-context.c                      |  6 ++--
 examples/cogl-gles2-gears.c                        |  2 +-
 examples/cogl-hello.c                              |  8 ++---
 examples/cogl-msaa.c                               | 10 +++---
 examples/cogl-point-sprites.c                      | 10 +++---
 examples/cogl-sdl2-hello.c                         |  6 ++--
 examples/cogl-x11-foreign.c                        |  2 +-
 examples/cogl-x11-tfp.c                            |  4 +--
 examples/cogland.c                                 | 11 +++---
 test-fixtures/test-utils.h                         | 11 ++++++
 tests/conform/Makefile.am                          |  3 +-
 tests/conform/test-alpha-test.c                    |  2 +-
 tests/conform/test-alpha-textures.c                |  4 +--
 tests/conform/test-backface-culling.c              |  2 +-
 tests/conform/test-color-mask.c                    |  3 +-
 tests/conform/test-copy-replace-texture.c          |  2 +-
 tests/conform/test-fence.c                         |  1 -
 tests/conform/test-framebuffer-get-bits.c          |  8 ++---
 tests/conform/test-gles2-context.c                 | 40 +++++++++++-----------
 tests/conform/test-map-buffer-range.c              |  6 ++--
 tests/conform/test-offscreen.c                     |  8 ++---
 tests/conform/test-pipeline-cache-unrefs-texture.c |  2 +-
 tests/conform/test-pipeline-shader-state.c         |  8 ++---
 tests/conform/test-pixel-buffer.c                  | 12 +++----
 tests/conform/test-point-sprite.c                  |  2 +-
 tests/conform/test-premult.c                       |  4 +--
 tests/conform/test-read-texture-formats.c          | 10 +++---
 tests/conform/test-sub-texture.c                   | 28 +++++++--------
 tests/conform/test-texture-3d.c                    |  6 ++--
 tests/conform/test-texture-mipmap-get-set.c        |  2 +-
 tests/conform/test-texture-no-allocate.c           |  8 ++---
 tests/conform/test-version.c                       |  8 +++++
 tests/conform/test-wrap-rectangle-textures.c       |  2 +-
 tests/micro-perf/test-journal.c                    |  2 +-
 58 files changed, 268 insertions(+), 142 deletions(-)

diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 4feb724..d7e8b61 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -31,17 +31,20 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <gst/gst.h>
 #include <gst/gstvalue.h>
 #include <gst/video/video.h>
 #include <gst/riff/riff-ids.h>
-#include <cogl/cogl.h>
 #include <string.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. */
+#undef COGL_COMPILATION
+#include <cogl/cogl.h>
+
 #include "cogl-gst-video-sink.h"
 
 #define COGL_GST_DEFAULT_PRIORITY G_PRIORITY_HIGH_IDLE
@@ -198,7 +201,7 @@ cogl_gst_video_sink_attach_frame (CoglGstVideoSink *sink,
   for (i = 0; i < G_N_ELEMENTS (priv->frame); i++)
     if (priv->frame[i] != NULL)
       cogl_pipeline_set_layer_texture (pln, i + priv->custom_start,
-                                       COGL_TEXTURE (priv->frame[i]));
+                                       priv->frame[i]);
 }
 
 static CoglBool
@@ -486,9 +489,9 @@ video_texture_new_from_data (CoglContext *ctx,
        is_pot (cogl_bitmap_get_height (bitmap))) ||
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC))
     {
-      tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap,
-                                                           internal_format,
-                                                           &internal_error));
+      tex = cogl_texture_2d_new_from_bitmap (bitmap,
+                                             internal_format,
+                                             &internal_error);
       if (!tex)
         {
           cogl_error_free (internal_error);
@@ -506,7 +509,7 @@ video_texture_new_from_data (CoglContext *ctx,
                                                 -1, /* no maximum waste */
                                                 internal_format,
                                                 error);
-      tex = COGL_TEXTURE (tex_2ds);
+      tex = tex_2ds;
     }
 
   cogl_object_unref (bitmap);
diff --git a/cogl-gst/cogl-gst-video-sink.h b/cogl-gst/cogl-gst-video-sink.h
index 39cca52..317e1c7 100644
--- a/cogl-gst/cogl-gst-video-sink.h
+++ b/cogl-gst/cogl-gst-video-sink.h
@@ -35,6 +35,16 @@
 #define __COGL_GST_VIDEO_SINK_H__
 #include <glib-object.h>
 #include <gst/base/gstbasesink.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. */
+#ifdef COGL_COMPILATION
+#undef COGL_COMPILATION
+#endif
+
+#include <cogl/cogl.h>
+
 #include <cogl/cogl.h>
 
 /**
diff --git a/cogl-pango/cogl-pango-display-list.c b/cogl-pango/cogl-pango-display-list.c
index 46f0d2a..f44d223 100644
--- a/cogl-pango/cogl-pango-display-list.c
+++ b/cogl-pango/cogl-pango-display-list.c
@@ -26,7 +26,6 @@
 #endif
 
 #include <glib.h>
-#include <cogl/cogl.h>
 #include <string.h>
 
 #include "cogl-pango-display-list.h"
diff --git a/cogl-pango/cogl-pango-display-list.h b/cogl-pango/cogl-pango-display-list.h
index 28ac4fd..27b591a 100644
--- a/cogl-pango/cogl-pango-display-list.h
+++ b/cogl-pango/cogl-pango-display-list.h
@@ -25,7 +25,6 @@
 #define __COGL_PANGO_DISPLAY_LIST_H__
 
 #include <glib.h>
-#include <cogl/cogl.h>
 #include "cogl-pango-pipeline-cache.h"
 
 COGL_BEGIN_DECLS
diff --git a/cogl-pango/cogl-pango-glyph-cache.h b/cogl-pango/cogl-pango-glyph-cache.h
index fc25a71..d0aba6c 100644
--- a/cogl-pango/cogl-pango-glyph-cache.h
+++ b/cogl-pango/cogl-pango-glyph-cache.h
@@ -25,9 +25,10 @@
 #define __COGL_PANGO_GLYPH_CACHE_H__
 
 #include <glib.h>
-#include <cogl/cogl.h>
 #include <pango/pango-font.h>
 
+#include "cogl/cogl-texture.h"
+
 COGL_BEGIN_DECLS
 
 typedef struct _CoglPangoGlyphCache      CoglPangoGlyphCache;
diff --git a/cogl-pango/cogl-pango-pipeline-cache.c b/cogl-pango/cogl-pango-pipeline-cache.c
index 1e702d0..68461ab 100644
--- a/cogl-pango/cogl-pango-pipeline-cache.c
+++ b/cogl-pango/cogl-pango-pipeline-cache.c
@@ -30,7 +30,6 @@
 #endif
 
 #include <glib.h>
-#include <cogl/cogl.h>
 #include "cogl-pango-pipeline-cache.h"
 
 #include "cogl/cogl-context-private.h"
diff --git a/cogl-pango/cogl-pango-pipeline-cache.h b/cogl-pango/cogl-pango-pipeline-cache.h
index 411650b..d97edb4 100644
--- a/cogl-pango/cogl-pango-pipeline-cache.h
+++ b/cogl-pango/cogl-pango-pipeline-cache.h
@@ -29,7 +29,8 @@
 #define __COGL_PANGO_PIPELINE_CACHE_H__
 
 #include <glib.h>
-#include <cogl/cogl.h>
+
+#include "cogl/cogl-context-private.h"
 
 COGL_BEGIN_DECLS
 
diff --git a/cogl-pango/cogl-pango.h b/cogl-pango/cogl-pango.h
index 9feff0c..25fbfd1 100644
--- a/cogl-pango/cogl-pango.h
+++ b/cogl-pango/cogl-pango.h
@@ -32,7 +32,20 @@
 #include <glib-object.h>
 #include <pango/pango.h>
 #include <pango/pangocairo.h>
+
+/* XXX: Currently this header may be included both as an internal
+ * header (within the cogl-pango implementation) and as a public
+ * header.
+ *
+ * Since <cogl/cogl.h> should not be included for internal use we
+ * determine the current context and switch between including cogl.h
+ * or specific internal cogl headers here...
+ */
+#ifndef COGL_COMPILATION
 #include <cogl/cogl.h>
+#else
+#include "cogl/cogl-context.h"
+#endif
 
 COGL_BEGIN_DECLS
 
diff --git a/cogl-path/cogl-path.c b/cogl-path/cogl-path.c
index 221f40f..aef43c0 100644
--- a/cogl-path/cogl-path.c
+++ b/cogl-path/cogl-path.c
@@ -26,9 +26,7 @@
  *  Robert Bragg  <robert at linux.intel.com>
  */
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include "cogl-util.h"
 #include "cogl-object.h"
diff --git a/cogl-path/cogl-path.h b/cogl-path/cogl-path.h
index 594a62b..81a6ac6 100644
--- a/cogl-path/cogl-path.h
+++ b/cogl-path/cogl-path.h
@@ -24,7 +24,11 @@
 #ifndef __COGL_PATH_H__
 #define __COGL_PATH_H__
 
+#ifdef COGL_COMPILATION
+#include "cogl-context.h"
+#else
 #include <cogl/cogl.h>
+#endif
 
 COGL_BEGIN_DECLS
 
@@ -46,11 +50,8 @@ COGL_BEGIN_DECLS
  * vertices of the path segments relative to the last pen location
  * rather then in the absolute coordinates.
  */
-
 typedef struct _CoglPath CoglPath;
 
-#define COGL_PATH(obj) ((CoglPath *)(obj))
-
 /**
  * cogl_path_new:
  * @context: A #CoglContext pointer
diff --git a/cogl/cogl-buffer.h b/cogl/cogl-buffer.h
index d160ed0..2df2598 100644
--- a/cogl/cogl-buffer.h
+++ b/cogl/cogl-buffer.h
@@ -59,9 +59,15 @@ COGL_BEGIN_DECLS
  * without blocking other Cogl operations.
  */
 
-#define COGL_BUFFER(buffer)     ((CoglBuffer *)(buffer))
-
+#ifdef __COGL_H_INSIDE__
+/* For the public C api we typedef interface types as void to avoid needing
+ * lots of casting in code and instead we will rely on runtime type checking
+ * for these objects. */
+typedef void CoglBuffer;
+#else
 typedef struct _CoglBuffer CoglBuffer;
+#define COGL_BUFFER(buffer) ((CoglBuffer *)(buffer))
+#endif
 
 #define COGL_BUFFER_ERROR (_cogl_buffer_error_domain ())
 
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index 650552b..8cba5d6 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -35,7 +35,15 @@
 /* We forward declare the CoglFramebuffer type here to avoid some circular
  * dependency issues with the following headers.
  */
+#ifdef __COGL_H_INSIDE__
+/* For the public C api we typedef interface types as void to avoid needing
+ * lots of casting in code and instead we will rely on runtime type checking
+ * for these objects. */
+typedef void CoglFramebuffer;
+#else
 typedef struct _CoglFramebuffer CoglFramebuffer;
+#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
+#endif
 
 #include <cogl/cogl-pipeline.h>
 #include <cogl/cogl-indices.h>
@@ -84,8 +92,6 @@ COGL_BEGIN_DECLS
  * configuration.
  */
 
-#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
-
 /**
  * cogl_framebuffer_allocate:
  * @framebuffer: A #CoglFramebuffer
diff --git a/cogl/cogl-gles2.h b/cogl/cogl-gles2.h
index eff995c..75d37f6 100644
--- a/cogl/cogl-gles2.h
+++ b/cogl/cogl-gles2.h
@@ -29,7 +29,16 @@
 #ifndef __COGL_GLES2_H__
 #define __COGL_GLES2_H__
 
+/* NB: cogl-gles2.h is a top-level header that can be included directly
+ * but we want to be careful not to define __COGL_H_INSIDE__ when this
+ * is included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private
+ * api definitions
+ */
+#ifndef COGL_COMPILATION
 #define __COGL_H_INSIDE__
+#endif
+
 #include <cogl/cogl-defines.h>
 #include <cogl/cogl-context.h>
 #include <cogl/cogl-framebuffer.h>
diff --git a/cogl/cogl-meta-texture.h b/cogl/cogl-meta-texture.h
index 60a3b4e..e7d9465 100644
--- a/cogl/cogl-meta-texture.h
+++ b/cogl/cogl-meta-texture.h
@@ -86,8 +86,15 @@ COGL_BEGIN_DECLS
  * meta-textures.</note>
  */
 
+#ifdef __COGL_H_INSIDE__
+/* For the public C api we typedef interface types as void to avoid needing
+ * lots of casting in code and instead we will rely on runtime type checking
+ * for these objects. */
+typedef void CoglMetaTexture;
+#else
 typedef struct _CoglMetaTexture CoglMetaTexture;
 #define COGL_META_TEXTURE(X) ((CoglMetaTexture *)X)
+#endif
 
 /**
  * CoglMetaTextureCallback:
diff --git a/cogl/cogl-primitive-texture.h b/cogl/cogl-primitive-texture.h
index a7e6a0f..4ceec24 100644
--- a/cogl/cogl-primitive-texture.h
+++ b/cogl/cogl-primitive-texture.h
@@ -57,8 +57,15 @@ COGL_BEGIN_DECLS
  * primitive textures.</note>
  */
 
+#ifdef __COGL_H_INSIDE__
+/* For the public C api we typedef interface types as void to avoid needing
+ * lots of casting in code and instead we will rely on runtime type checking
+ * for these objects. */
+typedef void CoglPrimitiveTexture;
+#else
 typedef struct _CoglPrimitiveTexture CoglPrimitiveTexture;
 #define COGL_PRIMITIVE_TEXTURE(X) ((CoglPrimitiveTexture *)X)
+#endif
 
 /**
  * cogl_is_primitive_texture:
diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h
index a3cd0cf..351376f 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -32,7 +32,15 @@
 /* We forward declare the CoglTexture type here to avoid some circular
  * dependency issues with the following headers.
  */
+#ifdef __COGL_H_INSIDE__
+/* For the public C api we typedef interface types as void to avoid needing
+ * lots of casting in code and instead we will rely on runtime type checking
+ * for these objects. */
+typedef void CoglTexture;
+#else
 typedef struct _CoglTexture CoglTexture;
+#define COGL_TEXTURE(X) ((CoglTexture *)X)
+#endif
 
 #include <cogl/cogl-types.h>
 #include <cogl/cogl-defines.h>
@@ -55,8 +63,6 @@ COGL_BEGIN_DECLS
  * via this #CoglTexture interface.
  */
 
-#define COGL_TEXTURE(X) ((CoglTexture *)X)
-
 #define COGL_TEXTURE_MAX_WASTE  127
 
 /**
diff --git a/cogl/cogl-wayland-client.h b/cogl/cogl-wayland-client.h
index 610f558..a211a1f 100644
--- a/cogl/cogl-wayland-client.h
+++ b/cogl/cogl-wayland-client.h
@@ -24,7 +24,16 @@
 #ifndef __COGL_WAYLAND_CLIENT_H
 #define __COGL_WAYLAND_CLIENT_H
 
+/* NB: this is a top-level header that can be included directly but we
+ * want to be careful not to define __COGL_H_INSIDE__ when this is
+ * included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private api
+ * definitions
+ */
+#ifndef COGL_COMPILATION
 #define __COGL_H_INSIDE__
+#endif
+
 #include <cogl/cogl-wayland-renderer.h>
 
 #endif /* __COGL_WAYLAND_CLIENT_H */
diff --git a/cogl/cogl-wayland-server.h b/cogl/cogl-wayland-server.h
index e56f5bd..26b30dc 100644
--- a/cogl/cogl-wayland-server.h
+++ b/cogl/cogl-wayland-server.h
@@ -26,7 +26,16 @@
 
 #include <wayland-server.h>
 
+/* NB: this is a top-level header that can be included directly but we
+ * want to be careful not to define __COGL_H_INSIDE__ when this is
+ * included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private api
+ * definitions
+ */
+#ifndef COGL_COMPILATION
 #define __COGL_H_INSIDE__
+#endif
+
 #include <cogl/cogl-context.h>
 #include <cogl/cogl-texture-2d.h>
 
diff --git a/cogl/cogl-xlib-renderer.h b/cogl/cogl-xlib-renderer.h
index db25b4e..569beaa 100644
--- a/cogl/cogl-xlib-renderer.h
+++ b/cogl/cogl-xlib-renderer.h
@@ -30,7 +30,15 @@
 
 #include <X11/Xlib.h>
 
+/* NB: this is a top-level header that can be included directly but we
+ * want to be careful not to define __COGL_H_INSIDE__ when this is
+ * included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private api
+ * definitions
+ */
+#ifndef COGL_COMPILATION
 #define __COGL_H_INSIDE__
+#endif
 #include <cogl/cogl-renderer.h>
 
 COGL_BEGIN_DECLS
diff --git a/cogl/cogl-xlib.h b/cogl/cogl-xlib.h
index 4e7e37f..87d7fa4 100644
--- a/cogl/cogl-xlib.h
+++ b/cogl/cogl-xlib.h
@@ -26,8 +26,16 @@
 
 #include <X11/Xlib.h>
 
+/* NB: this is a top-level header that can be included directly but we
+ * want to be careful not to define __COGL_H_INSIDE__ when this is
+ * included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private api
+ * definitions
+ */
+#ifndef COGL_COMPILATION
 #define __COGL_XLIB_H_INSIDE__
 #define __COGL_H_INSIDE__
+#endif
 
 #include <cogl/cogl-types.h>
 #include <cogl/cogl-clutter-xlib.h>
diff --git a/cogl/cogl.h b/cogl/cogl.h
index c5ad661..539a127 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -25,6 +25,10 @@
 #ifndef __COGL_H__
 #define __COGL_H__
 
+#ifdef COGL_COMPILATION
+#error "<cogl/cogl.h> shouldn't be included internally"
+#endif
+
 #define __COGL_H_INSIDE__
 
 #include <cogl/cogl-defines.h>
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.h b/cogl/winsys/cogl-texture-pixmap-x11.h
index eaa743d..41129a6 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.h
+++ b/cogl/winsys/cogl-texture-pixmap-x11.h
@@ -24,7 +24,15 @@
 #ifndef __COGL_TEXTURE_PIXMAP_X11_H
 #define __COGL_TEXTURE_PIXMAP_X11_H
 
+/* NB: this is a top-level header that can be included directly but we
+ * want to be careful not to define __COGL_H_INSIDE__ when this is
+ * included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private api
+ * definitions
+ */
+#ifndef COGL_COMPILATION
 #define __COGL_H_INSIDE__
+#endif
 
 #include <cogl/cogl-context.h>
 
diff --git a/examples/cogl-basic-video-player.c b/examples/cogl-basic-video-player.c
index ba1e6c6..cc1ace2 100644
--- a/examples/cogl-basic-video-player.c
+++ b/examples/cogl-basic-video-player.c
@@ -257,7 +257,7 @@ main (int argc,
   cogl_onscreen_add_resize_callback (onscreen, _resize_callback, &data, NULL);
   cogl_onscreen_show (onscreen);
 
-  data.fb = COGL_FRAMEBUFFER (onscreen);
+  data.fb = onscreen;
   cogl_framebuffer_orthographic (data.fb, 0, 0, 640, 480, -1, 100);
 
   data.border_pipeline = cogl_pipeline_new (ctx);
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index 9c22be7..67613fc 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -161,7 +161,7 @@ main (int argc, char **argv)
   }
 
   onscreen = cogl_onscreen_new (ctx, 640, 480);
-  fb = COGL_FRAMEBUFFER (onscreen);
+  fb = onscreen;
   data.fb = fb;
   data.framebuffer_width = cogl_framebuffer_get_width (fb);
   data.framebuffer_height = cogl_framebuffer_get_height (fb);
@@ -222,11 +222,11 @@ main (int argc, char **argv)
 
   /* Load a jpeg crate texture from a file */
   printf ("crate.jpg (CC by-nc-nd http://bit.ly/9kP45T) ShadowRunner27 http://bit.ly/m1YXLh\n");
-  data.texture = COGL_TEXTURE (
+  data.texture =
     cogl_texture_2d_new_from_file (ctx,
                                    COGL_EXAMPLES_DATA "crate.jpg",
                                    COGL_PIXEL_FORMAT_ANY,
-                                   &error));
+                                   &error);
   if (!data.texture)
     g_error ("Failed to load texture: %s", error->message);
 
diff --git a/examples/cogl-gles2-context.c b/examples/cogl-gles2-context.c
index 4f4fbfa..2b383a8 100644
--- a/examples/cogl-gles2-context.c
+++ b/examples/cogl-gles2-context.c
@@ -87,7 +87,7 @@ main (int argc, char **argv)
 
     onscreen = cogl_onscreen_new (data.ctx, 640, 480);
     cogl_onscreen_show (onscreen);
-    data.fb = COGL_FRAMEBUFFER (onscreen);
+    data.fb = onscreen;
 
     /* Prepare onscreen primitive */
     data.triangle = cogl_primitive_new_p2c4 (data.ctx,
@@ -95,11 +95,11 @@ main (int argc, char **argv)
                                              3, triangle_vertices);
     data.pipeline = cogl_pipeline_new (data.ctx);
 
-    data.offscreen_texture = COGL_TEXTURE (
+    data.offscreen_texture =
       cogl_texture_2d_new_with_size (data.ctx,
                                      OFFSCREEN_WIDTH,
                                      OFFSCREEN_HEIGHT,
-                                     COGL_PIXEL_FORMAT_ANY));
+                                     COGL_PIXEL_FORMAT_ANY);
     data.offscreen = cogl_offscreen_new_with_texture (data.offscreen_texture);
 
     data.gles2_ctx = cogl_gles2_context_new (data.ctx, &error);
diff --git a/examples/cogl-gles2-gears.c b/examples/cogl-gles2-gears.c
index c7185b6..048cd27 100644
--- a/examples/cogl-gles2-gears.c
+++ b/examples/cogl-gles2-gears.c
@@ -779,7 +779,7 @@ main (int argc, char **argv)
 
     onscreen = cogl_onscreen_new (data.ctx, 300, 300);
     cogl_onscreen_show (onscreen);
-    data.fb = COGL_FRAMEBUFFER (onscreen);
+    data.fb = onscreen;
 
     data.gles2_ctx = cogl_gles2_context_new (data.ctx, &error);
     if (!data.gles2_ctx)
diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c
index 602ac49..1387ab8 100644
--- a/examples/cogl-hello.c
+++ b/examples/cogl-hello.c
@@ -27,7 +27,7 @@ paint_cb (void *user_data)
     cogl_primitive_draw (data->triangle,
                          data->fb,
                          data->pipeline);
-    cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));
+    cogl_onscreen_swap_buffers (data->fb);
 
     return G_SOURCE_REMOVE;
 }
@@ -94,7 +94,7 @@ main (int argc, char **argv)
 
     onscreen = cogl_onscreen_new (data.ctx, 640, 480);
     cogl_onscreen_show (onscreen);
-    data.fb = COGL_FRAMEBUFFER (onscreen);
+    data.fb = onscreen;
 
     cogl_onscreen_set_resizable (onscreen, TRUE);
 
@@ -107,11 +107,11 @@ main (int argc, char **argv)
 
     g_source_attach (cogl_source, NULL);
 
-    cogl_onscreen_add_frame_callback (COGL_ONSCREEN (data.fb),
+    cogl_onscreen_add_frame_callback (data.fb,
                                       frame_event_cb,
                                       &data,
                                       NULL); /* destroy notify */
-    cogl_onscreen_add_dirty_callback (COGL_ONSCREEN (data.fb),
+    cogl_onscreen_add_dirty_callback (data.fb,
                                       dirty_cb,
                                       &data,
                                       NULL); /* destroy notify */
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index f1a0b96..4c7d1e0 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -41,7 +41,7 @@ main (int argc, char **argv)
       }
 
     onscreen = cogl_onscreen_new (ctx, 640, 480);
-    fb = COGL_FRAMEBUFFER (onscreen);
+    fb = onscreen;
 
     cogl_framebuffer_set_samples_per_pixel (fb, 4);
 
@@ -62,11 +62,11 @@ main (int argc, char **argv)
 
     cogl_onscreen_show (onscreen);
 
-    tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
-                                                       320, 480,
-                                                       COGL_PIXEL_FORMAT_ANY));
+    tex = cogl_texture_2d_new_with_size (ctx,
+                                         320, 480,
+                                         COGL_PIXEL_FORMAT_ANY);
     offscreen = cogl_offscreen_new_with_texture (tex);
-    offscreen_fb = COGL_FRAMEBUFFER (offscreen);
+    offscreen_fb = offscreen;
     cogl_framebuffer_set_samples_per_pixel (offscreen_fb, 4);
     if (!cogl_framebuffer_allocate (offscreen_fb, &error))
       {
diff --git a/examples/cogl-point-sprites.c b/examples/cogl-point-sprites.c
index 8f90805..8854591 100644
--- a/examples/cogl-point-sprites.c
+++ b/examples/cogl-point-sprites.c
@@ -89,7 +89,7 @@ generate_round_texture (CoglContext *context)
 
   g_free (data);
 
-  return COGL_TEXTURE (tex);
+  return tex;
 }
 
 static void
@@ -183,7 +183,7 @@ paint (Data *data)
       g_timer_reset (data->last_spark_time);
     }
 
-  cogl_buffer_set_data (COGL_BUFFER (data->attribute_buffer),
+  cogl_buffer_set_data (data->attribute_buffer,
                         0, /* offset */
                         data->sparks,
                         sizeof (data->sparks),
@@ -195,7 +195,7 @@ paint (Data *data)
                        data->fb,
                        data->pipeline);
 
-  cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));
+  cogl_onscreen_swap_buffers (data->fb);
 }
 
 static void
@@ -207,7 +207,7 @@ create_primitive (Data *data)
   data->attribute_buffer =
     cogl_attribute_buffer_new_with_size (data->context,
                                          sizeof (data->sparks));
-  cogl_buffer_set_update_hint (COGL_BUFFER (data->attribute_buffer),
+  cogl_buffer_set_update_hint (data->attribute_buffer,
                                COGL_BUFFER_UPDATE_HINT_DYNAMIC);
 
   attributes[0] = cogl_attribute_new (data->attribute_buffer,
@@ -289,7 +289,7 @@ main (int argc, char *argv[])
 
   onscreen = cogl_onscreen_new (data.context, 800, 600);
   cogl_onscreen_show (onscreen);
-  data.fb = COGL_FRAMEBUFFER (onscreen);
+  data.fb = onscreen;
 
   cogl_source = cogl_glib_source_new (data.context, G_PRIORITY_DEFAULT);
 
diff --git a/examples/cogl-sdl2-hello.c b/examples/cogl-sdl2-hello.c
index 7dfabdd..f84c40e 100644
--- a/examples/cogl-sdl2-hello.c
+++ b/examples/cogl-sdl2-hello.c
@@ -59,9 +59,9 @@ handle_event (Data *data, SDL_Event *event)
     case SDL_MOUSEMOTION:
       {
         int width =
-          cogl_framebuffer_get_width (COGL_FRAMEBUFFER (data->fb));
+          cogl_framebuffer_get_width (data->fb);
         int height =
-          cogl_framebuffer_get_height (COGL_FRAMEBUFFER (data->fb));
+          cogl_framebuffer_get_height (data->fb);
 
         data->center_x = event->motion.x * 2.0f / width - 1.0f;
         data->center_y = event->motion.y * 2.0f / height - 1.0f;
@@ -110,7 +110,7 @@ main (int argc, char **argv)
     }
 
   onscreen = cogl_onscreen_new (ctx, 800, 600);
-  data.fb = COGL_FRAMEBUFFER (onscreen);
+  data.fb = onscreen;
 
   cogl_onscreen_add_frame_callback (onscreen,
                                     frame_cb,
diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c
index e3ee8fc..7501b6f 100644
--- a/examples/cogl-x11-foreign.c
+++ b/examples/cogl-x11-foreign.c
@@ -150,7 +150,7 @@ main (int argc, char **argv)
 
   XMapWindow (xdpy, xwin);
 
-  fb = COGL_FRAMEBUFFER (onscreen);
+  fb = onscreen;
 
   cogl_onscreen_set_resizable (onscreen, TRUE);
   cogl_onscreen_add_resize_callback (onscreen, resize_handler, onscreen, NULL);
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index 7788da4..b5803d0 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -181,7 +181,7 @@ main (int argc, char **argv)
       return 1;
     }
 
-  fb = COGL_FRAMEBUFFER (onscreen);
+  fb = onscreen;
 
   for (;;)
     {
@@ -214,7 +214,7 @@ main (int argc, char **argv)
 
       cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
       pipeline = cogl_pipeline_new (ctx);
-      cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tfp));
+      cogl_pipeline_set_layer_texture (pipeline, 0, tfp);
       cogl_framebuffer_draw_rectangle (fb, pipeline, -0.8, 0.8, 0.8, -0.8);
       cogl_object_unref (pipeline);
       cogl_onscreen_swap_buffers (onscreen);
diff --git a/examples/cogland.c b/examples/cogland.c
index 82876c2..eb23e78 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -385,7 +385,7 @@ paint_cb (void *user_data)
   for (l = compositor->outputs; l; l = l->next)
     {
       CoglandOutput *output = l->data;
-      CoglFramebuffer *fb = COGL_FRAMEBUFFER (output->onscreen);
+      CoglFramebuffer *fb = output->onscreen;
       GList *l2;
 
       cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
@@ -402,8 +402,7 @@ paint_cb (void *user_data)
               CoglTexture2D *texture = surface->texture;
               CoglPipeline *pipeline =
                 cogl_pipeline_new (compositor->cogl_context);
-              cogl_pipeline_set_layer_texture (pipeline, 0,
-                                               COGL_TEXTURE (texture));
+              cogl_pipeline_set_layer_texture (pipeline, 0, texture);
               cogl_framebuffer_draw_rectangle (fb, pipeline, -1, 1, 1, -1);
               cogl_object_unref (pipeline);
             }
@@ -473,7 +472,7 @@ surface_damaged (CoglandSurface *surface,
               format = COGL_PIXEL_FORMAT_ARGB_8888;
             }
 
-          cogl_texture_set_region (COGL_TEXTURE (surface->texture),
+          cogl_texture_set_region (surface->texture,
                                    width, height,
                                    format,
                                    stride,
@@ -634,7 +633,7 @@ cogland_surface_commit (struct wl_client *client,
       !region_is_empty (&surface->pending.damage))
     {
       CoglandRegion *region = &surface->pending.damage;
-      CoglTexture *texture = COGL_TEXTURE (surface->texture);
+      CoglTexture *texture = surface->texture;
 
       if (region->x2 > cogl_texture_get_width (texture))
         region->x2 = cogl_texture_get_width (texture);
@@ -885,7 +884,7 @@ cogland_compositor_create_output (CoglandCompositor *compositor,
                                         width_mm, height_mm);
   /* Eventually there will be an implicit allocate on first use so this
    * will become optional... */
-  fb = COGL_FRAMEBUFFER (output->onscreen);
+  fb = output->onscreen;
   if (!cogl_framebuffer_allocate (fb, &error))
     g_error ("Failed to allocate framebuffer: %s\n", error->message);
 
diff --git a/test-fixtures/test-utils.h b/test-fixtures/test-utils.h
index 8449df2..9093fa8 100644
--- a/test-fixtures/test-utils.h
+++ b/test-fixtures/test-utils.h
@@ -1,6 +1,13 @@
 #ifndef _TEST_UTILS_H_
 #define _TEST_UTILS_H_
 
+/* NB: This header is for private and public api testing and so
+ * we need consider that if we are testing the public api we should
+ * just include <cogl/cogl.h> but since that will only provide
+ * opaque typedefs we need to include the specific internal headers
+ * for testing private apis...
+ */
+#ifdef COGL_COMPILATION
 #include <cogl/cogl-context.h>
 #include <cogl/cogl-onscreen.h>
 #include <cogl/cogl-offscreen.h>
@@ -9,6 +16,10 @@
 #include <cogl/cogl-texture-2d-sliced.h>
 #include <cogl/cogl-meta-texture.h>
 #include <cogl/cogl-atlas-texture.h>
+#else
+#include <cogl/cogl.h>
+#endif
+
 #include <glib.h>
 
 /* We don't really care about functions that are defined without a
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
index d00b83a..a54f0e7 100644
--- a/tests/conform/Makefile.am
+++ b/tests/conform/Makefile.am
@@ -135,8 +135,7 @@ endif
 
 AM_CPPFLAGS += \
 	-DCOGL_DISABLE_DEPRECATED \
-	-DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\" \
-	-DCOGL_COMPILATION
+	-DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\"
 
 test_conformance_CFLAGS = -g3 -O0 $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS)
 test_conformance_LDADD = \
diff --git a/tests/conform/test-alpha-test.c b/tests/conform/test-alpha-test.c
index 285118b..f164ede 100644
--- a/tests/conform/test-alpha-test.c
+++ b/tests/conform/test-alpha-test.c
@@ -24,7 +24,7 @@ create_texture (CoglContext *context)
 void
 test_alpha_test (void)
 {
-  CoglTexture *tex = COGL_TEXTURE (create_texture (test_ctx));
+  CoglTexture *tex = create_texture (test_ctx);
   CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
   int fb_width = cogl_framebuffer_get_width (test_fb);
   int fb_height = cogl_framebuffer_get_height (test_fb);
diff --git a/tests/conform/test-alpha-textures.c b/tests/conform/test-alpha-textures.c
index 659815c..524ba89 100644
--- a/tests/conform/test-alpha-textures.c
+++ b/tests/conform/test-alpha-textures.c
@@ -39,10 +39,10 @@ create_pipeline (CoglTexture **tex_out,
 
   cogl_pipeline_set_layer_texture (pipeline,
                                    0, /* layer */
-                                   COGL_TEXTURE (tex));
+                                   tex);
 
   *pipeline_out = pipeline;
-  *tex_out = COGL_TEXTURE (tex);
+  *tex_out = tex;
 }
 
 void
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index 15d45a4..3ff84f6 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -242,7 +242,7 @@ test_backface_culling (void)
                                           TEST_UTILS_TEXTURE_NO_SLICING,
                                           COGL_PIXEL_FORMAT_ANY); /* internal
                                                                      format */
-  state.offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (tex));
+  state.offscreen = cogl_offscreen_new_with_texture (tex);
   state.offscreen_tex = tex;
 
   paint (&state);
diff --git a/tests/conform/test-color-mask.c b/tests/conform/test-color-mask.c
index 62b89d8..41056af 100644
--- a/tests/conform/test-color-mask.c
+++ b/tests/conform/test-color-mask.c
@@ -86,8 +86,7 @@ test_color_mask (void)
                                                  COGL_PIXEL_FORMAT_RGB_888);
 
 
-      state.fbo[i] = COGL_FRAMEBUFFER (
-        cogl_offscreen_new_with_texture (state.tex[i]));
+      state.fbo[i] = cogl_offscreen_new_with_texture (state.tex[i]);
 
       /* Clear the texture color bits */
       cogl_framebuffer_clear4f (state.fbo[i],
diff --git a/tests/conform/test-copy-replace-texture.c b/tests/conform/test-copy-replace-texture.c
index 7d5ab48..47b0ae8 100644
--- a/tests/conform/test-copy-replace-texture.c
+++ b/tests/conform/test-copy-replace-texture.c
@@ -51,7 +51,7 @@ create_texture (void)
 
   texture_num++;
 
-  return COGL_TEXTURE (tex_2d);
+  return tex_2d;
 }
 
 void
diff --git a/tests/conform/test-fence.c b/tests/conform/test-fence.c
index 2390b71..d5e3586 100644
--- a/tests/conform/test-fence.c
+++ b/tests/conform/test-fence.c
@@ -6,7 +6,6 @@
 
 #include "test-utils.h"
 #include "config.h"
-#include <cogl/cogl-util.h>
 
 /* I'm writing this on the train after having dinner at a churrascuria. */
 #define MAGIC_CHUNK_O_DATA ((void *) 0xdeadbeef)
diff --git a/tests/conform/test-framebuffer-get-bits.c b/tests/conform/test-framebuffer-get-bits.c
index f1a85b2..c4a1dc4 100644
--- a/tests/conform/test-framebuffer-get-bits.c
+++ b/tests/conform/test-framebuffer-get-bits.c
@@ -10,15 +10,15 @@ test_framebuffer_get_bits (void)
                                    16, 16, /* width/height */
                                    COGL_PIXEL_FORMAT_A_8);
   CoglOffscreen *offscreen_a =
-    cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_a));
-  CoglFramebuffer *fb_a = COGL_FRAMEBUFFER (offscreen_a);
+    cogl_offscreen_new_with_texture (tex_a);
+  CoglFramebuffer *fb_a = offscreen_a;
   CoglTexture2D *tex_rgba =
     cogl_texture_2d_new_with_size (test_ctx,
                                    16, 16, /* width/height */
                                    COGL_PIXEL_FORMAT_RGBA_8888);
   CoglOffscreen *offscreen_rgba =
-    cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_rgba));
-  CoglFramebuffer *fb_rgba = COGL_FRAMEBUFFER (offscreen_rgba);
+    cogl_offscreen_new_with_texture (tex_rgba);
+  CoglFramebuffer *fb_rgba = offscreen_rgba;
 
   cogl_framebuffer_allocate (fb_a, NULL);
   cogl_framebuffer_allocate (fb_rgba, NULL);
diff --git a/tests/conform/test-gles2-context.c b/tests/conform/test-gles2-context.c
index 212b97c..1f2087d 100644
--- a/tests/conform/test-gles2-context.c
+++ b/tests/conform/test-gles2-context.c
@@ -23,11 +23,11 @@ test_push_pop_single_context (void)
   const CoglGLES2Vtable *gles2;
   CoglError *error = NULL;
 
-  offscreen_texture = COGL_TEXTURE (
+  offscreen_texture =
     cogl_texture_2d_new_with_size (test_ctx,
                                    cogl_framebuffer_get_width (test_fb),
                                    cogl_framebuffer_get_height (test_fb),
-                                   COGL_PIXEL_FORMAT_ANY));
+                                   COGL_PIXEL_FORMAT_ANY);
   offscreen = cogl_offscreen_new_with_texture (offscreen_texture);
 
   pipeline = cogl_pipeline_new (test_ctx);
@@ -67,8 +67,8 @@ test_push_pop_single_context (void)
 
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx,
-                                COGL_FRAMEBUFFER (offscreen),
-                                COGL_FRAMEBUFFER (offscreen),
+                                offscreen,
+                                offscreen,
                                 &error))
     {
       g_error ("Failed to push gles2 context: %s\n", error->message);
@@ -94,8 +94,8 @@ test_push_pop_single_context (void)
    */
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx,
-                                COGL_FRAMEBUFFER (offscreen),
-                                COGL_FRAMEBUFFER (offscreen),
+                                offscreen,
+                                offscreen,
                                 &error))
     {
       g_error ("Failed to push gles2 context: %s\n", error->message);
@@ -147,11 +147,11 @@ create_gles2_context (CoglTexture **offscreen_texture,
 {
   CoglError *error = NULL;
 
-  *offscreen_texture = COGL_TEXTURE (
+  *offscreen_texture =
     cogl_texture_2d_new_with_size (test_ctx,
                                    cogl_framebuffer_get_width (test_fb),
                                    cogl_framebuffer_get_height (test_fb),
-                                   COGL_PIXEL_FORMAT_ANY));
+                                   COGL_PIXEL_FORMAT_ANY);
   *offscreen = cogl_offscreen_new_with_texture (*offscreen_texture);
 
   *pipeline = cogl_pipeline_new (test_ctx);
@@ -195,8 +195,8 @@ test_push_pop_multi_context (void)
 
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx0,
-                                COGL_FRAMEBUFFER (offscreen0),
-                                COGL_FRAMEBUFFER (offscreen0),
+                                offscreen0,
+                                offscreen0,
                                 &error))
     {
       g_error ("Failed to push gles2 context 0: %s\n", error->message);
@@ -207,8 +207,8 @@ test_push_pop_multi_context (void)
 
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx1,
-                                COGL_FRAMEBUFFER (offscreen1),
-                                COGL_FRAMEBUFFER (offscreen1),
+                                offscreen1,
+                                offscreen1,
                                 &error))
     {
       g_error ("Failed to push gles2 context 1: %s\n", error->message);
@@ -290,8 +290,8 @@ test_gles2_read_pixels (void)
 
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx,
-                                COGL_FRAMEBUFFER (offscreen),
-                                COGL_FRAMEBUFFER (offscreen),
+                                offscreen,
+                                offscreen,
                                 &error))
     {
       g_error ("Failed to push gles2 context: %s\n", error->message);
@@ -328,7 +328,7 @@ test_gles2_read_pixels (void)
   /* Bind different read and write buffers */
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx,
-                                COGL_FRAMEBUFFER (offscreen),
+                                offscreen,
                                 test_fb,
                                 &error))
     {
@@ -349,7 +349,7 @@ test_gles2_read_pixels (void)
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx,
                                 test_fb,
-                                COGL_FRAMEBUFFER (offscreen),
+                                offscreen,
                                 &error))
     {
       g_error ("Failed to push gles2 context: %s\n", error->message);
@@ -682,8 +682,8 @@ test_gles2_context_fbo (void)
 
       if (!cogl_push_gles2_context (test_ctx,
                                     gles2_ctx,
-                                    COGL_FRAMEBUFFER (offscreen),
-                                    COGL_FRAMEBUFFER (offscreen),
+                                    offscreen,
+                                    offscreen,
                                     &error))
         g_error ("Failed to push gles2 context: %s\n", error->message);
 
@@ -817,8 +817,8 @@ test_gles2_context_copy_tex_image (void)
 
   if (!cogl_push_gles2_context (test_ctx,
                                 gles2_ctx,
-                                COGL_FRAMEBUFFER (offscreen),
-                                COGL_FRAMEBUFFER (offscreen),
+                                offscreen,
+                                offscreen,
                                 &error))
     g_error ("Failed to push gles2 context: %s\n", error->message);
 
diff --git a/tests/conform/test-map-buffer-range.c b/tests/conform/test-map-buffer-range.c
index a9c136b..e3f7b39 100644
--- a/tests/conform/test-map-buffer-range.c
+++ b/tests/conform/test-map-buffer-range.c
@@ -44,7 +44,7 @@ test_map_buffer_range (void)
 
   pipeline = cogl_pipeline_new (test_ctx);
 
-  cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex));
+  cogl_pipeline_set_layer_texture (pipeline, 0, tex);
   cogl_pipeline_set_layer_filters (pipeline,
                                    0, /* layer */
                                    COGL_PIPELINE_FILTER_NEAREST,
@@ -62,7 +62,7 @@ test_map_buffer_range (void)
 
   /* Replace the texture coordinates of the third vertex with the
    * coordinates for a green texel */
-  data = cogl_buffer_map_range (COGL_BUFFER (buffer),
+  data = cogl_buffer_map_range (buffer,
                                 sizeof (vertex_data[0]) * 2,
                                 sizeof (vertex_data[0]),
                                 COGL_BUFFER_ACCESS_WRITE,
@@ -75,7 +75,7 @@ test_map_buffer_range (void)
   data->s = 1.0f;
   data->t = 0.0f;
 
-  cogl_buffer_unmap (COGL_BUFFER (buffer));
+  cogl_buffer_unmap (buffer);
 
   pos_attribute =
     cogl_attribute_new (buffer,
diff --git a/tests/conform/test-offscreen.c b/tests/conform/test-offscreen.c
index faa08a7..9134cc9 100644
--- a/tests/conform/test-offscreen.c
+++ b/tests/conform/test-offscreen.c
@@ -48,9 +48,9 @@ test_paint (TestState *state)
                                           state->fb_width,
                                           state->fb_height,
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE);
-  tex = COGL_TEXTURE (tex_2d);
+  tex = tex_2d;
 
-  offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (tex));
+  offscreen = cogl_offscreen_new_with_texture (tex);
 
   /* Set a scale and translate transform on the window framebuffer
    * before switching to the offscreen framebuffer so we can verify it
@@ -128,9 +128,9 @@ test_flush (TestState *state)
       tex_2d = cogl_texture_2d_new_with_size (test_ctx,
                                               16, 16, /* width/height */
                                               COGL_PIXEL_FORMAT_RGBA_8888_PRE);
-      tex = COGL_TEXTURE (tex_2d);
+      tex = tex_2d;
 
-      offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (tex));
+      offscreen = cogl_offscreen_new_with_texture (tex);
 
       cogl_framebuffer_clear4f (offscreen, COGL_BUFFER_BIT_COLOR,
                                 0, 0, 0, 1);
diff --git a/tests/conform/test-pipeline-cache-unrefs-texture.c b/tests/conform/test-pipeline-cache-unrefs-texture.c
index ccd02e7..f00a4cb 100644
--- a/tests/conform/test-pipeline-cache-unrefs-texture.c
+++ b/tests/conform/test-pipeline-cache-unrefs-texture.c
@@ -37,7 +37,7 @@ create_texture (void)
                              GINT_TO_POINTER (1),
                              free_texture_cb);
 
-  return COGL_TEXTURE (tex_2d);
+  return tex_2d;
 }
 
 void
diff --git a/tests/conform/test-pipeline-shader-state.c b/tests/conform/test-pipeline-shader-state.c
index 790b43a..5ac7b09 100644
--- a/tests/conform/test-pipeline-shader-state.c
+++ b/tests/conform/test-pipeline-shader-state.c
@@ -24,8 +24,8 @@ test_pipeline_shader_state (void)
 
   tex = cogl_texture_2d_new_with_size (test_ctx,
                                        128, 128, COGL_PIXEL_FORMAT_ANY);
-  offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex));
-  fb = COGL_FRAMEBUFFER (offscreen);
+  offscreen = cogl_offscreen_new_with_texture (tex);
+  fb = offscreen;
   cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
   cogl_object_unref (offscreen);
 
@@ -35,7 +35,7 @@ test_pipeline_shader_state (void)
   /* Setup a template pipeline... */
 
   base_pipeline = cogl_pipeline_new (test_ctx);
-  cogl_pipeline_set_layer_texture (base_pipeline, 1, COGL_TEXTURE (tex));
+  cogl_pipeline_set_layer_texture (base_pipeline, 1, tex);
   cogl_pipeline_set_color4f (base_pipeline, 1, 0, 0, 1);
 
 
@@ -69,7 +69,7 @@ test_pipeline_shader_state (void)
    * cached vertex shader gets invalidated.
    */
 
-  cogl_pipeline_set_layer_texture (base_pipeline, 0, COGL_TEXTURE (tex));
+  cogl_pipeline_set_layer_texture (base_pipeline, 0, tex);
 
 
   /* Now we derive another pipeline from base_pipeline to verify that
diff --git a/tests/conform/test-pixel-buffer.c b/tests/conform/test-pixel-buffer.c
index 96b747d..a36430f 100644
--- a/tests/conform/test-pixel-buffer.c
+++ b/tests/conform/test-pixel-buffer.c
@@ -39,7 +39,7 @@ create_bitmap (void)
                                       BITMAP_SIZE,
                                       BITMAP_SIZE,
                                       COGL_PIXEL_FORMAT_RGBA_8888);
-  buffer = COGL_BUFFER (cogl_bitmap_get_buffer (bitmap));
+  buffer = cogl_bitmap_get_buffer (bitmap);
 
   g_assert (cogl_is_pixel_buffer (buffer));
   g_assert (cogl_is_buffer (buffer));
@@ -56,7 +56,7 @@ static CoglBitmap *
 create_and_fill_bitmap (void)
 {
   CoglBitmap *bitmap = create_bitmap ();
-  CoglBuffer *buffer = COGL_BUFFER (cogl_bitmap_get_buffer (bitmap));
+  CoglBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
   uint8_t *map;
   unsigned int stride;
 
@@ -70,7 +70,7 @@ create_and_fill_bitmap (void)
 
   generate_bitmap_data (map, stride);
 
-  cogl_buffer_unmap (COGL_BUFFER (buffer));
+  cogl_buffer_unmap (buffer);
 
   return bitmap;
 }
@@ -86,7 +86,7 @@ create_texture_from_bitmap (CoglBitmap *bitmap)
 
   g_assert (texture != NULL);
 
-  return COGL_TEXTURE (texture);
+  return texture;
 }
 
 static CoglPipeline *
@@ -169,7 +169,7 @@ void
 test_pixel_buffer_set_data (void)
 {
   CoglBitmap *bitmap = create_bitmap ();
-  CoglBuffer *buffer = COGL_BUFFER (cogl_bitmap_get_buffer (bitmap));
+  CoglBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
   CoglPipeline *pipeline;
   CoglTexture *texture;
   uint8_t *data;
@@ -230,7 +230,7 @@ create_white_texture (void)
 
   g_free (data);
 
-  return COGL_TEXTURE (texture);
+  return texture;
 }
 
 void
diff --git a/tests/conform/test-point-sprite.c b/tests/conform/test-point-sprite.c
index 4471a74..8de5251 100644
--- a/tests/conform/test-point-sprite.c
+++ b/tests/conform/test-point-sprite.c
@@ -59,7 +59,7 @@ do_test (CoglBool check_orientation,
   g_assert (error == NULL);
 
   pipeline = cogl_pipeline_new (test_ctx);
-  cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex_2d));
+  cogl_pipeline_set_layer_texture (pipeline, 0, tex_2d);
 
   cogl_pipeline_set_layer_filters (pipeline,
                                    0, /* layer_index */
diff --git a/tests/conform/test-premult.c b/tests/conform/test-premult.c
index a960409..8c7b4d0 100644
--- a/tests/conform/test-premult.c
+++ b/tests/conform/test-premult.c
@@ -57,7 +57,7 @@ make_texture (uint32_t color,
 
   g_free (tex_data);
 
-  return COGL_TEXTURE (tex_2d);
+  return tex_2d;
 }
 
 static void
@@ -84,7 +84,7 @@ check_texture (CoglPipeline *pipeline,
 	       CoglTexture *tex,
 	       uint32_t expected_result)
 {
-  cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex));
+  cogl_pipeline_set_layer_texture (pipeline, 0, tex);
   cogl_framebuffer_draw_rectangle (test_fb, pipeline,
 				   x * QUAD_WIDTH,
 				   y * QUAD_WIDTH,
diff --git a/tests/conform/test-read-texture-formats.c b/tests/conform/test-read-texture-formats.c
index 7a224d7..25195a7 100644
--- a/tests/conform/test-read-texture-formats.c
+++ b/tests/conform/test-read-texture-formats.c
@@ -17,7 +17,7 @@ test_read_byte (CoglTexture2D *tex_2d,
 {
   uint8_t received_byte;
 
-  cogl_texture_get_data (COGL_TEXTURE (tex_2d),
+  cogl_texture_get_data (tex_2d,
                          format,
                          1, /* rowstride */
                          &received_byte);
@@ -38,7 +38,7 @@ test_read_short (CoglTexture2D *tex_2d,
   char *expected_value_str;
   int bits_sum = 0;
 
-  cogl_texture_get_data (COGL_TEXTURE (tex_2d),
+  cogl_texture_get_data (tex_2d,
                          format,
                          2, /* rowstride */
                          (uint8_t *) &received_value);
@@ -71,7 +71,7 @@ test_read_888 (CoglTexture2D *tex_2d,
 {
   uint8_t pixel[4];
 
-  cogl_texture_get_data (COGL_TEXTURE (tex_2d),
+  cogl_texture_get_data (tex_2d,
                          format,
                          4, /* rowstride */
                          pixel);
@@ -88,7 +88,7 @@ test_read_8888 (CoglTexture2D *tex_2d,
   char *received_value_str;
   char *expected_value_str;
 
-  cogl_texture_get_data (COGL_TEXTURE (tex_2d),
+  cogl_texture_get_data (tex_2d,
                          format,
                          4, /* rowstride */
                          (uint8_t *) &received_pixel);
@@ -115,7 +115,7 @@ test_read_int (CoglTexture2D *tex_2d,
   char *expected_value_str;
   int bits_sum = 0;
 
-  cogl_texture_get_data (COGL_TEXTURE (tex_2d),
+  cogl_texture_get_data (tex_2d,
                          format,
                          4, /* rowstride */
                          (uint8_t *) &received_value);
diff --git a/tests/conform/test-sub-texture.c b/tests/conform/test-sub-texture.c
index e81f7b1..c58244a 100644
--- a/tests/conform/test-sub-texture.c
+++ b/tests/conform/test-sub-texture.c
@@ -105,14 +105,14 @@ paint (TestState *state)
 
   /* Create a sub texture of the bottom right quarter of the texture */
   sub_texture = cogl_sub_texture_new (test_ctx,
-                                      COGL_TEXTURE (state->tex),
+                                      state->tex,
                                       DIVISION_WIDTH,
                                       DIVISION_HEIGHT,
                                       DIVISION_WIDTH,
                                       DIVISION_HEIGHT);
 
   /* Paint it */
-  cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
+  cogl_pipeline_set_layer_texture (pipeline, 0, sub_texture);
   cogl_object_unref (sub_texture);
   cogl_framebuffer_draw_rectangle (test_fb, pipeline,
                                    0.0f, 0.0f, DIVISION_WIDTH, DIVISION_HEIGHT);
@@ -122,11 +122,11 @@ paint (TestState *state)
      documented to be undefined so it doesn't technically have to work
      but it will with the current implementation */
   sub_texture = cogl_sub_texture_new (test_ctx,
-                                      COGL_TEXTURE (state->tex),
+                                      state->tex,
                                       0, 0,
                                       SOURCE_SIZE,
                                       DIVISION_HEIGHT);
-  cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
+  cogl_pipeline_set_layer_texture (pipeline, 0, sub_texture);
   cogl_object_unref (sub_texture);
   cogl_framebuffer_draw_textured_rectangle (test_fb, pipeline,
                                             0.0f,
@@ -139,14 +139,14 @@ paint (TestState *state)
   /* Create a sub texture of a sub texture */
   full_texture = create_test_texture (state);
   sub_texture = cogl_sub_texture_new (test_ctx,
-                                      COGL_TEXTURE (full_texture),
+                                      full_texture,
                                       20, 10, 30, 20);
   cogl_object_unref (full_texture);
   sub_sub_texture = cogl_sub_texture_new (test_ctx,
-                                          COGL_TEXTURE (sub_texture),
+                                          sub_texture,
                                           20, 10, 10, 10);
   cogl_object_unref (sub_texture);
-  cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_sub_texture));
+  cogl_pipeline_set_layer_texture (pipeline, 0, sub_sub_texture);
   cogl_object_unref (sub_sub_texture);
   cogl_framebuffer_draw_rectangle (test_fb, pipeline,
                                    0.0f, SOURCE_SIZE * 2.0f,
@@ -230,15 +230,15 @@ validate_result (TestState *state)
 
   /* Try reading back the texture data */
   sub_texture = cogl_sub_texture_new (test_ctx,
-                                      COGL_TEXTURE (state->tex),
+                                      state->tex,
                                       SOURCE_SIZE / 4,
                                       SOURCE_SIZE / 4,
                                       SOURCE_SIZE / 2,
                                       SOURCE_SIZE / 2);
-  tex_width = cogl_texture_get_width (COGL_TEXTURE (sub_texture));
-  tex_height = cogl_texture_get_height (COGL_TEXTURE (sub_texture));
+  tex_width = cogl_texture_get_width (sub_texture);
+  tex_height = cogl_texture_get_height (sub_texture);
   p = texture_data = g_malloc (tex_width * tex_height * 4);
-  cogl_texture_get_data (COGL_TEXTURE (sub_texture),
+  cogl_texture_get_data (sub_texture,
                          COGL_PIXEL_FORMAT_RGBA_8888,
                          tex_width * 4,
                          texture_data);
@@ -261,11 +261,11 @@ validate_result (TestState *state)
   test_tex = create_test_texture (state);
   /* Create a sub texture the views the center half of the texture */
   sub_texture = cogl_sub_texture_new (test_ctx,
-                                      COGL_TEXTURE (test_tex),
+                                      test_tex,
                                       64, 64, 128, 128);
   /* Update the center half of the sub texture */
   texture_data = create_update_data ();
-  cogl_texture_set_region (COGL_TEXTURE (sub_texture),
+  cogl_texture_set_region (sub_texture,
                            64, 64,
                            COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                            256 * 4,
@@ -278,7 +278,7 @@ validate_result (TestState *state)
   cogl_object_unref (sub_texture);
   /* Get the texture data */
   p = texture_data = g_malloc (256 * 256 * 4);
-  cogl_texture_get_data (COGL_TEXTURE (test_tex),
+  cogl_texture_get_data (test_tex,
                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                          256 * 4, texture_data);
 
diff --git a/tests/conform/test-texture-3d.c b/tests/conform/test-texture-3d.c
index a52c55c..e4c959b 100644
--- a/tests/conform/test-texture-3d.c
+++ b/tests/conform/test-texture-3d.c
@@ -73,7 +73,7 @@ create_texture_3d (CoglContext *context)
 static void
 draw_frame (TestState *state)
 {
-  CoglTexture *tex = COGL_TEXTURE (create_texture_3d (test_ctx));
+  CoglTexture *tex = create_texture_3d (test_ctx);
   CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
   typedef struct { float x, y, s, t, r; } Vert;
   CoglPrimitive *primitive;
@@ -221,7 +221,7 @@ test_multi_texture (TestState *state)
                                           4, /* rowstride */
                                           tex_data,
                                           NULL);
-  cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex_2d));
+  cogl_pipeline_set_layer_texture (pipeline, 0, tex_2d);
 
   tex_data[0] = 0x00;
   tex_data[1] = 0xff;
@@ -235,7 +235,7 @@ test_multi_texture (TestState *state)
                                           4, /* image_stride */
                                           tex_data,
                                           NULL);
-  cogl_pipeline_set_layer_texture (pipeline, 1, COGL_TEXTURE (tex_3d));
+  cogl_pipeline_set_layer_texture (pipeline, 1, tex_3d);
 
   cogl_pipeline_set_layer_combine (pipeline, 0,
                                    "RGBA = REPLACE(PREVIOUS)",
diff --git a/tests/conform/test-texture-mipmap-get-set.c b/tests/conform/test-texture-mipmap-get-set.c
index 7d4e541..9cd86f0 100644
--- a/tests/conform/test-texture-mipmap-get-set.c
+++ b/tests/conform/test-texture-mipmap-get-set.c
@@ -35,7 +35,7 @@ make_texture (void)
                                           TEXTURE_SIZE * 4,
                                           tex_data);
 
-  cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (tex), FALSE);
+  cogl_primitive_texture_set_auto_mipmap (tex, FALSE);
 
   g_free (tex_data);
 
diff --git a/tests/conform/test-texture-no-allocate.c b/tests/conform/test-texture-no-allocate.c
index b2152c5..fb73e23 100644
--- a/tests/conform/test-texture-no-allocate.c
+++ b/tests/conform/test-texture-no-allocate.c
@@ -26,7 +26,7 @@ test_texture_no_allocate (void)
 
   /* Try to create an atlas texture that is too big so it will
    * internally be freed without allocating */
-  texture = COGL_TEXTURE (
+  texture =
     cogl_atlas_texture_new_from_data (test_ctx,
                                       BIG_TEX_WIDTH,
                                       BIG_TEX_HEIGHT,
@@ -37,7 +37,7 @@ test_texture_no_allocate (void)
                                       /* rowstride */
                                       BIG_TEX_WIDTH * 4,
                                       tex_data,
-                                      &error));
+                                      &error);
 
   g_free (tex_data);
 
@@ -50,12 +50,12 @@ test_texture_no_allocate (void)
     cogl_object_unref (texture);
 
   /* Try to create a sliced texture without allocating it */
-  texture = COGL_TEXTURE (
+  texture =
     cogl_texture_2d_sliced_new_with_size (test_ctx,
                                           BIG_TEX_WIDTH,
                                           BIG_TEX_HEIGHT,
                                           COGL_TEXTURE_MAX_WASTE,
-                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE));
+                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE);
   cogl_object_unref (texture);
 
   /* 2D texture */
diff --git a/tests/conform/test-version.c b/tests/conform/test-version.c
index f1d9de9..b651165 100644
--- a/tests/conform/test-version.c
+++ b/tests/conform/test-version.c
@@ -6,7 +6,15 @@
 
 #include "test-utils.h"
 #include "config.h"
+
+/* So we can use _COGL_STATIC_ASSERT we include the internal
+ * cogl-util.h header. Since internal headers explicitly guard against
+ * applications including them directly instead of including
+ * <cogl/cogl.h> we define __COGL_H_INSIDE__ here to subvert those
+ * guards in this case... */
+#define __COGL_H_INSIDE__
 #include <cogl/cogl-util.h>
+#undef __COGL_H_INSIDE__
 
 _COGL_STATIC_ASSERT (COGL_VERSION_ENCODE (COGL_VERSION_MAJOR,
                                           COGL_VERSION_MINOR,
diff --git a/tests/conform/test-wrap-rectangle-textures.c b/tests/conform/test-wrap-rectangle-textures.c
index bb8bf69..4274c98 100644
--- a/tests/conform/test-wrap-rectangle-textures.c
+++ b/tests/conform/test-wrap-rectangle-textures.c
@@ -40,7 +40,7 @@ create_base_pipeline (void)
 
   cogl_pipeline_set_layer_texture (pipeline,
                                    0, /* layer */
-                                   COGL_TEXTURE (tex));
+                                   tex);
 
   cogl_object_unref (tex);
 
diff --git a/tests/micro-perf/test-journal.c b/tests/micro-perf/test-journal.c
index 84d3c06..7bfdcf7 100644
--- a/tests/micro-perf/test-journal.c
+++ b/tests/micro-perf/test-journal.c
@@ -153,7 +153,7 @@ main (int argc, char **argv)
   cogl_onscreen_set_swap_throttled (onscreen, FALSE);
   cogl_onscreen_show (onscreen);
 
-  data.fb = COGL_FRAMEBUFFER (onscreen);
+  data.fb = onscreen;
   cogl_framebuffer_orthographic (data.fb,
                                  0, 0,
                                  FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
-- 
1.8.3.1



More information about the Cogl mailing list