[cogl] Removes all remaining use of CoglHandle



commit 6ed3aaf4be21d605a1ed3176b3ea825933f85cf0
Author: Robert Bragg <robert linux intel com>
Date:   Mon Apr 16 14:14:10 2012 +0100

    Removes all remaining use of CoglHandle
    
    Removing CoglHandle has been an on going goal for quite a long time now
    and finally this patch removes the last remaining uses of the CoglHandle
    type and the cogl_handle_ apis.
    
    Since the big remaining users of CoglHandle were the cogl_program_ and
    cogl_shader_ apis which have replaced with the CoglSnippets api this
    patch removes both of these apis.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl-pango/cogl-pango-glyph-cache.c                |    6 +-
 cogl-pango/cogl-pango-pipeline-cache.c             |    6 +-
 cogl-pango/cogl-pango-pipeline-cache.h             |    2 +-
 cogl/Makefile.am                                   |    9 +-
 cogl/cogl-atlas-texture-private.h                  |   12 +-
 cogl/cogl-atlas-texture.c                          |   72 +--
 cogl/cogl-atlas.c                                  |   28 +-
 cogl/cogl-atlas.h                                  |    7 +-
 cogl/cogl-attribute-buffer.h                       |    2 +-
 cogl/cogl-attribute.h                              |    2 +-
 cogl/cogl-bitmap-private.h                         |    2 +-
 cogl/cogl-bitmap.c                                 |    4 +-
 cogl/cogl-bitmap.h                                 |    8 +-
 cogl/cogl-blit.c                                   |  111 ++--
 cogl/cogl-blit.h                                   |    9 +-
 cogl/cogl-buffer.c                                 |    6 +-
 cogl/cogl-clip-state.c                             |    2 +-
 cogl/cogl-context-private.h                        |    9 +-
 cogl/cogl-context.c                                |   30 +-
 cogl/cogl-context.h                                |    2 +-
 cogl/cogl-debug-options.h                          |    2 +-
 cogl/cogl-debug.c                                  |    2 +-
 cogl/cogl-debug.h                                  |    2 +-
 cogl/cogl-framebuffer.c                            |   32 +-
 ...oilerplate.h => cogl-glsl-shader-boilerplate.h} |    0
 cogl/{cogl-handle.h => cogl-glsl-shader-private.h} |   24 +-
 cogl/cogl-glsl-shader.c                            |  154 +++++
 cogl/cogl-index-buffer.h                           |    2 +-
 cogl/cogl-journal-private.h                        |    2 +-
 cogl/cogl-journal.c                                |   19 +-
 cogl/cogl-object-private.h                         |   76 +---
 cogl/cogl-object.c                                 |   27 -
 cogl/cogl-onscreen.c                               |    2 +-
 cogl/cogl-pipeline-fragend-arbfp.c                 |   98 +---
 cogl/cogl-pipeline-fragend-fixed.c                 |   14 +-
 cogl/cogl-pipeline-fragend-glsl.c                  |   60 +--
 cogl/cogl-pipeline-layer-state.h                   |    4 +-
 cogl/cogl-pipeline-opengl-private.h                |    3 -
 cogl/cogl-pipeline-opengl.c                        |    6 +-
 cogl/cogl-pipeline-private.h                       |    7 -
 cogl/cogl-pipeline-progend-glsl.c                  |   45 +--
 cogl/cogl-pipeline-state-private.h                 |    4 +-
 cogl/cogl-pipeline-state.c                         |  160 ++----
 cogl/cogl-pipeline-state.h                         |   66 --
 cogl/cogl-pipeline-vertend-fixed.c                 |   14 +-
 cogl/cogl-pipeline-vertend-glsl.c                  |   57 +--
 cogl/cogl-pipeline.c                               |   45 +--
 cogl/cogl-pipeline.h                               |    8 +-
 cogl/cogl-pixel-buffer-private.h                   |    2 +-
 cogl/cogl-pixel-buffer.h                           |   20 +-
 cogl/cogl-primitive.h                              |    2 +-
 cogl/cogl-program-private.h                        |   82 ---
 cogl/cogl-program.c                                |  496 ---------------
 cogl/cogl-shader-private.h                         |   63 --
 cogl/cogl-shader.c                                 |  505 ---------------
 cogl/cogl-shader.h                                 |  654 --------------------
 cogl/cogl-snippet.h                                |    6 +-
 cogl/cogl-spans.h                                  |    2 +-
 cogl/cogl-sub-texture.c                            |    2 +-
 cogl/cogl-texture-2d-private.h                     |   10 +-
 cogl/cogl-texture-2d-sliced.c                      |   10 +-
 cogl/cogl-texture-2d.c                             |   48 +-
 cogl/cogl-texture-3d-private.h                     |    2 +-
 cogl/cogl-texture-3d.c                             |    6 +-
 cogl/cogl-texture-private.h                        |    6 +-
 cogl/cogl-texture-rectangle.c                      |    4 +-
 cogl/cogl-texture.c                                |   24 +-
 cogl/cogl-texture.h                                |    2 +-
 cogl/cogl-types.h                                  |   43 +--
 cogl/cogl-xlib.c                                   |    2 +-
 cogl/cogl.h                                        |    1 -
 cogl/cogl.symbols                                  |    6 -
 cogl/cogl1-context.h                               |   19 -
 cogl/driver/gl/cogl-texture-driver-gl.c            |    2 +-
 cogl/driver/gles/cogl-texture-driver-gles.c        |    2 +-
 cogl/winsys/cogl-texture-pixmap-x11-private.h      |    4 +-
 cogl/winsys/cogl-texture-pixmap-x11.c              |   68 +--
 cogl/winsys/cogl-winsys-egl-x11.c                  |    2 +-
 cogl/winsys/cogl-winsys-glx.c                      |   20 +-
 cogl/winsys/cogl-winsys-private.h                  |    2 +-
 examples/cogl-msaa.c                               |    4 +-
 tests/conform/test-materials.c                     |    4 +-
 tests/conform/test-texture-rectangle.c             |    4 +-
 tests/conform/test-utils.c                         |   12 +-
 84 files changed, 598 insertions(+), 2807 deletions(-)
---
diff --git a/cogl-pango/cogl-pango-glyph-cache.c b/cogl-pango/cogl-pango-glyph-cache.c
index 5ddb4ac..b7fb5b0 100644
--- a/cogl-pango/cogl-pango-glyph-cache.c
+++ b/cogl-pango/cogl-pango-glyph-cache.c
@@ -173,7 +173,7 @@ cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache)
 
 static void
 cogl_pango_glyph_cache_update_position_cb (void *user_data,
-                                           CoglHandle new_texture,
+                                           CoglTexture *new_texture,
                                            const CoglRectangleMapEntry *rect)
 {
   CoglPangoGlyphCacheValue *value = user_data;
@@ -204,7 +204,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
                                             PangoGlyph glyph,
                                             CoglPangoGlyphCacheValue *value)
 {
-  CoglTexture *texture;
+  CoglAtlasTexture *texture;
 
   if (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SHARED_ATLAS))
     return FALSE;
@@ -222,7 +222,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
   if (texture == NULL)
     return FALSE;
 
-  value->texture = texture;
+  value->texture = COGL_TEXTURE (texture);
   value->tx1 = 0;
   value->ty1 = 0;
   value->tx2 = 1;
diff --git a/cogl-pango/cogl-pango-pipeline-cache.c b/cogl-pango/cogl-pango-pipeline-cache.c
index 5a2e2ec..e07d646 100644
--- a/cogl-pango/cogl-pango-pipeline-cache.c
+++ b/cogl-pango/cogl-pango-pipeline-cache.c
@@ -54,7 +54,7 @@ struct _CoglPangoPipelineCacheEntry
   CoglTexture *texture;
 
   /* This will only take a weak reference */
-  CoglHandle pipeline;
+  CoglPipeline *pipeline;
 };
 
 static void
@@ -173,7 +173,7 @@ pipeline_destroy_notify_cb (void *user_data)
 
 CoglPipeline *
 _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
-                                CoglHandle texture)
+                                CoglTexture *texture)
 {
   CoglPangoPipelineCacheEntry *entry;
   PipelineDestroyNotifyData *destroy_data;
@@ -216,7 +216,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
   destroy_data = g_slice_new (PipelineDestroyNotifyData);
   destroy_data->cache = cache;
   destroy_data->texture = texture;
-  cogl_object_set_user_data (entry->pipeline,
+  cogl_object_set_user_data (COGL_OBJECT (entry->pipeline),
                              &pipeline_destroy_notify_key,
                              destroy_data,
                              pipeline_destroy_notify_cb);
diff --git a/cogl-pango/cogl-pango-pipeline-cache.h b/cogl-pango/cogl-pango-pipeline-cache.h
index d095c58..1ebfb67 100644
--- a/cogl-pango/cogl-pango-pipeline-cache.h
+++ b/cogl-pango/cogl-pango-pipeline-cache.h
@@ -43,7 +43,7 @@ _cogl_pango_pipeline_cache_new (gboolean use_mipmapping);
    to unref it */
 CoglPipeline *
 _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
-                                CoglHandle texture);
+                                CoglTexture *texture);
 
 void
 _cogl_pango_pipeline_cache_free (CoglPangoPipelineCache *cache);
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index 74d532d..82f5857 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -54,7 +54,6 @@ cogl_1_public_h = \
 	$(srcdir)/cogl-matrix.h 		\
 	$(srcdir)/cogl-offscreen.h 		\
 	$(srcdir)/cogl-primitives.h 		\
-	$(srcdir)/cogl-shader.h 		\
 	$(srcdir)/cogl-texture.h 		\
 	$(srcdir)/cogl-types.h 			\
 	$(srcdir)/cogl-clutter.h       		\
@@ -245,6 +244,9 @@ cogl_sources_c = \
 	$(srcdir)/cogl-pipeline-debug.c			\
 	$(srcdir)/cogl-pipeline-opengl.c		\
 	$(srcdir)/cogl-pipeline-opengl-private.h	\
+	$(srcdir)/cogl-glsl-shader.c			\
+	$(srcdir)/cogl-glsl-shader-private.h		\
+	$(srcdir)/cogl-glsl-shader-boilerplate.h	\
 	$(srcdir)/cogl-pipeline-fragend-glsl.c		\
 	$(srcdir)/cogl-pipeline-fragend-glsl-private.h	\
 	$(srcdir)/cogl-pipeline-fragend-arbfp.c		\
@@ -263,8 +265,6 @@ cogl_sources_c = \
 	$(srcdir)/cogl-pipeline-snippet.c		\
 	$(srcdir)/cogl-pipeline-cache.h			\
 	$(srcdir)/cogl-pipeline-cache.c			\
-	$(srcdir)/cogl-program.c			\
-	$(srcdir)/cogl-program-private.h		\
 	$(srcdir)/cogl-sampler-cache.c			\
 	$(srcdir)/cogl-sampler-cache-private.h		\
 	$(srcdir)/cogl-blend-string.c			\
@@ -306,9 +306,6 @@ cogl_sources_c = \
 	$(srcdir)/cogl-flags.h				\
 	$(srcdir)/cogl-bitmask.h                        \
 	$(srcdir)/cogl-bitmask.c                        \
-	$(srcdir)/cogl-shader-boilerplate.h		\
-	$(srcdir)/cogl-shader-private.h			\
-	$(srcdir)/cogl-shader.c                        	\
 	$(srcdir)/cogl-gtype-private.h                  \
 	$(srcdir)/cogl-point-in-poly-private.h       	\
 	$(srcdir)/cogl-point-in-poly.c       		\
diff --git a/cogl/cogl-atlas-texture-private.h b/cogl/cogl-atlas-texture-private.h
index 4387aff..43bc2fb 100644
--- a/cogl/cogl-atlas-texture-private.h
+++ b/cogl/cogl-atlas-texture-private.h
@@ -24,7 +24,7 @@
 #ifndef __COGL_ATLAS_TEXTURE_H
 #define __COGL_ATLAS_TEXTURE_H
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-texture-private.h"
 #include "cogl-rectangle-map.h"
 #include "cogl-atlas.h"
@@ -51,16 +51,18 @@ struct _CoglAtlasTexture
      atlas by the texture (but not vice versa so there is no cycle) */
   CoglAtlas            *atlas;
 
-  /* A CoglSubTexture representing the region for easy rendering */
-  CoglHandle            sub_texture;
+  /* Either a CoglSubTexture representing the atlas region for easy
+   * rendering or if the texture has been migrated out of the atlas it
+   * may be some other texture type such as CoglTexture2D */
+  CoglTexture          *sub_texture;
 };
 
-CoglHandle
+CoglAtlasTexture *
 _cogl_atlas_texture_new_from_bitmap (CoglBitmap      *bmp,
                                      CoglTextureFlags flags,
                                      CoglPixelFormat  internal_format);
 
-CoglHandle
+CoglAtlasTexture *
 _cogl_atlas_texture_new_with_size (unsigned int     width,
                                    unsigned int     height,
                                    CoglTextureFlags flags,
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index 53435d3..fa27e68 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -36,7 +36,7 @@
 #include "cogl-texture-2d-private.h"
 #include "cogl-sub-texture-private.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-texture-driver.h"
 #include "cogl-rectangle-map.h"
 #include "cogl-journal-private.h"
@@ -53,8 +53,8 @@ COGL_TEXTURE_INTERNAL_DEFINE (AtlasTexture, atlas_texture);
 
 static const CoglTextureVtable cogl_atlas_texture_vtable;
 
-static CoglHandle
-_cogl_atlas_texture_create_sub_texture (CoglHandle full_texture,
+static CoglSubTexture *
+_cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture,
                                         const CoglRectangleMapEntry *rectangle)
 {
   /* Create a subtexture for the given rectangle not including the
@@ -70,16 +70,16 @@ _cogl_atlas_texture_create_sub_texture (CoglHandle full_texture,
 
 static void
 _cogl_atlas_texture_update_position_cb (gpointer user_data,
-                                        CoglHandle new_texture,
+                                        CoglTexture *new_texture,
                                         const CoglRectangleMapEntry *rectangle)
 {
   CoglAtlasTexture *atlas_tex = user_data;
 
   /* Update the sub texture */
   if (atlas_tex->sub_texture)
-    cogl_handle_unref (atlas_tex->sub_texture);
-  atlas_tex->sub_texture =
-    _cogl_atlas_texture_create_sub_texture (new_texture, rectangle);
+    cogl_object_unref (atlas_tex->sub_texture);
+  atlas_tex->sub_texture = COGL_TEXTURE (
+    _cogl_atlas_texture_create_sub_texture (new_texture, rectangle));
 
   /* Update the position */
   atlas_tex->rectangle = *rectangle;
@@ -95,7 +95,7 @@ _cogl_atlas_texture_pre_reorganize_foreach_cb
 
   /* Keep a reference to the texture because we don't want it to be
      destroyed during the reorganization */
-  cogl_handle_ref (atlas_tex);
+  cogl_object_ref (atlas_tex);
 
   /* Notify cogl-pipeline.c that the texture's underlying GL texture
    * storage is changing so it knows it may need to bind a new texture
@@ -197,7 +197,7 @@ _cogl_atlas_texture_create_atlas (void)
 
   CoglAtlas *atlas;
 
-  _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
+  _COGL_GET_CONTEXT (ctx, NULL);
 
   atlas = _cogl_atlas_new (COGL_PIXEL_FORMAT_RGBA_8888,
                            0,
@@ -232,9 +232,10 @@ _cogl_atlas_texture_foreach_sub_texture_in_region (
                                        void *user_data)
 {
   CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
+  CoglMetaTexture *meta_texture = COGL_META_TEXTURE (atlas_tex->sub_texture);
 
   /* Forward on to the sub texture */
-  cogl_meta_texture_foreach_in_region (atlas_tex->sub_texture,
+  cogl_meta_texture_foreach_in_region (meta_texture,
                                        virtual_tx_1,
                                        virtual_ty_1,
                                        virtual_tx_2,
@@ -278,7 +279,7 @@ _cogl_atlas_texture_free (CoglAtlasTexture *atlas_tex)
 {
   _cogl_atlas_texture_remove_from_atlas (atlas_tex);
 
-  cogl_handle_unref (atlas_tex->sub_texture);
+  cogl_object_unref (atlas_tex->sub_texture);
 
   /* Chain up */
   _cogl_texture_free (COGL_TEXTURE (atlas_tex));
@@ -363,7 +364,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex)
   /* Make sure this texture is not in the atlas */
   if (atlas_tex->atlas)
     {
-      CoglHandle sub_texture;
+      CoglTexture *standalone_tex;
 
       COGL_NOTE (ATLAS, "Migrating texture out of the atlas");
 
@@ -377,7 +378,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex)
        */
       cogl_flush ();
 
-      sub_texture =
+      standalone_tex =
         _cogl_atlas_copy_rectangle (atlas_tex->atlas,
                                     atlas_tex->rectangle.x + 1,
                                     atlas_tex->rectangle.y + 1,
@@ -395,8 +396,8 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex)
          the copy can involve rendering which might cause the texture
          to be used if it is used from a layer that is left in a
          texture unit */
-      cogl_handle_unref (atlas_tex->sub_texture);
-      atlas_tex->sub_texture = sub_texture;
+      cogl_object_unref (atlas_tex->sub_texture);
+      atlas_tex->sub_texture = standalone_tex;
 
       _cogl_atlas_texture_remove_from_atlas (atlas_tex);
     }
@@ -632,7 +633,7 @@ _cogl_atlas_texture_can_use_format (CoglPixelFormat format)
           format == COGL_PIXEL_FORMAT_RGBA_8888);
 }
 
-CoglHandle
+CoglAtlasTexture *
 _cogl_atlas_texture_new_with_size (unsigned int width,
                                    unsigned int height,
                                    CoglTextureFlags flags,
@@ -642,28 +643,28 @@ _cogl_atlas_texture_new_with_size (unsigned int width,
   CoglAtlas        *atlas;
   GSList           *l;
 
-  _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
+  _COGL_GET_CONTEXT (ctx, NULL);
 
   /* Don't put textures in the atlas if the user has explicitly
      requested to disable it */
   if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_ATLAS)))
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* We can't put the texture in the atlas if there are any special
      flags. This precludes textures with COGL_TEXTURE_NO_ATLAS and
      COGL_TEXTURE_NO_SLICING from being atlased */
   if (flags)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* We can't atlas zero-sized textures because it breaks the atlas
      data structure */
   if (width < 1 || height < 1)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* If we can't use FBOs then it will be too slow to migrate textures
      and we shouldn't use the atlas */
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   COGL_NOTE (ATLAS, "Adding texture of size %ix%i", width, height);
 
@@ -673,7 +674,7 @@ _cogl_atlas_texture_new_with_size (unsigned int width,
       COGL_NOTE (ATLAS, "Texture can not be added because the "
                  "format is unsupported");
 
-      return COGL_INVALID_HANDLE;
+      return NULL;
     }
 
   /* We need to allocate the texture now because we need the pointer
@@ -686,7 +687,7 @@ _cogl_atlas_texture_new_with_size (unsigned int width,
   _cogl_texture_init (COGL_TEXTURE (atlas_tex),
                       &cogl_atlas_texture_vtable);
 
-  atlas_tex->sub_texture = COGL_INVALID_HANDLE;
+  atlas_tex->sub_texture = NULL;
 
   /* Look for an existing atlas that can hold the texture */
   for (l = ctx->atlases; l; l = l->next)
@@ -713,29 +714,28 @@ _cogl_atlas_texture_new_with_size (unsigned int width,
           /* Ok, this means we really can't add it to the atlas */
           cogl_object_unref (atlas);
           g_free (atlas_tex);
-          return COGL_INVALID_HANDLE;
+          return NULL;
         }
     }
 
   atlas_tex->format = internal_format;
   atlas_tex->atlas = atlas;
 
-  return _cogl_atlas_texture_handle_new (atlas_tex);
+  return _cogl_atlas_texture_object_new (atlas_tex);
 }
 
-CoglHandle
+CoglAtlasTexture *
 _cogl_atlas_texture_new_from_bitmap (CoglBitmap      *bmp,
                                      CoglTextureFlags flags,
                                      CoglPixelFormat  internal_format)
 {
-  CoglHandle atlas_tex_handle;
   CoglAtlasTexture *atlas_tex;
   CoglBitmap *dst_bmp;
   int bmp_width;
   int bmp_height;
   CoglPixelFormat bmp_format;
 
-  _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE);
+  _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
 
   bmp_width = cogl_bitmap_get_width (bmp);
   bmp_height = cogl_bitmap_get_height (bmp);
@@ -744,21 +744,19 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap      *bmp,
   internal_format = _cogl_texture_determine_internal_format (bmp_format,
                                                              internal_format);
 
-  atlas_tex_handle = _cogl_atlas_texture_new_with_size (bmp_width, bmp_height,
-                                                        flags, internal_format);
+  atlas_tex = _cogl_atlas_texture_new_with_size (bmp_width, bmp_height,
+                                                 flags, internal_format);
 
-  if (atlas_tex_handle == COGL_INVALID_HANDLE)
-    return COGL_INVALID_HANDLE;
-
-  atlas_tex = atlas_tex_handle;
+  if (atlas_tex == NULL)
+    return NULL;
 
   dst_bmp = _cogl_atlas_texture_prepare_for_upload (atlas_tex,
                                                     bmp);
 
   if (dst_bmp == NULL)
     {
-      cogl_handle_unref (atlas_tex_handle);
-      return COGL_INVALID_HANDLE;
+      cogl_object_unref (atlas_tex);
+      return NULL;
     }
 
   /* Defer to set_region so that we can share the code for copying the
@@ -774,7 +772,7 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap      *bmp,
 
   cogl_object_unref (dst_bmp);
 
-  return atlas_tex_handle;
+  return atlas_tex;
 }
 
 void
diff --git a/cogl/cogl-atlas.c b/cogl/cogl-atlas.c
index 7dd1cdc..03eee30 100644
--- a/cogl/cogl-atlas.c
+++ b/cogl/cogl-atlas.c
@@ -70,7 +70,7 @@ _cogl_atlas_free (CoglAtlas *atlas)
   COGL_NOTE (ATLAS, "%p: Atlas destroyed", atlas);
 
   if (atlas->texture)
-    cogl_handle_unref (atlas->texture);
+    cogl_object_unref (atlas->texture);
   if (atlas->map)
     _cogl_rectangle_map_free (atlas->map);
 
@@ -93,8 +93,8 @@ static void
 _cogl_atlas_migrate (CoglAtlas               *atlas,
                      unsigned int             n_textures,
                      CoglAtlasRepositionData *textures,
-                     CoglHandle               old_texture,
-                     CoglHandle               new_texture,
+                     CoglTexture             *old_texture,
+                     CoglTexture             *new_texture,
                      void                    *skip_user_data)
 {
   unsigned int i;
@@ -269,14 +269,14 @@ _cogl_atlas_create_map (CoglPixelFormat          format,
   return NULL;
 }
 
-static CoglHandle
+static CoglTexture2D *
 _cogl_atlas_create_texture (CoglAtlas *atlas,
                             int width,
                             int height)
 {
-  CoglHandle tex;
+  CoglTexture2D *tex;
 
-  _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
+  _COGL_GET_CONTEXT (ctx, NULL);
 
   if ((atlas->flags & COGL_ATLAS_CLEAR_TEXTURE))
     {
@@ -345,7 +345,7 @@ _cogl_atlas_reserve_space (CoglAtlas             *atlas,
 {
   CoglAtlasGetRectanglesData data;
   CoglRectangleMap *new_map;
-  CoglHandle new_tex;
+  CoglTexture2D *new_tex;
   unsigned int map_width, map_height;
   gboolean ret;
   CoglRectangleMapEntry new_position;
@@ -442,7 +442,7 @@ _cogl_atlas_reserve_space (CoglAtlas             *atlas,
   else if ((new_tex = _cogl_atlas_create_texture
             (atlas,
              _cogl_rectangle_map_get_width (new_map),
-             _cogl_rectangle_map_get_height (new_map))) == COGL_INVALID_HANDLE)
+             _cogl_rectangle_map_get_height (new_map))) == NULL)
     {
       COGL_NOTE (ATLAS, "%p: Could not create a CoglTexture2D", atlas);
       _cogl_rectangle_map_free (new_map);
@@ -472,20 +472,20 @@ _cogl_atlas_reserve_space (CoglAtlas             *atlas,
                                data.n_textures,
                                data.textures,
                                atlas->texture,
-                               new_tex,
+                               COGL_TEXTURE (new_tex),
                                user_data);
           _cogl_rectangle_map_free (atlas->map);
-          cogl_handle_unref (atlas->texture);
+          cogl_object_unref (atlas->texture);
         }
       else
         /* We know there's only one texture so we can just directly
            update the rectangle from its new position */
         atlas->update_position_cb (data.textures[0].user_data,
-                                   new_tex,
+                                   COGL_TEXTURE (new_tex),
                                    &data.textures[0].new_position);
 
       atlas->map = new_map;
-      atlas->texture = new_tex;
+      atlas->texture = COGL_TEXTURE (new_tex);
 
       waste = (_cogl_rectangle_map_get_remaining_space (atlas->map) *
                100 / (_cogl_rectangle_map_get_width (atlas->map) *
@@ -528,7 +528,7 @@ _cogl_atlas_remove (CoglAtlas *atlas,
                     _cogl_rectangle_map_get_height (atlas->map)));
 };
 
-CoglHandle
+CoglTexture *
 _cogl_atlas_copy_rectangle (CoglAtlas        *atlas,
                             unsigned int      x,
                             unsigned int      y,
@@ -537,7 +537,7 @@ _cogl_atlas_copy_rectangle (CoglAtlas        *atlas,
                             CoglTextureFlags  flags,
                             CoglPixelFormat   format)
 {
-  CoglHandle tex;
+  CoglTexture *tex;
   CoglBlitData blit_data;
 
   /* Create a new texture at the right size */
diff --git a/cogl/cogl-atlas.h b/cogl/cogl-atlas.h
index 95c4c11..2b7bb8e 100644
--- a/cogl/cogl-atlas.h
+++ b/cogl/cogl-atlas.h
@@ -26,10 +26,11 @@
 
 #include "cogl-rectangle-map.h"
 #include "cogl-object-private.h"
+#include "cogl-texture.h"
 
 typedef void
 (* CoglAtlasUpdatePositionCallback) (void *user_data,
-                                     CoglHandle new_texture,
+                                     CoglTexture *new_texture,
                                      const CoglRectangleMapEntry *rect);
 
 typedef enum
@@ -48,7 +49,7 @@ struct _CoglAtlas
 
   CoglRectangleMap *map;
 
-  CoglHandle texture;
+  CoglTexture *texture;
   CoglPixelFormat texture_format;
   CoglAtlasFlags flags;
 
@@ -73,7 +74,7 @@ void
 _cogl_atlas_remove (CoglAtlas *atlas,
                     const CoglRectangleMapEntry *rectangle);
 
-CoglHandle
+CoglTexture *
 _cogl_atlas_copy_rectangle (CoglAtlas        *atlas,
                             unsigned int      x,
                             unsigned int      y,
diff --git a/cogl/cogl-attribute-buffer.h b/cogl/cogl-attribute-buffer.h
index 492ba21..707cee1 100644
--- a/cogl/cogl-attribute-buffer.h
+++ b/cogl/cogl-attribute-buffer.h
@@ -77,7 +77,7 @@ cogl_attribute_buffer_new (CoglContext *context,
  *
  * Gets whether the given object references a #CoglAttributeBuffer.
  *
- * Returns: %TRUE if the handle references a #CoglAttributeBuffer,
+ * Returns: %TRUE if @object references a #CoglAttributeBuffer,
  *   %FALSE otherwise
  *
  * Since: 1.4
diff --git a/cogl/cogl-attribute.h b/cogl/cogl-attribute.h
index b59402c..a85b2de 100644
--- a/cogl/cogl-attribute.h
+++ b/cogl/cogl-attribute.h
@@ -210,7 +210,7 @@ cogl_attribute_set_buffer (CoglAttribute *attribute,
  *
  * Gets whether the given object references a #CoglAttribute.
  *
- * Return value: %TRUE if the handle references a #CoglAttribute,
+ * Return value: %TRUE if the @object references a #CoglAttribute,
  *   %FALSE otherwise
  */
 gboolean
diff --git a/cogl/cogl-bitmap-private.h b/cogl/cogl-bitmap-private.h
index b46ba73..b67c4f2 100644
--- a/cogl/cogl-bitmap-private.h
+++ b/cogl/cogl-bitmap-private.h
@@ -28,7 +28,7 @@
 
 #include <glib.h>
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-buffer.h"
 #include "cogl-bitmap.h"
 
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c
index b81c681..8952608 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -37,7 +37,7 @@
 
 struct _CoglBitmap
 {
-  CoglHandleObject         _parent;
+  CoglObject               _parent;
 
   /* Pointer back to the context that this bitmap was created with */
   CoglContext             *context;
@@ -256,7 +256,7 @@ CoglBitmap *
 cogl_bitmap_new_from_file (const char  *filename,
                            GError     **error)
 {
-  _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
+  _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL);
 
   return _cogl_bitmap_from_file (filename, error);
 }
diff --git a/cogl/cogl-bitmap.h b/cogl/cogl-bitmap.h
index e2e2962..e13d2c8 100644
--- a/cogl/cogl-bitmap.h
+++ b/cogl/cogl-bitmap.h
@@ -239,17 +239,17 @@ cogl_bitmap_get_size_from_file (const char *filename,
 
 /**
  * cogl_is_bitmap:
- * @handle: a #CoglHandle for a bitmap
+ * @object: a #CoglObject pointer
  *
- * Checks whether @handle is a #CoglHandle for a bitmap
+ * Checks whether @object is a #CoglBitmap
  *
- * Return value: %TRUE if the passed handle represents a bitmap,
+ * Return value: %TRUE if the passed @object represents a bitmap,
  *   and %FALSE otherwise
  *
  * Since: 1.0
  */
 gboolean
-cogl_is_bitmap (CoglHandle handle);
+cogl_is_bitmap (void *object);
 
 /**
  * COGL_BITMAP_ERROR:
diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c
index 56c0c14..493fc75 100644
--- a/cogl/cogl-blit.c
+++ b/cogl/cogl-blit.c
@@ -43,38 +43,37 @@ static const CoglBlitMode *_cogl_blit_default_mode = NULL;
 static gboolean
 _cogl_blit_texture_render_begin (CoglBlitData *data)
 {
-  CoglHandle fbo;
+  CoglOffscreen *offscreen;
+  CoglFramebuffer *fb;
   CoglPipeline *pipeline;
   unsigned int dst_width, dst_height;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
 
-  fbo = _cogl_offscreen_new_to_texture_full
+  offscreen = _cogl_offscreen_new_to_texture_full
     (data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
 
-  if (fbo == COGL_INVALID_HANDLE)
+  if (offscreen == NULL)
     return FALSE;
 
-  if (!cogl_framebuffer_allocate (fbo, NULL))
+  fb = COGL_FRAMEBUFFER (offscreen);
+  if (!cogl_framebuffer_allocate (fb, NULL))
     {
-      cogl_handle_unref (fbo);
+      cogl_object_unref (fb);
       return FALSE;
     }
 
-  cogl_push_framebuffer (fbo);
-  cogl_handle_unref (fbo);
+  cogl_push_framebuffer (fb);
+  cogl_object_unref (fb);
 
   dst_width = cogl_texture_get_width (data->dst_tex);
   dst_height = cogl_texture_get_height (data->dst_tex);
 
   /* Set up an orthographic projection so we can use pixel
      coordinates to render to the texture */
-  cogl_ortho (0, /* left */
-              dst_width, /* right */
-              dst_height, /* bottom */
-              0, /* top */
-              -1, /* near */
-              1 /* far */);
+  cogl_framebuffer_orthographic (fb,
+                                 0, 0, dst_width, dst_height,
+                                 -1 /* near */, 1 /* far */);
 
   /* We cache a pipeline used for migrating on to the context so
      that it doesn't have to continuously regenerate a shader
@@ -146,8 +145,8 @@ _cogl_blit_texture_render_end (CoglBlitData *data)
 static gboolean
 _cogl_blit_framebuffer_begin (CoglBlitData *data)
 {
-  CoglHandle dst_fbo, src_fbo;
-  gboolean ret;
+  CoglOffscreen *dst_offscreen = NULL, *src_offscreen = NULL;
+  CoglFramebuffer *dst_fb, *src_fb;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
 
@@ -158,39 +157,39 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
       !(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT))
     return FALSE;
 
-  dst_fbo = _cogl_offscreen_new_to_texture_full
+  dst_offscreen = _cogl_offscreen_new_to_texture_full
     (data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
+  if (dst_offscreen == NULL)
+    return FALSE;
 
-  if (dst_fbo == COGL_INVALID_HANDLE)
-    ret = FALSE;
-  else
-    {
-      if (!cogl_framebuffer_allocate (dst_fbo, NULL))
-        ret = FALSE;
-      else
-        {
-          src_fbo = _cogl_offscreen_new_to_texture_full
-            (data->src_tex,
-             COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
-             0 /* level */);
-
-          if (src_fbo == COGL_INVALID_HANDLE)
-            ret = FALSE;
-          else
-            {
-              if (!cogl_framebuffer_allocate (src_fbo, NULL))
-                ret = FALSE;
-              else
-                _cogl_push_framebuffers (dst_fbo, src_fbo);
+  dst_fb = COGL_FRAMEBUFFER (dst_offscreen);
+  if (!cogl_framebuffer_allocate (dst_fb, NULL))
+    goto ERROR;
 
-              cogl_handle_unref (src_fbo);
-            }
-        }
+  src_offscreen= _cogl_offscreen_new_to_texture_full
+    (data->src_tex,
+     COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
+     0 /* level */);
 
-      cogl_handle_unref (dst_fbo);
-    }
+  if (src_offscreen == NULL)
+    goto ERROR;
+
+  src_fb = COGL_FRAMEBUFFER (src_offscreen);
+  if (!cogl_framebuffer_allocate (src_fb, NULL))
+    goto ERROR;
+
+  _cogl_push_framebuffers (dst_fb, src_fb);
+
+  return TRUE;
+
+ERROR:
+
+  if (dst_offscreen)
+    cogl_object_unref (dst_offscreen);
+  if (src_offscreen)
+    cogl_object_unref (src_offscreen);
 
-  return ret;
+  return FALSE;
 }
 
 static void
@@ -216,7 +215,8 @@ _cogl_blit_framebuffer_end (CoglBlitData *data)
 static gboolean
 _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data)
 {
-  CoglHandle fbo;
+  CoglOffscreen *offscreen;
+  CoglFramebuffer *fb;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
 
@@ -224,20 +224,21 @@ _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data)
   if (!cogl_is_texture_2d (data->dst_tex))
     return FALSE;
 
-  fbo = _cogl_offscreen_new_to_texture_full
+  offscreen = _cogl_offscreen_new_to_texture_full
     (data->src_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
 
-  if (fbo == COGL_INVALID_HANDLE)
+  if (offscreen == NULL)
     return FALSE;
 
-  if (!cogl_framebuffer_allocate (fbo, NULL))
+  fb = COGL_FRAMEBUFFER (offscreen);
+  if (!cogl_framebuffer_allocate (fb, NULL))
     {
-      cogl_handle_unref (fbo);
+      cogl_object_unref (fb);
       return FALSE;
     }
 
-  cogl_push_framebuffer (fbo);
-  cogl_handle_unref (fbo);
+  cogl_push_framebuffer (fb);
+  cogl_object_unref (fb);
 
   return TRUE;
 }
@@ -251,7 +252,7 @@ _cogl_blit_copy_tex_sub_image_blit (CoglBlitData *data,
                                     unsigned int width,
                                     unsigned int height)
 {
-  _cogl_texture_2d_copy_from_framebuffer (data->dst_tex,
+  _cogl_texture_2d_copy_from_framebuffer (COGL_TEXTURE_2D (data->dst_tex),
                                           dst_x, dst_y,
                                           src_x, src_y,
                                           width, height);
@@ -334,8 +335,8 @@ _cogl_blit_modes[] =
 
 void
 _cogl_blit_begin (CoglBlitData *data,
-                  CoglHandle dst_tex,
-                  CoglHandle src_tex)
+                  CoglTexture *dst_tex,
+                  CoglTexture *src_tex)
 {
   int i;
 
diff --git a/cogl/cogl-blit.h b/cogl/cogl-blit.h
index 95e708e..738b82f 100644
--- a/cogl/cogl-blit.h
+++ b/cogl/cogl-blit.h
@@ -25,7 +25,8 @@
 #define __COGL_BLIT_H
 
 #include <glib.h>
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
+#include "cogl-texture.h"
 
 /* This structures and functions are used when a series of blits needs
    to be performed between two textures. In this case there are
@@ -55,7 +56,7 @@ typedef struct
 
 struct _CoglBlitData
 {
-  CoglHandle src_tex, dst_tex;
+  CoglTexture *src_tex, *dst_tex;
 
   unsigned int src_width;
   unsigned int src_height;
@@ -71,8 +72,8 @@ struct _CoglBlitData
 
 void
 _cogl_blit_begin (CoglBlitData *data,
-                  CoglHandle dst_tex,
-                  CoglHandle src_tex);
+                  CoglTexture *dst_tex,
+                  CoglTexture *src_tex);
 
 void
 _cogl_blit (CoglBlitData *data,
diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c
index f5a0fc5..8dd4f6d 100644
--- a/cogl/cogl-buffer.c
+++ b/cogl/cogl-buffer.c
@@ -41,7 +41,7 @@
 #include "cogl-internal.h"
 #include "cogl-util.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-pixel-buffer-private.h"
 
 /*
@@ -71,7 +71,7 @@
 #endif
 
 /* XXX:
- * The CoglHandle macros don't support any form of inheritance, so for
+ * The CoglObject macros don't support any form of inheritance, so for
  * now we implement the CoglObject support for the CoglBuffer
  * abstract class manually.
  */
@@ -87,7 +87,7 @@ _cogl_buffer_register_buffer_type (const CoglObjectClass *klass)
 gboolean
 cogl_is_buffer (void *object)
 {
-  const CoglHandleObject *obj = object;
+  const CoglObject *obj = object;
   GSList *l;
 
   if (object == NULL)
diff --git a/cogl/cogl-clip-state.c b/cogl/cogl-clip-state.c
index 97f8ce6..0ab9c5f 100644
--- a/cogl/cogl-clip-state.c
+++ b/cogl/cogl-clip-state.c
@@ -173,7 +173,7 @@ _cogl_clip_state_save_clip_stack (CoglClipState *clip_state)
 void
 _cogl_clip_state_restore_clip_stack (CoglClipState *clip_state)
 {
-  CoglHandle stack;
+  CoglClipStack *stack;
 
   _COGL_RETURN_IF_FAIL (clip_state->stacks != NULL);
 
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index 174944f..9b18ffe 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -171,7 +171,7 @@ struct _CoglContext
 
   /* Framebuffers */
   GSList           *framebuffer_stack;
-  CoglHandle        window_buffer;
+  CoglFramebuffer  *window_buffer;
   unsigned long     current_draw_buffer_state_flushed;
   unsigned long     current_draw_buffer_changes;
   CoglFramebuffer  *current_draw_buffer;
@@ -182,9 +182,9 @@ struct _CoglContext
 
   /* Pre-generated VBOs containing indices to generate GL_TRIANGLES
      out of a vertex array of quads */
-  CoglHandle        quad_buffer_indices_byte;
+  CoglIndices      *quad_buffer_indices_byte;
   unsigned int      quad_buffer_indices_len;
-  CoglHandle        quad_buffer_indices;
+  CoglIndices      *quad_buffer_indices;
 
   CoglIndices      *rectangle_byte_indices;
   CoglIndices      *rectangle_short_indices;
@@ -210,9 +210,6 @@ struct _CoglContext
   GLint             max_texture_image_units;
   GLint             max_activateable_texture_units;
 
-  /* Fragment processing programs */
-  CoglHandle              current_program;
-
   CoglPipelineProgramType current_fragment_program_type;
   CoglPipelineProgramType current_vertex_program_type;
   GLuint                  current_gl_program;
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 6a01fcc..aa61221 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -332,8 +332,6 @@ cogl_context_new (CoglDisplay *display,
   context->max_texture_units = -1;
   context->max_activateable_texture_units = -1;
 
-  context->current_program = COGL_INVALID_HANDLE;
-
   context->current_fragment_program_type = COGL_PIPELINE_PROGRAM_TYPE_FIXED;
   context->current_vertex_program_type = COGL_PIPELINE_PROGRAM_TYPE_FIXED;
   context->current_gl_program = 0;
@@ -374,16 +372,16 @@ cogl_context_new (CoglDisplay *display,
 
   context->in_begin_gl_block = FALSE;
 
-  context->quad_buffer_indices_byte = COGL_INVALID_HANDLE;
-  context->quad_buffer_indices = COGL_INVALID_HANDLE;
+  context->quad_buffer_indices_byte = NULL;
+  context->quad_buffer_indices = NULL;
   context->quad_buffer_indices_len = 0;
 
   context->rectangle_byte_indices = NULL;
   context->rectangle_short_indices = NULL;
   context->rectangle_short_indices_len = 0;
 
-  context->texture_download_pipeline = COGL_INVALID_HANDLE;
-  context->blit_texture_pipeline = COGL_INVALID_HANDLE;
+  context->texture_download_pipeline = NULL;
+  context->blit_texture_pipeline = NULL;
 
 #if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
   if (context->driver != COGL_DRIVER_GLES2)
@@ -469,14 +467,14 @@ _cogl_context_free (CoglContext *context)
     cogl_object_unref (context->default_gl_texture_rect_tex);
 
   if (context->opaque_color_pipeline)
-    cogl_handle_unref (context->opaque_color_pipeline);
+    cogl_object_unref (context->opaque_color_pipeline);
   if (context->blended_color_pipeline)
-    cogl_handle_unref (context->blended_color_pipeline);
+    cogl_object_unref (context->blended_color_pipeline);
   if (context->texture_pipeline)
-    cogl_handle_unref (context->texture_pipeline);
+    cogl_object_unref (context->texture_pipeline);
 
   if (context->blit_texture_pipeline)
-    cogl_handle_unref (context->blit_texture_pipeline);
+    cogl_object_unref (context->blit_texture_pipeline);
 
   if (context->journal_flush_attributes_array)
     g_array_free (context->journal_flush_attributes_array, TRUE);
@@ -487,9 +485,9 @@ _cogl_context_free (CoglContext *context)
     g_array_free (context->polygon_vertices, TRUE);
 
   if (context->quad_buffer_indices_byte)
-    cogl_handle_unref (context->quad_buffer_indices_byte);
+    cogl_object_unref (context->quad_buffer_indices_byte);
   if (context->quad_buffer_indices)
-    cogl_handle_unref (context->quad_buffer_indices);
+    cogl_object_unref (context->quad_buffer_indices);
 
   if (context->rectangle_byte_indices)
     cogl_object_unref (context->rectangle_byte_indices);
@@ -497,14 +495,14 @@ _cogl_context_free (CoglContext *context)
     cogl_object_unref (context->rectangle_short_indices);
 
   if (context->default_pipeline)
-    cogl_handle_unref (context->default_pipeline);
+    cogl_object_unref (context->default_pipeline);
 
   if (context->dummy_layer_dependant)
-    cogl_handle_unref (context->dummy_layer_dependant);
+    cogl_object_unref (context->dummy_layer_dependant);
   if (context->default_layer_n)
-    cogl_handle_unref (context->default_layer_n);
+    cogl_object_unref (context->default_layer_n);
   if (context->default_layer_0)
-    cogl_handle_unref (context->default_layer_0);
+    cogl_object_unref (context->default_layer_0);
 
   if (context->current_clip_stack_valid)
     _cogl_clip_stack_unref (context->current_clip_stack);
diff --git a/cogl/cogl-context.h b/cogl/cogl-context.h
index e2120d7..ed5bcf1 100644
--- a/cogl/cogl-context.h
+++ b/cogl/cogl-context.h
@@ -147,7 +147,7 @@ cogl_android_set_native_window (ANativeWindow *window);
  *
  * Gets whether the given object references an existing context object.
  *
- * Return value: %TRUE if the handle references a #CoglContext,
+ * Return value: %TRUE if the @object references a #CoglContext,
  *   %FALSE otherwise
  *
  * Since: 1.10
diff --git a/cogl/cogl-debug-options.h b/cogl/cogl-debug-options.h
index c5d486d..4b177ae 100644
--- a/cogl/cogl-debug-options.h
+++ b/cogl/cogl-debug-options.h
@@ -21,7 +21,7 @@
  *
  */
 
-OPT (HANDLE,
+OPT (OBJECT,
      N_("Cogl Tracing"),
      "ref-counts",
      N_("CoglObject references"),
diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c
index d838cae..7f0143d 100644
--- a/cogl/cogl-debug.c
+++ b/cogl/cogl-debug.c
@@ -41,7 +41,7 @@
  * used since they don't affect the behaviour of Cogl they
  * simply print out verbose information */
 static const GDebugKey cogl_log_debug_keys[] = {
-  { "handle", COGL_DEBUG_HANDLE },
+  { "object", COGL_DEBUG_OBJECT },
   { "slicing", COGL_DEBUG_SLICING },
   { "atlas", COGL_DEBUG_ATLAS },
   { "blend-strings", COGL_DEBUG_BLEND_STRINGS },
diff --git a/cogl/cogl-debug.h b/cogl/cogl-debug.h
index 83534c8..bf8fa58 100644
--- a/cogl/cogl-debug.h
+++ b/cogl/cogl-debug.h
@@ -38,7 +38,7 @@ typedef enum {
   COGL_DEBUG_DRAW,
   COGL_DEBUG_PANGO,
   COGL_DEBUG_RECTANGLES,
-  COGL_DEBUG_HANDLE,
+  COGL_DEBUG_OBJECT,
   COGL_DEBUG_BLEND_STRINGS,
   COGL_DEBUG_DISABLE_BATCHING,
   COGL_DEBUG_DISABLE_VBOS,
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index bc6bad8..14916fe 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -132,7 +132,6 @@ static void _cogl_offscreen_free (CoglOffscreen *offscreen);
 COGL_OBJECT_DEFINE_WITH_CODE (Offscreen, offscreen,
                               _cogl_offscreen_class.virt_unref =
                               _cogl_framebuffer_unref);
-COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (offscreen);
 
 /* XXX:
  * The CoglObject macros don't support any form of inheritance, so for
@@ -726,20 +725,20 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture,
   int level_width;
   int level_height;
   int i;
-  CoglHandle ret;
+  CoglOffscreen *ret;
 
-  _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
+  _COGL_GET_CONTEXT (ctx, NULL);
 
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Make texture is a valid texture object */
   if (!cogl_is_texture (texture))
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* The texture must not be sliced */
   if (cogl_texture_is_sliced (texture))
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Calculate the size of the texture at this mipmap level to ensure
      that it's a valid level */
@@ -754,7 +753,7 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture,
         {
           g_warning ("Invalid texture level passed to "
                      "_cogl_offscreen_new_to_texture_full");
-          return COGL_INVALID_HANDLE;
+          return NULL;
         }
 
       if (level_width > 1)
@@ -811,7 +810,7 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
 
   GE (ctx, glDeleteFramebuffers (1, &offscreen->fbo_handle));
 
-  if (offscreen->texture != COGL_INVALID_HANDLE)
+  if (offscreen->texture != NULL)
     cogl_object_unref (offscreen->texture);
 
   g_free (offscreen);
@@ -1096,7 +1095,7 @@ _cogl_create_framebuffer_stack (void)
   CoglFramebufferStackEntry *entry;
   GSList *stack = NULL;
 
-  entry = create_stack_entry (COGL_INVALID_HANDLE, COGL_INVALID_HANDLE);
+  entry = create_stack_entry (NULL, NULL);
 
   return g_slist_prepend (stack, entry);
 }
@@ -1199,21 +1198,6 @@ cogl_set_framebuffer (CoglFramebuffer *framebuffer)
   _cogl_set_framebuffers (framebuffer, framebuffer);
 }
 
-/* XXX: deprecated API */
-void
-cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle handle)
-{
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  if (target == COGL_WINDOW_BUFFER)
-    handle = ctx->window_buffer;
-
-  /* This is deprecated public API. The public API doesn't currently
-     really expose the concept of separate draw and read buffers so
-     for the time being this actually just sets both buffers */
-  cogl_set_framebuffer (handle);
-}
-
 CoglFramebuffer *
 cogl_get_draw_framebuffer (void)
 {
diff --git a/cogl/cogl-shader-boilerplate.h b/cogl/cogl-glsl-shader-boilerplate.h
similarity index 100%
rename from cogl/cogl-shader-boilerplate.h
rename to cogl/cogl-glsl-shader-boilerplate.h
diff --git a/cogl/cogl-handle.h b/cogl/cogl-glsl-shader-private.h
similarity index 53%
rename from cogl/cogl-handle.h
rename to cogl/cogl-glsl-shader-private.h
index f69e97e..9d50650 100644
--- a/cogl/cogl-handle.h
+++ b/cogl/cogl-glsl-shader-private.h
@@ -3,7 +3,7 @@
  *
  * An object oriented GL/GLES Abstraction/Utility Layer
  *
- * Copyright (C) 2010 Intel Corporation.
+ * Copyright (C) 2012 Intel Corporation.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,18 +18,18 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library. If not, see
  * <http://www.gnu.org/licenses/>.
- *
- *
  */
 
-/* This file is just kept for compatability while we eradicate
- * CoglHandle
- */
-
-#ifndef __COGL_HANDLE_H
-#define __COGL_HANDLE_H
-
-#include "cogl-object-private.h"
+#ifndef _COGL_GLSL_SHADER_PRIVATE_H_
+#define _COGL_GLSL_SHADER_PRIVATE_H_
 
-#endif /* __COGL_HANDLE_H */
+void
+_cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx,
+                                               GLuint shader_gl_handle,
+                                               GLenum shader_gl_type,
+                                               int n_tex_coord_attribs,
+                                               GLsizei count_in,
+                                               const char **strings_in,
+                                               const GLint *lengths_in);
 
+#endif /* _COGL_GLSL_SHADER_PRIVATE_H_ */
diff --git a/cogl/cogl-glsl-shader.c b/cogl/cogl-glsl-shader.c
new file mode 100644
index 0000000..ae97942
--- /dev/null
+++ b/cogl/cogl-glsl-shader.c
@@ -0,0 +1,154 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *
+ *
+ * Authors:
+ *   Robert Bragg <robert linux intel com>
+ *   Neil Roberts <neil linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "cogl-context-private.h"
+#include "cogl-glsl-shader-private.h"
+#include "cogl-glsl-shader-boilerplate.h"
+#include "cogl-internal.h"
+
+#include <string.h>
+
+#include <glib.h>
+
+void
+_cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx,
+                                               GLuint shader_gl_handle,
+                                               GLenum shader_gl_type,
+                                               int n_tex_coord_attribs,
+                                               GLsizei count_in,
+                                               const char **strings_in,
+                                               const GLint *lengths_in)
+{
+  const char *vertex_boilerplate;
+  const char *fragment_boilerplate;
+
+  const char **strings = g_alloca (sizeof (char *) * (count_in + 3));
+  GLint *lengths = g_alloca (sizeof (GLint) * (count_in + 3));
+  int count = 0;
+  char *tex_coord_declarations = NULL;
+
+  if (ctx->driver == COGL_DRIVER_GLES2)
+    {
+      vertex_boilerplate = _COGL_VERTEX_SHADER_BOILERPLATE_GLES2;
+      fragment_boilerplate = _COGL_FRAGMENT_SHADER_BOILERPLATE_GLES2;
+    }
+  else
+    {
+      vertex_boilerplate = _COGL_VERTEX_SHADER_BOILERPLATE_GL;
+      fragment_boilerplate = _COGL_FRAGMENT_SHADER_BOILERPLATE_GL;
+    }
+
+  if (ctx->driver == COGL_DRIVER_GLES2 &&
+      cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
+    {
+      static const char texture_3d_extension[] =
+        "#extension GL_OES_texture_3D : enable\n";
+      strings[count] = texture_3d_extension;
+      lengths[count++] = sizeof (texture_3d_extension) - 1;
+    }
+
+  if (shader_gl_type == GL_VERTEX_SHADER)
+    {
+      strings[count] = vertex_boilerplate;
+      lengths[count++] = strlen (vertex_boilerplate);
+    }
+  else if (shader_gl_type == GL_FRAGMENT_SHADER)
+    {
+      strings[count] = fragment_boilerplate;
+      lengths[count++] = strlen (fragment_boilerplate);
+    }
+
+  if (ctx->driver == COGL_DRIVER_GLES2 &&
+      n_tex_coord_attribs)
+    {
+      GString *declarations = g_string_new (NULL);
+
+      g_string_append_printf (declarations,
+                              "varying vec4 _cogl_tex_coord[%d];\n",
+                              n_tex_coord_attribs);
+
+      if (shader_gl_type == GL_VERTEX_SHADER)
+        {
+          int i;
+
+          g_string_append_printf (declarations,
+                                  "uniform mat4 cogl_texture_matrix[%d];\n",
+                                  n_tex_coord_attribs);
+
+          for (i = 0; i < n_tex_coord_attribs; i++)
+            g_string_append_printf (declarations,
+                                    "attribute vec4 cogl_tex_coord%d_in;\n",
+                                    i);
+        }
+
+      tex_coord_declarations = g_string_free (declarations, FALSE);
+      strings[count] = tex_coord_declarations;
+      lengths[count++] = -1; /* null terminated */
+    }
+
+  memcpy (strings + count, strings_in, sizeof (char *) * count_in);
+  if (lengths_in)
+    memcpy (lengths + count, lengths_in, sizeof (GLint) * count_in);
+  else
+    {
+      int i;
+
+      for (i = 0; i < count_in; i++)
+        lengths[count + i] = -1; /* null terminated */
+    }
+  count += count_in;
+
+  if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
+    {
+      GString *buf = g_string_new (NULL);
+      int i;
+
+      g_string_append_printf (buf,
+                              "%s shader:\n",
+                              shader_gl_type == GL_VERTEX_SHADER ?
+                              "vertex" : "fragment");
+      for (i = 0; i < count; i++)
+        if (lengths[i] != -1)
+          g_string_append_len (buf, strings[i], lengths[i]);
+        else
+          g_string_append (buf, strings[i]);
+
+      g_message ("%s", buf->str);
+
+      g_string_free (buf, TRUE);
+    }
+
+  GE( ctx, glShaderSource (shader_gl_handle, count,
+                           (const char **) strings, lengths) );
+
+  g_free (tex_coord_declarations);
+}
diff --git a/cogl/cogl-index-buffer.h b/cogl/cogl-index-buffer.h
index 2e64ab3..0c0f477 100644
--- a/cogl/cogl-index-buffer.h
+++ b/cogl/cogl-index-buffer.h
@@ -70,7 +70,7 @@ cogl_index_buffer_new (CoglContext *context,
  *
  * Gets whether the given object references a #CoglIndexBuffer.
  *
- * Returns: %TRUE if the handle references a #CoglIndexBuffer,
+ * Returns: %TRUE if the @object references a #CoglIndexBuffer,
  *   %FALSE otherwise
  *
  * Since: 1.4
diff --git a/cogl/cogl-journal-private.h b/cogl/cogl-journal-private.h
index 90363cd..650f093 100644
--- a/cogl/cogl-journal-private.h
+++ b/cogl/cogl-journal-private.h
@@ -25,7 +25,7 @@
 #define __COGL_JOURNAL_PRIVATE_H
 
 #include "cogl-texture.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-clip-stack.h"
 
 #define COGL_JOURNAL_VBO_POOL_SIZE 8
diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c
index 8aeee59..d68d921 100644
--- a/cogl/cogl-journal.c
+++ b/cogl/cogl-journal.c
@@ -31,6 +31,7 @@
 #include "cogl-journal-private.h"
 #include "cogl-texture-private.h"
 #include "cogl-pipeline-private.h"
+#include "cogl-pipeline-state-private.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-framebuffer-private.h"
 #include "cogl-profile.h"
@@ -853,7 +854,6 @@ can_software_clip_entry (CoglJournalEntry *journal_entry,
 {
   CoglPipeline *pipeline = journal_entry->pipeline;
   CoglClipStack *clip_entry;
-  int layer_num;
 
   clip_bounds_out->x_1 = -G_MAXFLOAT;
   clip_bounds_out->y_1 = -G_MAXFLOAT;
@@ -864,18 +864,11 @@ can_software_clip_entry (CoglJournalEntry *journal_entry,
      entries using the same pipeline as the previous entry */
   if (prev_journal_entry == NULL || pipeline != prev_journal_entry->pipeline)
     {
-      /* If the pipeline has a user program then we can't reliably modify
-         the texture coordinates */
-      if (cogl_pipeline_get_user_program (pipeline))
+      /* If there is a custom texture transform; either due to custom shader
+       * snippets or a custom texture matrix then we can't reliably modify the
+       * texture coordinates. */
+      if (_cogl_pipeline_maybe_has_custom_texture_transform (pipeline))
         return FALSE;
-
-      /* If any of the pipeline layers have a texture matrix then we can't
-         reliably modify the texture coordinates */
-      for (layer_num = cogl_pipeline_get_n_layers (pipeline) - 1;
-           layer_num >= 0;
-           layer_num--)
-        if (_cogl_pipeline_layer_has_user_matrix (pipeline, layer_num))
-          return FALSE;
     }
 
   /* Now we need to verify that each clip entry's matrix is just a
@@ -1596,7 +1589,7 @@ _cogl_journal_log_quad (CoglJournal  *journal,
   entry->clip_stack = _cogl_clip_stack_ref (clip_stack);
 
   if (G_UNLIKELY (final_pipeline != pipeline))
-    cogl_handle_unref (final_pipeline);
+    cogl_object_unref (final_pipeline);
 
   cogl_framebuffer_get_modelview_matrix (framebuffer,
                                          &entry->model_view);
diff --git a/cogl/cogl-object-private.h b/cogl/cogl-object-private.h
index be1e709..2dc9728 100644
--- a/cogl/cogl-object-private.h
+++ b/cogl/cogl-object-private.h
@@ -32,10 +32,6 @@
 #include "cogl-object.h"
 #include "cogl-debug.h"
 
-/* For compatability until all components have been converted */
-typedef struct _CoglObjectClass CoglHandleClass;
-typedef struct _CoglObject      CoglHandleObject;
-
 /* XXX: sadly we didn't fully consider when we copied the cairo API
  * for _set_user_data that the callback doesn't get a pointer to the
  * instance which is desired in most cases. This means you tend to end
@@ -90,23 +86,23 @@ struct _CoglObject
 #ifdef COGL_OBJECT_DEBUG
 
 #define _COGL_OBJECT_DEBUG_NEW(type_name, obj)                          \
-  COGL_NOTE (HANDLE, "COGL " G_STRINGIFY (type_name) " NEW   %p %i",    \
+  COGL_NOTE (OBJECT, "COGL " G_STRINGIFY (type_name) " NEW   %p %i",    \
              (obj), (obj)->ref_count)
 
 #define _COGL_OBJECT_DEBUG_REF(type_name, object)       G_STMT_START {  \
   CoglObject *__obj = (CoglObject *)object;                             \
-  COGL_NOTE (HANDLE, "COGL %s REF %p %i",                               \
+  COGL_NOTE (OBJECT, "COGL %s REF %p %i",                               \
              (__obj)->klass->name,                                      \
              (__obj), (__obj)->ref_count);              } G_STMT_END
 
 #define _COGL_OBJECT_DEBUG_UNREF(type_name, object)     G_STMT_START {  \
   CoglObject *__obj = (CoglObject *)object;                             \
-  COGL_NOTE (HANDLE, "COGL %s UNREF %p %i",                             \
+  COGL_NOTE (OBJECT, "COGL %s UNREF %p %i",                             \
              (__obj)->klass->name,                                      \
              (__obj), (__obj)->ref_count - 1);          } G_STMT_END
 
 #define COGL_OBJECT_DEBUG_FREE(obj)                                     \
-  COGL_NOTE (HANDLE, "COGL %s FREE %p",                                 \
+  COGL_NOTE (OBJECT, "COGL %s FREE %p",                                 \
              (obj)->klass->name, (obj))
 
 #else /* !COGL_OBJECT_DEBUG */
@@ -118,12 +114,6 @@ struct _CoglObject
 
 #endif /* COGL_OBJECT_DEBUG */
 
-/* For temporary compatability */
-#define _COGL_HANDLE_DEBUG_NEW _COGL_OBJECT_DEBUG_NEW
-#define _COGL_HANDLE_DEBUG_REF _COGL_OBJECT_DEBUG_REF
-#define _COGL_HANDLE_DEBUG_UNREF _COGL_OBJECT_DEBUG_UNREF
-#define COGL_HANDLE_DEBUG_FREE COGL_OBJECT_DEBUG_FREE
-
 #define COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code)  \
                                                                         \
 CoglObjectClass _cogl_##type_name##_class;                              \
@@ -214,70 +204,12 @@ _cogl_is_##type_name (void *object)                                     \
   return obj->klass == &_cogl_##type_name##_class;                      \
 }
 
-#define COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING(type_name)   \
-                                                                \
-void * G_GNUC_DEPRECATED                                        \
-cogl_##type_name##_ref (void *object)                           \
-{                                                               \
-  if (!cogl_is_##type_name (object))                            \
-    return NULL;                                                \
-                                                                \
-  _COGL_OBJECT_DEBUG_REF (TypeName, object);                    \
-                                                                \
-  cogl_handle_ref (object);                                     \
-                                                                \
-  return object;                                                \
-}                                                               \
-                                                                \
-void G_GNUC_DEPRECATED                                          \
-cogl_##type_name##_unref (void *object)                         \
-{                                                               \
-  if (!cogl_is_##type_name (object))                            \
-    {                                                           \
-      g_warning (G_STRINGIFY (cogl_##type_name##_unref)         \
-                 ": Ignoring unref of Cogl handle "             \
-                 "due to type mismatch");                       \
-      return;                                                   \
-    }                                                           \
-                                                                \
-  _COGL_OBJECT_DEBUG_UNREF (TypeName, object);                  \
-                                                                \
-  cogl_handle_unref (object);                                   \
-}
-
 #define COGL_OBJECT_DEFINE(TypeName, type_name)                 \
   COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
 
 #define COGL_OBJECT_INTERNAL_DEFINE(TypeName, type_name)         \
   COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
 
-/* For temporary compatability */
-#define COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE(TypeName, type_name, code) \
-                                                                         \
-COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, code)        \
-                                                                         \
-static Cogl##TypeName *                                                  \
-_cogl_##type_name##_handle_new (CoglHandle handle)                       \
-{                                                                        \
-  return _cogl_##type_name##_object_new (handle);                        \
-}
-
-#define COGL_HANDLE_DEFINE_WITH_CODE(TypeName, type_name, code)          \
-                                                                         \
-COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, code)                 \
-                                                                         \
-static Cogl##TypeName *                                                  \
-_cogl_##type_name##_handle_new (CoglHandle handle)                       \
-{                                                                        \
-  return _cogl_##type_name##_object_new (handle);                        \
-}
-
-#define COGL_HANDLE_INTERNAL_DEFINE(TypeName, type_name)        \
-  COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
-
-#define COGL_HANDLE_DEFINE(TypeName, type_name)                 \
-  COGL_HANDLE_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
-
 void
 _cogl_object_set_user_data (CoglObject *object,
                             CoglUserDataKey *key,
diff --git a/cogl/cogl-object.c b/cogl/cogl-object.c
index 9ae29f7..1ec2e8d 100644
--- a/cogl/cogl-object.c
+++ b/cogl/cogl-object.c
@@ -45,12 +45,6 @@ cogl_object_ref (void *object)
   return object;
 }
 
-CoglHandle
-cogl_handle_ref (CoglHandle handle)
-{
-  return cogl_object_ref (handle);
-}
-
 void
 _cogl_object_default_unref (void *object)
 {
@@ -104,27 +98,6 @@ cogl_object_unref (void *obj)
   unref_func (obj);
 }
 
-void
-cogl_handle_unref (CoglHandle handle)
-{
-  cogl_object_unref (handle);
-}
-
-GType
-cogl_handle_get_type (void)
-{
-  static GType our_type = 0;
-
-  /* XXX: We are keeping the "CoglHandle" name for now incase it would
-   * break bindings to change to "CoglObject" */
-  if (G_UNLIKELY (our_type == 0))
-    our_type = g_boxed_type_register_static (g_intern_static_string ("CoglHandle"),
-                                             (GBoxedCopyFunc) cogl_object_ref,
-                                             (GBoxedFreeFunc) cogl_object_unref);
-
-  return our_type;
-}
-
 /* XXX: Unlike for cogl_object_get_user_data this code will return
  * an empty entry if available and no entry for the given key can be
  * found. */
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
index 9a1d583..142639a 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -114,7 +114,7 @@ _cogl_onscreen_free (CoglOnscreen *onscreen)
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
 
-  if (framebuffer->context->window_buffer == onscreen)
+  if (framebuffer->context->window_buffer == COGL_FRAMEBUFFER (onscreen))
     framebuffer->context->window_buffer = NULL;
 
   winsys->onscreen_deinit (onscreen);
diff --git a/cogl/cogl-pipeline-fragend-arbfp.c b/cogl/cogl-pipeline-fragend-arbfp.c
index 2b58063..d4cf580 100644
--- a/cogl/cogl-pipeline-fragend-arbfp.c
+++ b/cogl/cogl-pipeline-fragend-arbfp.c
@@ -39,14 +39,13 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 
 #include "cogl-texture-private.h"
 #include "cogl-blend-string.h"
 #include "cogl-journal-private.h"
 #include "cogl-color-private.h"
 #include "cogl-profile.h"
-#include "cogl-program-private.h"
 
 #include <glib.h>
 #include <glib/gprintf.h>
@@ -72,17 +71,12 @@ typedef struct
 {
   int ref_count;
 
-  CoglHandle user_program;
   /* XXX: only valid during codegen */
   GString *source;
   GLuint gl_program;
   UnitState *unit_state;
   int next_constant_id;
 
-  /* Age of the program the last time the uniforms were flushed. This
-     is used to detect when we need to flush all of the uniforms */
-  unsigned int user_program_age;
-
   /* We need to track the last pipeline that an ARBfp program was used
    * with so know if we need to update any program.local parameters. */
   CoglPipeline *last_used_for_pipeline;
@@ -164,7 +158,6 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline,
   CoglPipelineShaderState *shader_state;
   CoglPipeline *authority;
   CoglPipeline *template_pipeline = NULL;
-  CoglHandle user_program;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
 
@@ -182,21 +175,6 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline,
   if (_cogl_pipeline_has_fragment_snippets (pipeline))
     return FALSE;
 
-  user_program = cogl_pipeline_get_user_program (pipeline);
-  if (user_program != COGL_INVALID_HANDLE)
-    {
-      /* If the program doesn't have a fragment shader then some other
-         vertend will handle the vertex shader state and we still need
-         to generate a fragment program */
-      if (!_cogl_program_has_fragment_shader (user_program))
-        user_program = COGL_INVALID_HANDLE;
-      /* If the user program does have a fragment shader then we can
-         only handle it if it's in ARBfp */
-      else if (_cogl_program_get_language (user_program) !=
-               COGL_SHADER_LANGUAGE_ARBFP)
-        return FALSE;
-    }
-
   /* Now lookup our ARBfp backend private state */
   shader_state = get_shader_state (pipeline);
 
@@ -250,21 +228,17 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline,
     {
       shader_state = shader_state_new (n_layers);
 
-      shader_state->user_program = user_program;
-      if (user_program == COGL_INVALID_HANDLE)
-        {
-          /* We reuse a single grow-only GString for code-gen */
-          g_string_set_size (ctx->codegen_source_buffer, 0);
-          shader_state->source = ctx->codegen_source_buffer;
-          g_string_append (shader_state->source,
-                           "!!ARBfp1.0\n"
-                           "TEMP output;\n"
-                           "TEMP tmp0, tmp1, tmp2, tmp3, tmp4;\n"
-                           "PARAM half = {.5, .5, .5, .5};\n"
-                           "PARAM one = {1, 1, 1, 1};\n"
-                           "PARAM two = {2, 2, 2, 2};\n"
-                           "PARAM minus_one = {-1, -1, -1, -1};\n");
-        }
+      /* We reuse a single grow-only GString for code-gen */
+      g_string_set_size (ctx->codegen_source_buffer, 0);
+      shader_state->source = ctx->codegen_source_buffer;
+      g_string_append (shader_state->source,
+                       "!!ARBfp1.0\n"
+                       "TEMP output;\n"
+                       "TEMP tmp0, tmp1, tmp2, tmp3, tmp4;\n"
+                       "PARAM half = {.5, .5, .5, .5};\n"
+                       "PARAM one = {1, 1, 1, 1};\n"
+                       "PARAM two = {2, 2, 2, 2};\n"
+                       "PARAM minus_one = {-1, -1, -1, -1};\n");
     }
 
   set_shader_state (pipeline, shader_state);
@@ -844,6 +818,7 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline,
 {
   CoglPipelineShaderState *shader_state = get_shader_state (pipeline);
   GLuint gl_program;
+  UpdateConstantsState state;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
 
@@ -886,47 +861,20 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline,
       shader_state->source = NULL;
     }
 
-  if (shader_state->user_program != COGL_INVALID_HANDLE)
-    {
-      /* An arbfp program should contain exactly one shader which we
-         can use directly */
-      CoglProgram *program = shader_state->user_program;
-      CoglShader *shader = program->attached_shaders->data;
-
-      gl_program = shader->gl_handle;
-    }
-  else
-    gl_program = shader_state->gl_program;
+  gl_program = shader_state->gl_program;
 
   GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, gl_program));
   _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_ARBFP);
 
-  if (shader_state->user_program == COGL_INVALID_HANDLE)
-    {
-      UpdateConstantsState state;
-      state.unit = 0;
-      state.shader_state = shader_state;
-      /* If this arbfp program was last used with a different pipeline
-       * then we need to ensure we update all program.local params */
-      state.update_all =
-        pipeline != shader_state->last_used_for_pipeline;
-      cogl_pipeline_foreach_layer (pipeline,
-                                   update_constants_cb,
-                                   &state);
-    }
-  else
-    {
-      CoglProgram *program = shader_state->user_program;
-      gboolean program_changed;
-
-      /* If the shader has changed since it was last flushed then we
-         need to update all uniforms */
-      program_changed = program->age != shader_state->user_program_age;
-
-      _cogl_program_flush_uniforms (program, gl_program, program_changed);
-
-      shader_state->user_program_age = program->age;
-    }
+  state.unit = 0;
+  state.shader_state = shader_state;
+  /* If this arbfp program was last used with a different pipeline
+   * then we need to ensure we update all program.local params */
+  state.update_all =
+    pipeline != shader_state->last_used_for_pipeline;
+  cogl_pipeline_foreach_layer (pipeline,
+                               update_constants_cb,
+                               &state);
 
   /* We need to track what pipeline used this arbfp program last since
    * we will need to update program.local params when switching
diff --git a/cogl/cogl-pipeline-fragend-fixed.c b/cogl/cogl-pipeline-fragend-fixed.c
index c8e8e2c..c11c1d2 100644
--- a/cogl/cogl-pipeline-fragend-fixed.c
+++ b/cogl/cogl-pipeline-fragend-fixed.c
@@ -38,12 +38,11 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 
 #include "cogl-texture-private.h"
 #include "cogl-blend-string.h"
 #include "cogl-profile.h"
-#include "cogl-program-private.h"
 
 #include <glib.h>
 #include <glib/gprintf.h>
@@ -95,8 +94,6 @@ _cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline,
                                     unsigned long pipelines_difference,
                                     int n_tex_coord_attribs)
 {
-  CoglHandle user_program;
-
   _COGL_GET_CONTEXT (ctx, FALSE);
 
   if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
@@ -109,15 +106,6 @@ _cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline,
   if (_cogl_pipeline_has_fragment_snippets (pipeline))
     return FALSE;
 
-  /* If there is a user program with a fragment shader then the
-     appropriate backend for that language should handle it. We can
-     still use the fixed fragment backend if the program only contains
-     a vertex shader */
-  user_program = cogl_pipeline_get_user_program (pipeline);
-  if (user_program != COGL_INVALID_HANDLE &&
-      _cogl_program_has_fragment_shader (user_program))
-    return FALSE;
-
   _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED);
   return TRUE;
 }
diff --git a/cogl/cogl-pipeline-fragend-glsl.c b/cogl/cogl-pipeline-fragend-glsl.c
index 1f44722..055e0ca 100644
--- a/cogl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/cogl-pipeline-fragend-glsl.c
@@ -35,7 +35,6 @@
 #include "cogl-context-private.h"
 #include "cogl-pipeline-private.h"
 #include "cogl-pipeline-layer-private.h"
-#include "cogl-shader-private.h"
 #include "cogl-blend-string.h"
 #include "cogl-snippet-private.h"
 
@@ -43,11 +42,10 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
-#include "cogl-shader-private.h"
-#include "cogl-program-private.h"
+#include "cogl-object-private.h"
 #include "cogl-pipeline-cache.h"
 #include "cogl-pipeline-fragend-glsl-private.h"
+#include "cogl-glsl-shader-private.h"
 
 #include <glib.h>
 
@@ -99,12 +97,6 @@ typedef struct
      again */
   LayerDataList layers;
 
-  /* Age of the user program that was current when the shader was
-     generated. We need to keep track of this because if the user
-     program changes then we may need to redecide whether to generate
-     a shader at all */
-  unsigned int user_program_age;
-
   /* The number of tex coord attributes that the shader was generated
      for. If this changes on GLES2 then we need to regenerate the
      shader */
@@ -223,7 +215,6 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline,
   CoglPipelineShaderState *shader_state;
   CoglPipeline *authority;
   CoglPipeline *template_pipeline = NULL;
-  CoglProgram *user_program;
   int i;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
@@ -231,15 +222,6 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline,
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
     return FALSE;
 
-  user_program = cogl_pipeline_get_user_program (pipeline);
-
-  /* If the user fragment shader isn't GLSL then we should let
-     another backend handle it */
-  if (user_program &&
-      _cogl_program_has_fragment_shader (user_program) &&
-      _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL)
-    return FALSE;
-
   /* Now lookup our glsl backend private state */
   shader_state = get_shader_state (pipeline);
 
@@ -305,15 +287,11 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline,
   if (shader_state->gl_shader)
     {
       /* If we already have a valid GLSL shader then we don't need to
-         generate a new one. However if there's a user program and it
-         has changed since the last link then we do need a new
-         shader. If the number of tex coord attribs changes on GLES2
-         then we need to regenerate the shader with a different boiler
-         plate */
-      if ((user_program == NULL ||
-           shader_state->user_program_age == user_program->age)
-          && (ctx->driver != COGL_DRIVER_GLES2 ||
-              shader_state->n_tex_coord_attribs == n_tex_coord_attribs))
+         generate a new one. However if the number of tex coord
+         attribs changes on GLES2 then we need to regenerate the
+         shader with a different boiler plate */
+      if ((ctx->driver != COGL_DRIVER_GLES2 ||
+          shader_state->n_tex_coord_attribs == n_tex_coord_attribs))
         return TRUE;
 
       /* We need to recreate the shader so destroy the existing one */
@@ -322,20 +300,11 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline,
     }
 
   /* If we make it here then we have a glsl_shader_state struct
-     without a gl_shader either because this is the first time we've
-     encountered it or because the user program has changed */
-
-  if (user_program)
-    shader_state->user_program_age = user_program->age;
+     without a gl_shader because this is the first time we've
+     encountered it. */
 
   shader_state->n_tex_coord_attribs = n_tex_coord_attribs;
 
-  /* If the user program contains a fragment shader then we don't need
-     to generate one */
-  if (user_program &&
-      _cogl_program_has_fragment_shader (user_program))
-    return TRUE;
-
   /* We reuse two grow-only GStrings for code-gen. One string
      contains the uniform and attribute declarations while the
      other contains the main function. We need two strings
@@ -1089,11 +1058,12 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline,
       lengths[1] = shader_state->source->len;
       source_strings[1] = shader_state->source->str;
 
-      _cogl_shader_set_source_with_boilerplate (shader, GL_FRAGMENT_SHADER,
-                                                shader_state
-                                                ->n_tex_coord_attribs,
-                                                2, /* count */
-                                                source_strings, lengths);
+      _cogl_glsl_shader_set_source_with_boilerplate (ctx,
+                                                     shader, GL_FRAGMENT_SHADER,
+                                                     shader_state
+                                                     ->n_tex_coord_attribs,
+                                                     2, /* count */
+                                                     source_strings, lengths);
 
       GE( ctx, glCompileShader (shader) );
       GE( ctx, glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) );
diff --git a/cogl/cogl-pipeline-layer-state.h b/cogl/cogl-pipeline-layer-state.h
index 90dbc6a..58c0c1e 100644
--- a/cogl/cogl-pipeline-layer-state.h
+++ b/cogl/cogl-pipeline-layer-state.h
@@ -413,7 +413,7 @@ cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline,
 
 /**
  * cogl_pipeline_set_layer_point_sprite_coords_enabled:
- * @pipeline: a #CoglHandle to a pipeline.
+ * @pipeline: A #CoglPipeline object
  * @layer_index: the layer number to change.
  * @enable: whether to enable point sprite coord generation.
  * @error: A return location for a GError, or NULL to ignore errors.
@@ -441,7 +441,7 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
 
 /**
  * cogl_pipeline_get_layer_point_sprite_coords_enabled:
- * @pipeline: a #CoglHandle to a pipeline.
+ * @pipeline: A #CoglPipeline object
  * @layer_index: the layer number to check.
  *
  * Gets whether point sprite coordinate generation is enabled for this
diff --git a/cogl/cogl-pipeline-opengl-private.h b/cogl/cogl-pipeline-opengl-private.h
index be7b6d0..882d4fb 100644
--- a/cogl/cogl-pipeline-opengl-private.h
+++ b/cogl/cogl-pipeline-opengl-private.h
@@ -142,9 +142,6 @@ void
 _cogl_delete_gl_texture (GLuint gl_texture);
 
 void
-_cogl_gl_use_program_wrapper (CoglHandle program);
-
-void
 _cogl_pipeline_flush_gl_state (CoglPipeline *pipeline,
                                gboolean skip_gl_state,
                                int n_tex_coord_attribs);
diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c
index fc331d0..d7e7434 100644
--- a/cogl/cogl-pipeline-opengl.c
+++ b/cogl/cogl-pipeline-opengl.c
@@ -872,9 +872,9 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
     }
 #endif
 
-  cogl_handle_ref (layer);
-  if (unit->layer != COGL_INVALID_HANDLE)
-    cogl_handle_unref (unit->layer);
+  cogl_object_ref (layer);
+  if (unit->layer != NULL)
+    cogl_object_unref (unit->layer);
 
   unit->layer = layer;
   unit->layer_changes_since_flush = 0;
diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
index b88e401..b22d196 100644
--- a/cogl/cogl-pipeline-private.h
+++ b/cogl/cogl-pipeline-private.h
@@ -175,7 +175,6 @@ typedef enum
   COGL_PIPELINE_STATE_ALPHA_FUNC_INDEX,
   COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE_INDEX,
   COGL_PIPELINE_STATE_BLEND_INDEX,
-  COGL_PIPELINE_STATE_USER_SHADER_INDEX,
   COGL_PIPELINE_STATE_DEPTH_INDEX,
   COGL_PIPELINE_STATE_FOG_INDEX,
   COGL_PIPELINE_STATE_POINT_SIZE_INDEX,
@@ -220,8 +219,6 @@ typedef enum _CoglPipelineState
     1L<<COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE_INDEX,
   COGL_PIPELINE_STATE_BLEND =
     1L<<COGL_PIPELINE_STATE_BLEND_INDEX,
-  COGL_PIPELINE_STATE_USER_SHADER =
-    1L<<COGL_PIPELINE_STATE_USER_SHADER_INDEX,
   COGL_PIPELINE_STATE_DEPTH =
     1L<<COGL_PIPELINE_STATE_DEPTH_INDEX,
   COGL_PIPELINE_STATE_FOG =
@@ -261,7 +258,6 @@ typedef enum _CoglPipelineState
    COGL_PIPELINE_STATE_LAYERS | \
    COGL_PIPELINE_STATE_LIGHTING | \
    COGL_PIPELINE_STATE_BLEND | \
-   COGL_PIPELINE_STATE_USER_SHADER | \
    COGL_PIPELINE_STATE_VERTEX_SNIPPETS | \
    COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS)
 
@@ -270,7 +266,6 @@ typedef enum _CoglPipelineState
    COGL_PIPELINE_STATE_ALPHA_FUNC | \
    COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE | \
    COGL_PIPELINE_STATE_BLEND | \
-   COGL_PIPELINE_STATE_USER_SHADER | \
    COGL_PIPELINE_STATE_DEPTH | \
    COGL_PIPELINE_STATE_FOG | \
    COGL_PIPELINE_STATE_POINT_SIZE | \
@@ -294,7 +289,6 @@ typedef enum _CoglPipelineState
 
 #define COGL_PIPELINE_STATE_AFFECTS_VERTEX_CODEGEN \
   (COGL_PIPELINE_STATE_LAYERS | \
-   COGL_PIPELINE_STATE_USER_SHADER | \
    COGL_PIPELINE_STATE_VERTEX_SNIPPETS)
 
 typedef enum
@@ -386,7 +380,6 @@ typedef struct
   CoglPipelineLightingState lighting_state;
   CoglPipelineAlphaFuncState alpha_state;
   CoglPipelineBlendState blend_state;
-  CoglHandle user_program;
   CoglDepthState depth_state;
   CoglPipelineFogState fog_state;
   float point_size;
diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c
index 6d7cf43..fac72c9 100644
--- a/cogl/cogl-pipeline-progend-glsl.c
+++ b/cogl/cogl-pipeline-progend-glsl.c
@@ -41,8 +41,7 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
-#include "cogl-program-private.h"
+#include "cogl-object-private.h"
 #include "cogl-pipeline-fragend-glsl-private.h"
 #include "cogl-pipeline-vertend-glsl-private.h"
 #include "cogl-pipeline-cache.h"
@@ -100,10 +99,6 @@ typedef struct
 {
   unsigned int ref_count;
 
-  /* Age that the user program had last time we generated a GL
-     program. If it's different then we need to relink the program */
-  unsigned int user_program_age;
-
   GLuint program;
 
   /* To allow writing shaders that are portable between GLES 2 and
@@ -654,7 +649,6 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
   GLuint gl_program;
   gboolean program_changed = FALSE;
   UpdateUniformsState state;
-  CoglProgram *user_program;
   CoglPipeline *template_pipeline = NULL;
 
   _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@@ -667,8 +661,6 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
 
   program_state = get_program_state (pipeline);
 
-  user_program = cogl_pipeline_get_user_program (pipeline);
-
   if (program_state == NULL)
     {
       CoglPipeline *authority;
@@ -722,16 +714,11 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
         }
     }
 
-  /* If the program has changed since the last link then we do
-   * need to relink
-   *
-   * Also if the number of texture coordinate attributes in use has
+  /* If the number of texture coordinate attributes in use has
    * changed, then delete the program so we can prepend a new
    * _cogl_tex_coord[] varying array declaration. */
-  if ((program_state->program && user_program &&
-       user_program->age != program_state->user_program_age) ||
-      (ctx->driver == COGL_DRIVER_GLES2 &&
-       n_tex_coord_attribs != program_state->n_tex_coord_attribs))
+  if (ctx->driver == COGL_DRIVER_GLES2 &&
+      n_tex_coord_attribs != program_state->n_tex_coord_attribs)
     {
       GE( ctx, glDeleteProgram (program_state->program) );
       program_state->program = 0;
@@ -740,28 +727,9 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
   if (program_state->program == 0)
     {
       GLuint backend_shader;
-      GSList *l;
 
       GE_RET( program_state->program, ctx, glCreateProgram () );
 
-      /* Attach all of the shader from the user program */
-      if (user_program)
-        {
-          for (l = user_program->attached_shaders; l; l = l->next)
-            {
-              CoglShader *shader = l->data;
-
-              _cogl_shader_compile_real (shader, n_tex_coord_attribs);
-
-              g_assert (shader->language == COGL_SHADER_LANGUAGE_GLSL);
-
-              GE( ctx, glAttachShader (program_state->program,
-                                       shader->gl_handle) );
-            }
-
-          program_state->user_program_age = user_program->age;
-        }
-
       /* Attach any shaders from the GLSL backends */
       if (pipeline->fragend == COGL_PIPELINE_FRAGEND_GLSL &&
           (backend_shader = _cogl_pipeline_fragend_glsl_get_shader (pipeline)))
@@ -847,11 +815,6 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
                                               gl_program,
                                               program_changed);
 
-  if (user_program)
-    _cogl_program_flush_uniforms (user_program,
-                                  gl_program,
-                                  program_changed);
-
   /* We need to track the last pipeline that the program was used with
    * so know if we need to update all of the uniforms */
   program_state->last_used_for_pipeline = pipeline;
diff --git a/cogl/cogl-pipeline-state-private.h b/cogl/cogl-pipeline-state-private.h
index 2bc162d..d70451c 100644
--- a/cogl/cogl-pipeline-state-private.h
+++ b/cogl/cogl-pipeline-state-private.h
@@ -28,8 +28,8 @@
 #ifndef __COGL_PIPELINE_STATE_PRIVATE_H
 #define __COGL_PIPELINE_STATE_PRIVATE_H
 
-CoglPipeline *
-_cogl_pipeline_get_user_program (CoglPipeline *pipeline);
+gboolean
+_cogl_pipeline_maybe_has_custom_texture_transform (CoglPipeline *pipeline);
 
 gboolean
 _cogl_pipeline_has_vertex_snippets (CoglPipeline *pipeline);
diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
index 4b18d23..2fc8cb6 100644
--- a/cogl/cogl-pipeline-state.c
+++ b/cogl/cogl-pipeline-state.c
@@ -43,19 +43,6 @@
 #define GL_FUNC_ADD 0x8006
 #endif
 
-CoglPipeline *
-_cogl_pipeline_get_user_program (CoglPipeline *pipeline)
-{
-  CoglPipeline *authority;
-
-  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL);
-
-  authority =
-    _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER);
-
-  return authority->big_state->user_program;
-}
-
 gboolean
 _cogl_pipeline_color_equal (CoglPipeline *authority0,
                             CoglPipeline *authority1)
@@ -231,14 +218,6 @@ _cogl_pipeline_cull_face_state_equal (CoglPipeline *authority0,
           cull_face_state0->front_winding == cull_face_state1->front_winding);
 }
 
-gboolean
-_cogl_pipeline_user_shader_equal (CoglPipeline *authority0,
-                                  CoglPipeline *authority1)
-{
-  return (authority0->big_state->user_program ==
-          authority1->big_state->user_program);
-}
-
 typedef struct
 {
   const CoglBoxedValue **dst_values;
@@ -1080,84 +1059,6 @@ cogl_pipeline_set_blend_constant (CoglPipeline *pipeline,
 #endif
 }
 
-CoglHandle
-cogl_pipeline_get_user_program (CoglPipeline *pipeline)
-{
-  CoglPipeline *authority;
-
-  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE);
-
-  authority =
-    _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER);
-
-  return authority->big_state->user_program;
-}
-
-/* XXX: for now we don't mind if the program has vertex shaders
- * attached but if we ever make a similar API public we should only
- * allow attaching of programs containing fragment shaders. Eventually
- * we will have a CoglPipeline abstraction to also cover vertex
- * processing.
- */
-void
-cogl_pipeline_set_user_program (CoglPipeline *pipeline,
-                                CoglHandle program)
-{
-  CoglPipelineState state = COGL_PIPELINE_STATE_USER_SHADER;
-  CoglPipeline *authority;
-
-  _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
-
-  authority = _cogl_pipeline_get_authority (pipeline, state);
-
-  if (authority->big_state->user_program == program)
-    return;
-
-  /* - Flush journal primitives referencing the current state.
-   * - Make sure the pipeline has no dependants so it may be modified.
-   * - If the pipeline isn't currently an authority for the state being
-   *   changed, then initialize that state from the current authority.
-   */
-  _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE);
-
-  if (program != COGL_INVALID_HANDLE)
-    {
-      _cogl_pipeline_set_fragend (pipeline, COGL_PIPELINE_FRAGEND_DEFAULT);
-      _cogl_pipeline_set_vertend (pipeline, COGL_PIPELINE_VERTEND_DEFAULT);
-    }
-
-  /* If we are the current authority see if we can revert to one of our
-   * ancestors being the authority */
-  if (pipeline == authority &&
-      _cogl_pipeline_get_parent (authority) != NULL)
-    {
-      CoglPipeline *parent = _cogl_pipeline_get_parent (authority);
-      CoglPipeline *old_authority =
-        _cogl_pipeline_get_authority (parent, state);
-
-      if (old_authority->big_state->user_program == program)
-        pipeline->differences &= ~state;
-    }
-  else if (pipeline != authority)
-    {
-      /* If we weren't previously the authority on this state then we
-       * need to extended our differences mask and so it's possible
-       * that some of our ancestry will now become redundant, so we
-       * aim to reparent ourselves if that's true... */
-      pipeline->differences |= state;
-      _cogl_pipeline_prune_redundant_ancestry (pipeline);
-    }
-
-  if (program != COGL_INVALID_HANDLE)
-    cogl_handle_ref (program);
-  if (authority == pipeline &&
-      pipeline->big_state->user_program != COGL_INVALID_HANDLE)
-    cogl_handle_unref (pipeline->big_state->user_program);
-  pipeline->big_state->user_program = program;
-
-  _cogl_pipeline_update_blend_enable (pipeline, state);
-}
-
 gboolean
 cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
                                const CoglDepthState *depth_state,
@@ -1704,6 +1605,58 @@ _cogl_pipeline_has_fragment_snippets (CoglPipeline *pipeline)
   return found_fragment_snippet;
 }
 
+static gboolean
+check_maybe_has_custom_texture_transform  (CoglPipelineLayer *layer,
+                                           void *user_data)
+{
+  gboolean *maybe_has_custom_texture_transform = user_data;
+  unsigned long matrix_state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
+  unsigned long frag_state = COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS;
+  unsigned long vert_state = COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS;
+  CoglPipelineLayer *matrix_authority;
+  CoglPipelineLayer *frag_authority;
+  CoglPipelineLayer *vert_authority;
+
+  matrix_authority = _cogl_pipeline_layer_get_authority (layer, matrix_state);
+  if (!_cogl_pipeline_layer_get_parent (matrix_authority))
+    {
+      *maybe_has_custom_texture_transform = TRUE;
+      return FALSE;
+    }
+
+  frag_authority = _cogl_pipeline_layer_get_authority (layer, frag_state);
+  if (!COGL_LIST_EMPTY (&frag_authority->big_state->fragment_snippets))
+    {
+      *maybe_has_custom_texture_transform = TRUE;
+      return FALSE;
+    }
+
+  vert_authority = _cogl_pipeline_layer_get_authority (layer, vert_state);
+  if (!COGL_LIST_EMPTY (&vert_authority->big_state->vertex_snippets))
+    {
+      *maybe_has_custom_texture_transform = TRUE;
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+gboolean
+_cogl_pipeline_maybe_has_custom_texture_transform (CoglPipeline *pipeline)
+{
+  gboolean maybe_has_custom_texture_transform = FALSE;
+
+  if (_cogl_pipeline_has_non_layer_fragment_snippets (pipeline))
+    return TRUE;
+
+  _cogl_pipeline_foreach_layer_internal (
+                                       pipeline,
+                                       check_maybe_has_custom_texture_transform,
+                                       &maybe_has_custom_texture_transform);
+
+  return maybe_has_custom_texture_transform;
+}
+
 void
 _cogl_pipeline_hash_color_state (CoglPipeline *authority,
                                  CoglPipelineHashState *state)
@@ -1804,15 +1757,6 @@ _cogl_pipeline_hash_blend_state (CoglPipeline *authority,
 }
 
 void
-_cogl_pipeline_hash_user_shader_state (CoglPipeline *authority,
-                                       CoglPipelineHashState *state)
-{
-  CoglHandle user_program = authority->big_state->user_program;
-  state->hash = _cogl_util_one_at_a_time_hash (state->hash, &user_program,
-                                               sizeof (user_program));
-}
-
-void
 _cogl_pipeline_hash_depth_state (CoglPipeline *authority,
                                  CoglPipelineHashState *state)
 {
diff --git a/cogl/cogl-pipeline-state.h b/cogl/cogl-pipeline-state.h
index 8686629..d10dd21 100644
--- a/cogl/cogl-pipeline-state.h
+++ b/cogl/cogl-pipeline-state.h
@@ -550,72 +550,6 @@ cogl_pipeline_set_color_mask (CoglPipeline *pipeline,
                               CoglColorMask color_mask);
 
 /**
- * cogl_pipeline_get_user_program:
- * @pipeline: a #CoglPipeline object.
- *
- * Queries what user program has been associated with the given
- * @pipeline using cogl_pipeline_set_user_program().
- *
- * Return value: The current user program or %COGL_INVALID_HANDLE.
- *
- * Since: 2.0
- * Stability: Unstable
- */
-CoglHandle
-cogl_pipeline_get_user_program (CoglPipeline *pipeline);
-
-/**
- * cogl_pipeline_set_user_program:
- * @pipeline: a #CoglPipeline object.
- * @program: A #CoglHandle to a linked CoglProgram
- *
- * Associates a linked CoglProgram with the given pipeline so that the
- * program can take full control of vertex and/or fragment processing.
- *
- * This is an example of how it can be used to associate an ARBfp
- * program with a #CoglPipeline:
- * |[
- * CoglHandle shader;
- * CoglHandle program;
- * CoglPipeline *pipeline;
- *
- * shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
- * cogl_shader_source (shader,
- *                     "!!ARBfp1.0\n"
- *                     "MOV result.color,fragment.color;\n"
- *                     "END\n");
- * cogl_shader_compile (shader);
- *
- * program = cogl_create_program ();
- * cogl_program_attach_shader (program, shader);
- * cogl_program_link (program);
- *
- * pipeline = cogl_pipeline_new ();
- * cogl_pipeline_set_user_program (pipeline, program);
- *
- * cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
- * cogl_rectangle (0, 0, 100, 100);
- * ]|
- *
- * It is possibly worth keeping in mind that this API is not part of
- * the long term design for how we want to expose shaders to Cogl
- * developers (We are planning on deprecating the cogl_program and
- * cogl_shader APIs in favour of a "snippet" framework) but in the
- * meantime we hope this will handle most practical GLSL and ARBfp
- * requirements.
- *
- * Also remember you need to check for either the
- * %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before
- * using the cogl_program or cogl_shader API.
- *
- * Since: 2.0
- * Stability: Unstable
- */
-void
-cogl_pipeline_set_user_program (CoglPipeline *pipeline,
-                                CoglHandle program);
-
-/**
  * cogl_pipeline_set_depth_state:
  * @pipeline: A #CoglPipeline object
  * @state: A #CoglDepthState struct
diff --git a/cogl/cogl-pipeline-vertend-fixed.c b/cogl/cogl-pipeline-vertend-fixed.c
index 2df593b..c3f06e2 100644
--- a/cogl/cogl-pipeline-vertend-fixed.c
+++ b/cogl/cogl-pipeline-vertend-fixed.c
@@ -38,8 +38,7 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
-#include "cogl-program-private.h"
+#include "cogl-object-private.h"
 
 const CoglPipelineVertend _cogl_pipeline_fixed_vertend;
 
@@ -49,8 +48,6 @@ _cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline,
                                     unsigned long pipelines_difference,
                                     int n_tex_coord_attribs)
 {
-  CoglProgram *user_program;
-
   _COGL_GET_CONTEXT (ctx, FALSE);
 
   if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
@@ -63,15 +60,6 @@ _cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline,
   if (_cogl_pipeline_has_vertex_snippets (pipeline))
     return FALSE;
 
-  /* If there is a user program with a vertex shader then the
-     appropriate backend for that language should handle it. We can
-     still use the fixed vertex backend if the program only contains
-     a fragment shader */
-  user_program = cogl_pipeline_get_user_program (pipeline);
-  if (user_program != COGL_INVALID_HANDLE &&
-      _cogl_program_has_vertex_shader (user_program))
-    return FALSE;
-
   _cogl_use_vertex_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED);
 
   return TRUE;
diff --git a/cogl/cogl-pipeline-vertend-glsl.c b/cogl/cogl-pipeline-vertend-glsl.c
index 6ecec90..1ceac16 100644
--- a/cogl/cogl-pipeline-vertend-glsl.c
+++ b/cogl/cogl-pipeline-vertend-glsl.c
@@ -39,10 +39,10 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
-#include "cogl-program-private.h"
+#include "cogl-object-private.h"
 #include "cogl-pipeline-vertend-glsl-private.h"
 #include "cogl-pipeline-state-private.h"
+#include "cogl-glsl-shader-private.h"
 
 const CoglPipelineVertend _cogl_pipeline_glsl_vertend;
 
@@ -53,12 +53,6 @@ typedef struct
   GLuint gl_shader;
   GString *header, *source;
 
-  /* Age of the user program that was current when the shader was
-     generated. We need to keep track of this because if the user
-     program changes then we may need to redecide whether to generate
-     a shader at all */
-  unsigned int user_program_age;
-
   /* The number of tex coord attributes that the shader was generated
      for. If this changes on GLES2 then we need to regenerate the
      shader */
@@ -157,22 +151,12 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline,
 {
   CoglPipelineShaderState *shader_state;
   CoglPipeline *template_pipeline = NULL;
-  CoglProgram *user_program;
 
   _COGL_GET_CONTEXT (ctx, FALSE);
 
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
     return FALSE;
 
-  user_program = cogl_pipeline_get_user_program (pipeline);
-
-  /* If the user program has a vertex shader that isn't GLSL then the
-     appropriate vertend for that language should handle it */
-  if (user_program &&
-      _cogl_program_has_vertex_shader (user_program) &&
-      _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL)
-    return FALSE;
-
   /* Now lookup our glsl backend private state (allocating if
    * necessary) */
   shader_state = get_shader_state (pipeline);
@@ -229,15 +213,11 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline,
   if (shader_state->gl_shader)
     {
       /* If we already have a valid GLSL shader then we don't need to
-         generate a new one. However if there's a user program and it
-         has changed since the last link then we do need a new
-         shader. If the number of tex coord attribs changes on GLES2
-         then we need to regenerate the shader with a different boiler
-         plate */
-      if ((user_program == NULL ||
-           shader_state->user_program_age == user_program->age)
-          && (ctx->driver != COGL_DRIVER_GLES2 ||
-              shader_state->n_tex_coord_attribs == n_tex_coord_attribs))
+         generate a new one. However if the number of tex coord
+         attribs changes on GLES2 then we need to regenerate the
+         shader with a different boiler plate */
+      if (ctx->driver != COGL_DRIVER_GLES2 ||
+          shader_state->n_tex_coord_attribs == n_tex_coord_attribs)
         return TRUE;
 
       /* We need to recreate the shader so destroy the existing one */
@@ -246,20 +226,10 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline,
     }
 
   /* If we make it here then we have a shader_state struct without a gl_shader
-     either because this is the first time we've encountered it or
-     because the user program has changed */
-
-  if (user_program)
-    shader_state->user_program_age = user_program->age;
+     because this is the first time we've encountered it */
 
   shader_state->n_tex_coord_attribs = n_tex_coord_attribs;
 
-  /* If the user program contains a vertex shader then we don't need
-     to generate one */
-  if (user_program &&
-      _cogl_program_has_vertex_shader (user_program))
-    return TRUE;
-
   /* We reuse two grow-only GStrings for code-gen. One string
      contains the uniform and attribute declarations while the
      other contains the main function. We need two strings
@@ -472,11 +442,12 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline,
       lengths[1] = shader_state->source->len;
       source_strings[1] = shader_state->source->str;
 
-      _cogl_shader_set_source_with_boilerplate (shader, GL_VERTEX_SHADER,
-                                                shader_state
-                                                ->n_tex_coord_attribs,
-                                                2, /* count */
-                                                source_strings, lengths);
+      _cogl_glsl_shader_set_source_with_boilerplate (ctx,
+                                                     shader, GL_VERTEX_SHADER,
+                                                     shader_state
+                                                     ->n_tex_coord_attribs,
+                                                     2, /* count */
+                                                     source_strings, lengths);
 
       GE( ctx, glCompileShader (shader) );
       GE( ctx, glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) );
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 0b37695..b0f0800 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -207,8 +207,6 @@ _cogl_pipeline_init_default_pipeline (void)
   blend_state->blend_src_factor_rgb = GL_ONE;
   blend_state->blend_dst_factor_rgb = GL_ONE_MINUS_SRC_ALPHA;
 
-  big_state->user_program = COGL_INVALID_HANDLE;
-
   cogl_depth_state_init (&big_state->depth_state);
 
   big_state->point_size = 1.0f;
@@ -453,10 +451,6 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
 
   _cogl_pipeline_unparent (COGL_NODE (pipeline));
 
-  if (pipeline->differences & COGL_PIPELINE_STATE_USER_SHADER &&
-      pipeline->big_state->user_program)
-    cogl_handle_unref (pipeline->big_state->user_program);
-
   if (pipeline->differences & COGL_PIPELINE_STATE_UNIFORMS)
     {
       CoglPipelineUniformsState *uniforms_state
@@ -744,17 +738,6 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline    *pipeline,
         return TRUE;
     }
 
-  if (changes & COGL_PIPELINE_STATE_USER_SHADER)
-    {
-      /* We can't make any assumptions about the alpha channel if the user
-       * is using an unknown fragment shader.
-       *
-       * TODO: check that it isn't just a vertex shader!
-       */
-      if (_cogl_pipeline_get_user_program (pipeline) != COGL_INVALID_HANDLE)
-        return TRUE;
-    }
-
   if (changes & COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS)
     {
       if (!_cogl_pipeline_has_non_layer_fragment_snippets (pipeline))
@@ -919,15 +902,6 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
               sizeof (CoglPipelineBlendState));
     }
 
-  if (differences & COGL_PIPELINE_STATE_USER_SHADER)
-    {
-      if (src->big_state->user_program)
-        big_state->user_program =
-          cogl_handle_ref (src->big_state->user_program);
-      else
-        big_state->user_program = COGL_INVALID_HANDLE;
-    }
-
   if (differences & COGL_PIPELINE_STATE_DEPTH)
     {
       memcpy (&big_state->depth_state,
@@ -1027,7 +1001,6 @@ _cogl_pipeline_init_multi_property_sparse_state (CoglPipeline *pipeline,
     case COGL_PIPELINE_STATE_ALPHA_FUNC:
     case COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE:
     case COGL_PIPELINE_STATE_POINT_SIZE:
-    case COGL_PIPELINE_STATE_USER_SHADER:
     case COGL_PIPELINE_STATE_REAL_BLEND_ENABLE:
       g_return_if_reached ();
 
@@ -1906,7 +1879,7 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
 typedef struct
 {
   CoglPipeline *pipeline;
-  CoglHandle texture;
+  CoglTexture *texture;
 } CoglPipelineOverrideLayerState;
 
 static gboolean
@@ -2251,11 +2224,6 @@ _cogl_pipeline_equal (CoglPipeline *pipeline0,
                                                      authorities1[bit]))
             goto done;
           break;
-        case COGL_PIPELINE_STATE_USER_SHADER_INDEX:
-          if (!_cogl_pipeline_user_shader_equal (authorities0[bit],
-                                                 authorities1[bit]))
-            goto done;
-          break;
         case COGL_PIPELINE_STATE_UNIFORMS_INDEX:
           if (!_cogl_pipeline_uniforms_state_equal (authorities0[bit],
                                                     authorities1[bit]))
@@ -2522,12 +2490,6 @@ _cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline)
    * the cogl_pipeline API instead.
    */
 
-  /* A program explicitly set on the pipeline has higher precedence than
-   * one associated with the context using cogl_program_use() */
-  if (ctx->current_program &&
-      cogl_pipeline_get_user_program (pipeline) == COGL_INVALID_HANDLE)
-    cogl_pipeline_set_user_program (pipeline, ctx->current_program);
-
   if (ctx->legacy_depth_test_enabled)
     {
       CoglDepthState depth_state;
@@ -2683,8 +2645,6 @@ _cogl_pipeline_init_state_hash_functions (void)
     _cogl_pipeline_hash_alpha_func_reference_state;
   state_hash_functions[COGL_PIPELINE_STATE_BLEND_INDEX] =
     _cogl_pipeline_hash_blend_state;
-  state_hash_functions[COGL_PIPELINE_STATE_USER_SHADER_INDEX] =
-    _cogl_pipeline_hash_user_shader_state;
   state_hash_functions[COGL_PIPELINE_STATE_DEPTH_INDEX] =
     _cogl_pipeline_hash_depth_state;
   state_hash_functions[COGL_PIPELINE_STATE_FOG_INDEX] =
@@ -2704,7 +2664,7 @@ _cogl_pipeline_init_state_hash_functions (void)
 
   {
   /* So we get a big error if we forget to update this code! */
-  _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 16,
+  _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 15,
                        "Make sure to install a hash function for "
                        "newly added pipeline state and update assert "
                        "in _cogl_pipeline_init_state_hash_functions");
@@ -2897,7 +2857,6 @@ CoglPipelineState
 _cogl_pipeline_get_state_for_fragment_codegen (CoglContext *context)
 {
   CoglPipelineState state = (COGL_PIPELINE_STATE_LAYERS |
-                             COGL_PIPELINE_STATE_USER_SHADER |
                              COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS);
 
   if (context->driver == COGL_DRIVER_GLES2)
diff --git a/cogl/cogl-pipeline.h b/cogl/cogl-pipeline.h
index d990e24..20f54fa 100644
--- a/cogl/cogl-pipeline.h
+++ b/cogl/cogl-pipeline.h
@@ -95,18 +95,18 @@ cogl_pipeline_copy (CoglPipeline *source);
 
 /**
  * cogl_is_pipeline:
- * @handle: A CoglHandle
+ * @object: A #CoglObject
  *
- * Gets whether the given handle references an existing pipeline object.
+ * Gets whether the given @object references an existing pipeline object.
  *
- * Return value: %TRUE if the handle references a #CoglPipeline,
+ * Return value: %TRUE if the @object references a #CoglPipeline,
  *   %FALSE otherwise
  *
  * Since: 2.0
  * Stability: Unstable
  */
 gboolean
-cogl_is_pipeline (CoglHandle handle);
+cogl_is_pipeline (void *object);
 
 /**
  * CoglPipelineLayerCallback:
diff --git a/cogl/cogl-pixel-buffer-private.h b/cogl/cogl-pixel-buffer-private.h
index 5db2a27..974afa6 100644
--- a/cogl/cogl-pixel-buffer-private.h
+++ b/cogl/cogl-pixel-buffer-private.h
@@ -28,7 +28,7 @@
 #ifndef __COGL_PIXEL_BUFFER_PRIVATE_H__
 #define __COGL_PIXEL_BUFFER_PRIVATE_H__
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-buffer-private.h"
 
 #include <glib.h>
diff --git a/cogl/cogl-pixel-buffer.h b/cogl/cogl-pixel-buffer.h
index 49bd603..7c22d16 100644
--- a/cogl/cogl-pixel-buffer.h
+++ b/cogl/cogl-pixel-buffer.h
@@ -81,9 +81,9 @@ cogl_pixel_buffer_new (CoglContext *context,
  * cogl_is_pixel_buffer:
  * @object: a #CoglObject to test
  *
- * Checks whether @handle is a pixel array.
+ * Checks whether @object is a pixel buffer.
  *
- * Return value: %TRUE if the @handle is a pixel array, and %FALSE
+ * Return value: %TRUE if the @object is a pixel buffer, and %FALSE
  *   otherwise
  *
  * Since: 1.2
@@ -95,7 +95,7 @@ cogl_is_pixel_buffer (void *object);
 #if 0
 /*
  * cogl_pixel_buffer_set_region:
- * @array: the #CoglHandle of a pixel array
+ * @buffer: A #CoglPixelBuffer object
  * @data: pixel data to upload to @array
  * @src_width: width in pixels of the region to update
  * @src_height: height in pixels of the region to update
@@ -114,13 +114,13 @@ cogl_is_pixel_buffer (void *object);
  * Stability: Unstable
  */
 gboolean
-cogl_pixel_buffer_set_region (CoglHandle    array,
-                              guint8       *data,
-                              unsigned int  src_width,
-                              unsigned int  src_height,
-                              unsigned int  src_rowstride,
-                              unsigned int  dst_x,
-                              unsigned int  dst_y);
+cogl_pixel_buffer_set_region (CoglPixelBuffer *buffer,
+                              guint8 *data,
+                              unsigned int src_width,
+                              unsigned int src_height,
+                              unsigned int src_rowstride,
+                              unsigned int dst_x,
+                              unsigned int dst_y);
 #endif
 
 G_END_DECLS
diff --git a/cogl/cogl-primitive.h b/cogl/cogl-primitive.h
index b99ae87..657507a 100644
--- a/cogl/cogl-primitive.h
+++ b/cogl/cogl-primitive.h
@@ -827,7 +827,7 @@ cogl_primitive_copy (CoglPrimitive *primitive);
  *
  * Gets whether the given object references a #CoglPrimitive.
  *
- * Returns: %TRUE if the handle references a #CoglPrimitive,
+ * Returns: %TRUE if the @object references a #CoglPrimitive,
  *   %FALSE otherwise
  *
  * Since: 1.6
diff --git a/cogl/cogl-snippet.h b/cogl/cogl-snippet.h
index 88a49d2..60eccc6 100644
--- a/cogl/cogl-snippet.h
+++ b/cogl/cogl-snippet.h
@@ -601,11 +601,11 @@ cogl_snippet_get_hook (CoglSnippet *snippet);
 
 /**
  * cogl_is_snippet:
- * @handle: A CoglHandle
+ * @object: A #CoglObject pointer
  *
- * Gets whether the given handle references an existing snippet object.
+ * Gets whether the given @object references an existing snippet object.
  *
- * Return value: %TRUE if the handle references a #CoglSnippet,
+ * Return value: %TRUE if the @object references a #CoglSnippet,
  *   %FALSE otherwise
  *
  * Since: 1.10
diff --git a/cogl/cogl-spans.h b/cogl/cogl-spans.h
index ac8d13a..b0b6c1d 100644
--- a/cogl/cogl-spans.h
+++ b/cogl/cogl-spans.h
@@ -24,7 +24,7 @@
 #ifndef __COGL_SPANS_PRIVATE_H
 #define __COGL_SPANS_PRIVATE_H
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-pipeline-layer-state.h"
 
 typedef struct _CoglSpan
diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c
index ee8a10f..38aac15 100644
--- a/cogl/cogl-sub-texture.c
+++ b/cogl/cogl-sub-texture.c
@@ -253,7 +253,7 @@ cogl_sub_texture_new (CoglContext *ctx,
   sub_tex->sub_width = sub_width;
   sub_tex->sub_height = sub_height;
 
-  return _cogl_sub_texture_handle_new (sub_tex);
+  return _cogl_sub_texture_object_new (sub_tex);
 }
 
 CoglTexture *
diff --git a/cogl/cogl-texture-2d-private.h b/cogl/cogl-texture-2d-private.h
index 8907610..855b2fb 100644
--- a/cogl/cogl-texture-2d-private.h
+++ b/cogl/cogl-texture-2d-private.h
@@ -24,7 +24,7 @@
 #ifndef __COGL_TEXTURE_2D_H
 #define __COGL_TEXTURE_2D_H
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-pipeline-private.h"
 #include "cogl-texture-private.h"
 #include "cogl-texture-2d.h"
@@ -68,18 +68,18 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
 
 /*
  * _cogl_texture_2d_externally_modified:
- * @handle: A handle to a 2D texture
+ * @texture: A #CoglTexture2D object
  *
  * This should be called whenever the texture is modified other than
  * by using cogl_texture_set_region. It will cause the mipmaps to be
  * invalidated
  */
 void
-_cogl_texture_2d_externally_modified (CoglHandle handle);
+_cogl_texture_2d_externally_modified (CoglTexture *texture);
 
 /*
  * _cogl_texture_2d_copy_from_framebuffer:
- * @handle: A handle to a 2D texture
+ * @texture: A #CoglTexture2D pointer
  * @dst_x: X-position to store the image within the texture
  * @dst_y: Y-position to store the image within the texture
  * @src_x: X-position to within the framebuffer to read from
@@ -91,7 +91,7 @@ _cogl_texture_2d_externally_modified (CoglHandle handle);
  * texture.
  */
 void
-_cogl_texture_2d_copy_from_framebuffer (CoglHandle handle,
+_cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *texture,
                                         int dst_x,
                                         int dst_y,
                                         int src_x,
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index 5f43252..f2872ad 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -40,7 +40,7 @@
 #include "cogl-texture-2d-sliced-private.h"
 #include "cogl-texture-driver.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-spans.h"
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-opengl-private.h"
@@ -790,7 +790,7 @@ _cogl_texture_2d_sliced_slices_free (CoglTexture2DSliced *tex_2ds)
         {
           CoglTexture2D *slice_tex =
             g_array_index (tex_2ds->slice_textures, CoglTexture2D *, i);
-          cogl_handle_unref (slice_tex);
+          cogl_object_unref (slice_tex);
         }
 
       g_array_free (tex_2ds->slice_textures, TRUE);
@@ -867,7 +867,7 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
       return NULL;
     }
 
-  return _cogl_texture_2d_sliced_handle_new (tex_2ds);
+  return _cogl_texture_2d_sliced_object_new (tex_2ds);
 }
 
 CoglTexture2DSliced *
@@ -935,7 +935,7 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap      *bmp,
         cogl_primitive_texture_set_auto_mipmap (slice_tex, FALSE);
       }
 
-  return _cogl_texture_2d_sliced_handle_new (tex_2ds);
+  return _cogl_texture_2d_sliced_object_new (tex_2ds);
 
  error:
   cogl_object_unref (dst_bmp);
@@ -1030,7 +1030,7 @@ _cogl_texture_2d_sliced_new_from_foreign (GLuint           gl_handle,
 
   g_array_append_val (tex_2ds->slice_textures, tex_2d);
 
-  return _cogl_texture_2d_sliced_handle_new (tex_2ds);
+  return _cogl_texture_2d_sliced_object_new (tex_2ds);
 }
 
 static gboolean
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index 5e988bd..beaf965 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -34,7 +34,7 @@
 #include "cogl-texture-2d-private.h"
 #include "cogl-texture-driver.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-framebuffer-private.h"
@@ -218,7 +218,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
   GE( ctx, glTexImage2D (GL_TEXTURE_2D, 0, gl_intformat,
                          width, height, 0, gl_format, gl_type, NULL) );
 
-  return _cogl_texture_2d_handle_new (tex_2d);
+  return _cogl_texture_2d_object_new (tex_2d);
 }
 
 CoglTexture2D *
@@ -234,7 +234,7 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
   guint8        *data;
   CoglContext   *ctx;
 
-  _COGL_RETURN_VAL_IF_FAIL (bmp != NULL, COGL_INVALID_HANDLE);
+  _COGL_RETURN_VAL_IF_FAIL (bmp != NULL, NULL);
 
   ctx = _cogl_bitmap_get_context (bmp);
 
@@ -300,7 +300,7 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
 
   cogl_object_unref (dst_bmp);
 
-  return _cogl_texture_2d_handle_new (tex_2d);
+  return _cogl_texture_2d_object_new (tex_2d);
 }
 
 CoglTexture2D *
@@ -314,7 +314,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
                                GError **error)
 {
   CoglBitmap *bmp;
-  CoglHandle tex;
+  CoglTexture2D *tex_2d;
 
   _COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL);
   _COGL_RETURN_VAL_IF_FAIL (data != NULL, NULL);
@@ -330,13 +330,13 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
                                   rowstride,
                                   (guint8 *) data);
 
-  tex = cogl_texture_2d_new_from_bitmap (bmp,
-                                         internal_format,
-                                         error);
+  tex_2d = cogl_texture_2d_new_from_bitmap (bmp,
+                                            internal_format,
+                                            error);
 
   cogl_object_unref (bmp);
 
-  return tex;
+  return tex_2d;
 }
 
 CoglTexture2D *
@@ -357,11 +357,11 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
   CoglTexture2D *tex_2d;
 
   if (!ctx->texture_driver->allows_foreign_gl_target (ctx, GL_TEXTURE_2D))
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Make sure it is a valid GL texture object */
   if (!ctx->glIsTexture (gl_handle))
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Make sure binding succeeds */
   while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
@@ -369,7 +369,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
 
   _cogl_bind_gl_texture_transient (GL_TEXTURE_2D, gl_handle, TRUE);
   if (ctx->glGetError () != GL_NO_ERROR)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Obtain texture parameters
      (only level 0 we are interested in) */
@@ -396,7 +396,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
       if (!ctx->driver_vtable->pixel_format_from_gl_internal (ctx,
                                                               gl_int_format,
                                                               &format))
-        return COGL_INVALID_HANDLE;
+        return NULL;
     }
   else
 #endif
@@ -419,11 +419,11 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
 
   /* Validate width and height */
   if (width <= 0 || height <= 0)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Compressed texture images not supported */
   if (gl_compressed == GL_TRUE)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Note: previously this code would query the texture object for
      whether it has GL_GENERATE_MIPMAP enabled to determine whether to
@@ -454,7 +454,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
   tex_2d->min_filter = GL_FALSE;
   tex_2d->mag_filter = GL_FALSE;
 
-  return _cogl_texture_2d_handle_new (tex_2d);
+  return _cogl_texture_2d_object_new (tex_2d);
 }
 
 #if defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base)
@@ -500,7 +500,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
       return NULL;
     }
 
-  return _cogl_texture_2d_handle_new (tex_2d);
+  return _cogl_texture_2d_object_new (tex_2d);
 }
 #endif /* defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) */
 
@@ -574,16 +574,16 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
 #endif /* COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT */
 
 void
-_cogl_texture_2d_externally_modified (CoglHandle handle)
+_cogl_texture_2d_externally_modified (CoglTexture *texture)
 {
-  if (!cogl_is_texture_2d (handle))
+  if (!cogl_is_texture_2d (texture))
     return;
 
-  COGL_TEXTURE_2D (handle)->mipmaps_dirty = TRUE;
+  COGL_TEXTURE_2D (texture)->mipmaps_dirty = TRUE;
 }
 
 void
-_cogl_texture_2d_copy_from_framebuffer (CoglHandle handle,
+_cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *tex_2d,
                                         int dst_x,
                                         int dst_y,
                                         int src_x,
@@ -591,13 +591,9 @@ _cogl_texture_2d_copy_from_framebuffer (CoglHandle handle,
                                         int width,
                                         int height)
 {
-  CoglTexture2D *tex_2d;
-
   _COGL_GET_CONTEXT (ctx, NO_RETVAL);
 
-  _COGL_RETURN_IF_FAIL (cogl_is_texture_2d (handle));
-
-  tex_2d = COGL_TEXTURE_2D (handle);
+  _COGL_RETURN_IF_FAIL (cogl_is_texture_2d (tex_2d));
 
   /* Make sure the current framebuffers are bound, though we don't need to
    * flush the clip state here since we aren't going to draw to the
diff --git a/cogl/cogl-texture-3d-private.h b/cogl/cogl-texture-3d-private.h
index db7194e..dec6390 100644
--- a/cogl/cogl-texture-3d-private.h
+++ b/cogl/cogl-texture-3d-private.h
@@ -25,7 +25,7 @@
 #ifndef __COGL_TEXTURE_3D_PRIVATE_H
 #define __COGL_TEXTURE_3D_PRIVATE_H
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-pipeline-private.h"
 #include "cogl-texture-private.h"
 #include "cogl-texture-3d.h"
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index c4500d5..290b89b 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -33,7 +33,7 @@
 #include "cogl-texture-3d.h"
 #include "cogl-texture-driver.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-private.h"
 #include "cogl-pipeline-opengl-private.h"
@@ -241,7 +241,7 @@ cogl_texture_3d_new_with_size (CoglContext *ctx,
   GE( ctx, glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat,
                          width, height, depth, 0, gl_format, gl_type, NULL) );
 
-  return _cogl_texture_3d_handle_new (tex_3d);
+  return _cogl_texture_3d_object_new (tex_3d);
 }
 
 CoglTexture3D *
@@ -325,7 +325,7 @@ cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
 
   cogl_object_unref (dst_bmp);
 
-  return _cogl_texture_3d_handle_new (tex_3d);
+  return _cogl_texture_3d_object_new (tex_3d);
 }
 
 CoglTexture3D *
diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h
index 505d515..6d5dc7a 100644
--- a/cogl/cogl-texture-private.h
+++ b/cogl/cogl-texture-private.h
@@ -25,7 +25,7 @@
 #define __COGL_TEXTURE_PRIVATE_H
 
 #include "cogl-bitmap-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-pipeline-private.h"
 #include "cogl-spans.h"
 #include "cogl-meta-texture.h"
@@ -181,12 +181,12 @@ void
 _cogl_texture_register_texture_type (const CoglObjectClass *klass);
 
 #define COGL_TEXTURE_DEFINE(TypeName, type_name)                        \
-  COGL_HANDLE_DEFINE_WITH_CODE                                          \
+  COGL_OBJECT_DEFINE_WITH_CODE                                          \
   (TypeName, type_name,                                                 \
    _cogl_texture_register_texture_type (&_cogl_##type_name##_class))
 
 #define COGL_TEXTURE_INTERNAL_DEFINE(TypeName, type_name)               \
-  COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE                                 \
+  COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE                                 \
   (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 192e0dc..e50c699 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -34,7 +34,7 @@
 #include "cogl-texture-rectangle-private.h"
 #include "cogl-texture-driver.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-opengl-private.h"
 
@@ -387,7 +387,7 @@ _cogl_texture_rectangle_new_from_foreign (GLuint gl_handle,
   tex_rect->min_filter = GL_FALSE;
   tex_rect->mag_filter = GL_FALSE;
 
-  return _cogl_texture_rectangle_handle_new (tex_rect);
+  return _cogl_texture_rectangle_object_new (tex_rect);
 }
 
 static int
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 2948983..900ae9e 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -47,7 +47,7 @@
 #include "cogl-atlas-texture-private.h"
 #include "cogl-pipeline.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-object-private.h"
 #include "cogl-primitives.h"
 #include "cogl-framebuffer-private.h"
@@ -66,8 +66,8 @@ cogl_texture_error_quark (void)
 }
 
 /* XXX:
- * The CoglHandle macros don't support any form of inheritance, so for
- * now we implement the CoglHandle support for the CoglTexture
+ * The CoglObject macros don't support any form of inheritance, so for
+ * now we implement the CoglObject support for the CoglTexture
  * abstract class manually.
  */
 
@@ -320,7 +320,7 @@ cogl_texture_new_with_size (unsigned int     width,
 {
   CoglTexture *tex;
 
-  _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
+  _COGL_GET_CONTEXT (ctx, NULL);
 
   /* First try creating a fast-path non-sliced texture */
   tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
@@ -392,14 +392,14 @@ cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
                               CoglTextureFlags flags,
                               CoglPixelFormat  internal_format)
 {
-  CoglTexture *tex;
+  CoglAtlasTexture *atlas_tex;
   CoglTexture2D *tex_2d;
 
   /* First try putting the texture in the atlas */
-  if ((tex = _cogl_atlas_texture_new_from_bitmap (bitmap,
-                                                  flags,
-                                                  internal_format)))
-    return tex;
+  if ((atlas_tex = _cogl_atlas_texture_new_from_bitmap (bitmap,
+                                                        flags,
+                                                        internal_format)))
+    return COGL_TEXTURE (atlas_tex);
 
   /* If that doesn't work try a fast path 2D texture */
   if ((tex_2d = cogl_texture_2d_new_from_bitmap (bitmap,
@@ -467,7 +467,7 @@ cogl_texture_new_from_foreign (GLuint           gl_handle,
       CoglTextureRectangle *texture_rectangle;
       CoglSubTexture *sub_texture;
 
-      _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
+      _COGL_GET_CONTEXT (ctx, NULL);
 
       if (x_pot_waste != 0 || y_pot_waste != 0)
         {
@@ -475,7 +475,7 @@ cogl_texture_new_from_foreign (GLuint           gl_handle,
            * the texture isn't limited to power of two sizes. */
           g_warning ("You can't create a foreign GL_TEXTURE_RECTANGLE cogl "
                      "texture with waste\n");
-          return COGL_INVALID_HANDLE;
+          return NULL;
         }
 
       texture_rectangle = _cogl_texture_rectangle_new_from_foreign (gl_handle,
@@ -503,7 +503,7 @@ cogl_texture_new_from_foreign (GLuint           gl_handle,
                                                                    format));
   else
     {
-      _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
+      _COGL_GET_CONTEXT (ctx, NULL);
       return COGL_TEXTURE (cogl_texture_2d_new_from_foreign (ctx,
                                                              gl_handle,
                                                              width,
diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h
index c73ea8a..825e83d 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -239,7 +239,7 @@ cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
  *
  * Gets whether the given object references a texture object.
  *
- * Return value: %TRUE if the handle references a texture, and
+ * Return value: %TRUE if the @object references a texture, and
  *   %FALSE otherwise
  */
 gboolean
diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h
index 215e08d..6f3f353 100644
--- a/cogl/cogl-types.h
+++ b/cogl/cogl-types.h
@@ -55,51 +55,10 @@ typedef struct { \
         } _ ## TYPE ## SizeCheck
 
 /**
- * CoglHandle:
- *
- * Type used for storing references to cogl objects, the CoglHandle is
- * a fully opaque type without any public data members.
- */
-typedef gpointer CoglHandle;
-
-/**
- * COGL_INVALID_HANDLE:
- *
- * A COGL handle that is not valid, used for unitialized handles as well as
- * error conditions.
- */
-#define COGL_INVALID_HANDLE NULL
-
-#define COGL_TYPE_HANDLE        (cogl_handle_get_type ())
-GType
-cogl_handle_get_type (void) G_GNUC_CONST;
-
-/**
- * cogl_handle_ref:
- * @handle: a #CoglHandle
- *
- * Increases the reference count of @handle by 1
- *
- * Return value: (transfer none): the handle, with its reference count increased
- */
-CoglHandle
-cogl_handle_ref (CoglHandle handle);
-
-/**
- * cogl_handle_unref:
- * @handle: a #CoglHandle
- *
- * Drecreases the reference count of @handle by 1; if the reference
- * count reaches 0, the resources allocated by @handle will be freed
- */
-void
-cogl_handle_unref (CoglHandle handle);
-
-/**
  * cogl_object_ref: (skip)
  * @object: a #CoglObject
  *
- * Increases the reference count of @handle by 1
+ * Increases the reference count of @object by 1
  *
  * Returns: the @object, with its reference count increased
  */
diff --git a/cogl/cogl-xlib.c b/cogl/cogl-xlib.c
index 6c8ebea..53078d9 100644
--- a/cogl/cogl-xlib.c
+++ b/cogl/cogl-xlib.c
@@ -32,7 +32,7 @@
 #include <cogl-xlib.h>
 
 #include <cogl-internal.h>
-#include <cogl-handle.h>
+#include <cogl-object-private.h>
 #include <cogl-context-private.h>
 #include <cogl-framebuffer-private.h>
 #include <cogl-display-private.h>
diff --git a/cogl/cogl.h b/cogl/cogl.h
index 6f2a5d1..1984e3f 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -68,7 +68,6 @@
 #ifndef COGL_ENABLE_EXPERIMENTAL_2_0_API
 #include <cogl/cogl-clip-state.h>
 #include <cogl/cogl-enum-types.h>
-#include <cogl/cogl-shader.h>
 #endif
 
 /*
diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols
index a18f839..9a9d2f9 100644
--- a/cogl/cogl.symbols
+++ b/cogl/cogl.symbols
@@ -290,10 +290,6 @@ cogl_glib_source_new
 /* cogl_gtype_matrix_get_type */ /* Not Implemented */
 #endif
 
-cogl_handle_get_type
-cogl_handle_ref
-cogl_handle_unref
-
 cogl_has_feature
 cogl_has_features
 
@@ -428,7 +424,6 @@ cogl_pipeline_get_point_size
 cogl_pipeline_get_shininess
 cogl_pipeline_get_specular
 cogl_pipeline_get_uniform_location
-cogl_pipeline_get_user_program
 cogl_pipeline_new
 cogl_pipeline_set_alpha_test_function
 cogl_pipeline_set_ambient
@@ -464,7 +459,6 @@ cogl_pipeline_set_uniform_int
 cogl_pipeline_set_uniform_matrix
 cogl_pipeline_set_uniform_1f
 cogl_pipeline_set_uniform_1i
-cogl_pipeline_set_user_program
 
 cogl_pixel_buffer_new_EXP
 #if 0
diff --git a/cogl/cogl1-context.h b/cogl/cogl1-context.h
index 519b8b0..a07bb56 100644
--- a/cogl/cogl1-context.h
+++ b/cogl/cogl1-context.h
@@ -962,25 +962,6 @@ cogl_pop_framebuffer (void);
 #ifndef COGL_DISABLE_DEPRECATED
 
 /**
- * cogl_set_draw_buffer:
- * @target: A #CoglBufferTarget that specifies what kind of framebuffer you
- *          are setting as the render target.
- * @offscreen: If you are setting a framebuffer of type COGL_OFFSCREEN_BUFFER
- *             then this is a CoglHandle for the offscreen buffer.
- *
- * Redirects all subsequent drawing to the specified framebuffer. This
- * can either be an offscreen buffer created with
- * cogl_offscreen_new_to_texture () or you can revert to your original
- * on screen window buffer.
- *
- * Deprecated: 1.2: The target argument was redundant since we could look at
- *    the type of CoglHandle given instead.
- */
-void
-cogl_set_draw_buffer (CoglBufferTarget target,
-                      CoglHandle offscreen) G_GNUC_DEPRECATED;
-
-/**
  * cogl_push_draw_buffer:
  *
  * Save cogl_set_draw_buffer() state.
diff --git a/cogl/driver/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/cogl-texture-driver-gl.c
index bb8c67d..4f8b8f5 100644
--- a/cogl/driver/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/cogl-texture-driver-gl.c
@@ -37,7 +37,7 @@
 #include "cogl-texture-private.h"
 #include "cogl-pipeline.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-primitives.h"
 #include "cogl-pipeline-opengl-private.h"
 
diff --git a/cogl/driver/gles/cogl-texture-driver-gles.c b/cogl/driver/gles/cogl-texture-driver-gles.c
index bce772e..0cbb986 100644
--- a/cogl/driver/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gles/cogl-texture-driver-gles.c
@@ -38,7 +38,7 @@
 #include "cogl-pipeline.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-primitives.h"
 
 #include <string.h>
diff --git a/cogl/winsys/cogl-texture-pixmap-x11-private.h b/cogl/winsys/cogl-texture-pixmap-x11-private.h
index 92b672c..515aa05 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11-private.h
+++ b/cogl/winsys/cogl-texture-pixmap-x11-private.h
@@ -34,7 +34,7 @@
 #include <GL/glx.h>
 #endif
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-texture-private.h"
 #include "cogl-texture-pixmap-x11.h"
 
@@ -53,7 +53,7 @@ struct _CoglTexturePixmapX11
   CoglTexture _parent;
 
   Pixmap pixmap;
-  CoglHandle tex;
+  CoglTexture *tex;
 
   unsigned int depth;
   Visual *visual;
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 3e6b12a..92e8c21 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -43,7 +43,7 @@
 #include "cogl-context-private.h"
 #include "cogl-display-private.h"
 #include "cogl-renderer-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-winsys-private.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-xlib.h"
@@ -290,7 +290,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
   tex_pixmap->pixmap = pixmap;
   tex_pixmap->image = NULL;
   tex_pixmap->shm_info.shmid = -1;
-  tex_pixmap->tex = COGL_INVALID_HANDLE;
+  tex_pixmap->tex = NULL;
   tex_pixmap->damage_owned = FALSE;
   tex_pixmap->damage = 0;
 
@@ -354,7 +354,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
   if (!tex_pixmap->use_winsys_texture)
     tex_pixmap->winsys = NULL;
 
-  return _cogl_texture_pixmap_x11_handle_new (tex_pixmap);
+  return _cogl_texture_pixmap_x11_object_new (tex_pixmap);
 }
 
 /* Tries to allocate enough shared mem to handle a full size
@@ -495,7 +495,7 @@ _cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap)
   /* We lazily create the texture the first time it is needed in case
      this texture can be entirely handled using the GLX texture
      instead */
-  if (tex_pixmap->tex == COGL_INVALID_HANDLE)
+  if (tex_pixmap->tex == NULL)
     {
       CoglPixelFormat texture_format;
 
@@ -638,10 +638,10 @@ _cogl_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
   _cogl_texture_pixmap_x11_update_image_texture (tex_pixmap);
 }
 
-static CoglHandle
+static CoglTexture *
 _cogl_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap)
 {
-  CoglHandle tex;
+  CoglTexture *tex;
   int i;
 
   /* We try getting the texture twice, once without flushing the
@@ -672,7 +672,7 @@ _cogl_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap)
 
   g_assert_not_reached ();
 
-  return COGL_INVALID_HANDLE;
+  return NULL;
 }
 
 static gboolean
@@ -697,9 +697,7 @@ _cogl_texture_pixmap_x11_get_data (CoglTexture     *tex,
                                    guint8          *data)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   return cogl_texture_get_data (child_tex, format, rowstride, data);
@@ -743,7 +741,7 @@ _cogl_texture_pixmap_x11_foreach_sub_texture_in_region
                                    void                     *user_data)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
 
@@ -793,9 +791,7 @@ static int
 _cogl_texture_pixmap_x11_get_max_waste (CoglTexture *tex)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   return cogl_texture_get_max_waste (child_tex);
 }
@@ -804,9 +800,7 @@ static gboolean
 _cogl_texture_pixmap_x11_is_sliced (CoglTexture *tex)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   return cogl_texture_is_sliced (child_tex);
 }
@@ -815,9 +809,7 @@ static gboolean
 _cogl_texture_pixmap_x11_can_hardware_repeat (CoglTexture *tex)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   return _cogl_texture_can_hardware_repeat (child_tex);
 }
@@ -828,9 +820,7 @@ _cogl_texture_pixmap_x11_transform_coords_to_gl (CoglTexture *tex,
                                                  float       *t)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   _cogl_texture_transform_coords_to_gl (child_tex, s, t);
@@ -841,9 +831,7 @@ _cogl_texture_pixmap_x11_transform_quad_coords_to_gl (CoglTexture *tex,
                                                       float       *coords)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   return _cogl_texture_transform_quad_coords_to_gl (child_tex, coords);
@@ -855,9 +843,7 @@ _cogl_texture_pixmap_x11_get_gl_texture (CoglTexture *tex,
                                          GLenum      *out_gl_target)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   return cogl_texture_get_gl_texture (child_tex,
@@ -871,9 +857,7 @@ _cogl_texture_pixmap_x11_set_filters (CoglTexture *tex,
                                       GLenum       mag_filter)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   _cogl_texture_set_filters (child_tex, min_filter, mag_filter);
@@ -884,7 +868,7 @@ _cogl_texture_pixmap_x11_pre_paint (CoglTexture *tex,
                                     CoglTexturePrePaintFlags flags)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
+  CoglTexture *child_tex;
 
   _cogl_texture_pixmap_x11_update (tex_pixmap,
                                    !!(flags & COGL_TEXTURE_NEEDS_MIPMAP));
@@ -898,9 +882,7 @@ static void
 _cogl_texture_pixmap_x11_ensure_non_quad_rendering (CoglTexture *tex)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   _cogl_texture_ensure_non_quad_rendering (child_tex);
@@ -913,9 +895,7 @@ _cogl_texture_pixmap_x11_set_wrap_mode_parameters (CoglTexture *tex,
                                                    GLenum       wrap_mode_p)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   _cogl_texture_set_wrap_mode_parameters (child_tex,
@@ -928,9 +908,7 @@ static CoglPixelFormat
 _cogl_texture_pixmap_x11_get_format (CoglTexture *tex)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   /* Forward on to the child texture */
   return cogl_texture_get_format (child_tex);
@@ -940,9 +918,7 @@ static GLenum
 _cogl_texture_pixmap_x11_get_gl_format (CoglTexture *tex)
 {
   CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
-  CoglHandle child_tex;
-
-  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
+  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 
   return _cogl_texture_get_gl_format (child_tex);
 }
@@ -993,7 +969,7 @@ _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
     }
 
   if (tex_pixmap->tex)
-    cogl_handle_unref (tex_pixmap->tex);
+    cogl_object_unref (tex_pixmap->tex);
 
   if (tex_pixmap->winsys)
     {
diff --git a/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/winsys/cogl-winsys-egl-x11.c
index 55cbbc2..61b1b6d 100644
--- a/cogl/winsys/cogl-winsys-egl-x11.c
+++ b/cogl/winsys/cogl-winsys-egl-x11.c
@@ -680,7 +680,7 @@ _cogl_winsys_texture_pixmap_x11_damage_notify (CoglTexturePixmapX11 *tex_pixmap)
 {
 }
 
-static CoglHandle
+static CoglTexture *
 _cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap)
 {
   CoglTexturePixmapEGL *egl_tex_pixmap = tex_pixmap->winsys;
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index b8ba90d..4e0abfa 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -88,7 +88,7 @@ typedef struct _CoglTexturePixmapGLX
   gboolean has_mipmap_space;
   gboolean can_mipmap;
 
-  CoglHandle glx_tex;
+  CoglTexture *glx_tex;
 
   gboolean bind_tex_image_queued;
   gboolean pixmap_bound;
@@ -1715,7 +1715,7 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap)
   glx_tex_pixmap->can_mipmap = FALSE;
   glx_tex_pixmap->has_mipmap_space = FALSE;
 
-  glx_tex_pixmap->glx_tex = COGL_INVALID_HANDLE;
+  glx_tex_pixmap->glx_tex = NULL;
 
   glx_tex_pixmap->bind_tex_image_queued = TRUE;
   glx_tex_pixmap->pixmap_bound = FALSE;
@@ -1793,7 +1793,7 @@ _cogl_winsys_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
   free_glx_pixmap (ctx, glx_tex_pixmap);
 
   if (glx_tex_pixmap->glx_tex)
-    cogl_handle_unref (glx_tex_pixmap->glx_tex);
+    cogl_object_unref (glx_tex_pixmap->glx_tex);
 
   tex_pixmap->winsys = NULL;
   g_free (glx_tex_pixmap);
@@ -1817,7 +1817,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
   glx_renderer = ctx->display->renderer->winsys;
 
   /* Lazily create a texture to hold the pixmap */
-  if (glx_tex_pixmap->glx_tex == COGL_INVALID_HANDLE)
+  if (glx_tex_pixmap->glx_tex == NULL)
     {
       CoglPixelFormat texture_format;
       GError *error = NULL;
@@ -1828,12 +1828,12 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
 
       if (should_use_rectangle (ctx))
         {
-          glx_tex_pixmap->glx_tex =
+          glx_tex_pixmap->glx_tex = COGL_TEXTURE (
             cogl_texture_rectangle_new_with_size (ctx,
                                                   tex_pixmap->width,
                                                   tex_pixmap->height,
                                                   texture_format,
-                                                  &error);
+                                                  &error));
 
           if (glx_tex_pixmap->glx_tex)
             COGL_NOTE (TEXTURE_PIXMAP, "Created a texture rectangle for %p",
@@ -1850,12 +1850,12 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
         }
       else
         {
-          glx_tex_pixmap->glx_tex =
+          glx_tex_pixmap->glx_tex = COGL_TEXTURE (
             cogl_texture_2d_new_with_size (ctx,
                                            tex_pixmap->width,
                                            tex_pixmap->height,
                                            texture_format,
-                                           NULL);
+                                           NULL));
 
           if (glx_tex_pixmap->glx_tex)
             COGL_NOTE (TEXTURE_PIXMAP, "Created a texture 2d for %p",
@@ -1895,7 +1895,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
                          "with mipmap support failed", tex_pixmap);
 
               if (glx_tex_pixmap->glx_tex)
-                cogl_handle_unref (glx_tex_pixmap->glx_tex);
+                cogl_object_unref (glx_tex_pixmap->glx_tex);
               return FALSE;
             }
 
@@ -1953,7 +1953,7 @@ _cogl_winsys_texture_pixmap_x11_damage_notify (CoglTexturePixmapX11 *tex_pixmap)
   glx_tex_pixmap->bind_tex_image_queued = TRUE;
 }
 
-static CoglHandle
+static CoglTexture *
 _cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap)
 {
   CoglTexturePixmapGLX *glx_tex_pixmap = tex_pixmap->winsys;
diff --git a/cogl/winsys/cogl-winsys-private.h b/cogl/winsys/cogl-winsys-private.h
index 0e6c78b..e924fff 100644
--- a/cogl/winsys/cogl-winsys-private.h
+++ b/cogl/winsys/cogl-winsys-private.h
@@ -154,7 +154,7 @@ typedef struct _CoglWinsysVtable
   void
   (*texture_pixmap_x11_damage_notify) (CoglTexturePixmapX11 *tex_pixmap);
 
-  CoglHandle
+  CoglTexture *
   (*texture_pixmap_x11_get_texture) (CoglTexturePixmapX11 *tex_pixmap);
 #endif
 
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index 0b1b590..446f443 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -17,8 +17,8 @@ main (int argc, char **argv)
         {0.7, -0.7, 0x00, 0x00, 0xff, 0xff}
     };
     CoglPrimitive *triangle;
-    CoglHandle tex;
-    CoglHandle offscreen;
+    CoglTexture *tex;
+    CoglOffscreen *offscreen;
     CoglFramebuffer *offscreen_fb;
     CoglPipeline *pipeline;
 
diff --git a/tests/conform/test-materials.c b/tests/conform/test-materials.c
index 84b1444..ab483e8 100644
--- a/tests/conform/test-materials.c
+++ b/tests/conform/test-materials.c
@@ -85,7 +85,7 @@ test_invalid_texture_layers (TestState *state, int x, int y)
   /* explicitly create a layer with an invalid handle. This may be desireable
    * if the user also sets a texture combine string that e.g. refers to a
    * constant color. */
-  cogl_material_set_layer (material, 0, COGL_INVALID_HANDLE);
+  cogl_material_set_layer (material, 0, NULL);
 
   cogl_set_source (material);
 
@@ -172,7 +172,7 @@ test_invalid_texture_layers_with_constant_colors (TestState *state,
   CoglColor constant_color;
 
   /* explicitly create a layer with an invalid handle */
-  cogl_material_set_layer (material, 0, COGL_INVALID_HANDLE);
+  cogl_material_set_layer (material, 0, NULL);
 
   /* ignore the fallback texture on the layer and use a constant color
      instead */
diff --git a/tests/conform/test-texture-rectangle.c b/tests/conform/test-texture-rectangle.c
index d7cc354..3aadd04 100644
--- a/tests/conform/test-texture-rectangle.c
+++ b/tests/conform/test-texture-rectangle.c
@@ -78,7 +78,7 @@ create_source_rect (void)
 
 #else /* GL_TEXTURE_RECTANGLE_ARB */
 
-  return COGL_INVALID_HANDLE;
+  return NULL;
 
 #endif /* GL_TEXTURE_RECTANGLE_ARB */
 }
@@ -119,7 +119,7 @@ draw_frame (TestState *state)
   CoglHandle tex_2d = create_source_2d ();
   CoglHandle material_2d = cogl_material_new ();
 
-  g_assert (tex_rect != COGL_INVALID_HANDLE);
+  g_assert (tex_rect != NULL);
 
   cogl_material_set_layer (material_rect, 0, tex_rect);
   cogl_material_set_layer_filters (material_rect, 0,
diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c
index 97f06fa..500ad23 100644
--- a/tests/conform/test-utils.c
+++ b/tests/conform/test-utils.c
@@ -87,15 +87,15 @@ test_utils_init (TestFlags flags)
     }
   else
     {
-      CoglHandle offscreen;
-      CoglHandle tex = cogl_texture_2d_new_with_size (test_ctx,
-                                                      FB_WIDTH, FB_HEIGHT,
-                                                      COGL_PIXEL_FORMAT_ANY,
-                                                      &error);
+      CoglOffscreen *offscreen;
+      CoglTexture2D *tex = cogl_texture_2d_new_with_size (test_ctx,
+                                                          FB_WIDTH, FB_HEIGHT,
+                                                          COGL_PIXEL_FORMAT_ANY,
+                                                          &error);
       if (!tex)
         g_critical ("Failed to allocate texture: %s", error->message);
 
-      offscreen = cogl_offscreen_new_to_texture (tex);
+      offscreen = cogl_offscreen_new_to_texture (COGL_TEXTURE (tex));
       test_fb = COGL_FRAMEBUFFER (offscreen);
     }
 



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