[cogl/wip/rib/cogl-1.12: 49/142] Removes all remaining use of CoglHandle



commit afe638a2f29f66326c8007720f74e65f7731245a
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>
    
    (cherry picked from commit 6ed3aaf4be21d605a1ed3176b3ea825933f85cf0)
    
      Since the original patch was done after removing deprecated API
      this back ported patch doesn't affect deprecated API and so
      actually this cherry-pick doesn't remove all remaining use of
      CoglHandle as it did for the master branch of Cogl.

 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                                |    1 -
 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                     |    6 +-
 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-enum-types.c.in                       |    4 +
 cogl/cogl-framebuffer.c                         |   16 ++--
 cogl/cogl-index-buffer.h                        |    2 +-
 cogl/cogl-journal-private.h                     |    2 +-
 cogl/cogl-journal.c                             |    2 +-
 cogl/cogl-object-private.h                      |   17 +---
 cogl/cogl-onscreen.c                            |    2 +-
 cogl/cogl-pipeline-fragend-arbfp.c              |    2 +-
 cogl/cogl-pipeline-fragend-fixed.c              |    2 +-
 cogl/cogl-pipeline-fragend-glsl.c               |    1 -
 cogl/cogl-pipeline-layer-state.h                |    4 +-
 cogl/cogl-pipeline-opengl-private.h             |    3 -
 cogl/cogl-pipeline-opengl.c                     |    6 +-
 cogl/cogl-pipeline-progend-glsl.c               |    2 +-
 cogl/cogl-pipeline-vertend-fixed.c              |    2 +-
 cogl/cogl-pipeline-vertend-glsl.c               |    2 +-
 cogl/cogl-pipeline.c                            |    2 +-
 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                     |    2 +-
 cogl/cogl-program.c                             |    2 +-
 cogl/cogl-shader-private.h                      |    2 +-
 cogl/cogl-shader.c                              |    2 +-
 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                               |    4 +-
 cogl/cogl-vertex-buffer-private.h               |    2 +-
 cogl/cogl-vertex-buffer.c                       |    2 +-
 cogl/cogl-xlib.c                                |    2 +-
 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 +-
 doc/reference/cogl-2.0-experimental/Makefile.am |    1 -
 doc/reference/cogl/Makefile.am                  |    1 -
 examples/cogl-msaa.c                            |    4 +-
 tests/conform/test-materials.c                  |    4 +-
 tests/conform/test-texture-rectangle.c          |    4 +-
 tests/conform/test-utils.c                      |   12 ++--
 77 files changed, 327 insertions(+), 366 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 424170f..f6c1bb2 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -183,7 +183,6 @@ cogl_sources_c = \
 	$(srcdir)/cogl-debug-options.h			\
 	$(srcdir)/cogl-gpu-info.c			\
 	$(srcdir)/cogl-gpu-info-private.h		\
-	$(srcdir)/cogl-handle.h 			\
 	$(srcdir)/cogl-context-private.h		\
 	$(srcdir)/cogl-context.c			\
 	$(srcdir)/cogl-renderer-private.h		\
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 ca34d78..9d1af9a 100644
--- a/cogl/cogl-clip-state.c
+++ b/cogl/cogl-clip-state.c
@@ -193,7 +193,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 faeff49..b4a2490 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;
@@ -183,9 +183,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;
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 94ce2f1..e59ca9e 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;
@@ -375,16 +373,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)
@@ -473,14 +471,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);
@@ -491,9 +489,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);
@@ -501,14 +499,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-enum-types.c.in b/cogl/cogl-enum-types.c.in
index 4ca1d75..a77911b 100644
--- a/cogl/cogl-enum-types.c.in
+++ b/cogl/cogl-enum-types.c.in
@@ -1,4 +1,8 @@
 /*** BEGIN file-header ***/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "cogl-enum-types.h"
 /*** END file-header ***/
 
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index bc6bad8..60ca097 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -726,20 +726,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 +754,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 +811,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 +1096,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);
 }
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 7b7a3e9..30c3c79 100644
--- a/cogl/cogl-journal.c
+++ b/cogl/cogl-journal.c
@@ -1597,7 +1597,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..1d593d5 100644
--- a/cogl/cogl-object-private.h
+++ b/cogl/cogl-object-private.h
@@ -90,23 +90,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 +118,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;                              \
@@ -272,9 +266,6 @@ _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)
 
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..e8b01e0 100644
--- a/cogl/cogl-pipeline-fragend-arbfp.c
+++ b/cogl/cogl-pipeline-fragend-arbfp.c
@@ -39,7 +39,7 @@
 
 #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"
diff --git a/cogl/cogl-pipeline-fragend-fixed.c b/cogl/cogl-pipeline-fragend-fixed.c
index c8e8e2c..d4a0fb6 100644
--- a/cogl/cogl-pipeline-fragend-fixed.c
+++ b/cogl/cogl-pipeline-fragend-fixed.c
@@ -38,7 +38,7 @@
 
 #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"
diff --git a/cogl/cogl-pipeline-fragend-glsl.c b/cogl/cogl-pipeline-fragend-glsl.c
index 1f44722..5692bda 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"
 
diff --git a/cogl/cogl-pipeline-layer-state.h b/cogl/cogl-pipeline-layer-state.h
index bfe0483..c143fa1 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-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c
index 6d7cf43..d7561d9 100644
--- a/cogl/cogl-pipeline-progend-glsl.c
+++ b/cogl/cogl-pipeline-progend-glsl.c
@@ -41,7 +41,7 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-program-private.h"
 #include "cogl-pipeline-fragend-glsl-private.h"
 #include "cogl-pipeline-vertend-glsl-private.h"
diff --git a/cogl/cogl-pipeline-vertend-fixed.c b/cogl/cogl-pipeline-vertend-fixed.c
index 2df593b..2cb12a2 100644
--- a/cogl/cogl-pipeline-vertend-fixed.c
+++ b/cogl/cogl-pipeline-vertend-fixed.c
@@ -38,7 +38,7 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-program-private.h"
 
 const CoglPipelineVertend _cogl_pipeline_fixed_vertend;
diff --git a/cogl/cogl-pipeline-vertend-glsl.c b/cogl/cogl-pipeline-vertend-glsl.c
index 6ecec90..c8e6b0d 100644
--- a/cogl/cogl-pipeline-vertend-glsl.c
+++ b/cogl/cogl-pipeline-vertend-glsl.c
@@ -39,7 +39,7 @@
 
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-program-private.h"
 #include "cogl-pipeline-vertend-glsl-private.h"
 #include "cogl-pipeline-state-private.h"
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 0b37695..9f138e7 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -1906,7 +1906,7 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
 typedef struct
 {
   CoglPipeline *pipeline;
-  CoglHandle texture;
+  CoglTexture *texture;
 } CoglPipelineOverrideLayerState;
 
 static gboolean
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 134bb87..72bb3d4 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-program-private.h b/cogl/cogl-program-private.h
index 5c33f61..3558862 100644
--- a/cogl/cogl-program-private.h
+++ b/cogl/cogl-program-private.h
@@ -24,7 +24,7 @@
 #ifndef __COGL_PROGRAM_H
 #define __COGL_PROGRAM_H
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-internal.h"
 #include "cogl-shader-private.h"
 
diff --git a/cogl/cogl-program.c b/cogl/cogl-program.c
index 3d265ff..94e0de0 100644
--- a/cogl/cogl-program.c
+++ b/cogl/cogl-program.c
@@ -29,7 +29,7 @@
 #include "cogl-util.h"
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 
 #include "cogl-shader-private.h"
 #include "cogl-program-private.h"
diff --git a/cogl/cogl-shader-private.h b/cogl/cogl-shader-private.h
index 06575e6..b23cb42 100644
--- a/cogl/cogl-shader-private.h
+++ b/cogl/cogl-shader-private.h
@@ -24,7 +24,7 @@
 #ifndef __COGL_SHADER_H
 #define __COGL_SHADER_H
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 #include "cogl-shader.h"
 #include "cogl-gl-header.h"
 
diff --git a/cogl/cogl-shader.c b/cogl/cogl-shader.c
index c80020e..fe26d1c 100644
--- a/cogl/cogl-shader.c
+++ b/cogl/cogl-shader.c
@@ -29,7 +29,7 @@
 #include "cogl-shader-boilerplate.h"
 #include "cogl-internal.h"
 #include "cogl-context-private.h"
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 
 #include <glib.h>
 
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 8cec89f..3f7b0d5 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 92c5e9a..db5631a 100644
--- a/cogl/cogl-types.h
+++ b/cogl/cogl-types.h
@@ -60,7 +60,7 @@ typedef struct { \
  * Type used for storing references to cogl objects, the CoglHandle is
  * a fully opaque type without any public data members.
  */
-typedef gpointer CoglHandle;
+typedef void * CoglHandle;
 
 /**
  * COGL_INVALID_HANDLE:
@@ -99,7 +99,7 @@ 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-vertex-buffer-private.h b/cogl/cogl-vertex-buffer-private.h
index a4143d2..e16950c 100644
--- a/cogl/cogl-vertex-buffer-private.h
+++ b/cogl/cogl-vertex-buffer-private.h
@@ -27,7 +27,7 @@
 #ifndef __COGL_VERTEX_BUFFER_H
 #define __COGL_VERTEX_BUFFER_H
 
-#include "cogl-handle.h"
+#include "cogl-object-private.h"
 
 #include "cogl-primitive.h"
 
diff --git a/cogl/cogl-vertex-buffer.c b/cogl/cogl-vertex-buffer.c
index 36c89e2..7628c05 100644
--- a/cogl/cogl-vertex-buffer.c
+++ b/cogl/cogl-vertex-buffer.c
@@ -99,7 +99,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-vertex-buffer-private.h"
 #include "cogl-texture-private.h"
 #include "cogl-pipeline.h"
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/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/doc/reference/cogl-2.0-experimental/Makefile.am b/doc/reference/cogl-2.0-experimental/Makefile.am
index df29aaf..464643e 100644
--- a/doc/reference/cogl-2.0-experimental/Makefile.am
+++ b/doc/reference/cogl-2.0-experimental/Makefile.am
@@ -105,7 +105,6 @@ IGNORE_HFILES=\
 	cogl-debug.h 				\
 	cogl-defines.h 				\
 	cogl-deprecated.h 			\
-	cogl-handle.h 				\
 	cogl-internal.h 			\
 	cogl-matrix-mesa.h 			\
 	cogl-matrix-stack.h 			\
diff --git a/doc/reference/cogl/Makefile.am b/doc/reference/cogl/Makefile.am
index 303b2e7..1dc050f 100644
--- a/doc/reference/cogl/Makefile.am
+++ b/doc/reference/cogl/Makefile.am
@@ -98,7 +98,6 @@ IGNORE_HFILES=\
 	cogl-debug.h 				\
 	cogl-defines.h 				\
 	cogl-deprecated.h 			\
-	cogl-handle.h 				\
 	cogl-internal.h 			\
 	cogl-matrix-mesa.h 			\
 	cogl-matrix-stack.h 			\
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 2259173..0f40f3b 100644
--- a/tests/conform/test-utils.c
+++ b/tests/conform/test-utils.c
@@ -88,15 +88,15 @@ test_utils_init (TestFlags flags)
     }
   else
     {
-      CoglHandle offscreen;
-      CoglHandle tex = cogl_texture_2d_new_with_size (ctx,
-                                                      FB_WIDTH, FB_HEIGHT,
-                                                      COGL_PIXEL_FORMAT_ANY,
-                                                      &error);
+      CoglOffscreen *offscreen;
+      CoglTexture2D *tex = cogl_texture_2d_new_with_size (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));
       fb = COGL_FRAMEBUFFER (offscreen);
     }
 



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