[cogl/wip/for-cairo-cogl: 6/12] Add a strong CoglTexture type to replace CoglHandle



commit 68e31cb0ba8448f8328ad0d411c3a4b8c52a4985
Author: Robert Bragg <robert linux intel com>
Date:   Wed Aug 24 21:30:34 2011 +0100

    Add a strong CoglTexture type to replace CoglHandle
    
    As part of the on going, incremental effort to purge the non type safe
    CoglHandle type from the Cogl API this patch tackles most of the
    CoglHandle uses relating to textures.
    
    We'd postponed making this change for quite a while because we wanted to
    have a clearer understanding of how we wanted to evolve the texture APIs
    towards Cogl 2.0 before exposing type safety here which would be
    difficult to change later since it would imply breaking APIs.
    
    The basic idea that we are steering towards now is that CoglTexture
    can be considered to be the most primitive interface we have for any
    object representing a texture. The texture interface would provide
    roughly these methods:
    
      cogl_texture_get_width
      cogl_texture_get_height
      cogl_texture_can_repeat
      cogl_texture_can_mipmap
      cogl_texture_generate_mipmap;
      cogl_texture_get_format
      cogl_texture_set_region
      cogl_texture_get_region
    
    Besides the texture interface we will then start to expose types
    corresponding to specific texture types: CoglTexture2D,
    CoglTexture3D, CoglTexture2DSliced, CoglSubTexture, CoglAtlasTexture and
    CoglTexturePixmapX11.
    
    We will then also expose an interface for the high-level texture types
    we have (such as CoglTexture2DSlice, CoglSubTexture and
    CoglAtlasTexture) called CoglMetaTexture. CoglMetaTexture is an
    additional interface that lets you iterate a virtual region of a meta
    texture and get mappings of primitive textures to sub-regions of that
    virtual region. Internally we already have this kind of abstraction for
    dealing with sliced texture, sub-textures and atlas textures in a
    consistent way, so this will just make that abstraction public. The aim
    here is to clarify that there is a difference between primitive textures
    (CoglTexture2D/3D) and some of the other high-level textures, and also
    enable developers to implement primitives that can support meta textures
    since they can only be used with the cogl_rectangle API currently.
    
    The thing that's not so clean-cut with this are the texture constructors
    we have currently; such as cogl_texture_new_from_file which no longer
    make sense when CoglTexture is considered to be an interface.  These
    will basically just become convenient factory functions and it's just a
    bit unusual that they are within the cogl_texture namespace.  It's worth
    noting here that all the texture type APIs will also have their own type
    specific constructors so these functions will only be used for the
    convenience of being able to create a texture without really wanting to
    know the details of what type of texture you need.  Longer term for 2.0
    we may come up with replacement names for these factory functions or the
    other thing we are considering is designing some asynchronous factory
    functions instead since it's so often detrimental to application
    performance to be blocked waiting for a texture to be uploaded to the
    GPU.

 cogl-pango/cogl-pango-display-list.c   |   10 +-
 cogl-pango/cogl-pango-display-list.h   |    2 +-
 cogl-pango/cogl-pango-glyph-cache.c    |   12 +-
 cogl-pango/cogl-pango-glyph-cache.h    |   22 +-
 cogl-pango/cogl-pango-pipeline-cache.c |    8 +-
 cogl-pango/cogl-pango-render.c         |    6 +-
 cogl/cogl-atlas-texture.c              |    2 +-
 cogl/cogl-attribute.c                  |    4 +-
 cogl/cogl-context.c                    |    8 +-
 cogl/cogl-framebuffer.c                |    6 +-
 cogl/cogl-journal-private.h            |    2 +-
 cogl/cogl-journal.c                    |    4 +-
 cogl/cogl-pipeline-fragend-glsl.c      |    2 +-
 cogl/cogl-pipeline-layer-state.c       |   12 +-
 cogl/cogl-pipeline-layer-state.h       |    4 +-
 cogl/cogl-pipeline-opengl.c            |   18 +-
 cogl/cogl-pipeline-private.h           |   16 +-
 cogl/cogl-pipeline.c                   |    4 +-
 cogl/cogl-primitives.c                 |   50 ++--
 cogl/cogl-sub-texture.c                |    4 +-
 cogl/cogl-texture-2d-sliced.c          |    4 +-
 cogl/cogl-texture-private.h            |   35 ++--
 cogl/cogl-texture.c                    |  412 ++++++++++++--------------------
 cogl/cogl-texture.h                    |  164 ++++++-------
 cogl/cogl.c                            |    6 +-
 cogl/cogl.h                            |    6 +-
 cogl/cogl2-path.c                      |    4 +-
 cogl/winsys/cogl-texture-pixmap-x11.c  |    2 +-
 cogl/winsys/cogl-winsys-egl.c          |    8 +-
 examples/crate.c                       |    2 +-
 30 files changed, 360 insertions(+), 479 deletions(-)
---
diff --git a/cogl-pango/cogl-pango-display-list.c b/cogl-pango/cogl-pango-display-list.c
index be62dac..a6320d8 100644
--- a/cogl-pango/cogl-pango-display-list.c
+++ b/cogl-pango/cogl-pango-display-list.c
@@ -72,7 +72,7 @@ struct _CoglPangoDisplayListNode
     struct
     {
       /* The texture to render these coords from */
-      CoglHandle texture;
+      CoglTexture *texture;
       /* Array of rectangles in the format expected by
          cogl_rectangles_with_texture_coords */
       GArray *rectangles;
@@ -134,7 +134,7 @@ _cogl_pango_display_list_remove_color_override (CoglPangoDisplayList *dl)
 
 void
 _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
-                                      CoglHandle texture,
+                                      CoglTexture *texture,
                                       float x_1, float y_1,
                                       float x_2, float y_2,
                                       float tx_1, float ty_1,
@@ -168,7 +168,7 @@ _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
       node->color_override = dl->color_override;
       node->color = dl->color;
       node->pipeline = NULL;
-      node->d.texture.texture = cogl_handle_ref (texture);
+      node->d.texture.texture = cogl_object_ref (texture);
       node->d.texture.rectangles
         = g_array_new (FALSE, FALSE, sizeof (CoglPangoDisplayListRectangle));
       node->d.texture.primitive = NULL;
@@ -465,8 +465,8 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
   if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE)
     {
       g_array_free (node->d.texture.rectangles, TRUE);
-      if (node->d.texture.texture != COGL_INVALID_HANDLE)
-        cogl_handle_unref (node->d.texture.texture);
+      if (node->d.texture.texture != NULL)
+        cogl_object_unref (node->d.texture.texture);
       if (node->d.texture.primitive != NULL)
         cogl_object_unref (node->d.texture.primitive);
     }
diff --git a/cogl-pango/cogl-pango-display-list.h b/cogl-pango/cogl-pango-display-list.h
index dd14edd..f98dbc8 100644
--- a/cogl-pango/cogl-pango-display-list.h
+++ b/cogl-pango/cogl-pango-display-list.h
@@ -39,7 +39,7 @@ void _cogl_pango_display_list_set_color_override (CoglPangoDisplayList *dl,
 void _cogl_pango_display_list_remove_color_override (CoglPangoDisplayList *dl);
 
 void _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
-                                           CoglHandle texture,
+                                           CoglTexture *texture,
                                            float x_1, float y_1,
                                            float x_2, float y_2,
                                            float tx_1, float ty_1,
diff --git a/cogl-pango/cogl-pango-glyph-cache.c b/cogl-pango/cogl-pango-glyph-cache.c
index bbcfe8f..317d826 100644
--- a/cogl-pango/cogl-pango-glyph-cache.c
+++ b/cogl-pango/cogl-pango-glyph-cache.c
@@ -71,7 +71,7 @@ static void
 cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
 {
   if (value->texture)
-    cogl_handle_unref (value->texture);
+    cogl_object_unref (value->texture);
   g_slice_free (CoglPangoGlyphCacheValue, value);
 }
 
@@ -178,8 +178,8 @@ cogl_pango_glyph_cache_update_position_cb (void *user_data,
   float tex_width, tex_height;
 
   if (value->texture)
-    cogl_handle_unref (value->texture);
-  value->texture = cogl_handle_ref (new_texture);
+    cogl_object_unref (value->texture);
+  value->texture = cogl_object_ref (new_texture);
 
   tex_width = cogl_texture_get_width (new_texture);
   tex_height = cogl_texture_get_height (new_texture);
@@ -202,7 +202,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
                                             PangoGlyph glyph,
                                             CoglPangoGlyphCacheValue *value)
 {
-  CoglHandle texture;
+  CoglTexture *texture;
 
   if (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SHARED_ATLAS))
     return FALSE;
@@ -217,7 +217,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
                                                COGL_TEXTURE_NONE,
                                                COGL_PIXEL_FORMAT_RGBA_8888_PRE);
 
-  if (texture == COGL_INVALID_HANDLE)
+  if (texture == NULL)
     return FALSE;
 
   value->texture = texture;
@@ -310,7 +310,7 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
       PangoRectangle ink_rect;
 
       value = g_slice_new (CoglPangoGlyphCacheValue);
-      value->texture = COGL_INVALID_HANDLE;
+      value->texture = NULL;
 
       pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
       pango_extents_to_pixels (&ink_rect, NULL);
diff --git a/cogl-pango/cogl-pango-glyph-cache.h b/cogl-pango/cogl-pango-glyph-cache.h
index 2020447..df6b632 100644
--- a/cogl-pango/cogl-pango-glyph-cache.h
+++ b/cogl-pango/cogl-pango-glyph-cache.h
@@ -35,20 +35,20 @@ typedef struct _CoglPangoGlyphCacheValue CoglPangoGlyphCacheValue;
 
 struct _CoglPangoGlyphCacheValue
 {
-  CoglHandle texture;
+  CoglTexture *texture;
 
-  float      tx1;
-  float      ty1;
-  float      tx2;
-  float      ty2;
+  float tx1;
+  float ty1;
+  float tx2;
+  float ty2;
 
-  int        tx_pixel;
-  int        ty_pixel;
+  int tx_pixel;
+  int ty_pixel;
 
-  int        draw_x;
-  int        draw_y;
-  int        draw_width;
-  int        draw_height;
+  int draw_x;
+  int draw_y;
+  int draw_width;
+  int draw_height;
 
   /* This will be set to TRUE when the glyph atlas is reorganized
      which means the glyph will need to be redrawn */
diff --git a/cogl-pango/cogl-pango-pipeline-cache.c b/cogl-pango/cogl-pango-pipeline-cache.c
index 5f6a5a0..6733282 100644
--- a/cogl-pango/cogl-pango-pipeline-cache.c
+++ b/cogl-pango/cogl-pango-pipeline-cache.c
@@ -49,7 +49,7 @@ struct _CoglPangoPipelineCacheEntry
 {
   /* This will take a reference or it can be NULL to represent the
      pipeline used to render colors */
-  CoglHandle texture;
+  CoglTexture *texture;
 
   /* This will only take a weak reference */
   CoglHandle pipeline;
@@ -155,7 +155,7 @@ get_base_texture_alpha_pipeline (CoglPangoPipelineCache *cache)
 typedef struct
 {
   CoglPangoPipelineCache *cache;
-  CoglHandle texture;
+  CoglTexture *texture;
 } PipelineDestroyNotifyData;
 
 static void
@@ -188,7 +188,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
     {
       CoglPipeline *base;
 
-      entry->texture = cogl_handle_ref (texture);
+      entry->texture = cogl_object_ref (texture);
 
       if (cogl_texture_get_format (entry->texture) == COGL_PIXEL_FORMAT_A_8)
         base = get_base_texture_alpha_pipeline (cache);
@@ -216,7 +216,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
                              pipeline_destroy_notify_cb);
 
   g_hash_table_insert (cache->hash_table,
-                       texture ? cogl_handle_ref (texture) : NULL,
+                       texture ? cogl_object_ref (texture) : NULL,
                        entry);
 
   /* This doesn't take a reference on the pipeline so that it will use
diff --git a/cogl-pango/cogl-pango-render.c b/cogl-pango/cogl-pango-render.c
index 5c12741..9ffaf2b 100644
--- a/cogl-pango/cogl-pango-render.c
+++ b/cogl-pango/cogl-pango-render.c
@@ -94,7 +94,7 @@ typedef struct
 } CoglPangoRendererSliceCbData;
 
 void
-cogl_pango_renderer_slice_cb (CoglHandle handle,
+cogl_pango_renderer_slice_cb (CoglTexture *texture,
                               const float *slice_coords,
                               const float *virtual_coords,
                               void *user_data)
@@ -106,7 +106,7 @@ cogl_pango_renderer_slice_cb (CoglHandle handle,
      coordinates based on the virtual_coords */
 
   _cogl_pango_display_list_add_texture (data->display_list,
-                                        handle,
+                                        texture,
                                         data->x1,
                                         data->y1,
                                         data->x2,
@@ -486,7 +486,7 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
   /* Glyphs that don't take up any space will end up without a
      texture. These should never become dirty so they shouldn't end up
      here */
-  g_return_if_fail (value->texture != COGL_INVALID_HANDLE);
+  g_return_if_fail (value->texture != NULL);
 
   if (cogl_texture_get_format (value->texture) == COGL_PIXEL_FORMAT_A_8)
     {
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index 08e1db9..042cd7b 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -384,7 +384,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *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
        * if the CoglTexture is reused with the same texture unit. */
-      _cogl_pipeline_texture_storage_change_notify (atlas_tex);
+      _cogl_pipeline_texture_storage_change_notify (COGL_TEXTURE (atlas_tex));
 
       /* We need to unref the sub texture after doing the copy because
          the copy can involve rendering which might cause the texture
diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c
index 118937e..578d41b 100644
--- a/cogl/cogl-attribute.c
+++ b/cogl/cogl-attribute.c
@@ -339,14 +339,14 @@ validate_layer_cb (CoglPipeline *pipeline,
                    int layer_index,
                    void *user_data)
 {
-  CoglHandle texture =
+  CoglTexture *texture =
     _cogl_pipeline_get_layer_texture (pipeline, layer_index);
   ValidateLayerState *state = user_data;
   gboolean status = TRUE;
 
   /* invalid textures will be handled correctly in
    * _cogl_pipeline_flush_layers_gl_state */
-  if (texture == COGL_INVALID_HANDLE)
+  if (texture == NULL)
     goto validated;
 
   _cogl_texture_flush_journal_rendering (texture);
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index d4bbc20..bc6af0d 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -243,8 +243,8 @@ cogl_context_new (CoglDisplay *display,
 
   context->legacy_state_set = 0;
 
-  context->default_gl_texture_2d_tex = COGL_INVALID_HANDLE;
-  context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE;
+  context->default_gl_texture_2d_tex = NULL;
+  context->default_gl_texture_rect_tex = NULL;
 
   context->framebuffers = NULL;
 
@@ -410,9 +410,9 @@ _cogl_context_free (CoglContext *context)
     cogl_handle_unref (context->current_path);
 
   if (context->default_gl_texture_2d_tex)
-    cogl_handle_unref (context->default_gl_texture_2d_tex);
+    cogl_object_unref (context->default_gl_texture_2d_tex);
   if (context->default_gl_texture_rect_tex)
-    cogl_handle_unref (context->default_gl_texture_rect_tex);
+    cogl_object_unref (context->default_gl_texture_rect_tex);
 
   if (context->opaque_color_pipeline)
     cogl_handle_unref (context->opaque_color_pipeline);
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 0fa36c4..c8f2a42 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -734,7 +734,7 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
     }
 
   offscreen = g_new0 (CoglOffscreen, 1);
-  offscreen->texture = cogl_handle_ref (texhandle);
+  offscreen->texture = cogl_object_ref (texhandle);
   offscreen->texture_level = level;
   offscreen->texture_level_width = level_width;
   offscreen->texture_level_height = level_height;
@@ -779,8 +779,8 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
 
   GE (ctx, glDeleteFramebuffers (1, &offscreen->fbo_handle));
 
-  if (offscreen->texture != COGL_INVALID_HANDLE)
-    cogl_handle_unref (offscreen->texture);
+  if (offscreen->texture != NULL)
+    cogl_object_unref (offscreen->texture);
 
   g_free (offscreen);
 }
diff --git a/cogl/cogl-journal-private.h b/cogl/cogl-journal-private.h
index 6eb7a2d..9befcd4 100644
--- a/cogl/cogl-journal-private.h
+++ b/cogl/cogl-journal-private.h
@@ -76,7 +76,7 @@ _cogl_journal_log_quad (CoglJournal  *journal,
                         const float  *position,
                         CoglPipeline *pipeline,
                         int           n_layers,
-                        CoglHandle    layer0_override_texture,
+                        CoglTexture  *layer0_override_texture,
                         const float  *tex_coords,
                         unsigned int  tex_coords_len);
 
diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c
index 91128d9..c4a0238 100644
--- a/cogl/cogl-journal.c
+++ b/cogl/cogl-journal.c
@@ -1449,7 +1449,7 @@ static gboolean
 add_framebuffer_deps_cb (CoglPipelineLayer *layer, void *user_data)
 {
   CoglFramebuffer *framebuffer = user_data;
-  CoglHandle texture = _cogl_pipeline_layer_get_texture_real (layer);
+  CoglTexture *texture = _cogl_pipeline_layer_get_texture_real (layer);
   const GList *l;
 
   if (!texture)
@@ -1466,7 +1466,7 @@ _cogl_journal_log_quad (CoglJournal  *journal,
                         const float  *position,
                         CoglPipeline *pipeline,
                         int           n_layers,
-                        CoglHandle    layer0_override_texture,
+                        CoglTexture  *layer0_override_texture,
                         const float  *tex_coords,
                         unsigned int  tex_coords_len)
 {
diff --git a/cogl/cogl-pipeline-fragend-glsl.c b/cogl/cogl-pipeline-fragend-glsl.c
index 48e523b..a7a21e3 100644
--- a/cogl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/cogl-pipeline-fragend-glsl.c
@@ -366,7 +366,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
 
   texture = _cogl_pipeline_layer_get_texture (layer);
 
-  if (texture == COGL_INVALID_HANDLE)
+  if (texture == NULL)
     {
       target_string = "2D";
       tex_coord_swizzle = "st";
diff --git a/cogl/cogl-pipeline-layer-state.c b/cogl/cogl-pipeline-layer-state.c
index ae89782..8b63010 100644
--- a/cogl/cogl-pipeline-layer-state.c
+++ b/cogl/cogl-pipeline-layer-state.c
@@ -108,7 +108,7 @@ _cogl_pipeline_set_layer_unit (CoglPipeline *required_owner,
   return layer;
 }
 
-CoglHandle
+CoglTexture *
 _cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer)
 {
   CoglPipelineLayer *authority =
@@ -118,7 +118,7 @@ _cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer)
   return authority->texture;
 }
 
-CoglHandle
+CoglTexture *
 _cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
                                   int layer_index)
 {
@@ -201,7 +201,7 @@ changed:
 static void
 _cogl_pipeline_set_layer_texture_data (CoglPipeline *pipeline,
                                        int layer_index,
-                                       CoglHandle texture)
+                                       CoglTexture *texture)
 {
   CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA;
   CoglPipelineLayer *layer;
@@ -282,7 +282,7 @@ changed:
  * with no associated CoglTexture will have a texture target of 0.
  */
 static GLenum
-get_texture_target (CoglHandle texture)
+get_texture_target (CoglTexture *texture)
 {
   GLuint ignore_handle;
   GLenum gl_target;
@@ -297,7 +297,7 @@ get_texture_target (CoglHandle texture)
 void
 cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
                                  int layer_index,
-                                 CoglHandle texture)
+                                 CoglTexture *texture)
 {
   /* For the convenience of fragend code we separate texture state
    * into the "target" and the "data", and setting a layer texture
@@ -1305,7 +1305,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
 
 /* FIXME: deprecate and replace with
  * cogl_pipeline_get_layer_texture() instead. */
-CoglHandle
+CoglTexture *
 _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer)
 {
   g_return_val_if_fail (_cogl_is_pipeline_layer (layer), NULL);
diff --git a/cogl/cogl-pipeline-layer-state.h b/cogl/cogl-pipeline-layer-state.h
index 415e544..cf31bf5 100644
--- a/cogl/cogl-pipeline-layer-state.h
+++ b/cogl/cogl-pipeline-layer-state.h
@@ -121,7 +121,7 @@ typedef enum {
  * cogl_pipeline_set_layer:
  * @pipeline: A #CoglPipeline object
  * @layer_index: the index of the layer
- * @texture: a #CoglHandle for the layer object
+ * @texture: a #CoglTexture for the layer object
  *
  * In addition to the standard OpenGL lighting model a Cogl pipeline may have
  * one or more layers comprised of textures that can be blended together in
@@ -139,7 +139,7 @@ typedef enum {
 void
 cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
                                  int           layer_index,
-                                 CoglHandle    texture);
+                                 CoglTexture  *texture);
 
 #define cogl_pipeline_remove_layer cogl_pipeline_remove_layer_EXP
 /**
diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c
index caede90..552fa49 100644
--- a/cogl/cogl-pipeline-opengl.c
+++ b/cogl/cogl-pipeline-opengl.c
@@ -217,7 +217,7 @@ _cogl_delete_gl_texture (GLuint gl_texture)
  * if it is reused again with the same texture unit.
  */
 void
-_cogl_pipeline_texture_storage_change_notify (CoglHandle texture)
+_cogl_pipeline_texture_storage_change_notify (CoglTexture *texture)
 {
   int i;
 
@@ -781,11 +781,11 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
       unsigned long state = COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA;
       CoglPipelineLayer *authority =
         _cogl_pipeline_layer_get_authority (layer, state);
-      CoglHandle texture;
-      GLuint     gl_texture;
-      GLenum     gl_target;
+      CoglTexture *texture;
+      GLuint gl_texture;
+      GLenum gl_target;
 
-      texture = (authority->texture == COGL_INVALID_HANDLE ?
+      texture = (authority->texture == NULL ?
                  ctx->default_gl_texture_2d_tex :
                  authority->texture);
 
@@ -897,12 +897,12 @@ _cogl_pipeline_flush_common_gl_state (CoglPipeline  *pipeline,
  */
 static void
 _cogl_pipeline_layer_forward_wrap_modes (CoglPipelineLayer *layer,
-                                         CoglHandle texture)
+                                         CoglTexture *texture)
 {
   CoglPipelineWrapModeInternal wrap_mode_s, wrap_mode_t, wrap_mode_p;
   GLenum gl_wrap_mode_s, gl_wrap_mode_t, gl_wrap_mode_p;
 
-  if (texture == COGL_INVALID_HANDLE)
+  if (texture == NULL)
     return;
 
   _cogl_pipeline_layer_get_wrap_modes (layer,
@@ -964,9 +964,9 @@ foreach_texture_unit_update_filter_and_wrap_modes (void)
 
       if (unit->layer)
         {
-          CoglHandle texture = _cogl_pipeline_layer_get_texture (unit->layer);
+          CoglTexture *texture = _cogl_pipeline_layer_get_texture (unit->layer);
 
-          if (texture != COGL_INVALID_HANDLE)
+          if (texture != NULL)
             {
               CoglPipelineFilter min;
               CoglPipelineFilter mag;
diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
index 346026e..931642a 100644
--- a/cogl/cogl-pipeline-private.h
+++ b/cogl/cogl-pipeline-private.h
@@ -387,9 +387,9 @@ struct _CoglPipelineLayer
   /* Each layer is directly associated with a single texture unit */
   int                        unit_index;
 
-  /* The texture for this layer, or COGL_INVALID_HANDLE for an empty
+  /* The texture for this layer, or NULL for an empty
    * layer */
-  CoglHandle                 texture;
+  CoglTexture               *texture;
   GLenum                     target;
 
   CoglPipelineFilter         mag_filter;
@@ -1006,7 +1006,7 @@ typedef struct _CoglPipelineFlushOptions
 
   guint32                       fallback_layers;
   guint32                       disable_layers;
-  CoglHandle                    layer0_override_texture;
+  CoglTexture                  *layer0_override_texture;
 } CoglPipelineFlushOptions;
 
 void
@@ -1194,7 +1194,7 @@ _cogl_pipeline_get_layer_matrix (CoglPipeline *pipeline,
                                  int layer_index);
 
 void
-_cogl_pipeline_texture_storage_change_notify (CoglHandle texture);
+_cogl_pipeline_texture_storage_change_notify (CoglTexture *texture);
 
 void
 _cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline);
@@ -1229,7 +1229,7 @@ _cogl_pipeline_find_equivalent_parent (CoglPipeline *pipeline,
                                        CoglPipelineState pipeline_state,
                                        CoglPipelineLayerState layer_state);
 
-CoglHandle
+CoglTexture *
 _cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
                                   int layer_index);
 
@@ -1273,10 +1273,10 @@ typedef enum {
 CoglPipelineLayerType
 _cogl_pipeline_layer_get_type (CoglPipelineLayer *layer);
 
-CoglHandle
+CoglTexture *
 _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
 
-CoglHandle
+CoglTexture *
 _cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
 
 CoglPipelineFilter
@@ -1302,7 +1302,7 @@ CoglPipelineLayer *
 _cogl_pipeline_layer_get_authority (CoglPipelineLayer *layer,
                                     unsigned long difference);
 
-CoglHandle
+CoglTexture *
 _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
 
 typedef gboolean (*CoglPipelineInternalLayerCallback) (CoglPipelineLayer *layer,
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 42923be..88e1bd7 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -2149,7 +2149,7 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
 
   COGL_COUNTER_INC (_cogl_uprof_context, layer_fallback_counter);
 
-  if (G_LIKELY (texture != COGL_INVALID_HANDLE))
+  if (G_LIKELY (texture != NULL))
     cogl_texture_get_gl_texture (texture, NULL, &gl_target);
   else
     gl_target = GL_TEXTURE_2D;
@@ -3161,7 +3161,7 @@ _cogl_pipeline_layer_pre_paint (CoglPipelineLayer *layer)
     _cogl_pipeline_layer_get_authority (layer,
                                         COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA);
 
-  if (texture_authority->texture != COGL_INVALID_HANDLE)
+  if (texture_authority->texture != NULL)
     {
       CoglTexturePrePaintFlags flags = 0;
       CoglPipelineFilter min_filter;
diff --git a/cogl/cogl-primitives.c b/cogl/cogl-primitives.c
index 9fd412e..c996b5e 100644
--- a/cogl/cogl-primitives.c
+++ b/cogl/cogl-primitives.c
@@ -46,7 +46,7 @@
 typedef struct _TextureSlicedQuadState
 {
   CoglPipeline *pipeline;
-  CoglHandle main_texture;
+  CoglTexture *main_texture;
   float tex_virtual_origin_x;
   float tex_virtual_origin_y;
   float quad_origin_x;
@@ -68,14 +68,14 @@ typedef struct _TextureSlicedPolygonState
 } TextureSlicedPolygonState;
 
 static void
-log_quad_sub_textures_cb (CoglHandle texture_handle,
+log_quad_sub_textures_cb (CoglTexture *texture,
                           const float *subtexture_coords,
                           const float *virtual_coords,
                           void *user_data)
 {
   TextureSlicedQuadState *state = user_data;
   CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
-  CoglHandle texture_override;
+  CoglTexture *texture_override;
   float quad_coords[4];
 
 #define TEX_VIRTUAL_TO_QUAD(V, Q, AXIS) \
@@ -112,10 +112,10 @@ log_quad_sub_textures_cb (CoglHandle texture_handle,
 
   /* We only need to override the texture if it's different from the
      main texture */
-  if (texture_handle == state->main_texture)
-    texture_override = COGL_INVALID_HANDLE;
+  if (texture == state->main_texture)
+    texture_override = NULL;
   else
-    texture_override = texture_handle;
+    texture_override = texture;
 
   _cogl_journal_log_quad (framebuffer->journal,
                           quad_coords,
@@ -180,7 +180,7 @@ validate_first_layer_cb (CoglPipeline *pipeline,
  */
 /* TODO: support multitexturing */
 static void
-_cogl_texture_quad_multiple_primitives (CoglHandle    tex_handle,
+_cogl_texture_quad_multiple_primitives (CoglTexture  *texture,
                                         CoglPipeline *pipeline,
                                         gboolean      clamp_s,
                                         gboolean      clamp_t,
@@ -220,7 +220,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle    tex_handle,
                (position[2] - position[0]) *
                (tx_1 - old_tx_1) / (old_tx_2 - old_tx_1)),
               position[3] };
-          _cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
+          _cogl_texture_quad_multiple_primitives (texture, pipeline,
                                                   FALSE, clamp_t,
                                                   tmp_position,
                                                   tx_1, ty_1, tx_1, ty_2);
@@ -235,7 +235,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle    tex_handle,
                (position[2] - position[0]) *
                (tx_2 - old_tx_1) / (old_tx_2 - old_tx_1)),
               position[1], position[2], position[3] };
-          _cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
+          _cogl_texture_quad_multiple_primitives (texture, pipeline,
                                                   FALSE, clamp_t,
                                                   tmp_position,
                                                   tx_2, ty_1, tx_2, ty_2);
@@ -267,7 +267,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle    tex_handle,
               (position[1] +
                (position[3] - position[1]) *
                (ty_1 - old_ty_1) / (old_ty_2 - old_ty_1)) };
-          _cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
+          _cogl_texture_quad_multiple_primitives (texture, pipeline,
                                                   clamp_s, FALSE,
                                                   tmp_position,
                                                   tx_1, ty_1, tx_2, ty_1);
@@ -283,7 +283,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle    tex_handle,
                (position[3] - position[1]) *
                (ty_2 - old_ty_1) / (old_ty_2 - old_ty_1)),
               position[2], position[3] };
-          _cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
+          _cogl_texture_quad_multiple_primitives (texture, pipeline,
                                                   clamp_s, FALSE,
                                                   tmp_position,
                                                   tx_1, ty_2, tx_2, ty_2);
@@ -302,7 +302,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle    tex_handle,
                                validate_first_layer_cb,
                                &validate_first_layer_state);
 
-  state.main_texture = tex_handle;
+  state.main_texture = texture;
 
   if (validate_first_layer_state.override_pipeline)
     state.pipeline = validate_first_layer_state.override_pipeline;
@@ -350,7 +350,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle    tex_handle,
   state.v_to_q_scale_x = fabs (state.quad_len_x / (tx_2 - tx_1));
   state.v_to_q_scale_y = fabs (state.quad_len_y / (ty_2 - ty_1));
 
-  _cogl_texture_foreach_sub_texture_in_region (tex_handle,
+  _cogl_texture_foreach_sub_texture_in_region (texture,
                                                tx_1, ty_1, tx_2, ty_2,
                                                log_quad_sub_textures_cb,
                                                &state);
@@ -379,7 +379,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
                         void *user_data)
 {
   ValidateTexCoordsState *state = user_data;
-  CoglHandle texture;
+  CoglTexture *texture;
   const float *in_tex_coords;
   float *out_tex_coords;
   float default_tex_coords[4] = {0.0, 0.0, 1.0, 1.0};
@@ -457,7 +457,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
                        "supported with multi-texturing.", state->i);
           warning_seen = TRUE;
 
-          cogl_pipeline_set_layer_texture (texture, layer_index, NULL);
+          cogl_pipeline_set_layer_texture (pipeline, layer_index, NULL);
         }
     }
 
@@ -543,7 +543,7 @@ _cogl_multitexture_quad_single_primitive (const float  *position,
                           position,
                           pipeline,
                           n_layers,
-                          COGL_INVALID_HANDLE, /* no texture override */
+                          NULL, /* no texture override */
                           final_tex_coords,
                           n_layers * 4);
 
@@ -567,7 +567,7 @@ _cogl_rectangles_validate_layer_cb (CoglPipeline *pipeline,
                                     void *user_data)
 {
   ValidateLayerState *state = user_data;
-  CoglHandle texture;
+  CoglTexture *texture;
 
   state->i++;
 
@@ -615,9 +615,9 @@ _cogl_rectangles_validate_layer_cb (CoglPipeline *pipeline,
 
   texture = _cogl_pipeline_get_layer_texture (pipeline, layer_index);
 
-  /* COGL_INVALID_HANDLE textures are handled by
+  /* NULL textures are handled by
    * _cogl_pipeline_flush_gl_state */
-  if (texture == COGL_INVALID_HANDLE)
+  if (texture == NULL)
     return TRUE;
 
   if (state->i == 0)
@@ -753,7 +753,7 @@ _cogl_rectangles_with_multitexture_coords (
 
   for (i = 0; i < n_rects; i++)
     {
-      CoglHandle texture;
+      CoglTexture *texture;
       const float default_tex_coords[4] = {0.0, 0.0, 1.0, 1.0};
       const float *tex_coords;
       gboolean clamp_s, clamp_t;
@@ -981,19 +981,19 @@ append_tex_coord_attributes_cb (CoglPipeline *pipeline,
                                 void *user_data)
 {
   AppendTexCoordsState *state = user_data;
-  CoglHandle tex_handle;
+  CoglTexture *texture;
   float tx, ty;
   float *t;
 
   tx = state->vertices_in[state->vertex].tx;
   ty = state->vertices_in[state->vertex].ty;
 
-  /* COGL_INVALID_HANDLE textures will be handled in
+  /* NULL textures will be handled in
    * _cogl_pipeline_flush_layers_gl_state but there is no need to worry
    * about scaling texture coordinates in this case */
-  tex_handle = _cogl_pipeline_get_layer_texture (pipeline, layer_index);
-  if (tex_handle != COGL_INVALID_HANDLE)
-    _cogl_texture_transform_coords_to_gl (tex_handle, &tx, &ty);
+  texture = _cogl_pipeline_get_layer_texture (pipeline, layer_index);
+  if (texture != NULL)
+    _cogl_texture_transform_coords_to_gl (texture, &tx, &ty);
 
   /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
   t = state->vertices_out + 3 + 2 * state->layer;
diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c
index 933a325..331eecc 100644
--- a/cogl/cogl-sub-texture.c
+++ b/cogl/cogl-sub-texture.c
@@ -155,7 +155,7 @@ typedef struct _CoglSubTextureForeachData
 } CoglSubTextureForeachData;
 
 static void
-_cogl_sub_texture_foreach_cb (CoglHandle handle,
+_cogl_sub_texture_foreach_cb (CoglTexture *texture,
                               const float *slice_coords,
                               const float *full_virtual_coords,
                               void *user_data)
@@ -173,7 +173,7 @@ _cogl_sub_texture_foreach_cb (CoglHandle handle,
                                   &virtual_coords[2],
                                   &virtual_coords[3]);
 
-  data->callback (handle,
+  data->callback (texture,
                   slice_coords, virtual_coords,
                   data->user_data);
 }
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index f592617..ffaeb75 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -67,7 +67,7 @@ typedef struct
 } ForeachData;
 
 static void
-_cogl_texture_2d_sliced_foreach_cb (CoglHandle handle,
+_cogl_texture_2d_sliced_foreach_cb (CoglTexture *texture,
                                     const float *slice_coords,
                                     const float *virtual_coords_in,
                                     void *user_data)
@@ -86,7 +86,7 @@ _cogl_texture_2d_sliced_foreach_cb (CoglHandle handle,
   virtual_coords_out[3] = (virtual_coords_in[3] * data->y_span->size +
                            data->y_span->start) / data->tex->height;
 
-  data->callback (handle,
+  data->callback (texture,
                   slice_coords,
                   virtual_coords_out,
                   data->user_data);
diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h
index 01fba91..0ca0a45 100644
--- a/cogl/cogl-texture-private.h
+++ b/cogl/cogl-texture-private.h
@@ -28,12 +28,9 @@
 #include "cogl-handle.h"
 #include "cogl-pipeline-private.h"
 
-#define COGL_TEXTURE(tex) ((CoglTexture *)(tex))
-
-typedef struct _CoglTexture           CoglTexture;
 typedef struct _CoglTextureVtable     CoglTextureVtable;
 
-typedef void (*CoglTextureSliceCallback) (CoglHandle handle,
+typedef void (*CoglTextureSliceCallback) (CoglTexture *texture,
                                           const float *slice_coords,
                                           const float *virtual_coords,
                                           void *user_data);
@@ -136,7 +133,7 @@ struct _CoglTextureVtable
 
 struct _CoglTexture
 {
-  CoglHandleObject         _parent;
+  CoglObject               _parent;
   GList                   *framebuffers;
   const CoglTextureVtable *vtable;
 };
@@ -193,7 +190,7 @@ _cogl_texture_register_texture_type (GQuark type);
                                         ## type_name ## _get_type ()))
 
 void
-_cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
+_cogl_texture_foreach_sub_texture_in_region (CoglTexture *texture,
                                              float virtual_tx_1,
                                              float virtual_ty_1,
                                              float virtual_tx_2,
@@ -202,36 +199,36 @@ _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
                                              void *user_data);
 
 gboolean
-_cogl_texture_can_hardware_repeat (CoglHandle handle);
+_cogl_texture_can_hardware_repeat (CoglTexture *texture);
 
 void
-_cogl_texture_transform_coords_to_gl (CoglHandle handle,
+_cogl_texture_transform_coords_to_gl (CoglTexture *texture,
                                       float *s,
                                       float *t);
 CoglTransformResult
-_cogl_texture_transform_quad_coords_to_gl (CoglHandle handle,
+_cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
                                            float *coords);
 
 GLenum
-_cogl_texture_get_gl_format (CoglHandle handle);
+_cogl_texture_get_gl_format (CoglTexture *texture);
 
 void
-_cogl_texture_set_wrap_mode_parameters (CoglHandle handle,
+_cogl_texture_set_wrap_mode_parameters (CoglTexture *texture,
                                         GLenum wrap_mode_s,
                                         GLenum wrap_mode_t,
                                         GLenum wrap_mode_p);
 
 
 void
-_cogl_texture_set_filters (CoglHandle handle,
+_cogl_texture_set_filters (CoglTexture *texture,
                            GLenum min_filter,
                            GLenum mag_filter);
 
 void
-_cogl_texture_pre_paint (CoglHandle handle, CoglTexturePrePaintFlags flags);
+_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags);
 
 void
-_cogl_texture_ensure_non_quad_rendering (CoglHandle handle);
+_cogl_texture_ensure_non_quad_rendering (CoglTexture *texture);
 
 /* Utility function to determine which pixel format to use when
    dst_format is COGL_PIXEL_FORMAT_ANY. If dst_format is not ANY then
@@ -274,22 +271,22 @@ _cogl_texture_iterate_manual_repeats (CoglTextureManualRepeatCallback callback,
    texture via the framebuffer */
 
 gboolean
-_cogl_texture_draw_and_read (CoglHandle   handle,
+_cogl_texture_draw_and_read (CoglTexture *texture,
                              CoglBitmap  *target_bmp,
                              GLuint       target_gl_format,
                              GLuint       target_gl_type);
 
 gboolean
-_cogl_texture_is_foreign (CoglHandle handle);
+_cogl_texture_is_foreign (CoglTexture *texture);
 
 void
-_cogl_texture_associate_framebuffer (CoglHandle handle,
+_cogl_texture_associate_framebuffer (CoglTexture *texture,
                                      CoglFramebuffer *framebuffer);
 
 const GList *
-_cogl_texture_get_associated_framebuffers (CoglHandle handle);
+_cogl_texture_get_associated_framebuffers (CoglTexture *texture);
 
 void
-_cogl_texture_flush_journal_rendering (CoglHandle handle);
+_cogl_texture_flush_journal_rendering (CoglTexture *texture);
 
 #endif /* __COGL_TEXTURE_PRIVATE_H */
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 3551a9d..c2b3a82 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -79,14 +79,14 @@ _cogl_texture_register_texture_type (GQuark type)
 }
 
 gboolean
-cogl_is_texture (CoglHandle handle)
+cogl_is_texture (void *object)
 {
-  CoglHandleObject *obj = (CoglHandleObject *)handle;
+  CoglObject *obj = (CoglObject *)object;
   GSList *l;
 
   _COGL_GET_CONTEXT (ctxt, FALSE);
 
-  if (handle == COGL_INVALID_HANDLE)
+  if (object == NULL)
     return FALSE;
 
   for (l = ctxt->texture_types; l; l = l->next)
@@ -96,33 +96,33 @@ cogl_is_texture (CoglHandle handle)
   return FALSE;
 }
 
-CoglHandle
-cogl_texture_ref (CoglHandle handle)
+void *
+cogl_texture_ref (void *object)
 {
-  if (!cogl_is_texture (handle))
-    return COGL_INVALID_HANDLE;
+  if (!cogl_is_texture (object))
+    return NULL;
 
-  _COGL_HANDLE_DEBUG_REF (CoglTexture, handle);
+  _COGL_OBJECT_DEBUG_REF (CoglTexture, object);
 
-  cogl_handle_ref (handle);
+  cogl_object_ref (object);
 
-  return handle;
+  return object;
 }
 
 void
-cogl_texture_unref (CoglHandle handle)
+cogl_texture_unref (void *object)
 {
-  if (!cogl_is_texture (handle))
+  if (!cogl_is_texture (object))
     {
       g_warning (G_STRINGIFY (cogl_texture_unref)
-                 ": Ignoring unref of Cogl handle "
+                 ": Ignoring unref of CoglObject "
                  "due to type mismatch");
       return;
     }
 
-  _COGL_HANDLE_DEBUG_UNREF (CoglTexture, handle);
+  _COGL_OBJECT_DEBUG_UNREF (CoglTexture, object);
 
-  cogl_handle_unref (handle);
+  cogl_object_unref (object);
 }
 
 void
@@ -281,17 +281,15 @@ _cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride)
 
 /* FIXME: wrap modes should be set on pipelines not textures */
 void
-_cogl_texture_set_wrap_mode_parameters (CoglHandle handle,
+_cogl_texture_set_wrap_mode_parameters (CoglTexture *texture,
                                         GLenum wrap_mode_s,
                                         GLenum wrap_mode_t,
                                         GLenum wrap_mode_p)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
-
-  tex->vtable->set_wrap_mode_parameters (tex,
-                                         wrap_mode_s,
-                                         wrap_mode_t,
-                                         wrap_mode_p);
+  texture->vtable->set_wrap_mode_parameters (texture,
+                                             wrap_mode_s,
+                                             wrap_mode_t,
+                                             wrap_mode_p);
 }
 
 /* This is like CoglSpanIter except it deals with floats and it
@@ -389,32 +387,33 @@ _cogl_texture_iterate_manual_repeats (CoglTextureManualRepeatCallback callback,
       }
 }
 
-CoglHandle
+CoglTexture *
 cogl_texture_new_with_size (unsigned int     width,
 			    unsigned int     height,
                             CoglTextureFlags flags,
 			    CoglPixelFormat  internal_format)
 {
-  CoglHandle tex;
+  CoglTexture *tex;
 
   _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
 
   /* First try creating a fast-path non-sliced texture */
-  tex = cogl_texture_2d_new_with_size (ctx,
-                                       width, height, internal_format,
-                                       NULL);
+  tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
+                                                     width, height,
+                                                     internal_format,
+                                                     NULL));
 
   /* If it fails resort to sliced textures */
-  if (tex == COGL_INVALID_HANDLE)
-    tex = _cogl_texture_2d_sliced_new_with_size (width,
-                                                 height,
-                                                 flags,
-                                                 internal_format);
+  if (tex == NULL)
+    tex = COGL_TEXTURE (_cogl_texture_2d_sliced_new_with_size (width,
+                                                               height,
+                                                               flags,
+                                                               internal_format));
 
   return tex;
 }
 
-CoglHandle
+CoglTexture *
 cogl_texture_new_from_data (unsigned int      width,
 			    unsigned int      height,
                             CoglTextureFlags  flags,
@@ -424,13 +423,13 @@ cogl_texture_new_from_data (unsigned int      width,
 			    const guint8     *data)
 {
   CoglBitmap *bmp;
-  CoglHandle tex;
+  CoglTexture *tex;
 
   if (format == COGL_PIXEL_FORMAT_ANY)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   if (data == NULL)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   /* Rowstride from width if not given */
   if (rowstride == 0)
@@ -451,47 +450,47 @@ cogl_texture_new_from_data (unsigned int      width,
   return tex;
 }
 
-CoglHandle
-cogl_texture_new_from_bitmap (CoglHandle       bmp_handle,
+CoglTexture *
+cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
                               CoglTextureFlags flags,
                               CoglPixelFormat  internal_format)
 {
-  CoglHandle tex;
+  CoglTexture *tex;
 
   /* First try putting the texture in the atlas */
-  if ((tex = _cogl_atlas_texture_new_from_bitmap (bmp_handle,
+  if ((tex = _cogl_atlas_texture_new_from_bitmap (bitmap,
                                                   flags,
                                                   internal_format)))
     return tex;
 
   /* If that doesn't work try a fast path 2D texture */
-  if ((tex = _cogl_texture_2d_new_from_bitmap (bmp_handle,
+  if ((tex = _cogl_texture_2d_new_from_bitmap (bitmap,
                                                flags,
                                                internal_format,
                                                NULL)))
     return tex;
 
   /* Otherwise create a sliced texture */
-  return _cogl_texture_2d_sliced_new_from_bitmap (bmp_handle,
+  return _cogl_texture_2d_sliced_new_from_bitmap (bitmap,
                                                   flags,
                                                   internal_format);
 }
 
-CoglHandle
+CoglTexture *
 cogl_texture_new_from_file (const char        *filename,
                             CoglTextureFlags   flags,
                             CoglPixelFormat    internal_format,
                             GError           **error)
 {
   CoglBitmap *bmp;
-  CoglHandle handle = COGL_INVALID_HANDLE;
+  CoglTexture *texture = NULL;
   CoglPixelFormat src_format;
 
-  g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   bmp = cogl_bitmap_new_from_file (filename, error);
   if (bmp == NULL)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   src_format = _cogl_bitmap_get_format (bmp);
 
@@ -503,14 +502,14 @@ cogl_texture_new_from_file (const char        *filename,
     _cogl_texture_determine_internal_format (src_format, internal_format);
   if (!_cogl_texture_needs_premult_conversion (src_format, internal_format) ||
       _cogl_bitmap_convert_premult_status (bmp, src_format ^ COGL_PREMULT_BIT))
-    handle = cogl_texture_new_from_bitmap (bmp, flags, internal_format);
+    texture = cogl_texture_new_from_bitmap (bmp, flags, internal_format);
 
   cogl_object_unref (bmp);
 
-  return handle;
+  return texture;
 }
 
-CoglHandle
+CoglTexture *
 cogl_texture_new_from_foreign (GLuint           gl_handle,
 			       GLenum           gl_target,
 			       GLuint           width,
@@ -549,43 +548,37 @@ cogl_texture_new_from_foreign (GLuint           gl_handle,
   else
     {
       _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
-      return cogl_texture_2d_new_from_foreign (ctx,
-                                               gl_handle,
-                                               width,
-                                               height,
-                                               format,
-                                               NULL);
+      return COGL_TEXTURE (cogl_texture_2d_new_from_foreign (ctx,
+                                                             gl_handle,
+                                                             width,
+                                                             height,
+                                                             format,
+                                                             NULL));
     }
 }
 
 gboolean
-_cogl_texture_is_foreign (CoglHandle handle)
+_cogl_texture_is_foreign (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  g_return_val_if_fail (cogl_is_texture (handle), FALSE);
-
-  tex = COGL_TEXTURE (handle);
-
-  if (tex->vtable->is_foreign)
-    return tex->vtable->is_foreign (tex);
+  if (texture->vtable->is_foreign)
+    return texture->vtable->is_foreign (texture);
   else
     return FALSE;
 }
 
-CoglHandle
-cogl_texture_new_from_sub_texture (CoglHandle full_texture,
-                                   int        sub_x,
-                                   int        sub_y,
-                                   int        sub_width,
-                                   int        sub_height)
+CoglTexture *
+cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
+                                   int sub_x,
+                                   int sub_y,
+                                   int sub_width,
+                                   int sub_height)
 {
   return _cogl_sub_texture_new (full_texture, sub_x, sub_y,
                                 sub_width, sub_height);
 }
 
-CoglHandle
-cogl_texture_new_from_buffer_EXP (CoglHandle          buffer,
+CoglTexture *
+cogl_texture_new_from_buffer_EXP (CoglPixelBuffer    *buffer,
                                   unsigned int        width,
                                   unsigned int        height,
                                   CoglTextureFlags    flags,
@@ -594,15 +587,15 @@ cogl_texture_new_from_buffer_EXP (CoglHandle          buffer,
                                   unsigned int        rowstride,
                                   const unsigned int  offset)
 {
-  CoglHandle texture;
+  CoglTexture *texture;
   CoglBuffer *cogl_buffer;
   CoglPixelBuffer *pixel_buffer;
   CoglBitmap *bmp;
 
-  g_return_val_if_fail (cogl_is_buffer (buffer), COGL_INVALID_HANDLE);
+  g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
 
   if (format == COGL_PIXEL_FORMAT_ANY)
-    return COGL_INVALID_HANDLE;
+    return NULL;
 
   cogl_buffer = COGL_BUFFER (buffer);
   pixel_buffer = COGL_PIXEL_BUFFER (buffer);
@@ -623,7 +616,7 @@ cogl_texture_new_from_buffer_EXP (CoglHandle          buffer,
       /* no width or height specified, neither at creation time (because the
        * array was created by cogl_pixel_buffer_new()) nor when calling this
        * function */
-      return COGL_INVALID_HANDLE;
+      return NULL;
     }
 
   /* Wrap the buffer into a bitmap */
@@ -641,87 +634,45 @@ cogl_texture_new_from_buffer_EXP (CoglHandle          buffer,
 }
 
 unsigned int
-cogl_texture_get_width (CoglHandle handle)
+cogl_texture_get_width (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return 0;
-
-  tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->get_width (tex);
+  return texture->vtable->get_width (texture);
 }
 
 unsigned int
-cogl_texture_get_height (CoglHandle handle)
+cogl_texture_get_height (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return 0;
-
-  tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->get_height (tex);
+  return texture->vtable->get_height (texture);
 }
 
 CoglPixelFormat
-cogl_texture_get_format (CoglHandle handle)
+cogl_texture_get_format (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return COGL_PIXEL_FORMAT_ANY;
-
-  tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->get_format (tex);
+  return texture->vtable->get_format (texture);
 }
 
 unsigned int
-cogl_texture_get_rowstride (CoglHandle handle)
+cogl_texture_get_rowstride (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return 0;
-
   /* FIXME: This function should go away. It previously just returned
      the rowstride that was used to upload the data as far as I can
      tell. This is not helpful */
 
-  tex = COGL_TEXTURE (handle);
-
   /* Just guess at a suitable rowstride */
-  return (_cogl_get_format_bpp (cogl_texture_get_format (tex))
-          * cogl_texture_get_width (tex));
+  return (_cogl_get_format_bpp (cogl_texture_get_format (texture))
+          * cogl_texture_get_width (texture));
 }
 
 int
-cogl_texture_get_max_waste (CoglHandle handle)
+cogl_texture_get_max_waste (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return 0;
-
-  tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->get_max_waste (tex);
+  return texture->vtable->get_max_waste (texture);
 }
 
 gboolean
-cogl_texture_is_sliced (CoglHandle handle)
+cogl_texture_is_sliced (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return FALSE;
-
-  tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->is_sliced (tex);
+  return texture->vtable->is_sliced (texture);
 }
 
 /* Some CoglTextures, notably sliced textures or atlas textures when repeating
@@ -734,7 +685,7 @@ cogl_texture_is_sliced (CoglHandle handle)
  * region specified in texture coordinates.
  */
 void
-_cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
+_cogl_texture_foreach_sub_texture_in_region (CoglTexture *texture,
                                              float virtual_tx_1,
                                              float virtual_ty_1,
                                              float virtual_tx_2,
@@ -742,15 +693,13 @@ _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
                                              CoglTextureSliceCallback callback,
                                              void *user_data)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
-
-  tex->vtable->foreach_sub_texture_in_region (tex,
-                                              virtual_tx_1,
-                                              virtual_ty_1,
-                                              virtual_tx_2,
-                                              virtual_ty_2,
-                                              callback,
-                                              user_data);
+  texture->vtable->foreach_sub_texture_in_region (texture,
+                                                  virtual_tx_1,
+                                                  virtual_ty_1,
+                                                  virtual_tx_2,
+                                                  virtual_ty_2,
+                                                  callback,
+                                                  user_data);
 }
 
 /* If this returns FALSE, that implies _foreach_sub_texture_in_region
@@ -758,101 +707,66 @@ _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
  * texture coordinates extend out of the range [0,1]
  */
 gboolean
-_cogl_texture_can_hardware_repeat (CoglHandle handle)
+_cogl_texture_can_hardware_repeat (CoglTexture *texture)
 {
-  CoglTexture *tex = (CoglTexture *)handle;
-
-  return tex->vtable->can_hardware_repeat (tex);
+  return texture->vtable->can_hardware_repeat (texture);
 }
 
 /* NB: You can't use this with textures comprised of multiple sub textures (use
  * cogl_texture_is_sliced() to check) since coordinate transformation for such
  * textures will be different for each slice. */
 void
-_cogl_texture_transform_coords_to_gl (CoglHandle handle,
+_cogl_texture_transform_coords_to_gl (CoglTexture *texture,
                                       float *s,
                                       float *t)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
-
-  tex->vtable->transform_coords_to_gl (tex, s, t);
+  texture->vtable->transform_coords_to_gl (texture, s, t);
 }
 
 CoglTransformResult
-_cogl_texture_transform_quad_coords_to_gl (CoglHandle handle,
+_cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
                                            float *coords)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->transform_quad_coords_to_gl (tex, coords);
+  return texture->vtable->transform_quad_coords_to_gl (texture, coords);
 }
 
 GLenum
-_cogl_texture_get_gl_format (CoglHandle handle)
+_cogl_texture_get_gl_format (CoglTexture *texture)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->get_gl_format (tex);
+  return texture->vtable->get_gl_format (texture);
 }
 
 gboolean
-cogl_texture_get_gl_texture (CoglHandle handle,
+cogl_texture_get_gl_texture (CoglTexture *texture,
 			     GLuint *out_gl_handle,
 			     GLenum *out_gl_target)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return FALSE;
-
-  tex = COGL_TEXTURE (handle);
-
-  return tex->vtable->get_gl_texture (tex, out_gl_handle, out_gl_target);
+  return texture->vtable->get_gl_texture (texture,
+                                          out_gl_handle, out_gl_target);
 }
 
 void
-_cogl_texture_set_filters (CoglHandle handle,
+_cogl_texture_set_filters (CoglTexture *texture,
                            GLenum min_filter,
                            GLenum mag_filter)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return;
-
-  tex = COGL_TEXTURE (handle);
-
-  tex->vtable->set_filters (tex, min_filter, mag_filter);
+  texture->vtable->set_filters (texture, min_filter, mag_filter);
 }
 
 void
-_cogl_texture_pre_paint (CoglHandle handle, CoglTexturePrePaintFlags flags)
+_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return;
-
-  tex = COGL_TEXTURE (handle);
-
-  tex->vtable->pre_paint (tex, flags);
+  texture->vtable->pre_paint (texture, flags);
 }
 
 void
-_cogl_texture_ensure_non_quad_rendering (CoglHandle handle)
+_cogl_texture_ensure_non_quad_rendering (CoglTexture *texture)
 {
-  CoglTexture *tex;
-
-  if (!cogl_is_texture (handle))
-    return;
-
-  tex = COGL_TEXTURE (handle);
-
-  tex->vtable->ensure_non_quad_rendering (tex);
+  texture->vtable->ensure_non_quad_rendering (texture);
 }
 
 gboolean
-cogl_texture_set_region_from_bitmap (CoglHandle handle,
+cogl_texture_set_region_from_bitmap (CoglTexture *texture,
                                      int src_x,
                                      int src_y,
                                      int dst_x,
@@ -861,8 +775,7 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
                                      unsigned int dst_height,
                                      CoglBitmap *bmp)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
-  gboolean     ret;
+  gboolean ret;
 
   /* Shortcut out early if the image is empty */
   if (dst_width == 0 || dst_height == 0)
@@ -875,17 +788,17 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
      always stored in an RGBA texture even if the texture format is
      advertised as RGB. */
 
-  ret = tex->vtable->set_region (handle,
-                                 src_x, src_y,
-                                 dst_x, dst_y,
-                                 dst_width, dst_height,
-                                 bmp);
+  ret = texture->vtable->set_region (texture,
+                                     src_x, src_y,
+                                     dst_x, dst_y,
+                                     dst_width, dst_height,
+                                     bmp);
 
   return ret;
 }
 
 gboolean
-cogl_texture_set_region (CoglHandle       handle,
+cogl_texture_set_region (CoglTexture     *texture,
 			 int              src_x,
 			 int              src_y,
 			 int              dst_x,
@@ -918,7 +831,7 @@ cogl_texture_set_region (CoglHandle       handle,
                                            NULL, /* destroy_fn */
                                            NULL); /* destroy_fn_data */
 
-  ret = cogl_texture_set_region_from_bitmap (handle,
+  ret = cogl_texture_set_region_from_bitmap (texture,
                                              src_x, src_y,
                                              dst_x, dst_y,
                                              dst_width, dst_height,
@@ -943,7 +856,7 @@ cogl_texture_set_region (CoglHandle       handle,
  * glGetTexImage, but may be used as a fallback in some circumstances.
  */
 static void
-do_texture_draw_and_read (CoglHandle   handle,
+do_texture_draw_and_read (CoglTexture *texture,
                           CoglBitmap  *target_bmp,
                           float       *viewport)
 {
@@ -958,8 +871,8 @@ do_texture_draw_and_read (CoglHandle   handle,
 
   bpp = _cogl_get_format_bpp (COGL_PIXEL_FORMAT_RGBA_8888);
 
-  tex_width = cogl_texture_get_width (handle);
-  tex_height = cogl_texture_get_height (handle);
+  tex_width = cogl_texture_get_width (texture);
+  tex_height = cogl_texture_get_height (texture);
 
   ry2 = 0;
   ty2 = 0;
@@ -1045,7 +958,7 @@ do_texture_draw_and_read (CoglHandle   handle,
  * glGetTexImage, but may be used as a fallback in some circumstances.
  */
 gboolean
-_cogl_texture_draw_and_read (CoglHandle   handle,
+_cogl_texture_draw_and_read (CoglTexture *texture,
                              CoglBitmap  *target_bmp,
                              GLuint       target_gl_format,
                              GLuint       target_gl_type)
@@ -1091,7 +1004,7 @@ _cogl_texture_draw_and_read (CoglHandle   handle,
 
   /* Direct copy operation */
 
-  if (ctx->texture_download_pipeline == COGL_INVALID_HANDLE)
+  if (ctx->texture_download_pipeline == NULL)
     {
       ctx->texture_download_pipeline = cogl_pipeline_new ();
       cogl_pipeline_set_blend (ctx->texture_download_pipeline,
@@ -1101,7 +1014,7 @@ _cogl_texture_draw_and_read (CoglHandle   handle,
 
   _cogl_push_source (ctx->texture_download_pipeline, FALSE);
 
-  cogl_pipeline_set_layer_texture (ctx->texture_download_pipeline, 0, handle);
+  cogl_pipeline_set_layer_texture (ctx->texture_download_pipeline, 0, texture);
 
   cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline,
                                    0, /* layer */
@@ -1112,7 +1025,7 @@ _cogl_texture_draw_and_read (CoglHandle   handle,
                                    COGL_PIPELINE_FILTER_NEAREST,
                                    COGL_PIPELINE_FILTER_NEAREST);
 
-  do_texture_draw_and_read (handle, target_bmp, viewport);
+  do_texture_draw_and_read (texture, target_bmp, viewport);
 
   /* Check whether texture has alpha and framebuffer not */
   /* FIXME: For some reason even if ALPHA_BITS is 8, the framebuffer
@@ -1127,7 +1040,7 @@ _cogl_texture_draw_and_read (CoglHandle   handle,
   printf ("G bits: %d\n", g_bits);
   printf ("B bits: %d\n", b_bits);
   printf ("A bits: %d\n", a_bits); */
-  if ((cogl_texture_get_format (handle) & COGL_A_BIT)/* && a_bits == 0*/)
+  if ((cogl_texture_get_format (texture) & COGL_A_BIT)/* && a_bits == 0*/)
     {
       guint8 *srcdata;
       guint8 *dstdata;
@@ -1157,7 +1070,7 @@ _cogl_texture_draw_and_read (CoglHandle   handle,
                                        "RGBA = REPLACE (TEXTURE[A])",
                                        NULL);
 
-      do_texture_draw_and_read (handle, alpha_bmp, viewport);
+      do_texture_draw_and_read (texture, alpha_bmp, viewport);
 
       /* Copy temp R to target A */
 
@@ -1189,7 +1102,7 @@ _cogl_texture_draw_and_read (CoglHandle   handle,
 }
 
 static gboolean
-get_texture_bits_via_offscreen (CoglHandle      texture_handle,
+get_texture_bits_via_offscreen (CoglTexture    *texture,
                                 int             x,
                                 int             y,
                                 int             width,
@@ -1206,7 +1119,7 @@ get_texture_bits_via_offscreen (CoglHandle      texture_handle,
     return FALSE;
 
   framebuffer = _cogl_offscreen_new_to_texture_full
-                                      (texture_handle,
+                                      (texture,
                                        COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
                                        0);
 
@@ -1227,7 +1140,7 @@ get_texture_bits_via_offscreen (CoglHandle      texture_handle,
 }
 
 static gboolean
-get_texture_bits_via_copy (CoglHandle      texture_handle,
+get_texture_bits_via_copy (CoglTexture    *texture,
                            int             x,
                            int             y,
                            int             width,
@@ -1236,25 +1149,24 @@ get_texture_bits_via_copy (CoglHandle      texture_handle,
                            unsigned int    dst_rowstride,
                            CoglPixelFormat dst_format)
 {
-  CoglTexture *tex = COGL_TEXTURE (texture_handle);
   unsigned int full_rowstride;
   guint8 *full_bits;
   gboolean ret = TRUE;
   int bpp;
   int full_tex_width, full_tex_height;
 
-  full_tex_width = cogl_texture_get_width (texture_handle);
-  full_tex_height = cogl_texture_get_height (texture_handle);
+  full_tex_width = cogl_texture_get_width (texture);
+  full_tex_height = cogl_texture_get_height (texture);
 
   bpp = _cogl_get_format_bpp (dst_format);
 
   full_rowstride = bpp * full_tex_width;
   full_bits = g_malloc (full_rowstride * full_tex_height);
 
-  if (tex->vtable->get_data (tex,
-                             dst_format,
-                             full_rowstride,
-                             full_bits))
+  if (texture->vtable->get_data (texture,
+                                 dst_format,
+                                 full_rowstride,
+                                 full_bits))
     {
       guint8 *dst = dst_bits;
       guint8 *src = full_bits + x * bpp + y * full_rowstride;
@@ -1285,18 +1197,17 @@ typedef struct
 } CoglTextureGetData;
 
 static void
-texture_get_cb (CoglHandle   texture_handle,
+texture_get_cb (CoglTexture *texture,
                 const float *subtexture_coords,
                 const float *virtual_coords,
                 void        *user_data)
 {
-  CoglTexture *tex = COGL_TEXTURE (texture_handle);
   CoglTextureGetData *tg_data = user_data;
   CoglPixelFormat format = _cogl_bitmap_get_format (tg_data->target_bmp);
   int bpp = _cogl_get_format_bpp (format);
   unsigned int rowstride = _cogl_bitmap_get_rowstride (tg_data->target_bmp);
-  int subtexture_width = cogl_texture_get_width (texture_handle);
-  int subtexture_height = cogl_texture_get_height (texture_handle);
+  int subtexture_width = cogl_texture_get_width (texture);
+  int subtexture_height = cogl_texture_get_height (texture);
 
   int x_in_subtexture = (int) (0.5 + subtexture_width * subtexture_coords[0]);
   int y_in_subtexture = (int) (0.5 + subtexture_height * subtexture_coords[1]);
@@ -1321,15 +1232,15 @@ texture_get_cb (CoglHandle   texture_handle,
   if (x_in_subtexture == 0 && y_in_subtexture == 0 &&
       width == subtexture_width && height == subtexture_height)
     {
-      if (tex->vtable->get_data (tex,
-                                 format,
-                                 rowstride,
-                                 dst_bits))
+      if (texture->vtable->get_data (texture,
+                                     format,
+                                     rowstride,
+                                     dst_bits))
         return;
     }
 
   /* Next best option is a FBO and glReadPixels */
-  if (get_texture_bits_via_offscreen (texture_handle,
+  if (get_texture_bits_via_offscreen (texture,
                                       x_in_subtexture, y_in_subtexture,
                                       width, height,
                                       dst_bits,
@@ -1338,7 +1249,7 @@ texture_get_cb (CoglHandle   texture_handle,
     return;
 
   /* Getting ugly: read the entire texture, copy out the part we want */
-  if (get_texture_bits_via_copy (texture_handle,
+  if (get_texture_bits_via_copy (texture,
                                  x_in_subtexture, y_in_subtexture,
                                  width, height,
                                  dst_bits,
@@ -1352,12 +1263,11 @@ texture_get_cb (CoglHandle   texture_handle,
 }
 
 int
-cogl_texture_get_data (CoglHandle       handle,
+cogl_texture_get_data (CoglTexture     *texture,
 		       CoglPixelFormat  format,
 		       unsigned int     rowstride,
 		       guint8          *data)
 {
-  CoglTexture     *tex;
   int              bpp;
   int              byte_size;
   CoglPixelFormat  closest_format;
@@ -1376,17 +1286,12 @@ cogl_texture_get_data (CoglHandle       handle,
 
   _COGL_GET_CONTEXT (ctx, 0);
 
-  if (!cogl_is_texture (handle))
-    return 0;
-
-  tex = COGL_TEXTURE (handle);
-
   /* Default to internal format if none specified */
   if (format == COGL_PIXEL_FORMAT_ANY)
-    format = cogl_texture_get_format (handle);
+    format = cogl_texture_get_format (texture);
 
-  tex_width = cogl_texture_get_width (handle);
-  tex_height = cogl_texture_get_height (handle);
+  tex_width = cogl_texture_get_width (texture);
+  tex_height = cogl_texture_get_height (texture);
 
   /* Rowstride from texture width if none specified */
   bpp = _cogl_get_format_bpp (format);
@@ -1442,7 +1347,7 @@ cogl_texture_get_data (CoglHandle       handle,
    * the data for a sliced texture, and allows us to do the
    * read-from-framebuffer logic here in a simple fashion rather than
    * passing offsets down through the code. */
-  _cogl_texture_foreach_sub_texture_in_region (handle,
+  _cogl_texture_foreach_sub_texture_in_region (texture,
                                                0, 0, 1, 1,
                                                texture_get_cb,
                                                &tg_data);
@@ -1454,7 +1359,7 @@ cogl_texture_get_data (CoglHandle       handle,
    * support glGetTexImage, so here we fallback to drawing the
    * texture and reading the pixels from the framebuffer. */
   if (!tg_data.success)
-    _cogl_texture_draw_and_read (tex, target_bmp,
+    _cogl_texture_draw_and_read (texture, target_bmp,
                                  closest_gl_format,
                                  closest_gl_type);
 
@@ -1512,40 +1417,37 @@ _cogl_texture_framebuffer_destroy_cb (void *user_data,
 }
 
 void
-_cogl_texture_associate_framebuffer (CoglHandle handle,
+_cogl_texture_associate_framebuffer (CoglTexture *texture,
                                      CoglFramebuffer *framebuffer)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
   static CoglUserDataKey framebuffer_destroy_notify_key;
 
   /* Note: we don't take a reference on the framebuffer here because
    * that would introduce a circular reference. */
-  tex->framebuffers = g_list_prepend (tex->framebuffers, framebuffer);
+  texture->framebuffers = g_list_prepend (texture->framebuffers, framebuffer);
 
   /* Since we haven't taken a reference on the framebuffer we setup
-   * some private data so we will be notified if it is destroyed... */
+    * some private data so we will be notified if it is destroyed... */
   _cogl_object_set_user_data (COGL_OBJECT (framebuffer),
                               &framebuffer_destroy_notify_key,
-                              tex,
+                              texture,
                               _cogl_texture_framebuffer_destroy_cb);
 }
 
 const GList *
-_cogl_texture_get_associated_framebuffers (CoglHandle handle)
+_cogl_texture_get_associated_framebuffers (CoglTexture *texture)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
-  return tex->framebuffers;
+  return texture->framebuffers;
 }
 
 void
-_cogl_texture_flush_journal_rendering (CoglHandle handle)
+_cogl_texture_flush_journal_rendering (CoglTexture *texture)
 {
-  CoglTexture *tex = COGL_TEXTURE (handle);
   GList *l;
 
   /* It could be that a referenced texture is part of a framebuffer
    * which has an associated journal that must be flushed before it
    * can be sampled from by the current primitive... */
-  for (l = tex->framebuffers; l; l = l->next)
+  for (l = texture->framebuffers; l; l = l->next)
     _cogl_framebuffer_flush_journal (l->data);
 }
diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h
index 41e6ee4..12a6b74 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -30,6 +30,9 @@
 
 #include <cogl/cogl-types.h>
 #include <cogl/cogl-defines.h>
+#if defined (COGL_ENABLE_EXPERIMENTAL_API)
+#include <cogl/cogl-pixel-buffer.h>
+#endif
 
 G_BEGIN_DECLS
 
@@ -37,11 +40,14 @@ G_BEGIN_DECLS
  * SECTION:cogl-texture
  * @short_description: Fuctions for creating and manipulating textures
  *
- * COGL allows creating and manipulating GL textures using a uniform
+ * Cogl allows creating and manipulating textures using a uniform
  * API that tries to hide all the various complexities of creating,
  * loading and manipulating textures.
  */
 
+typedef struct _CoglTexture CoglTexture;
+#define COGL_TEXTURE(X) ((CoglTexture *)X)
+
 #define COGL_TEXTURE_MAX_WASTE  127
 
 /**
@@ -80,14 +86,13 @@ GQuark cogl_texture_error_quark (void);
  * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
  *    texture.
  *
- * Creates a new COGL texture with the specified dimensions and pixel format.
+ * Creates a new #CoglTexture with the specified dimensions and pixel format.
  *
- * Return value: a #CoglHandle to the newly created texture or
- *   %COGL_INVALID_HANDLE on failure
+ * Return value: A newly created #CoglTexture or %NULL on failure
  *
  * Since: 0.8
  */
-CoglHandle
+CoglTexture *
 cogl_texture_new_with_size (unsigned int width,
                             unsigned int height,
                             CoglTextureFlags flags,
@@ -107,14 +112,13 @@ cogl_texture_new_with_size (unsigned int width,
  *    other than straight blending.
  * @error: return location for a #GError or %NULL
  *
- * Creates a COGL texture from an image file.
+ * Creates a #CoglTexture from an image file.
  *
- * Return value: a #CoglHandle to the newly created texture or
- *    %COGL_INVALID_HANDLE on failure
+ * Return value: A newly created #CoglTexture or %NULL on failure
  *
  * Since: 0.8
  */
-CoglHandle
+CoglTexture *
 cogl_texture_new_from_file (const char       *filename,
                             CoglTextureFlags   flags,
                             CoglPixelFormat    internal_format,
@@ -138,14 +142,13 @@ cogl_texture_new_from_file (const char       *filename,
  *    scanlines in @data
  * @data: pointer the memory region where the source buffer resides
  *
- * Creates a new COGL texture based on data residing in memory.
+ * Creates a new #CoglTexture based on data residing in memory.
  *
- * Return value: a #CoglHandle to the newly created texture or
- *   %COGL_INVALID_HANDLE on failure
+ * Return value: A newly created #CoglTexture or %NULL on failure
  *
  * Since: 0.8
  */
-CoglHandle
+CoglTexture *
 cogl_texture_new_from_data (unsigned int      width,
                             unsigned int      height,
                             CoglTextureFlags  flags,
@@ -164,7 +167,7 @@ cogl_texture_new_from_data (unsigned int      width,
  * @y_pot_waste: vertical waste on the bottom edge of the texture.
  * @format: format of the foreign texture.
  *
- * Creates a COGL texture based on an existing OpenGL texture; the
+ * Creates a #CoglTexture based on an existing OpenGL texture; the
  * width, height and format are passed along since it is not always
  * possible to query these from OpenGL.
  *
@@ -175,12 +178,11 @@ cogl_texture_new_from_data (unsigned int      width,
  * the waste arguments to tell Cogl which region should be mapped to
  * the texture coordinate range [0:1].
  *
- * Return value: a #CoglHandle to the newly created texture or
- *   %COGL_INVALID_HANDLE on failure
+ * Return value: A newly created #CoglTexture or %NULL on failure
  *
  * Since: 0.8
  */
-CoglHandle
+CoglTexture *
 cogl_texture_new_from_foreign (GLuint          gl_handle,
                                GLenum          gl_target,
                                GLuint          width,
@@ -191,83 +193,82 @@ cogl_texture_new_from_foreign (GLuint          gl_handle,
 
 /**
  * cogl_texture_new_from_bitmap:
- * @bmp_handle: A CoglBitmap handle
+ * @bitmap: A #CoglBitmap pointer
  * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
  * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
  * texture
  *
- * Creates a COGL texture from a CoglBitmap.
+ * Creates a #CoglTexture from a #CoglBitmap.
  *
- * Return value: a #CoglHandle to the newly created texture or
- *   %COGL_INVALID_HANDLE on failure
+ * Return value: A newly created #CoglTexture or %NULL on failure
  *
  * Since: 1.0
  */
-CoglHandle
-cogl_texture_new_from_bitmap (CoglHandle       bmp_handle,
+CoglTexture *
+cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
                               CoglTextureFlags flags,
-                              CoglPixelFormat  internal_format);
+                              CoglPixelFormat internal_format);
 
 /**
  * cogl_is_texture:
- * @handle: A CoglHandle
+ * @object: A #CoglObject pointer
  *
- * Gets whether the given handle references an existing texture object.
+ * Gets whether the given object references a texture object.
  *
  * Return value: %TRUE if the handle references a texture, and
  *   %FALSE otherwise
  */
 gboolean
-cogl_is_texture (CoglHandle handle);
+cogl_is_texture (void *object);
 
 /**
  * cogl_texture_get_width:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  *
  * Queries the width of a cogl texture.
  *
  * Return value: the width of the GPU side texture in pixels
  */
 unsigned int
-cogl_texture_get_width (CoglHandle handle);
+cogl_texture_get_width (CoglTexture *texture);
 
 /**
  * cogl_texture_get_height:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  *
  * Queries the height of a cogl texture.
  *
  * Return value: the height of the GPU side texture in pixels
  */
 unsigned int
-cogl_texture_get_height (CoglHandle handle);
+cogl_texture_get_height (CoglTexture *texture);
 
 /**
  * cogl_texture_get_format:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  *
  * Queries the #CoglPixelFormat of a cogl texture.
  *
  * Return value: the #CoglPixelFormat of the GPU side texture
  */
 CoglPixelFormat
-cogl_texture_get_format (CoglHandle handle);
+cogl_texture_get_format (CoglTexture *texture);
 
 
 /**
  * cogl_texture_get_rowstride:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  *
  * Queries the rowstride of a cogl texture.
  *
  * Return value: the offset in bytes between each consequetive row of pixels
  */
 unsigned int
-cogl_texture_get_rowstride (CoglHandle handle);
+cogl_texture_get_rowstride (CoglTexture *texture);
 
 /**
  * cogl_texture_get_max_waste:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  *
  * Queries the maximum wasted (unused) pixels in one dimension of a GPU side
  * texture.
@@ -275,11 +276,11 @@ cogl_texture_get_rowstride (CoglHandle handle);
  * Return value: the maximum waste
  */
 int
-cogl_texture_get_max_waste (CoglHandle handle);
+cogl_texture_get_max_waste (CoglTexture *texture);
 
 /**
  * cogl_texture_is_sliced:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  *
  * Queries if a texture is sliced (stored as multiple GPU side tecture
  * objects).
@@ -288,17 +289,17 @@ cogl_texture_get_max_waste (CoglHandle handle);
  *   is stored as a single GPU texture
  */
 gboolean
-cogl_texture_is_sliced (CoglHandle handle);
+cogl_texture_is_sliced (CoglTexture *texture);
 
 /**
  * cogl_texture_get_gl_texture:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  * @out_gl_handle: (out) (allow-none): pointer to return location for the
  *   textures GL handle, or %NULL.
  * @out_gl_target: (out) (allow-none): pointer to return location for the
  *   GL target type, or %NULL.
  *
- * Queries the GL handles for a GPU side texture through its #CoglHandle.
+ * Queries the GL handles for a GPU side texture through its #CoglTexture.
  *
  * If the texture is spliced the data for the first sub texture will be
  * queried.
@@ -307,13 +308,13 @@ cogl_texture_is_sliced (CoglHandle handle);
  *   if the handle was invalid
  */
 gboolean
-cogl_texture_get_gl_texture (CoglHandle   handle,
+cogl_texture_get_gl_texture (CoglTexture *texture,
                              GLuint      *out_gl_handle,
                              GLenum      *out_gl_target);
 
 /**
  * cogl_texture_get_data:
- * @handle: a #CoglHandle for a texture.
+ * @texture a #CoglTexture pointer.
  * @format: the #CoglPixelFormat to store the texture as.
  * @rowstride: the rowstride of @data or retrieved from texture if none is
  * specified.
@@ -326,14 +327,14 @@ cogl_texture_get_gl_texture (CoglHandle   handle,
  *   is not valid
  */
 int
-cogl_texture_get_data (CoglHandle       handle,
-                       CoglPixelFormat  format,
-                       unsigned int     rowstride,
-                       guint8          *data);
+cogl_texture_get_data (CoglTexture *texture,
+                       CoglPixelFormat format,
+                       unsigned int rowstride,
+                       guint8 *data);
 
 /**
  * cogl_texture_set_region:
- * @handle: a #CoglHandle.
+ * @texture a #CoglTexture.
  * @src_x: upper left coordinate to use from source data.
  * @src_y: upper left coordinate to use from source data.
  * @dst_x: upper left destination horizontal coordinate.
@@ -354,7 +355,7 @@ cogl_texture_get_data (CoglHandle       handle,
  *   %FALSE otherwise
  */
 gboolean
-cogl_texture_set_region (CoglHandle       handle,
+cogl_texture_set_region (CoglTexture     *texture,
                          int              src_x,
                          int              src_y,
                          int              dst_x,
@@ -373,7 +374,7 @@ cogl_texture_set_region (CoglHandle       handle,
   cogl_texture_set_region_from_bitmap_EXP
 /**
  * cogl_texture_set_region_from_bitmap:
- * @handle: a #CoglHandle for a texture
+ * @texture a #CoglTexture pointer
  * @src_x: upper left coordinate to use from the source bitmap.
  * @src_y: upper left coordinate to use from the source bitmap
  * @dst_x: upper left destination horizontal coordinate.
@@ -392,7 +393,7 @@ cogl_texture_set_region (CoglHandle       handle,
  * Stability: unstable
  */
 gboolean
-cogl_texture_set_region_from_bitmap (CoglHandle handle,
+cogl_texture_set_region_from_bitmap (CoglTexture *texture,
                                      int src_x,
                                      int src_y,
                                      int dst_x,
@@ -404,7 +405,7 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
 
 /**
  * cogl_texture_new_from_sub_texture:
- * @full_texture: a #CoglHandle to an existing texture
+ * @full_texture: a #CoglTexture pointer
  * @sub_x: X coordinate of the top-left of the subregion
  * @sub_y: Y coordinate of the top-left of the subregion
  * @sub_width: Width in pixels of the subregion
@@ -422,22 +423,22 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
  * not need to keep one separately if you only want to use the sub
  * texture.
  *
- * Return value: a #CoglHandle to the new texture.
- *
+ * Return value: A newly created #CoglTexture or %NULL on failure
  * Since: 1.2
  */
-CoglHandle
-cogl_texture_new_from_sub_texture (CoglHandle full_texture,
-                                   int        sub_x,
-                                   int        sub_y,
-                                   int        sub_width,
-                                   int        sub_height);
+CoglTexture *
+cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
+                                   int sub_x,
+                                   int sub_y,
+                                   int sub_width,
+                                   int sub_height);
 
 #if defined (COGL_ENABLE_EXPERIMENTAL_API)
 
+#define cogl_texture_new_from_buffer cogl_texture_new_from_buffer_EXP
 /**
  * cogl_texture_new_from_buffer:
- * @buffer: the #CoglHandle of a pixel buffer
+ * @buffer: A #CoglPixelBuffer pointer
  * @width: width of texture in pixels or 0
  * @height: height of texture in pixels or 0
  * @flags: optional flags for the texture, or %COGL_TEXTURE_NONE
@@ -459,14 +460,13 @@ cogl_texture_new_from_sub_texture (CoglHandle full_texture,
  * has been created using cogl_pixel_buffer_new_for_size() it's possible to omit
  * the height and width values already specified at creation time.
  *
- * Return value: a #CoglHandle to the new texture or %COGL_INVALID_HANDLE on
- *    failure
+ * Return value: A newly created #CoglTexture or %NULL on failure
  *
  * Since: 1.2
  * Stability: Unstable
  */
-CoglHandle
-cogl_texture_new_from_buffer  (CoglHandle       buffer,
+CoglTexture *
+cogl_texture_new_from_buffer  (CoglPixelBuffer *buffer,
                                unsigned int     width,
                                unsigned int     height,
                                CoglTextureFlags flags,
@@ -474,51 +474,33 @@ cogl_texture_new_from_buffer  (CoglHandle       buffer,
                                CoglPixelFormat  internal_format,
                                unsigned int     rowstride,
                                unsigned int     offset);
-
-/* the function above is experimental, the actual symbol is suffixed by _EXP so
- * we can ensure ABI compatibility and leave the cogl_buffer namespace free for
- * future use. A bunch of defines translates the symbols documented above into
- * the real symbols */
-
-CoglHandle
-cogl_texture_new_from_buffer_EXP (CoglHandle       buffer,
-                                  unsigned int     width,
-                                  unsigned int     height,
-                                  CoglTextureFlags flags,
-                                  CoglPixelFormat  format,
-                                  CoglPixelFormat  internal_format,
-                                  unsigned int     rowstride,
-                                  unsigned int     offset);
-
-#define cogl_texture_new_from_buffer cogl_texture_new_from_buffer_EXP
-
 #endif
 
 #ifndef COGL_DISABLE_DEPRECATED
 
 /**
  * cogl_texture_ref:
- * @handle: a @CoglHandle.
+ * @texture: a #CoglTexture.
  *
  * Increment the reference count for a cogl texture.
  *
- * Deprecated: 1.2: Use cogl_handle_ref() instead
+ * Deprecated: 1.2: Use cogl_object_ref() instead
  *
- * Return value: the @handle.
+ * Return value: the @texture pointer.
  */
-CoglHandle
-cogl_texture_ref (CoglHandle handle) G_GNUC_DEPRECATED;
+void *
+cogl_texture_ref (void *texture) G_GNUC_DEPRECATED;
 
 /**
  * cogl_texture_unref:
- * @handle: a @CoglHandle.
+ * @texture: a #CoglTexture.
  *
  * Decrement the reference count for a cogl texture.
  *
- * Deprecated: 1.2: Use cogl_handle_unref() instead
+ * Deprecated: 1.2: Use cogl_object_unref() instead
  */
 void
-cogl_texture_unref (CoglHandle handle) G_GNUC_DEPRECATED;
+cogl_texture_unref (void *texture) G_GNUC_DEPRECATED;
 
 #endif /* COGL_DISABLE_DEPRECATED */
 
diff --git a/cogl/cogl.c b/cogl/cogl.c
index 9bbc322..e81caa7 100644
--- a/cogl/cogl.c
+++ b/cogl/cogl.c
@@ -1004,13 +1004,13 @@ cogl_set_source (void *material_or_pipeline)
 }
 
 void
-cogl_set_source_texture (CoglHandle texture_handle)
+cogl_set_source_texture (CoglTexture *texture)
 {
   _COGL_GET_CONTEXT (ctx, NO_RETVAL);
 
-  g_return_if_fail (texture_handle != NULL);
+  g_return_if_fail (texture != NULL);
 
-  cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture_handle);
+  cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture);
   cogl_set_source (ctx->texture_pipeline);
 }
 
diff --git a/cogl/cogl.h b/cogl/cogl.h
index db4366b..240fa2a 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -693,10 +693,10 @@ cogl_set_source_color4f (float red,
 
 /**
  * cogl_set_source_texture:
- * @texture_handle: The Cogl texture you want as your source
+ * @texture: The #CoglTexture you want as your source
  *
  * This is a convenience function for creating a material with the first
- * layer set to #texture_handle and setting that material as the source with
+ * layer set to @texture and setting that material as the source with
  * cogl_set_source.
  *
  * Note: There is no interaction between calls to cogl_set_source_color
@@ -712,7 +712,7 @@ cogl_set_source_color4f (float red,
  * Since: 1.0
  */
 void
-cogl_set_source_texture (CoglHandle texture_handle);
+cogl_set_source_texture (CoglTexture *texture);
 
 /**
  * SECTION:cogl-clipping
diff --git a/cogl/cogl2-path.c b/cogl/cogl2-path.c
index 6b2757b..a5d6ad0 100644
--- a/cogl/cogl2-path.c
+++ b/cogl/cogl2-path.c
@@ -307,9 +307,9 @@ _cogl_path_fill_nodes (CoglPath *path)
   for (l = _cogl_pipeline_get_layers (cogl_get_source ()); l; l = l->next)
     {
       CoglHandle layer = l->data;
-      CoglHandle texture = _cogl_pipeline_layer_get_texture (layer);
+      CoglTexture *texture = _cogl_pipeline_layer_get_texture (layer);
 
-      if (texture != COGL_INVALID_HANDLE &&
+      if (texture != NULL &&
           (cogl_texture_is_sliced (texture) ||
            !_cogl_texture_can_hardware_repeat (texture)))
         {
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 767262e..90ddbb6 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -637,7 +637,7 @@ _cogl_texture_pixmap_x11_set_use_winsys_texture (CoglTexturePixmapX11 *tex_pixma
       /* 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
        * if the CoglTexture is reused with the same texture unit. */
-      _cogl_pipeline_texture_storage_change_notify (tex_pixmap);
+      _cogl_pipeline_texture_storage_change_notify (COGL_TEXTURE (tex_pixmap));
 
       tex_pixmap->use_winsys_texture = new_value;
     }
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 72b678e..e7c273a 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -179,7 +179,7 @@ typedef struct _CoglOnscreenEGL
 typedef struct _CoglTexturePixmapEGL
 {
   EGLImageKHR image;
-  CoglHandle texture;
+  CoglTexture *texture;
 } CoglTexturePixmapEGL;
 #endif
 
@@ -1699,13 +1699,13 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap)
                     COGL_PIXEL_FORMAT_RGBA_8888_PRE :
                     COGL_PIXEL_FORMAT_RGB_888);
 
-  egl_tex_pixmap->texture =
+  egl_tex_pixmap->texture = COGL_TEXTURE (
     _cogl_egl_texture_2d_new_from_image (ctx,
                                          tex_pixmap->width,
                                          tex_pixmap->height,
                                          texture_format,
                                          egl_tex_pixmap->image,
-                                         NULL);
+                                         NULL));
 
   tex_pixmap->winsys = egl_tex_pixmap;
 
@@ -1727,7 +1727,7 @@ _cogl_winsys_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
   egl_tex_pixmap = tex_pixmap->winsys;
 
   if (egl_tex_pixmap->texture)
-    cogl_handle_unref (egl_tex_pixmap->texture);
+    cogl_object_unref (egl_tex_pixmap->texture);
 
   if (egl_tex_pixmap->image != EGL_NO_IMAGE_KHR)
     _cogl_egl_destroy_image (ctx, egl_tex_pixmap->image);
diff --git a/examples/crate.c b/examples/crate.c
index e6a83b1..506b931 100644
--- a/examples/crate.c
+++ b/examples/crate.c
@@ -10,7 +10,7 @@ typedef struct _Data
   CoglMatrix view;
 
   CoglPrimitive *prim;
-  CoglHandle texture;
+  CoglTexture *texture;
   CoglPipeline *crate_pipeline;
 
   /* The cube continually rotates around each axis. */



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