[Cogl] [PATCH 13/13] remove internal_format and redundant error arguments

Robert Bragg robert at sixbynine.org
Wed Dec 11 10:31:34 PST 2013


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

Texture allocation is now consistently handled lazily such that the
internal format can now be controlled using
cogl_texture_set_components() and cogl_texture_set_premultiplied()
before allocating the texture with cogl_texture_allocate(). This means
that the internal_format arguments to texture constructors are now
redundant and since most of the texture constructors now can't ever fail
the error arguments are also redundant. This now means we no longer
use CoglPixelFormat in the public api for describing the internal format
of textures which had been bad solution originally due to how specific
CoglPixelFormat is which is missleading when we don't support such
explicit control over the internal format.
---
 cogl-gst/cogl-gst-video-sink.c                     | 40 +++++------
 cogl-pango/cogl-pango-glyph-cache.c                |  7 +-
 cogl/cogl-atlas-texture-private.h                  |  6 --
 cogl/cogl-atlas-texture.c                          | 30 +++-----
 cogl/cogl-atlas-texture.h                          | 55 ++++-----------
 cogl/cogl-atlas.c                                  | 40 +++++++----
 cogl/cogl-context.c                                |  6 +-
 cogl/cogl-gles2-context.c                          |  9 +--
 cogl/cogl-gles2.h                                  |  6 +-
 cogl/cogl-texture-2d-gl.h                          |  9 +--
 cogl/cogl-texture-2d-private.h                     |  6 --
 cogl/cogl-texture-2d-sliced-private.h              |  7 --
 cogl/cogl-texture-2d-sliced.c                      | 45 ++++--------
 cogl/cogl-texture-2d-sliced.h                      | 35 +---------
 cogl/cogl-texture-2d.c                             | 80 +++++++++++-----------
 cogl/cogl-texture-2d.h                             | 40 +----------
 cogl/cogl-texture-3d.c                             | 25 ++-----
 cogl/cogl-texture-3d.h                             | 30 +-------
 cogl/cogl-texture-private.h                        |  6 +-
 cogl/cogl-texture-rectangle.c                      | 23 ++-----
 cogl/cogl-texture-rectangle.h                      | 41 ++++-------
 cogl/cogl-texture.c                                | 18 ++++-
 cogl/driver/gl/cogl-framebuffer-gl.c               | 17 ++---
 cogl/driver/gl/cogl-texture-2d-gl.c                |  3 +-
 cogl/winsys/cogl-texture-pixmap-x11.c              | 10 +--
 cogl/winsys/cogl-winsys-glx.c                      | 10 +--
 examples/cogl-crate.c                              |  1 -
 examples/cogl-gles2-context.c                      |  3 +-
 examples/cogl-msaa.c                               |  4 +-
 examples/cogl-point-sprites.c                      |  1 -
 test-fixtures/test-utils.c                         | 49 +++++++------
 test-fixtures/test-utils.h                         | 32 ++++-----
 tests/conform/test-alpha-test.c                    |  1 -
 tests/conform/test-alpha-textures.c                |  1 -
 tests/conform/test-atlas-migration.c               |  6 +-
 tests/conform/test-backface-culling.c              |  4 +-
 tests/conform/test-blend-strings.c                 |  7 +-
 tests/conform/test-color-mask.c                    |  2 +-
 tests/conform/test-copy-replace-texture.c          |  1 -
 tests/conform/test-framebuffer-get-bits.c          |  8 +--
 tests/conform/test-gles2-context.c                 |  6 +-
 tests/conform/test-just-vertex-shader.c            |  1 -
 tests/conform/test-map-buffer-range.c              |  1 -
 tests/conform/test-npot-texture.c                  |  1 -
 tests/conform/test-offscreen.c                     |  6 +-
 tests/conform/test-pipeline-cache-unrefs-texture.c |  1 -
 tests/conform/test-pipeline-shader-state.c         |  3 +-
 tests/conform/test-pixel-buffer.c                  |  5 +-
 tests/conform/test-point-sprite.c                  |  1 -
 tests/conform/test-premult.c                       | 57 ++++++++-------
 tests/conform/test-primitive.c                     |  1 -
 tests/conform/test-read-texture-formats.c          |  1 -
 tests/conform/test-snippets.c                      |  1 -
 tests/conform/test-sub-texture.c                   |  2 -
 tests/conform/test-texture-3d.c                    |  3 -
 tests/conform/test-texture-get-set-data.c          | 16 +++--
 tests/conform/test-texture-mipmap-get-set.c        |  1 -
 tests/conform/test-texture-no-allocate.c           | 14 ++--
 tests/conform/test-wrap-modes.c                    |  1 -
 tests/conform/test-wrap-rectangle-textures.c       |  5 +-
 60 files changed, 308 insertions(+), 543 deletions(-)

diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 9a811b2..a811484 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -470,10 +470,8 @@ video_texture_new_from_data (CoglContext *ctx,
                              int width,
                              int height,
                              CoglPixelFormat format,
-                             CoglPixelFormat internal_format,
                              int rowstride,
-                             const uint8_t *data,
-                             CoglError **error)
+                             const uint8_t *data)
 {
   CoglBitmap *bitmap;
   CoglTexture *tex;
@@ -489,9 +487,7 @@ video_texture_new_from_data (CoglContext *ctx,
        is_pot (cogl_bitmap_get_height (bitmap))) ||
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC))
     {
-      tex = cogl_texture_2d_new_from_bitmap (bitmap,
-                                             internal_format,
-                                             &internal_error);
+      tex = cogl_texture_2d_new_from_bitmap (bitmap);
       if (!tex)
         {
           cogl_error_free (internal_error);
@@ -504,12 +500,8 @@ video_texture_new_from_data (CoglContext *ctx,
   if (!tex)
     {
       /* Otherwise create a sliced texture */
-      CoglTexture2DSliced *tex_2ds =
-        cogl_texture_2d_sliced_new_from_bitmap (bitmap,
-                                                -1, /* no maximum waste */
-                                                internal_format,
-                                                error);
-      tex = tex_2ds;
+      tex = cogl_texture_2d_sliced_new_from_bitmap (bitmap,
+                                                    -1); /* no maximum waste */
     }
 
   cogl_object_unref (bitmap);
@@ -537,9 +529,9 @@ cogl_gst_rgb24_upload (CoglGstVideoSink *sink,
 
   priv->frame[0] = video_texture_new_from_data (priv->ctx, priv->info.width,
                                                 priv->info.height,
-                                                format, format,
+                                                format,
                                                 priv->info.stride[0],
-                                                frame.data[0], NULL);
+                                                frame.data[0]);
 
   gst_video_frame_unmap (&frame);
 
@@ -583,9 +575,9 @@ cogl_gst_rgb32_upload (CoglGstVideoSink *sink,
 
   priv->frame[0] = video_texture_new_from_data (priv->ctx, priv->info.width,
                                                 priv->info.height,
-                                                format, format,
+                                                format,
                                                 priv->info.stride[0],
-                                                frame.data[0], NULL);
+                                                frame.data[0]);
 
   gst_video_frame_unmap (&frame);
 
@@ -671,22 +663,22 @@ cogl_gst_i420_upload (CoglGstVideoSink *sink,
     video_texture_new_from_data (priv->ctx,
                                  GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 0),
                                  GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 0),
-                                 format, format,
-                                 priv->info.stride[0], frame.data[0], NULL);
+                                 format,
+                                 priv->info.stride[0], frame.data[0]);
 
   priv->frame[1] =
     video_texture_new_from_data (priv->ctx,
                                  GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 1),
                                  GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 1),
-                                 format, format,
-                                 priv->info.stride[1], frame.data[1], NULL);
+                                 format,
+                                 priv->info.stride[1], frame.data[1]);
 
   priv->frame[2] =
     video_texture_new_from_data (priv->ctx,
                                  GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 2),
                                  GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 2),
-                                 format, format,
-                                 priv->info.stride[2], frame.data[2], NULL);
+                                 format,
+                                 priv->info.stride[2], frame.data[2]);
 
   gst_video_frame_unmap (&frame);
 
@@ -814,9 +806,9 @@ cogl_gst_ayuv_upload (CoglGstVideoSink *sink,
 
   priv->frame[0] = video_texture_new_from_data (priv->ctx, priv->info.width,
                                                 priv->info.height,
-                                                format, format,
+                                                format,
                                                 priv->info.stride[0],
-                                                frame.data[0], NULL);
+                                                frame.data[0]);
 
   gst_video_frame_unmap (&frame);
 
diff --git a/cogl-pango/cogl-pango-glyph-cache.c b/cogl-pango/cogl-pango-glyph-cache.c
index d7da0bc..7b1d5d6 100644
--- a/cogl-pango/cogl-pango-glyph-cache.c
+++ b/cogl-pango/cogl-pango-glyph-cache.c
@@ -226,11 +226,8 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
 
   texture = cogl_atlas_texture_new_with_size (cache->ctx,
                                               value->draw_width,
-                                              value->draw_height,
-                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                              &ignore_error);
-
-  if (texture == NULL)
+                                              value->draw_height);
+  if (!cogl_texture_allocate (COGL_TEXTURE (texture), &ignore_error))
     {
       cogl_error_free (ignore_error);
       return FALSE;
diff --git a/cogl/cogl-atlas-texture-private.h b/cogl/cogl-atlas-texture-private.h
index 9b22669..47e20bf 100644
--- a/cogl/cogl-atlas-texture-private.h
+++ b/cogl/cogl-atlas-texture-private.h
@@ -54,12 +54,6 @@ struct _CoglAtlasTexture
   CoglTexture          *sub_texture;
 };
 
-CoglAtlasTexture *
-_cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
-                                     CoglPixelFormat internal_format,
-                                     CoglBool can_convert_in_place,
-                                     CoglError **error);
-
 void
 _cogl_atlas_texture_add_reorganize_callback (CoglContext *ctx,
                                              GHookFunc callback,
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index 93a2423..4c955f4 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -677,9 +677,7 @@ _cogl_atlas_texture_create_base (CoglContext *ctx,
 CoglAtlasTexture *
 cogl_atlas_texture_new_with_size (CoglContext *ctx,
                                   int width,
-                                  int height,
-                                  CoglPixelFormat internal_format,
-                                  CoglError **error)
+                                  int height)
 {
   CoglTextureLoader *loader;
 
@@ -693,7 +691,8 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
   loader->src.sized.height = height;
 
   return _cogl_atlas_texture_create_base (ctx, width, height,
-                                          internal_format, loader);
+                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+                                          loader);
 }
 
 static CoglBool
@@ -880,11 +879,9 @@ _cogl_atlas_texture_allocate (CoglTexture *tex,
   g_return_val_if_reached (FALSE);
 }
 
-CoglAtlasTexture *
+static CoglAtlasTexture *
 _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
-                                     CoglPixelFormat internal_format,
-                                     CoglBool can_convert_in_place,
-                                     CoglError **error)
+                                     CoglBool can_convert_in_place)
 {
   CoglTextureLoader *loader;
 
@@ -898,17 +895,14 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
   return _cogl_atlas_texture_create_base (_cogl_bitmap_get_context (bmp),
                                           cogl_bitmap_get_width (bmp),
                                           cogl_bitmap_get_height (bmp),
-                                          internal_format,
+                                          cogl_bitmap_get_format (bmp),
                                           loader);
 }
 
 CoglAtlasTexture *
-cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
-                                    CoglPixelFormat internal_format,
-                                    CoglError **error)
+cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp)
 {
-  return _cogl_atlas_texture_new_from_bitmap (bmp, internal_format,
-                                              FALSE, error);
+  return _cogl_atlas_texture_new_from_bitmap (bmp, FALSE);
 }
 
 CoglAtlasTexture *
@@ -916,7 +910,6 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
                                   int width,
                                   int height,
                                   CoglPixelFormat format,
-                                  CoglPixelFormat internal_format,
                                   int rowstride,
                                   const uint8_t *data,
                                   CoglError **error)
@@ -938,7 +931,7 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
                                   rowstride,
                                   (uint8_t *) data);
 
-  atlas_tex = cogl_atlas_texture_new_from_bitmap (bmp, internal_format, error);
+  atlas_tex = cogl_atlas_texture_new_from_bitmap (bmp);
 
   cogl_object_unref (bmp);
 
@@ -955,7 +948,6 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
 CoglAtlasTexture *
 cogl_atlas_texture_new_from_file (CoglContext *ctx,
                                   const char *filename,
-                                  CoglPixelFormat internal_format,
                                   CoglError **error)
 {
   CoglBitmap *bmp;
@@ -968,9 +960,7 @@ cogl_atlas_texture_new_from_file (CoglContext *ctx,
     return NULL;
 
   atlas_tex = _cogl_atlas_texture_new_from_bitmap (bmp,
-                                                   internal_format,
-                                                   TRUE, /* convert in-place */
-                                                   error);
+                                                   TRUE); /* convert in-place */
 
   cogl_object_unref (bmp);
 
diff --git a/cogl/cogl-atlas-texture.h b/cogl/cogl-atlas-texture.h
index 53803c6..e4fc594 100644
--- a/cogl/cogl-atlas-texture.h
+++ b/cogl/cogl-atlas-texture.h
@@ -67,7 +67,6 @@ typedef struct _CoglAtlasTexture CoglAtlasTexture;
  * @ctx: A #CoglContext
  * @width: The width of your atlased texture.
  * @height: The height of your atlased texture.
- * @internal_format: The format of the texture
  *
  * Creates a #CoglAtlasTexture with a given @width and @height. A
  * #CoglAtlasTexture represents a sub-region within one of Cogl's
@@ -83,32 +82,28 @@ typedef struct _CoglAtlasTexture CoglAtlasTexture;
  * using cogl_texture_set_components() and
  * cogl_texture_set_premultiplied().
  *
- * <note>This call can fail if Cogl considers the given
- * @internal_format incompatible with the format of its internal
+ * <note>Allocate call can fail if Cogl considers the internal
+ * format to be incompatible with the format of its internal
  * atlases.</note>
  *
  * <note>The returned #CoglAtlasTexture is a high-level meta-texture
  * with some limitations. See the documentation for #CoglMetaTexture
  * for more details.</note>
  *
- * Return value: (transfer full): A new #CoglAtlasTexture object with
- *          no storage allocated yet or %NULL on failure and @error
- *          will be updated.
+ * Returns: (transfer full): A new #CoglAtlasTexture object.
  * Since: 1.16
  * Stability: unstable
  */
 CoglAtlasTexture *
 cogl_atlas_texture_new_with_size (CoglContext *ctx,
                                   int width,
-                                  int height,
-                                  CoglPixelFormat internal_format,
-                                  CoglError **error);
+                                  int height);
 
 /**
  * cogl_atlas_texture_new_from_file:
  * @ctx: A #CoglContext
  * @filename: the file to load
- * @internal_format: The format of the texture
+ * @error: A #CoglError to catch exceptional errors or %NULL
  *
  * Creates a #CoglAtlasTexture from an image file. A #CoglAtlasTexture
  * represents a sub-region within one of Cogl's shared texture
@@ -124,8 +119,8 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
  * using cogl_texture_set_components() and
  * cogl_texture_set_premultiplied().
  *
- * <note>Allocation can fail later if Cogl considers the given
- * @internal_format incompatible with the format of its internal
+ * <note>Allocate call can fail if Cogl considers the internal
+ * format to be incompatible with the format of its internal
  * atlases.</note>
  *
  * <note>The returned #CoglAtlasTexture is a high-level meta-texture
@@ -140,7 +135,6 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
 CoglAtlasTexture *
 cogl_atlas_texture_new_from_file (CoglContext *ctx,
                                   const char *filename,
-                                  CoglPixelFormat internal_format,
                                   CoglError **error);
 
 /**
@@ -149,14 +143,6 @@ cogl_atlas_texture_new_from_file (CoglContext *ctx,
  * @width: width of texture in pixels
  * @height: height of texture in pixels
  * @format: the #CoglPixelFormat the buffer is stored in in RAM
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
- *    format similar to the format of the source data will be used. The
- *    default blending equations of Cogl expect premultiplied color data;
- *    the main use of passing a non-premultiplied format here is if you
- *    have non-premultiplied source data and are going to adjust the blend
- *    mode (see cogl_material_set_blend()) or use the data for something
- *    other than straight blending.
  * @rowstride: the memory offset in bytes between the start of each
  *    row in @data. A value of 0 will make Cogl automatically
  *    calculate @rowstride from @width and @format.
@@ -178,8 +164,8 @@ cogl_atlas_texture_new_from_file (CoglContext *ctx,
  * cogl_atlas_texture_new_with_size() and then upload data using
  * cogl_texture_set_data()</note>
  *
- * <note>Allocation can fail if Cogl considers the given
- * @internal_format incompatible with the format of its internal
+ * <note>Allocate call can fail if Cogl considers the internal
+ * format to be incompatible with the format of its internal
  * atlases.</note>
  *
  * <note>The returned #CoglAtlasTexture is a high-level
@@ -196,23 +182,13 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
                                   int width,
                                   int height,
                                   CoglPixelFormat format,
-                                  CoglPixelFormat internal_format,
                                   int rowstride,
                                   const uint8_t *data,
                                   CoglError **error);
 
 /**
  * cogl_atlas_texture_new_from_bitmap:
- * @bmp: A #CoglBitmap
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
- *    format similar to the format of the source data will be used. The
- *    default blending equations of Cogl expect premultiplied color data;
- *    the main use of passing a non-premultiplied format here is if you
- *    have non-premultiplied source data and are going to adjust the blend
- *    mode (see cogl_material_set_blend()) or use the data for something
- *    other than straight blending.
- * @error: A #CoglError to catch exceptional errors or %NULL
+ * @bitmap: A #CoglBitmap
  *
  * Creates a new #CoglAtlasTexture texture based on data residing in a
  * @bitmap. A #CoglAtlasTexture represents a sub-region within one of
@@ -229,23 +205,20 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
  * using cogl_texture_set_components() and
  * cogl_texture_set_premultiplied().
  *
- * <note>Allocation can fail if Cogl considers the given
- * @internal_format incompatible with the format of its internal
+ * <note>Allocate call can fail if Cogl considers the internal
+ * format to be incompatible with the format of its internal
  * atlases.</note>
  *
  * <note>The returned #CoglAtlasTexture is a high-level meta-texture
  * with some limitations. See the documentation for #CoglMetaTexture
  * for more details.</note>
  *
- * Return value: (transfer full): A new #CoglAtlasTexture object or
- *          %NULL on failure and @error will be updated.
+ * Returns: (transfer full): A new #CoglAtlasTexture object.
  * Since: 1.16
  * Stability: unstable
  */
 CoglAtlasTexture *
-cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
-                                    CoglPixelFormat internal_format,
-                                    CoglError **error);
+cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp);
 
 /**
  * cogl_is_atlas_texture:
diff --git a/cogl/cogl-atlas.c b/cogl/cogl-atlas.c
index 23f430b..952c0cc 100644
--- a/cogl/cogl-atlas.c
+++ b/cogl/cogl-atlas.c
@@ -299,11 +299,17 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
                                             width * bpp,
                                             clear_data);
 
-      tex = cogl_texture_2d_new_from_bitmap (clear_bmp,
-                                             atlas->texture_format,
-                                             &ignore_error);
-      if (!tex)
-        cogl_error_free (ignore_error);
+      tex = cogl_texture_2d_new_from_bitmap (clear_bmp);
+
+      _cogl_texture_set_internal_format (COGL_TEXTURE (tex),
+                                         atlas->texture_format);
+
+      if (!cogl_texture_allocate (COGL_TEXTURE (tex), &ignore_error))
+        {
+          cogl_error_free (ignore_error);
+          cogl_object_unref (tex);
+          tex = NULL;
+        }
 
       cogl_object_unref (clear_bmp);
 
@@ -311,9 +317,11 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
     }
   else
     {
-      tex = cogl_texture_2d_new_with_size (ctx,
-                                           width, height,
-                                           atlas->texture_format);
+      tex = cogl_texture_2d_new_with_size (ctx, width, height);
+
+      _cogl_texture_set_internal_format (COGL_TEXTURE (tex),
+                                         atlas->texture_format);
+
       if (!cogl_texture_allocate (COGL_TEXTURE (tex), &ignore_error))
         {
           cogl_error_free (ignore_error);
@@ -557,8 +565,9 @@ create_migration_texture (CoglContext *ctx,
     {
       /* First try creating a fast-path non-sliced texture */
       tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
-                                                         width, height,
-                                                         internal_format));
+                                                         width, height));
+
+      _cogl_texture_set_internal_format (tex, internal_format);
 
       /* TODO: instead of allocating storage here it would be better
        * if we had some api that let us just check that the size is
@@ -580,8 +589,11 @@ create_migration_texture (CoglContext *ctx,
         cogl_texture_2d_sliced_new_with_size (ctx,
                                               width,
                                               height,
-                                              COGL_TEXTURE_MAX_WASTE,
-                                              internal_format);
+                                              COGL_TEXTURE_MAX_WASTE);
+
+      _cogl_texture_set_internal_format (COGL_TEXTURE (tex_2ds),
+                                         internal_format);
+
       tex = COGL_TEXTURE (tex_2ds);
     }
 
@@ -594,7 +606,7 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas,
                             int y,
                             int width,
                             int height,
-                            CoglPixelFormat format)
+                            CoglPixelFormat internal_format)
 {
   CoglTexture *tex;
   CoglBlitData blit_data;
@@ -603,7 +615,7 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas,
   _COGL_GET_CONTEXT (ctx, NULL);
 
   /* Create a new texture at the right size */
-  tex = create_migration_texture (ctx, width, height, format);
+  tex = create_migration_texture (ctx, width, height, internal_format);
   if (!cogl_texture_allocate (tex, &ignore_error))
     {
       cogl_error_free (ignore_error);
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 4e2e0b0..63cf39f 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -386,7 +386,6 @@ cogl_context_new (CoglDisplay *display,
     cogl_texture_2d_new_from_data (context,
                                    1, 1,
                                    COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                   COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                    0, /* rowstride */
                                    white_pixel,
                                    NULL); /* abort on error */
@@ -398,7 +397,6 @@ cogl_context_new (CoglDisplay *display,
     cogl_texture_3d_new_from_data (context,
                                    1, 1, 1, /* width, height, depth */
                                    COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                   COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                    0, /* rowstride */
                                    0, /* image stride */
                                    white_pixel,
@@ -416,9 +414,7 @@ cogl_context_new (CoglDisplay *display,
 
   internal_error = NULL;
   context->default_gl_texture_rect_tex =
-    cogl_texture_rectangle_new_from_bitmap (white_pixel_bitmap,
-                                            COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                            NULL); /* legacy error argument */
+    cogl_texture_rectangle_new_from_bitmap (white_pixel_bitmap);
 
   /* XXX: we need to allocate the texture now because the white_pixel
    * data is on the stack */
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index ebe70e2..fe87701 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -315,8 +315,7 @@ copy_flipped_texture (CoglGLES2Context *gles2_ctx,
                                            tex_id,
                                            tex_object_data->width,
                                            tex_object_data->height,
-                                           internal_format,
-                                           NULL /* error */);
+                                           internal_format);
 
   if (dst_texture)
     {
@@ -1936,15 +1935,13 @@ cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx,
                                        unsigned int handle,
                                        int width,
                                        int height,
-                                       CoglPixelFormat internal_format,
-                                       CoglError **error)
+                                       CoglPixelFormat format)
 {
   return cogl_texture_2d_gl_new_from_foreign (ctx,
                                               handle,
                                               width,
                                               height,
-                                              internal_format,
-                                              error);
+                                              format);
 }
 
 CoglBool
diff --git a/cogl/cogl-gles2.h b/cogl/cogl-gles2.h
index 9c551ad..a97ecdf 100644
--- a/cogl/cogl-gles2.h
+++ b/cogl/cogl-gles2.h
@@ -301,8 +301,7 @@ cogl_gles2_get_current_vtable (void);
  *          glGenTextures()
  * @width: Width of the texture to allocate
  * @height: Height of the texture to allocate
- * @internal_format: The format of the texture
- * @error: A #CoglError for exceptions
+ * @format: The format of the texture
  *
  * Creates a #CoglTexture2D from an OpenGL ES 2.0 texture handle that
  * was created within the given @gles2_ctx via glGenTextures(). The
@@ -326,8 +325,7 @@ cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx,
                                        unsigned int handle,
                                        int width,
                                        int height,
-                                       CoglPixelFormat internal_format,
-                                       CoglError **error);
+                                       CoglPixelFormat format);
 
 /**
  * cogl_gles2_texture_get_handle:
diff --git a/cogl/cogl-texture-2d-gl.h b/cogl/cogl-texture-2d-gl.h
index d635e50..656ee39 100644
--- a/cogl/cogl-texture-2d-gl.h
+++ b/cogl/cogl-texture-2d-gl.h
@@ -43,7 +43,6 @@ COGL_BEGIN_DECLS
  * @width: Width of the foreign GL texture
  * @height: Height of the foreign GL texture
  * @format: The format of the texture
- * @error: A #CoglError for exceptions
  *
  * Wraps an existing GL_TEXTURE_2D texture object as a #CoglTexture2D.
  * This can be used for integrating Cogl with software using OpenGL
@@ -57,10 +56,7 @@ COGL_BEGIN_DECLS
  * or if @width or @height don't have the correct texture
  * geometry.</note>
  *
- * Return value: (transfer full): A newly allocated #CoglTexture2D, or
- *          if Cogl could not validate the @gl_handle in some way
- *          (perhaps because of an unsupported format) it will return
- *          %NULL and set @error.
+ * Returns: (transfer full): A newly allocated #CoglTexture2D
  *
  * Since: 2.0
  */
@@ -69,8 +65,7 @@ cogl_texture_2d_gl_new_from_foreign (CoglContext *ctx,
                                      unsigned int gl_handle,
                                      int width,
                                      int height,
-                                     CoglPixelFormat format,
-                                     CoglError **error);
+                                     CoglPixelFormat format);
 
 COGL_END_DECLS
 
diff --git a/cogl/cogl-texture-2d-private.h b/cogl/cogl-texture-2d-private.h
index 3d6c3c5..dee4117 100644
--- a/cogl/cogl-texture-2d-private.h
+++ b/cogl/cogl-texture-2d-private.h
@@ -59,12 +59,6 @@ struct _CoglTexture2D
   CoglTexturePixel first_pixel;
 };
 
-CoglTexture2D *
-_cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
-                                  CoglPixelFormat internal_format,
-                                  CoglBool can_convert_in_place,
-                                  CoglError **error);
-
 #if defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base)
 /* NB: The reason we require the width, height and format to be passed
  * even though they may seem redundant is because GLES 1/2 don't
diff --git a/cogl/cogl-texture-2d-sliced-private.h b/cogl/cogl-texture-2d-sliced-private.h
index 8e8e69c..e6eab7a 100644
--- a/cogl/cogl-texture-2d-sliced-private.h
+++ b/cogl/cogl-texture-2d-sliced-private.h
@@ -42,11 +42,4 @@ struct _CoglTexture2DSliced
   CoglPixelFormat internal_format;
 };
 
-CoglTexture2DSliced *
-_cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
-                                         int max_waste,
-                                         CoglPixelFormat internal_format,
-                                         CoglBool can_convert_in_place,
-                                         CoglError **error);
-
 #endif /* __COGL_TEXTURE_2D_SLICED_PRIVATE_H */
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index e79a2db..bfaad50 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -881,8 +881,10 @@ allocate_slices (CoglTexture2DSliced *tex_2ds,
 
           slice = COGL_TEXTURE (
             cogl_texture_2d_new_with_size (ctx,
-                                           x_span->size, y_span->size,
-                                           internal_format));
+                                           x_span->size, y_span->size));
+
+          _cogl_texture_copy_internal_format (tex, slice);
+
           g_array_append_val (tex_2ds->slice_textures, slice);
           if (!cogl_texture_allocate (slice, error))
             {
@@ -927,16 +929,9 @@ CoglTexture2DSliced *
 cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
                                       int width,
                                       int height,
-                                      int max_waste,
-                                      CoglPixelFormat internal_format)
+                                      int max_waste)
 {
-  CoglTextureLoader *loader;
-
-  /* Since no data, we need some internal format */
-  if (internal_format == COGL_PIXEL_FORMAT_ANY)
-    internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
-
-  loader = _cogl_texture_create_loader ();
+  CoglTextureLoader *loader = _cogl_texture_create_loader ();
   loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
   loader->src.sized.width = width;
   loader->src.sized.height = height;
@@ -945,16 +940,14 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
                                               width,
                                               height,
                                               max_waste,
-                                              internal_format,
+                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                               loader);
 }
 
-CoglTexture2DSliced *
+static CoglTexture2DSliced *
 _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
                                          int max_waste,
-                                         CoglPixelFormat internal_format,
-                                         CoglBool can_convert_in_place,
-                                         CoglError **error)
+                                         CoglBool can_convert_in_place)
 {
   CoglTextureLoader *loader;
 
@@ -969,21 +962,17 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
                                               cogl_bitmap_get_width (bmp),
                                               cogl_bitmap_get_height (bmp),
                                               max_waste,
-                                              internal_format,
+                                              cogl_bitmap_get_format (bmp),
                                               loader);
 }
 
 CoglTexture2DSliced *
 cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
-                                        int max_waste,
-                                        CoglPixelFormat internal_format,
-                                        CoglError **error)
+                                        int max_waste)
 {
   return _cogl_texture_2d_sliced_new_from_bitmap (bmp,
                                                   max_waste,
-                                                  internal_format,
-                                                  FALSE,
-                                                  error);
+                                                  FALSE);
 }
 
 CoglTexture2DSliced *
@@ -992,7 +981,6 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
                                       int height,
                                       int max_waste,
                                       CoglPixelFormat format,
-                                      CoglPixelFormat internal_format,
                                       int rowstride,
                                       const uint8_t *data,
                                       CoglError **error)
@@ -1014,9 +1002,7 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
                                   rowstride,
                                   (uint8_t *) data);
 
-  tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, max_waste,
-                                                    internal_format,
-                                                    error);
+  tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, max_waste);
 
   cogl_object_unref (bmp);
 
@@ -1034,7 +1020,6 @@ CoglTexture2DSliced *
 cogl_texture_2d_sliced_new_from_file (CoglContext *ctx,
                                       const char *filename,
                                       int max_waste,
-                                      CoglPixelFormat internal_format,
                                       CoglError **error)
 {
   CoglBitmap *bmp;
@@ -1048,9 +1033,7 @@ cogl_texture_2d_sliced_new_from_file (CoglContext *ctx,
 
   tex_2ds = _cogl_texture_2d_sliced_new_from_bitmap (bmp,
                                            max_waste,
-                                           internal_format,
-                                           TRUE, /* can convert in-place */
-                                           error);
+                                           TRUE); /* can convert in-place */
 
   cogl_object_unref (bmp);
 
diff --git a/cogl/cogl-texture-2d-sliced.h b/cogl/cogl-texture-2d-sliced.h
index c52d5d6..94fdf22 100644
--- a/cogl/cogl-texture-2d-sliced.h
+++ b/cogl/cogl-texture-2d-sliced.h
@@ -73,7 +73,6 @@ typedef struct _CoglTexture2DSliced CoglTexture2DSliced;
  *             are allowed along the right and bottom textures before
  *             they must be sliced to reduce the amount of waste. A
  *             negative can be passed to disable slicing.
- * @internal_format: The format of the texture
  *
  * Creates a #CoglTexture2DSliced that may internally be comprised of
  * 1 or more #CoglTexture2D textures depending on GPU limitations.
@@ -110,8 +109,7 @@ CoglTexture2DSliced *
 cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
                                       int width,
                                       int height,
-                                      int max_waste,
-                                      CoglPixelFormat internal_format);
+                                      int max_waste);
 
 /**
  * cogl_texture_2d_sliced_new_from_file:
@@ -121,14 +119,6 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
  *             are allowed along the right and bottom textures before
  *             they must be sliced to reduce the amount of waste. A
  *             negative can be passed to disable slicing.
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
- *    format similar to the format of the source data will be used. The
- *    default blending equations of Cogl expect premultiplied color data;
- *    the main use of passing a non-premultiplied format here is if you
- *    have non-premultiplied source data and are going to adjust the blend
- *    mode (see cogl_material_set_blend()) or use the data for something
- *    other than straight blending.
  * @error: A #CoglError to catch exceptional errors or %NULL
  *
  * Creates a #CoglTexture2DSliced from an image file.
@@ -167,7 +157,6 @@ CoglTexture2DSliced *
 cogl_texture_2d_sliced_new_from_file (CoglContext *ctx,
                                       const char *filename,
                                       int max_waste,
-                                      CoglPixelFormat internal_format,
                                       CoglError **error);
 
 /**
@@ -180,14 +169,6 @@ cogl_texture_2d_sliced_new_from_file (CoglContext *ctx,
  *             are allowed along the right and bottom textures before
  *             they must be sliced to reduce the amount of waste. A
  *             negative can be passed to disable slicing.
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
- *    format similar to the format of the source data will be used. The
- *    default blending equations of Cogl expect premultiplied color data;
- *    the main use of passing a non-premultiplied format here is if you
- *    have non-premultiplied source data and are going to adjust the blend
- *    mode (see cogl_material_set_blend()) or use the data for something
- *    other than straight blending.
  * @rowstride: the memory offset in bytes between the start of each
  *    row in @data. A value of 0 will make Cogl automatically
  *    calculate @rowstride from @width and @format.
@@ -239,7 +220,6 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
                                       int height,
                                       int max_waste,
                                       CoglPixelFormat format,
-                                      CoglPixelFormat internal_format,
                                       int rowstride,
                                       const uint8_t *data,
                                       CoglError **error);
@@ -251,15 +231,6 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
  *             are allowed along the right and bottom textures before
  *             they must be sliced to reduce the amount of waste. A
  *             negative can be passed to disable slicing.
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
- *    format similar to the format of the source data will be used. The
- *    default blending equations of Cogl expect premultiplied color data;
- *    the main use of passing a non-premultiplied format here is if you
- *    have non-premultiplied source data and are going to adjust the blend
- *    mode (see cogl_material_set_blend()) or use the data for something
- *    other than straight blending.
- * @error: A #CoglError to catch exceptional errors or %NULL
  *
  * Creates a new #CoglTexture2DSliced texture based on data residing
  * in a bitmap.
@@ -296,9 +267,7 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
  */
 CoglTexture2DSliced *
 cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
-                                        int max_waste,
-                                        CoglPixelFormat internal_format,
-                                        CoglError **error);
+                                        int max_waste);
 
 /**
  * cogl_is_texture_2d_sliced:
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index 3a725cd..2f8808c 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -110,22 +110,17 @@ _cogl_texture_2d_create_base (CoglContext *ctx,
 CoglTexture2D *
 cogl_texture_2d_new_with_size (CoglContext *ctx,
                                int width,
-                               int height,
-                               CoglPixelFormat internal_format)
+                               int height)
 {
   CoglTextureLoader *loader;
 
-  /* Since no data, we need some internal format */
-  if (internal_format == COGL_PIXEL_FORMAT_ANY)
-    internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
-
   loader = _cogl_texture_create_loader ();
   loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
   loader->src.sized.width = width;
   loader->src.sized.height = height;
 
   return _cogl_texture_2d_create_base (ctx, width, height,
-                                       internal_format, loader);
+                                       COGL_PIXEL_FORMAT_RGBA_8888_PRE, loader);
 }
 
 static CoglBool
@@ -137,11 +132,9 @@ _cogl_texture_2d_allocate (CoglTexture *tex,
   return ctx->driver_vtable->texture_2d_allocate (tex, error);
 }
 
-CoglTexture2D *
+static CoglTexture2D *
 _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
-                                  CoglPixelFormat internal_format,
-                                  CoglBool can_convert_in_place,
-                                  CoglError **error)
+                                  CoglBool can_convert_in_place)
 {
   CoglTextureLoader *loader;
 
@@ -155,22 +148,20 @@ _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
   return  _cogl_texture_2d_create_base (_cogl_bitmap_get_context (bmp),
                                         cogl_bitmap_get_width (bmp),
                                         cogl_bitmap_get_height (bmp),
-                                        internal_format,
+                                        cogl_bitmap_get_format (bmp),
                                         loader);
 }
 
 CoglTexture2D *
-cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
-                                 CoglPixelFormat internal_format,
-                                 CoglError **error)
+cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp)
 {
-  return _cogl_texture_2d_new_from_bitmap (bmp, internal_format, FALSE, error);
+  return _cogl_texture_2d_new_from_bitmap (bmp,
+                                           FALSE); /* can't convert in place */
 }
 
 CoglTexture2D *
 cogl_texture_2d_new_from_file (CoglContext *ctx,
                                const char *filename,
-                               CoglPixelFormat internal_format,
                                CoglError **error)
 {
   CoglBitmap *bmp;
@@ -183,9 +174,7 @@ cogl_texture_2d_new_from_file (CoglContext *ctx,
     return NULL;
 
   tex_2d = _cogl_texture_2d_new_from_bitmap (bmp,
-                                             internal_format,
-                                             TRUE, /* can convert in-place */
-                                             error);
+                                             TRUE); /* can convert in-place */
 
   cogl_object_unref (bmp);
 
@@ -197,7 +186,6 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
                                int width,
                                int height,
                                CoglPixelFormat format,
-                               CoglPixelFormat internal_format,
                                int rowstride,
                                const uint8_t *data,
                                CoglError **error)
@@ -219,9 +207,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
                                   rowstride,
                                   (uint8_t *) data);
 
-  tex_2d = cogl_texture_2d_new_from_bitmap (bmp,
-                                            internal_format,
-                                            error);
+  tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
 
   cogl_object_unref (bmp);
 
@@ -273,10 +259,10 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
 static void
 shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
                                   CoglPixelFormat *format_out,
-                                  CoglPixelFormat *internal_format_out)
+                                  CoglTextureComponents *components_out)
 {
   CoglPixelFormat format;
-  CoglPixelFormat internal_format = COGL_PIXEL_FORMAT_ANY;
+  CoglTextureComponents components = COGL_TEXTURE_COMPONENTS_RGBA;
 
   switch (wl_shm_buffer_get_format (shm_buffer))
     {
@@ -286,7 +272,7 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
       break;
     case WL_SHM_FORMAT_XRGB8888:
       format = COGL_PIXEL_FORMAT_ARGB_8888;
-      internal_format = COGL_PIXEL_FORMAT_RGB_888;
+      components = COGL_TEXTURE_COMPONENTS_RGB;
       break;
 #elif G_BYTE_ORDER == G_LITTLE_ENDIAN
     case WL_SHM_FORMAT_ARGB8888:
@@ -294,7 +280,7 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
       break;
     case WL_SHM_FORMAT_XRGB8888:
       format = COGL_PIXEL_FORMAT_BGRA_8888;
-      internal_format = COGL_PIXEL_FORMAT_BGR_888;
+      components = COGL_TEXTURE_COMPONENTS_RGB;
       break;
 #endif
     default:
@@ -304,8 +290,8 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
 
   if (format_out)
     *format_out = format;
-  if (internal_format_out)
-    *internal_format_out = internal_format;
+  if (components_out)
+    *components_out = components;
 }
 
 CoglBool
@@ -345,6 +331,7 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
                                          CoglError **error)
 {
   struct wl_shm_buffer *shm_buffer;
+  CoglTexture2D *tex = NULL;
 
   shm_buffer = wl_shm_buffer_get (buffer);
 
@@ -353,17 +340,31 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
       int stride = wl_shm_buffer_get_stride (shm_buffer);
       int width = wl_shm_buffer_get_width (shm_buffer);
       int height = wl_shm_buffer_get_height (shm_buffer);
-      CoglPixelFormat format, internal_format;
+      CoglPixelFormat format;
+      CoglTextureComponents components;
+      CoglBitmap *bmp;
+
+      shm_buffer_get_cogl_pixel_format (shm_buffer, &format, &components);
+
+      bmp = cogl_bitmap_new_for_data (ctx,
+                                      width, height,
+                                      format,
+                                      stride,
+                                      wl_shm_buffer_get_data (shm_buffer));
 
-      shm_buffer_get_cogl_pixel_format (shm_buffer, &format, &internal_format);
+      tex = cogl_texture_2d_new_from_bitmap (bmp);
 
-      return cogl_texture_2d_new_from_data (ctx,
-                                            width, height,
-                                            format,
-                                            internal_format,
-                                            stride,
-                                            wl_shm_buffer_get_data (shm_buffer),
-                                            error);
+      cogl_texture_set_components (COGL_TEXTURE (tex), components);
+
+      cogl_object_unref (bmp);
+
+      if (!cogl_texture_allocate (COGL_TEXTURE (tex), error))
+        {
+          cogl_object_unref (tex);
+          return NULL;
+        }
+      else
+        return tex;
     }
   else
     {
@@ -383,7 +384,6 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
                                           &height))
         {
           EGLImageKHR image;
-          CoglTexture2D *tex = NULL;
           CoglPixelFormat internal_format;
 
           _COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->constraints &
diff --git a/cogl/cogl-texture-2d.h b/cogl/cogl-texture-2d.h
index 9b985c7..ae30b15 100644
--- a/cogl/cogl-texture-2d.h
+++ b/cogl/cogl-texture-2d.h
@@ -73,7 +73,6 @@ cogl_is_texture_2d (void *object);
  * @ctx: A #CoglContext
  * @width: Width of the texture to allocate
  * @height: Height of the texture to allocate
- * @internal_format: The format of the texture
  *
  * Creates a low-level #CoglTexture2D texture with a given @width and
  * @height that your GPU can texture from directly.
@@ -101,21 +100,12 @@ cogl_is_texture_2d (void *object);
 CoglTexture2D *
 cogl_texture_2d_new_with_size (CoglContext *ctx,
                                int width,
-                               int height,
-                               CoglPixelFormat internal_format);
+                               int height);
 
 /**
  * cogl_texture_2d_new_from_file:
  * @ctx: A #CoglContext
  * @filename: the file to load
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
- *    format similar to the format of the source data will be used. The
- *    default blending equations of Cogl expect premultiplied color data;
- *    the main use of passing a non-premultiplied format here is if you
- *    have non-premultiplied source data and are going to adjust the blend
- *    mode (see cogl_material_set_blend()) or use the data for something
- *    other than straight blending.
  * @error: A #CoglError to catch exceptional errors or %NULL
  *
  * Creates a low-level #CoglTexture2D texture from an image file.
@@ -144,7 +134,6 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
 CoglTexture2D *
 cogl_texture_2d_new_from_file (CoglContext *ctx,
                                const char *filename,
-                               CoglPixelFormat internal_format,
                                CoglError **error);
 
 /**
@@ -153,14 +142,6 @@ cogl_texture_2d_new_from_file (CoglContext *ctx,
  * @width: width of texture in pixels
  * @height: height of texture in pixels
  * @format: the #CoglPixelFormat the buffer is stored in in RAM
- * @internal_format: the #CoglPixelFormat that will be used for storing
- *    the buffer on the GPU. If %COGL_PIXEL_FORMAT_ANY is given then a
- *    premultiplied format similar to the format of the source data will
- *    be used. The default blending equations of Cogl expect premultiplied
- *    color data; the main use of passing a non-premultiplied format here
- *    is if you have non-premultiplied source data and are going to adjust
- *    the blend mode (see cogl_pipeline_set_blend()) or use the data for
- *    something other than straight blending.
  * @rowstride: the memory offset in bytes between the starts of
  *    scanlines in @data. A value of 0 will make Cogl automatically
  *    calculate @rowstride from @width and @format.
@@ -198,7 +179,6 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
                                int width,
                                int height,
                                CoglPixelFormat format,
-                               CoglPixelFormat internal_format,
                                int rowstride,
                                const uint8_t *data,
                                CoglError **error);
@@ -206,15 +186,6 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
 /**
  * cogl_texture_2d_new_from_bitmap:
  * @bitmap: A #CoglBitmap
- * @internal_format: the #CoglPixelFormat that will be used for storing
- *    the buffer on the GPU. If %COGL_PIXEL_FORMAT_ANY is given then a
- *    premultiplied format similar to the format of the source data will
- *    be used. The default blending equations of Cogl expect premultiplied
- *    color data; the main use of passing a non-premultiplied format here
- *    is if you have non-premultiplied source data and are going to adjust
- *    the blend mode (see cogl_pipeline_set_blend()) or use the data for
- *    something other than straight blending.
- * @error: A #CoglError for exceptions
  *
  * Creates a low-level #CoglTexture2D texture based on data residing
  * in a #CoglBitmap.
@@ -235,18 +206,13 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
  * checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature via
  * cogl_has_feature().</note>
  *
- * Returns: (transfer full): A newly allocated #CoglTexture2D, or if
- *          the size is not supported (because it is too large or a
- *          non-power-of-two size that the hardware doesn't support)
- *          it will return %NULL and set @error.
+ * Returns: (transfer full): A newly allocated #CoglTexture2D
  *
  * Since: 2.0
  * Stability: unstable
  */
 CoglTexture2D *
-cogl_texture_2d_new_from_bitmap (CoglBitmap *bitmap,
-                                 CoglPixelFormat internal_format,
-                                 CoglError **error);
+cogl_texture_2d_new_from_bitmap (CoglBitmap *bitmap);
 
 COGL_END_DECLS
 
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index 14bf7d2..438edc6 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -147,31 +147,23 @@ CoglTexture3D *
 cogl_texture_3d_new_with_size (CoglContext *ctx,
                                int width,
                                int height,
-                               int depth,
-                               CoglPixelFormat internal_format)
+                               int depth)
 {
-  CoglTextureLoader *loader;
-
-  /* Since no data, we need some internal format */
-  if (internal_format == COGL_PIXEL_FORMAT_ANY)
-    internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
-
-  loader = _cogl_texture_create_loader ();
+  CoglTextureLoader *loader = _cogl_texture_create_loader ();
   loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
   loader->src.sized.width = width;
   loader->src.sized.height = height;
   loader->src.sized.depth = depth;
 
   return _cogl_texture_3d_create_base (ctx, width, height, depth,
-                                       internal_format, loader);
+                                       COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+                                       loader);
 }
 
 CoglTexture3D *
 cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
                                  int height,
-                                 int depth,
-                                 CoglPixelFormat internal_format,
-                                 CoglError **error)
+                                 int depth)
 {
   CoglTextureLoader *loader;
 
@@ -188,7 +180,7 @@ cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
                                        cogl_bitmap_get_width (bmp),
                                        height,
                                        depth,
-                                       internal_format,
+                                       cogl_bitmap_get_format (bmp),
                                        loader);
 }
 
@@ -198,7 +190,6 @@ cogl_texture_3d_new_from_data (CoglContext *context,
                                int height,
                                int depth,
                                CoglPixelFormat format,
-                               CoglPixelFormat internal_format,
                                int rowstride,
                                int image_stride,
                                const uint8_t *data,
@@ -271,9 +262,7 @@ cogl_texture_3d_new_from_data (CoglContext *context,
 
   ret = cogl_texture_3d_new_from_bitmap (bitmap,
                                          height,
-                                         depth,
-                                         internal_format,
-                                         error);
+                                         depth);
 
   cogl_object_unref (bitmap);
 
diff --git a/cogl/cogl-texture-3d.h b/cogl/cogl-texture-3d.h
index 6ab2093..091812a 100644
--- a/cogl/cogl-texture-3d.h
+++ b/cogl/cogl-texture-3d.h
@@ -53,8 +53,6 @@ typedef struct _CoglTexture3D CoglTexture3D;
  * @width: width of the texture in pixels.
  * @height: height of the texture in pixels.
  * @depth: depth of the texture in pixels.
- * @internal_format: the #CoglPixelFormat to use for the GPU
- *    storage of the texture.
  *
  * Creates a low-level #CoglTexture3D texture with the specified
  * dimensions and pixel format.
@@ -84,8 +82,7 @@ CoglTexture3D *
 cogl_texture_3d_new_with_size (CoglContext *context,
                                int width,
                                int height,
-                               int depth,
-                               CoglPixelFormat internal_format);
+                               int depth);
 
 /**
  * cogl_texture_3d_new_from_data:
@@ -94,14 +91,6 @@ cogl_texture_3d_new_with_size (CoglContext *context,
  * @height: height of the texture in pixels.
  * @depth: depth of the texture in pixels.
  * @format: the #CoglPixelFormat the buffer is stored in in RAM
- * @internal_format: the #CoglPixelFormat that will be used for storing
- *    the buffer on the GPU. If %COGL_PIXEL_FORMAT_ANY is given then a
- *    premultiplied format similar to the format of the source data will
- *    be used. The default blending equations of Cogl expect premultiplied
- *    color data; the main use of passing a non-premultiplied format here
- *    is if you have non-premultiplied source data and are going to adjust
- *    the blend mode (see cogl_pipeline_set_blend()) or use the data for
- *    something other than straight blending.
  * @rowstride: the memory offset in bytes between the starts of
  *    scanlines in @data or 0 to infer it from the width and format
  * @image_stride: the number of bytes from one image to the next. This
@@ -137,7 +126,6 @@ cogl_texture_3d_new_from_data (CoglContext *context,
                                int height,
                                int depth,
                                CoglPixelFormat format,
-                               CoglPixelFormat internal_format,
                                int rowstride,
                                int image_stride,
                                const uint8_t *data,
@@ -148,15 +136,6 @@ cogl_texture_3d_new_from_data (CoglContext *context,
  * @bitmap: A #CoglBitmap object.
  * @height: height of the texture in pixels.
  * @depth: depth of the texture in pixels.
- * @internal_format: the #CoglPixelFormat that will be used for storing
- *    the buffer on the GPU. If %COGL_PIXEL_FORMAT_ANY is given then a
- *    premultiplied format similar to the format of the source data will
- *    be used. The default blending equations of Cogl expect premultiplied
- *    color data; the main use of passing a non-premultiplied format here
- *    is if you have non-premultiplied source data and are going to adjust
- *    the blend mode (see cogl_pipeline_set_blend()) or use the data for
- *    something other than straight blending.
- * @error: A CoglError return location.
  *
  * Creates a low-level 3D texture and initializes it with the images
  * in @bitmap. The images are assumed to be packed together after one
@@ -182,17 +161,14 @@ cogl_texture_3d_new_from_data (CoglContext *context,
  * fail if the requested dimensions are not supported by the
  * GPU.</note>
  *
- * Return value: (transfer full): the newly created texture or %NULL
- *   if there was an error.
+ * Return value: (transfer full): a newly created #CoglTexture3D
  * Since: 2.0
  * Stability: unstable
  */
 CoglTexture3D *
 cogl_texture_3d_new_from_bitmap (CoglBitmap *bitmap,
                                  int height,
-                                 int depth,
-                                 CoglPixelFormat internal_format,
-                                 CoglError **error);
+                                 int depth);
 
 /**
  * cogl_is_texture_3d:
diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h
index 7b94b6c..59e519a 100644
--- a/cogl/cogl-texture-private.h
+++ b/cogl/cogl-texture-private.h
@@ -229,7 +229,7 @@ _cogl_texture_init (CoglTexture *texture,
                     CoglContext *ctx,
                     int width,
                     int height,
-                    CoglPixelFormat internal_format,
+                    CoglPixelFormat src_format,
                     CoglTextureLoader *loader,
                     const CoglTextureVtable *vtable);
 
@@ -366,4 +366,8 @@ _cogl_texture_get_format (CoglTexture *texture);
 CoglTextureLoader *
 _cogl_texture_create_loader (void);
 
+void
+_cogl_texture_copy_internal_format (CoglTexture *src,
+                                    CoglTexture *dest);
+
 #endif /* __COGL_TEXTURE_PRIVATE_H */
diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c
index d9ca1f7..894e9e6 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -193,22 +193,16 @@ _cogl_texture_rectangle_create_base (CoglContext *ctx,
 CoglTextureRectangle *
 cogl_texture_rectangle_new_with_size (CoglContext *ctx,
                                       int width,
-                                      int height,
-                                      CoglPixelFormat internal_format)
+                                      int height)
 {
-  CoglTextureLoader *loader;
-
-  /* Since no data, we need some internal format */
-  if (internal_format == COGL_PIXEL_FORMAT_ANY)
-    internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
-
-  loader = _cogl_texture_create_loader ();
+  CoglTextureLoader *loader = _cogl_texture_create_loader ();
   loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
   loader->src.sized.width = width;
   loader->src.sized.height = height;
 
   return _cogl_texture_rectangle_create_base (ctx, width, height,
-                                              internal_format, loader);
+                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+                                              loader);
 }
 
 static CoglBool
@@ -485,9 +479,7 @@ _cogl_texture_rectangle_allocate (CoglTexture *tex,
 }
 
 CoglTextureRectangle *
-cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
-                                        CoglPixelFormat internal_format,
-                                        CoglError **error)
+cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp)
 {
   CoglTextureLoader *loader;
 
@@ -501,7 +493,7 @@ cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
   return _cogl_texture_rectangle_create_base (_cogl_bitmap_get_context (bmp),
                                               cogl_bitmap_get_width (bmp),
                                               cogl_bitmap_get_height (bmp),
-                                              internal_format,
+                                              cogl_bitmap_get_format (bmp),
                                               loader);
 }
 
@@ -510,8 +502,7 @@ cogl_texture_rectangle_new_from_foreign (CoglContext *ctx,
                                          unsigned int gl_handle,
                                          int width,
                                          int height,
-                                         CoglPixelFormat format,
-                                         CoglError **error)
+                                         CoglPixelFormat format)
 {
   CoglTextureLoader *loader;
 
diff --git a/cogl/cogl-texture-rectangle.h b/cogl/cogl-texture-rectangle.h
index eef20bf..86e415b 100644
--- a/cogl/cogl-texture-rectangle.h
+++ b/cogl/cogl-texture-rectangle.h
@@ -81,12 +81,11 @@ cogl_is_texture_rectangle (void *object);
  * @ctx: A #CoglContext pointer
  * @width: The texture width to allocate
  * @height: The texture height to allocate
- * @internal_format: The desired internal texture format
  *
  * Creates a new #CoglTextureRectangle texture with a given @width,
- * @height and @internal_format. This texture is a low-level texture
- * that the GPU can sample from directly unlike high-level textures
- * such as #CoglTexture2DSliced and #CoglAtlasTexture.
+ * and @height. This texture is a low-level texture that the GPU can
+ * sample from directly unlike high-level textures such as
+ * #CoglTexture2DSliced and #CoglAtlasTexture.
  *
  * <note>Unlike for #CoglTexture2D textures, coordinates for
  * #CoglTextureRectangle textures should not be normalized. So instead
@@ -117,22 +116,17 @@ cogl_is_texture_rectangle (void *object);
 CoglTextureRectangle *
 cogl_texture_rectangle_new_with_size (CoglContext *ctx,
                                       int width,
-                                      int height,
-                                      CoglPixelFormat internal_format);
+                                      int height);
 
 /**
  * cogl_texture_rectangle_new_from_bitmap:
  * @bitmap: A #CoglBitmap
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture
- * @error: A return location for a CoglError or %NULL
  *
  * Allocates a new #CoglTextureRectangle texture which will be
- * initialized with the pixel data from @bitmap. Internally the data
- * will be stored in the format given by @internal_format. This
- * texture is a low-level texture that the GPU can sample from
- * directly unlike high-level textures such as #CoglTexture2DSliced
- * and #CoglAtlasTexture.
+ * initialized with the pixel data from @bitmap. This texture is a
+ * low-level texture that the GPU can sample from directly unlike
+ * high-level textures such as #CoglTexture2DSliced and
+ * #CoglAtlasTexture.
  *
  * <note>Unlike for #CoglTexture2D textures, coordinates for
  * #CoglTextureRectangle textures should not be normalized. So instead
@@ -154,16 +148,12 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
  * how the texture is going to be used and can optimize how it is
  * allocated.
  *
- * Returns: A pointer to a newly allocated #CoglTextureRectangle texture
- *          or if the size was too large or there wasn't enough memory
- *          %NULL is returned and @error set.
+ * Returns: A pointer to a new #CoglTextureRectangle texture.
  * Since: 2.0
  * Stability: unstable
  */
 CoglTextureRectangle *
-cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bitmap,
-                                        CoglPixelFormat internal_format,
-                                        CoglError **error);
+cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bitmap);
 
 /**
  * cogl_texture_rectangle_new_from_foreign:
@@ -172,7 +162,6 @@ cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bitmap,
  * @width: Width of the foreign GL texture
  * @height: Height of the foreign GL texture
  * @format: The format of the texture
- * @error: A #CoglError for exceptions
  *
  * Wraps an existing GL_TEXTURE_RECTANGLE texture object as a
  * #CoglTextureRectangle.  This can be used for integrating Cogl with
@@ -199,20 +188,14 @@ cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bitmap,
  * for example you can declare whether the texture is premultiplied
  * with cogl_texture_set_premultiplied().
  *
- * Returns: A newly allocated #CoglTextureRectangle, or if Cogl could
- *          not validate the @gl_handle in some way (perhaps because
- *          of an unsupported format) it will return %NULL and set
- *          @error.
- *
-
+ * Returns: A new #CoglTextureRectangle texture
  */
 CoglTextureRectangle *
 cogl_texture_rectangle_new_from_foreign (CoglContext *ctx,
                                          unsigned int gl_handle,
                                          int width,
                                          int height,
-                                         CoglPixelFormat format,
-                                         CoglError **error);
+                                         CoglPixelFormat format);
 
 COGL_END_DECLS
 
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index cd65dda..7b2fb3c 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -105,7 +105,7 @@ _cogl_texture_init (CoglTexture *texture,
                     CoglContext *context,
                     int width,
                     int height,
-                    CoglPixelFormat internal_format,
+                    CoglPixelFormat src_format,
                     CoglTextureLoader *loader,
                     const CoglTextureVtable *vtable)
 {
@@ -119,7 +119,13 @@ _cogl_texture_init (CoglTexture *texture,
 
   texture->loader = loader;
 
-  _cogl_texture_set_internal_format (texture, internal_format);
+  _cogl_texture_set_internal_format (texture, src_format);
+
+  /* Although we want to initialize texture::components according
+   * to the source format, we always want the internal layout to
+   * be premultiplied by default if applicable... */
+  if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (src_format))
+    texture->premultiplied = TRUE;
 }
 
 static void
@@ -1405,3 +1411,11 @@ cogl_texture_get_premultiplied (CoglTexture *texture)
 {
   return texture->premultiplied;
 }
+
+void
+_cogl_texture_copy_internal_format (CoglTexture *src,
+                                    CoglTexture *dest)
+{
+  cogl_texture_set_components (dest, src->components);
+  cogl_texture_set_premultiplied (dest, src->premultiplied);
+}
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index 1510de8..684b27b 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -386,20 +386,11 @@ create_depth_texture (CoglContext *ctx,
                       int width,
                       int height)
 {
-  CoglPixelFormat format;
-  CoglTexture2D *depth_texture;
-
-  if (_cogl_has_private_feature
-      (ctx, COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL) ||
-      _cogl_has_private_feature
-      (ctx, COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL))
-    format = COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8;
-  else
-    format = COGL_PIXEL_FORMAT_DEPTH_16;
+  CoglTexture2D *depth_texture =
+    cogl_texture_2d_new_with_size (ctx, width, height);
 
-  depth_texture =  cogl_texture_2d_new_with_size (ctx,
-                                                  width, height,
-                                                  format);
+  cogl_texture_set_components (COGL_TEXTURE (depth_texture),
+                               COGL_TEXTURE_COMPONENTS_DEPTH);
 
   return COGL_TEXTURE (depth_texture);
 }
diff --git a/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/driver/gl/cogl-texture-2d-gl.c
index 27e30f5..671c8a0 100644
--- a/cogl/driver/gl/cogl-texture-2d-gl.c
+++ b/cogl/driver/gl/cogl-texture-2d-gl.c
@@ -525,8 +525,7 @@ cogl_texture_2d_gl_new_from_foreign (CoglContext *ctx,
                                      unsigned int gl_handle,
                                      int width,
                                      int height,
-                                     CoglPixelFormat format,
-                                     CoglError **error)
+                                     CoglPixelFormat format)
 {
   CoglTextureLoader *loader;
 
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 7e8584a..5a03650 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -516,8 +516,9 @@ create_fallback_texture (CoglContext *ctx,
     {
       /* First try creating a fast-path non-sliced texture */
       tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
-                                                         width, height,
-                                                         internal_format));
+                                                         width, height));
+
+      _cogl_texture_set_internal_format (tex, internal_format);
 
       /* TODO: instead of allocating storage here it would be better
        * if we had some api that let us just check that the size is
@@ -539,9 +540,10 @@ create_fallback_texture (CoglContext *ctx,
         cogl_texture_2d_sliced_new_with_size (ctx,
                                               width,
                                               height,
-                                              COGL_TEXTURE_MAX_WASTE,
-                                              internal_format);
+                                              COGL_TEXTURE_MAX_WASTE);
       tex = COGL_TEXTURE (tex_2ds);
+
+      _cogl_texture_set_internal_format (tex, internal_format);
     }
 
   return tex;
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 6c91f73..8579cb6 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -2486,8 +2486,9 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
           glx_tex_pixmap->glx_tex = COGL_TEXTURE (
             cogl_texture_rectangle_new_with_size (ctx,
                                                   tex->width,
-                                                  tex->height,
-                                                  texture_format));
+                                                  tex->height));
+
+          _cogl_texture_set_internal_format (tex, texture_format);
 
           if (cogl_texture_allocate (glx_tex_pixmap->glx_tex, &error))
             COGL_NOTE (TEXTURE_PIXMAP, "Created a texture rectangle for %p",
@@ -2507,8 +2508,9 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
           glx_tex_pixmap->glx_tex = COGL_TEXTURE (
             cogl_texture_2d_new_with_size (ctx,
                                            tex->width,
-                                           tex->height,
-                                           texture_format));
+                                           tex->height));
+
+          _cogl_texture_set_internal_format (tex, texture_format);
 
           if (cogl_texture_allocate (glx_tex_pixmap->glx_tex, &error))
             COGL_NOTE (TEXTURE_PIXMAP, "Created a texture 2d for %p",
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index 67613fc..570c196 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -225,7 +225,6 @@ main (int argc, char **argv)
   data.texture =
     cogl_texture_2d_new_from_file (ctx,
                                    COGL_EXAMPLES_DATA "crate.jpg",
-                                   COGL_PIXEL_FORMAT_ANY,
                                    &error);
   if (!data.texture)
     g_error ("Failed to load texture: %s", error->message);
diff --git a/examples/cogl-gles2-context.c b/examples/cogl-gles2-context.c
index 2b383a8..da52423 100644
--- a/examples/cogl-gles2-context.c
+++ b/examples/cogl-gles2-context.c
@@ -98,8 +98,7 @@ main (int argc, char **argv)
     data.offscreen_texture =
       cogl_texture_2d_new_with_size (data.ctx,
                                      OFFSCREEN_WIDTH,
-                                     OFFSCREEN_HEIGHT,
-                                     COGL_PIXEL_FORMAT_ANY);
+                                     OFFSCREEN_HEIGHT);
     data.offscreen = cogl_offscreen_new_with_texture (data.offscreen_texture);
 
     data.gles2_ctx = cogl_gles2_context_new (data.ctx, &error);
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index 4c7d1e0..0ea5e36 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -62,9 +62,7 @@ main (int argc, char **argv)
 
     cogl_onscreen_show (onscreen);
 
-    tex = cogl_texture_2d_new_with_size (ctx,
-                                         320, 480,
-                                         COGL_PIXEL_FORMAT_ANY);
+    tex = cogl_texture_2d_new_with_size (ctx, 320, 480);
     offscreen = cogl_offscreen_new_with_texture (tex);
     offscreen_fb = offscreen;
     cogl_framebuffer_set_samples_per_pixel (offscreen_fb, 4);
diff --git a/examples/cogl-point-sprites.c b/examples/cogl-point-sprites.c
index 8854591..da13138 100644
--- a/examples/cogl-point-sprites.c
+++ b/examples/cogl-point-sprites.c
@@ -82,7 +82,6 @@ generate_round_texture (CoglContext *context)
   tex = cogl_texture_2d_new_from_data (context,
                                        TEXTURE_SIZE, TEXTURE_SIZE,
                                        COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                       COGL_PIXEL_FORMAT_ANY,
                                        TEXTURE_SIZE * 4,
                                        data,
                                        NULL /* error */);
diff --git a/test-fixtures/test-utils.c b/test-fixtures/test-utils.c
index 1948922..a70d492 100644
--- a/test-fixtures/test-utils.c
+++ b/test-fixtures/test-utils.c
@@ -177,8 +177,7 @@ test_utils_init (TestFlags requirement_flags,
     {
       CoglOffscreen *offscreen;
       CoglTexture2D *tex = cogl_texture_2d_new_with_size (test_ctx,
-                                                          FB_WIDTH, FB_HEIGHT,
-                                                          COGL_PIXEL_FORMAT_ANY);
+                                                          FB_WIDTH, FB_HEIGHT);
       offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex));
       test_fb = COGL_FRAMEBUFFER (offscreen);
     }
@@ -335,7 +334,6 @@ test_utils_create_color_texture (CoglContext *context,
   tex_2d = cogl_texture_2d_new_from_data (context,
                                           1, 1, /* width/height */
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                           4, /* rowstride */
                                           (uint8_t *) &color,
                                           NULL);
@@ -364,7 +362,7 @@ test_utils_texture_new_with_size (CoglContext *ctx,
                                   int width,
                                   int height,
                                   TestUtilsTextureFlags flags,
-                                  CoglPixelFormat internal_format)
+                                  CoglTextureComponents components)
 {
   CoglTexture *tex;
   CoglError *skip_error = NULL;
@@ -375,8 +373,9 @@ test_utils_texture_new_with_size (CoglContext *ctx,
     {
       /* First try creating a fast-path non-sliced texture */
       tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
-                                                         width, height,
-                                                         internal_format));
+                                                         width, height));
+
+      cogl_texture_set_components (tex, components);
 
       if (!cogl_texture_allocate (tex, &skip_error))
         {
@@ -397,9 +396,10 @@ test_utils_texture_new_with_size (CoglContext *ctx,
         cogl_texture_2d_sliced_new_with_size (ctx,
                                               width,
                                               height,
-                                              max_waste,
-                                              internal_format);
+                                              max_waste);
       tex = COGL_TEXTURE (tex_2ds);
+
+      cogl_texture_set_components (tex, components);
     }
 
   if (flags & TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP)
@@ -424,7 +424,7 @@ test_utils_texture_new_with_size (CoglContext *ctx,
 CoglTexture *
 test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
                                     TestUtilsTextureFlags flags,
-                                    CoglPixelFormat internal_format)
+                                    CoglBool premultiplied)
 {
   CoglAtlasTexture *atlas_tex;
   CoglTexture *tex;
@@ -433,15 +433,15 @@ test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
   if (!flags)
     {
       /* First try putting the texture in the atlas */
-      if ((atlas_tex = cogl_atlas_texture_new_from_bitmap (bitmap,
-                                                           internal_format,
-                                                           &internal_error)) &&
-           cogl_texture_allocate (COGL_TEXTURE (atlas_tex), &internal_error))
-        {
-          return COGL_TEXTURE (atlas_tex);
-        }
+      atlas_tex = cogl_atlas_texture_new_from_bitmap (bitmap);
+
+      cogl_texture_set_premultiplied (COGL_TEXTURE (atlas_tex), premultiplied);
+
+      if (cogl_texture_allocate (COGL_TEXTURE (atlas_tex), &internal_error))
+        return COGL_TEXTURE (atlas_tex);
 
       cogl_error_free (internal_error);
+      cogl_object_unref (atlas_tex);
       internal_error = NULL;
     }
 
@@ -451,9 +451,9 @@ test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
       (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
        cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
     {
-      tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap,
-                                                           internal_format,
-                                                           &internal_error));
+      tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
+
+      cogl_texture_set_premultiplied (tex, premultiplied);
 
       if (cogl_error_matches (internal_error,
                               COGL_SYSTEM_ERROR,
@@ -478,12 +478,10 @@ test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
       int max_waste = flags & TEST_UTILS_TEXTURE_NO_SLICING ?
         -1 : COGL_TEXTURE_MAX_WASTE;
       CoglTexture2DSliced *tex_2ds =
-        cogl_texture_2d_sliced_new_from_bitmap (bitmap,
-                                                max_waste,
-                                                internal_format,
-                                                NULL); /* don't catch
-                                                          exceptions */
+        cogl_texture_2d_sliced_new_from_bitmap (bitmap, max_waste);
       tex = COGL_TEXTURE (tex_2ds);
+
+      cogl_texture_set_premultiplied (tex, premultiplied);
     }
 
   if (flags & TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP)
@@ -507,7 +505,6 @@ test_utils_texture_new_from_data (CoglContext *ctx,
                                   int height,
                                   TestUtilsTextureFlags flags,
                                   CoglPixelFormat format,
-                                  CoglPixelFormat internal_format,
                                   int rowstride,
                                   const uint8_t *data)
 {
@@ -524,7 +521,7 @@ test_utils_texture_new_from_data (CoglContext *ctx,
                                   rowstride,
                                   (uint8_t *) data);
 
-  tex = test_utils_texture_new_from_bitmap (bmp, flags, internal_format);
+  tex = test_utils_texture_new_from_bitmap (bmp, flags, TRUE);
 
   cogl_object_unref (bmp);
 
diff --git a/test-fixtures/test-utils.h b/test-fixtures/test-utils.h
index 9093fa8..5e40370 100644
--- a/test-fixtures/test-utils.h
+++ b/test-fixtures/test-utils.h
@@ -81,8 +81,7 @@ test_utils_fini (void);
  * @width: width of texture in pixels.
  * @height: height of texture in pixels.
  * @flags: Optional flags for the texture, or %TEST_UTILS_TEXTURE_NONE
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture.
+ * @components: What texture components are required
  *
  * Creates a new #CoglTexture with the specified dimensions and pixel format.
  *
@@ -100,7 +99,7 @@ test_utils_texture_new_with_size (CoglContext *ctx,
                                   int width,
                                   int height,
                                   TestUtilsTextureFlags flags,
-                                  CoglPixelFormat internal_format);
+                                  CoglTextureComponents components);
 
 /*
  * test_utils_texture_new_from_data:
@@ -109,14 +108,6 @@ test_utils_texture_new_with_size (CoglContext *ctx,
  * @height: height of texture in pixels
  * @flags: Optional flags for the texture, or %TEST_UTILS_TEXTURE_NONE
  * @format: the #CoglPixelFormat the buffer is stored in in RAM
- * @internal_format: the #CoglPixelFormat that will be used for storing
- *    the buffer on the GPU. If COGL_PIXEL_FORMAT_ANY is given then a
- *    premultiplied format similar to the format of the source data will
- *    be used. The default blending equations of Cogl expect premultiplied
- *    color data; the main use of passing a non-premultiplied format here
- *    is if you have non-premultiplied source data and are going to adjust
- *    the blend mode (see cogl_material_set_blend()) or use the data for
- *    something other than straight blending.
  * @rowstride: the memory offset in bytes between the starts of
  *    scanlines in @data
  * @data: pointer the memory region where the source buffer resides
@@ -124,6 +115,13 @@ test_utils_texture_new_with_size (CoglContext *ctx,
  *
  * Creates a new #CoglTexture based on data residing in memory.
  *
+ * Note: If the given @format has an alpha channel then the data
+ * will be loaded into a premultiplied internal format. If you want
+ * to avoid having the source data be premultiplied then you can
+ * either specify that the data is already premultiplied or use
+ * test_utils_texture_new_from_bitmap which lets you explicitly
+ * request whether the data should internally be premultipled or not.
+ *
  * Return value: A newly created #CoglTexture or %NULL on failure
  */
 CoglTexture *
@@ -132,7 +130,6 @@ test_utils_texture_new_from_data (CoglContext *ctx,
                                   int height,
                                   TestUtilsTextureFlags flags,
                                   CoglPixelFormat format,
-                                  CoglPixelFormat internal_format,
                                   int rowstride,
                                   const uint8_t *data);
 
@@ -140,9 +137,12 @@ test_utils_texture_new_from_data (CoglContext *ctx,
  * test_utils_texture_new_from_bitmap:
  * @bitmap: A #CoglBitmap pointer
  * @flags: Optional flags for the texture, or %TEST_UTILS_TEXTURE_NONE
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- * texture
- * @error: A #CoglError to catch exceptional errors or %NULL
+ * @premultiplied: Whether the texture should hold premultipled data.
+ *                 (if the bitmap already holds premultiplied data
+ *                 and %TRUE is given then no premultiplication will
+ *                 be done. The data will be premultipled while
+ *                 uploading if the bitmap has an alpha channel but
+ *                 does not already have a premultiplied format.)
  *
  * Creates a #CoglTexture from a #CoglBitmap.
  *
@@ -151,7 +151,7 @@ test_utils_texture_new_from_data (CoglContext *ctx,
 CoglTexture *
 test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
                                     TestUtilsTextureFlags flags,
-                                    CoglPixelFormat internal_format);
+                                    CoglBool premultiplied);
 
 /*
  * test_utils_check_pixel:
diff --git a/tests/conform/test-alpha-test.c b/tests/conform/test-alpha-test.c
index f164ede..e74f6d8 100644
--- a/tests/conform/test-alpha-test.c
+++ b/tests/conform/test-alpha-test.c
@@ -15,7 +15,6 @@ create_texture (CoglContext *context)
   return cogl_texture_2d_new_from_data (context,
                                         2, 1, /* width/height */
                                         COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                        COGL_PIXEL_FORMAT_ANY,
                                         4, /* rowstride */
                                         data,
                                         NULL /* error */);
diff --git a/tests/conform/test-alpha-textures.c b/tests/conform/test-alpha-textures.c
index 524ba89..f4ad49b 100644
--- a/tests/conform/test-alpha-textures.c
+++ b/tests/conform/test-alpha-textures.c
@@ -16,7 +16,6 @@ create_pipeline (CoglTexture **tex_out,
   tex = cogl_texture_2d_new_from_data (test_ctx,
                                        2, 2, /* width/height */
                                        COGL_PIXEL_FORMAT_A_8, /* format */
-                                       COGL_PIXEL_FORMAT_ANY, /* int. format */
                                        2, /* rowstride */
                                        tex_data,
                                        NULL);
diff --git a/tests/conform/test-atlas-migration.c b/tests/conform/test-atlas-migration.c
index f8435bc..39e8a3c 100644
--- a/tests/conform/test-atlas-migration.c
+++ b/tests/conform/test-atlas-migration.c
@@ -58,9 +58,7 @@ create_texture (int size)
                                               size, /* height */
                                               TEST_UTILS_TEXTURE_NONE, /* flags */
                                               /* format */
-                                              COGL_PIXEL_FORMAT_RGBA_8888,
-                                              /* internal format */
-                                              COGL_PIXEL_FORMAT_RGBA_8888,
+                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                               /* rowstride */
                                               size * 4,
                                               data);
@@ -82,7 +80,7 @@ verify_texture (CoglTexture *texture, int size)
   p = data = g_malloc (size * size * 4);
 
   cogl_texture_get_data (texture,
-                         COGL_PIXEL_FORMAT_RGBA_8888,
+                         COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                          size * 4,
                          data);
 
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index 3ff84f6..02836d8 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -215,7 +215,6 @@ make_texture (void)
                                           TEXTURE_SIZE,
                                           TEST_UTILS_TEXTURE_NO_ATLAS,
                                           COGL_PIXEL_FORMAT_RGBA_8888,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           TEXTURE_SIZE * 4,
                                           tex_data);
 
@@ -240,8 +239,7 @@ test_backface_culling (void)
   tex = test_utils_texture_new_with_size (test_ctx,
                                           state.width, state.height,
                                           TEST_UTILS_TEXTURE_NO_SLICING,
-                                          COGL_PIXEL_FORMAT_ANY); /* internal
-                                                                     format */
+                                          COGL_TEXTURE_COMPONENTS_RGBA);
   state.offscreen = cogl_offscreen_new_with_texture (tex);
   state.offscreen_tex = tex;
 
diff --git a/tests/conform/test-blend-strings.c b/tests/conform/test-blend-strings.c
index 34049d5..4c1a09b 100644
--- a/tests/conform/test-blend-strings.c
+++ b/tests/conform/test-blend-strings.c
@@ -142,14 +142,13 @@ make_texture (uint32_t color)
       *(--p) = r;
     }
 
-  /* Note: we don't use COGL_PIXEL_FORMAT_ANY for the internal format here
-   * since we don't want to allow Cogl to premultiply our data. */
+  /* Note: we claim that the data is premultiplied so that Cogl won't
+   * premultiply the data on upload */
   tex = test_utils_texture_new_from_data (test_ctx,
                                           QUAD_WIDTH,
                                           QUAD_WIDTH,
                                           TEST_UTILS_TEXTURE_NONE,
-                                          COGL_PIXEL_FORMAT_RGBA_8888,
-                                          COGL_PIXEL_FORMAT_RGBA_8888,
+                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                           QUAD_WIDTH * 4,
                                           tex_data);
 
diff --git a/tests/conform/test-color-mask.c b/tests/conform/test-color-mask.c
index 41056af..4cbfb98 100644
--- a/tests/conform/test-color-mask.c
+++ b/tests/conform/test-color-mask.c
@@ -83,7 +83,7 @@ test_color_mask (void)
     {
       state.tex[i] = test_utils_texture_new_with_size (test_ctx, 128, 128,
                                                  TEST_UTILS_TEXTURE_NO_ATLAS,
-                                                 COGL_PIXEL_FORMAT_RGB_888);
+                                                 COGL_TEXTURE_COMPONENTS_RGB);
 
 
       state.fbo[i] = cogl_offscreen_new_with_texture (state.tex[i]);
diff --git a/tests/conform/test-copy-replace-texture.c b/tests/conform/test-copy-replace-texture.c
index 47b0ae8..f11070e 100644
--- a/tests/conform/test-copy-replace-texture.c
+++ b/tests/conform/test-copy-replace-texture.c
@@ -37,7 +37,6 @@ create_texture (void)
   tex_2d = cogl_texture_2d_new_from_data (test_ctx,
                                           1, 1, /* width / height */
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           4, /* rowstride */
                                           data,
                                           NULL);
diff --git a/tests/conform/test-framebuffer-get-bits.c b/tests/conform/test-framebuffer-get-bits.c
index c4a1dc4..31c220d 100644
--- a/tests/conform/test-framebuffer-get-bits.c
+++ b/tests/conform/test-framebuffer-get-bits.c
@@ -7,19 +7,19 @@ test_framebuffer_get_bits (void)
 {
   CoglTexture2D *tex_a =
     cogl_texture_2d_new_with_size (test_ctx,
-                                   16, 16, /* width/height */
-                                   COGL_PIXEL_FORMAT_A_8);
+                                   16, 16); /* width/height */
   CoglOffscreen *offscreen_a =
     cogl_offscreen_new_with_texture (tex_a);
   CoglFramebuffer *fb_a = offscreen_a;
   CoglTexture2D *tex_rgba =
     cogl_texture_2d_new_with_size (test_ctx,
-                                   16, 16, /* width/height */
-                                   COGL_PIXEL_FORMAT_RGBA_8888);
+                                   16, 16); /* width/height */
   CoglOffscreen *offscreen_rgba =
     cogl_offscreen_new_with_texture (tex_rgba);
   CoglFramebuffer *fb_rgba = offscreen_rgba;
 
+  cogl_texture_set_components (tex_a,
+                               COGL_TEXTURE_COMPONENTS_A);
   cogl_framebuffer_allocate (fb_a, NULL);
   cogl_framebuffer_allocate (fb_rgba, NULL);
 
diff --git a/tests/conform/test-gles2-context.c b/tests/conform/test-gles2-context.c
index 1f2087d..5e1d278 100644
--- a/tests/conform/test-gles2-context.c
+++ b/tests/conform/test-gles2-context.c
@@ -26,8 +26,7 @@ test_push_pop_single_context (void)
   offscreen_texture =
     cogl_texture_2d_new_with_size (test_ctx,
                                    cogl_framebuffer_get_width (test_fb),
-                                   cogl_framebuffer_get_height (test_fb),
-                                   COGL_PIXEL_FORMAT_ANY);
+                                   cogl_framebuffer_get_height (test_fb));
   offscreen = cogl_offscreen_new_with_texture (offscreen_texture);
 
   pipeline = cogl_pipeline_new (test_ctx);
@@ -150,8 +149,7 @@ create_gles2_context (CoglTexture **offscreen_texture,
   *offscreen_texture =
     cogl_texture_2d_new_with_size (test_ctx,
                                    cogl_framebuffer_get_width (test_fb),
-                                   cogl_framebuffer_get_height (test_fb),
-                                   COGL_PIXEL_FORMAT_ANY);
+                                   cogl_framebuffer_get_height (test_fb));
   *offscreen = cogl_offscreen_new_with_texture (*offscreen_texture);
 
   *pipeline = cogl_pipeline_new (test_ctx);
diff --git a/tests/conform/test-just-vertex-shader.c b/tests/conform/test-just-vertex-shader.c
index 355b57d..1ed951c 100644
--- a/tests/conform/test-just-vertex-shader.c
+++ b/tests/conform/test-just-vertex-shader.c
@@ -20,7 +20,6 @@ create_dummy_texture (void)
                                            1, 1, /* size */
                                            TEST_UTILS_TEXTURE_NONE,
                                            COGL_PIXEL_FORMAT_RGB_888,
-                                           COGL_PIXEL_FORMAT_ANY,
                                            4, /* rowstride */
                                            data);
 }
diff --git a/tests/conform/test-map-buffer-range.c b/tests/conform/test-map-buffer-range.c
index e3f7b39..e979240 100644
--- a/tests/conform/test-map-buffer-range.c
+++ b/tests/conform/test-map-buffer-range.c
@@ -37,7 +37,6 @@ test_map_buffer_range (void)
   tex = cogl_texture_2d_new_from_data (test_ctx,
                                        2, 2, /* width/height */
                                        COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                       COGL_PIXEL_FORMAT_ANY,
                                        2 * 4, /* rowstride */
                                        tex_data,
                                        NULL /* error */);
diff --git a/tests/conform/test-npot-texture.c b/tests/conform/test-npot-texture.c
index 3460fed..85c16c9 100644
--- a/tests/conform/test-npot-texture.c
+++ b/tests/conform/test-npot-texture.c
@@ -92,7 +92,6 @@ make_texture (void)
                                           TEXTURE_SIZE,
                                           TEST_UTILS_TEXTURE_NO_ATLAS,
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           TEXTURE_SIZE * 4,
                                           tex_data);
 
diff --git a/tests/conform/test-offscreen.c b/tests/conform/test-offscreen.c
index 9134cc9..dc32968 100644
--- a/tests/conform/test-offscreen.c
+++ b/tests/conform/test-offscreen.c
@@ -46,8 +46,7 @@ test_paint (TestState *state)
 
   tex_2d = cogl_texture_2d_new_with_size (test_ctx,
                                           state->fb_width,
-                                          state->fb_height,
-                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+                                          state->fb_height);
   tex = tex_2d;
 
   offscreen = cogl_offscreen_new_with_texture (tex);
@@ -126,8 +125,7 @@ test_flush (TestState *state)
          journal */
 
       tex_2d = cogl_texture_2d_new_with_size (test_ctx,
-                                              16, 16, /* width/height */
-                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+                                              16, 16); /* width/height */
       tex = tex_2d;
 
       offscreen = cogl_offscreen_new_with_texture (tex);
diff --git a/tests/conform/test-pipeline-cache-unrefs-texture.c b/tests/conform/test-pipeline-cache-unrefs-texture.c
index f00a4cb..5d278dc 100644
--- a/tests/conform/test-pipeline-cache-unrefs-texture.c
+++ b/tests/conform/test-pipeline-cache-unrefs-texture.c
@@ -25,7 +25,6 @@ create_texture (void)
   tex_2d = cogl_texture_2d_new_from_data (test_ctx,
                                           1, 1, /* width / height */
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           4, /* rowstride */
                                           data,
                                           NULL);
diff --git a/tests/conform/test-pipeline-shader-state.c b/tests/conform/test-pipeline-shader-state.c
index 5ac7b09..4d1e5f2 100644
--- a/tests/conform/test-pipeline-shader-state.c
+++ b/tests/conform/test-pipeline-shader-state.c
@@ -22,8 +22,7 @@ test_pipeline_shader_state (void)
                                  -1,
                                  100);
 
-  tex = cogl_texture_2d_new_with_size (test_ctx,
-                                       128, 128, COGL_PIXEL_FORMAT_ANY);
+  tex = cogl_texture_2d_new_with_size (test_ctx, 128, 128);
   offscreen = cogl_offscreen_new_with_texture (tex);
   fb = offscreen;
   cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
diff --git a/tests/conform/test-pixel-buffer.c b/tests/conform/test-pixel-buffer.c
index a36430f..d3102f2 100644
--- a/tests/conform/test-pixel-buffer.c
+++ b/tests/conform/test-pixel-buffer.c
@@ -80,9 +80,7 @@ create_texture_from_bitmap (CoglBitmap *bitmap)
 {
   CoglTexture2D *texture;
 
-  texture = cogl_texture_2d_new_from_bitmap (bitmap,
-                                             COGL_PIXEL_FORMAT_RGBA_8888,
-                                             NULL); /* don't catch errors */
+  texture = cogl_texture_2d_new_from_bitmap (bitmap);
 
   g_assert (texture != NULL);
 
@@ -223,7 +221,6 @@ create_white_texture (void)
                                            BITMAP_SIZE,
                                            BITMAP_SIZE,
                                            COGL_PIXEL_FORMAT_RGBA_8888,
-                                           COGL_PIXEL_FORMAT_ANY,
                                            BITMAP_SIZE * 4, /* rowstride */
                                            data,
                                            NULL); /* don't catch errors */
diff --git a/tests/conform/test-point-sprite.c b/tests/conform/test-point-sprite.c
index 8de5251..65ce9a8 100644
--- a/tests/conform/test-point-sprite.c
+++ b/tests/conform/test-point-sprite.c
@@ -51,7 +51,6 @@ do_test (CoglBool check_orientation,
   tex_2d = cogl_texture_2d_new_from_data (test_ctx,
                                           2, tex_height, /* width/height */
                                           COGL_PIXEL_FORMAT_RGB_888,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           6, /* row stride */
                                           tex_data,
                                           &error);
diff --git a/tests/conform/test-premult.c b/tests/conform/test-premult.c
index 8c7b4d0..816c487 100644
--- a/tests/conform/test-premult.c
+++ b/tests/conform/test-premult.c
@@ -16,6 +16,12 @@
 #define MASK_BLUE(COLOR)  ((COLOR & 0xff00) >> 8)
 #define MASK_ALPHA(COLOR) (COLOR & 0xff)
 
+typedef enum _MakeTextureFlags
+{
+  TEXTURE_FLAG_SET_PREMULTIPLIED = 1,
+  TEXTURE_FLAG_SET_UNPREMULTIPLIED = 1<<1,
+} MakeTextureFlags;
+
 static guchar *
 gen_tex_data (uint32_t color)
 {
@@ -41,20 +47,25 @@ gen_tex_data (uint32_t color)
 static CoglTexture *
 make_texture (uint32_t color,
 	      CoglPixelFormat src_format,
-	      CoglPixelFormat internal_format)
+              MakeTextureFlags flags)
 {
   CoglTexture2D *tex_2d;
   guchar *tex_data = gen_tex_data (color);
+  CoglBitmap *bmp = cogl_bitmap_new_for_data (test_ctx,
+                                              QUAD_WIDTH,
+                                              QUAD_WIDTH,
+                                              src_format,
+                                              QUAD_WIDTH * 4,
+                                              tex_data);
+
+  tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
 
-  tex_2d = cogl_texture_2d_new_from_data (test_ctx,
-                                          QUAD_WIDTH,
-                                          QUAD_WIDTH,
-                                          src_format,
-                                          internal_format,
-                                          QUAD_WIDTH * 4,
-                                          tex_data,
-                                          NULL);
+  if (flags & TEXTURE_FLAG_SET_PREMULTIPLIED)
+    cogl_texture_set_premultiplied (tex_2d, TRUE);
+  else if (flags & TEXTURE_FLAG_SET_UNPREMULTIPLIED)
+    cogl_texture_set_premultiplied (tex_2d, FALSE);
 
+  cogl_object_unref (bmp);
   g_free (tex_data);
 
   return tex_2d;
@@ -125,7 +136,7 @@ test_premult (void)
                             "src = RGBA_8888, internal = RGBA_8888)\n");
   tex = make_texture (0xff00ff80,
                       COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888); /* internal format */
+                      TEXTURE_FLAG_SET_UNPREMULTIPLIED);
   check_texture (pipeline, 0, 0, /* position */
 		 tex,
 		 0xff00ff80); /* expected */
@@ -138,21 +149,21 @@ test_premult (void)
                             "src = RGBA_8888, internal = RGBA_8888_PRE)\n");
   tex = make_texture (0xff00ff80,
                       COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888_PRE); /* internal format */
+                      TEXTURE_FLAG_SET_PREMULTIPLIED);
   check_texture (pipeline, 1, 0, /* position */
 		 tex,
 		 0x80008080); /* expected */
 
-  /* If the user gives COGL_PIXEL_FORMAT_ANY for the internal format then
-   * by default Cogl should premultiply the given texture data...
-   * (In the future there will be additional Cogl API to control this
-   *  behaviour) */
+  /* If the user doesn't explicitly declare that the texture is premultiplied
+   * then Cogl should assume it is by default should premultiply
+   * unpremultiplied texture data...
+   */
   if (cogl_test_verbose ())
     g_print ("make_texture (0xff00ff80, "
                             "src = RGBA_8888, internal = ANY)\n");
   tex = make_texture (0xff00ff80,
                       COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
-                      COGL_PIXEL_FORMAT_ANY); /* internal format */
+                      0); /* default premultiplied status */
   check_texture (pipeline, 2, 0, /* position */
 		 tex,
 		 0x80008080); /* expected */
@@ -166,7 +177,7 @@ test_premult (void)
                             "internal = RGBA_8888_PRE)\n");
   tex = make_texture (0x80008080,
                       COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888_PRE); /* internal format */
+                      TEXTURE_FLAG_SET_PREMULTIPLIED);
   check_texture (pipeline, 3, 0, /* position */
 		 tex,
 		 0x80008080); /* expected */
@@ -179,7 +190,7 @@ test_premult (void)
                             "src = RGBA_8888_PRE, internal = RGBA_8888)\n");
   tex = make_texture (0x80008080,
                       COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888); /* internal format */
+                      TEXTURE_FLAG_SET_UNPREMULTIPLIED);
   check_texture (pipeline, 4, 0, /* position */
 		 tex,
 		 0xff00ff80); /* expected */
@@ -193,7 +204,7 @@ test_premult (void)
                             "src = RGBA_8888_PRE, internal = ANY)\n");
   tex = make_texture (0x80008080,
                       COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
-                      COGL_PIXEL_FORMAT_ANY); /* internal format */
+                      0); /* default premultiplied status */
   check_texture (pipeline, 5, 0, /* position */
 		 tex,
 		 0x80008080); /* expected */
@@ -207,7 +218,7 @@ test_premult (void)
                             "src = RGBA_8888, internal = RGBA_8888)\n");
   tex = make_texture (0xDEADBEEF,
                       COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888); /* internal format */
+                      TEXTURE_FLAG_SET_UNPREMULTIPLIED);
   if (cogl_test_verbose ())
     g_print ("set_region (0xff00ff80, RGBA_8888)\n");
   set_region (tex, 0xff00ff80, COGL_PIXEL_FORMAT_RGBA_8888);
@@ -223,7 +234,7 @@ test_premult (void)
                             "src = RGBA_8888, internal = RGBA_8888)\n");
   tex = make_texture (0xDEADBEEF,
                       COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888); /* internal format */
+                      TEXTURE_FLAG_SET_UNPREMULTIPLIED);
   if (cogl_test_verbose ())
     g_print ("set_region (0x80008080, RGBA_8888_PRE)\n");
   set_region (tex, 0x80008080, COGL_PIXEL_FORMAT_RGBA_8888_PRE);
@@ -238,7 +249,7 @@ test_premult (void)
                             "internal = RGBA_8888_PRE)\n");
   tex = make_texture (0xDEADBEEF,
                       COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888_PRE); /* internal format */
+                      TEXTURE_FLAG_SET_PREMULTIPLIED);
   if (cogl_test_verbose ())
     g_print ("set_region (0x80008080, RGBA_8888_PRE)\n");
   set_region (tex, 0x80008080, COGL_PIXEL_FORMAT_RGBA_8888_PRE);
@@ -256,7 +267,7 @@ test_premult (void)
                             "internal = RGBA_8888_PRE)\n");
   tex = make_texture (0xDEADBEEF,
                       COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
-                      COGL_PIXEL_FORMAT_RGBA_8888_PRE); /* internal format */
+                      TEXTURE_FLAG_SET_PREMULTIPLIED);
   if (cogl_test_verbose ())
     g_print ("set_region (0xff00ff80, RGBA_8888)\n");
   set_region (tex, 0xff00ff80, COGL_PIXEL_FORMAT_RGBA_8888);
diff --git a/tests/conform/test-primitive.c b/tests/conform/test-primitive.c
index 45166a8..1cd2ffc 100644
--- a/tests/conform/test-primitive.c
+++ b/tests/conform/test-primitive.c
@@ -174,7 +174,6 @@ test_paint (TestState *state)
                                           2, 1, /* size */
                                           TEST_UTILS_TEXTURE_NO_ATLAS,
                                           COGL_PIXEL_FORMAT_RGB_888,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           6, /* rowstride */
                                           tex_data);
   pipeline = cogl_pipeline_new (test_ctx);
diff --git a/tests/conform/test-read-texture-formats.c b/tests/conform/test-read-texture-formats.c
index 25195a7..12b04ae 100644
--- a/tests/conform/test-read-texture-formats.c
+++ b/tests/conform/test-read-texture-formats.c
@@ -149,7 +149,6 @@ test_read_texture_formats (void)
   tex_2d = cogl_texture_2d_new_from_data (test_ctx,
                                           1, 1, /* width / height */
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                           4, /* rowstride */
                                           tex_data,
                                           NULL);
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index e8a0125..96f32a0 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -26,7 +26,6 @@ create_texture_pipeline (TestState *state)
                                           2, 2, /* width/height */
                                           TEST_UTILS_TEXTURE_NO_ATLAS,
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           8, /* rowstride */
                                           tex_data);
 
diff --git a/tests/conform/test-sub-texture.c b/tests/conform/test-sub-texture.c
index c58244a..cec5b67 100644
--- a/tests/conform/test-sub-texture.c
+++ b/tests/conform/test-sub-texture.c
@@ -57,7 +57,6 @@ create_source (TestState *state)
   tex = cogl_texture_2d_new_from_data (test_ctx,
                                        SOURCE_SIZE, SOURCE_SIZE,
                                        COGL_PIXEL_FORMAT_RGBA_8888,
-                                       COGL_PIXEL_FORMAT_ANY,
                                        SOURCE_SIZE * 4,
                                        data,
                                        NULL);
@@ -87,7 +86,6 @@ create_test_texture (TestState *state)
   tex = cogl_texture_2d_new_from_data (test_ctx,
                                        256, 256,
                                        COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                       COGL_PIXEL_FORMAT_ANY,
                                        256 * 4,
                                        data,
                                        NULL);
diff --git a/tests/conform/test-texture-3d.c b/tests/conform/test-texture-3d.c
index e4c959b..80d077a 100644
--- a/tests/conform/test-texture-3d.c
+++ b/tests/conform/test-texture-3d.c
@@ -52,7 +52,6 @@ create_texture_3d (CoglContext *context)
   tex = cogl_texture_3d_new_from_data (context,
                                        TEX_WIDTH, TEX_HEIGHT, TEX_DEPTH,
                                        COGL_PIXEL_FORMAT_RGBA_8888,
-                                       COGL_PIXEL_FORMAT_ANY,
                                        TEX_ROWSTRIDE,
                                        TEX_IMAGE_STRIDE,
                                        data,
@@ -217,7 +216,6 @@ test_multi_texture (TestState *state)
   tex_2d = cogl_texture_2d_new_from_data (test_ctx,
                                           1, 1, /* width/height */
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                           4, /* rowstride */
                                           tex_data,
                                           NULL);
@@ -230,7 +228,6 @@ test_multi_texture (TestState *state)
   tex_3d = cogl_texture_3d_new_from_data (test_ctx,
                                           1, 1, 1, /* width/height/depth */
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                           4, /* rowstride */
                                           4, /* image_stride */
                                           tex_data,
diff --git a/tests/conform/test-texture-get-set-data.c b/tests/conform/test-texture-get-set-data.c
index 4c66f27..626823d 100644
--- a/tests/conform/test-texture-get-set-data.c
+++ b/tests/conform/test-texture-get-set-data.c
@@ -11,6 +11,7 @@ check_texture (int width, int height, TestUtilsTextureFlags flags)
   uint8_t *data, *p;
   int y, x;
   int rowstride;
+  CoglBitmap *bmp;
 
   p = data = g_malloc (width * height * 4);
   for (y = 0; y < height; y++)
@@ -22,13 +23,14 @@ check_texture (int width, int height, TestUtilsTextureFlags flags)
         *(p++) = (x ^ y);
       }
 
-  tex = test_utils_texture_new_from_data (test_ctx,
-                                          width, height,
-                                          flags,
-                                          COGL_PIXEL_FORMAT_RGBA_8888,
-                                          COGL_PIXEL_FORMAT_RGBA_8888,
-                                          width * 4,
-                                          data);
+  bmp = cogl_bitmap_new_for_data (test_ctx,
+                                  width, height,
+                                  COGL_PIXEL_FORMAT_RGBA_8888,
+                                  width * 4,
+                                  data);
+
+  tex = test_utils_texture_new_from_bitmap (bmp, flags,
+                                            FALSE);
 
   /* Replace the bottom right quarter of the data with negated data to
      test set_region */
diff --git a/tests/conform/test-texture-mipmap-get-set.c b/tests/conform/test-texture-mipmap-get-set.c
index 9cd86f0..c4cd0be 100644
--- a/tests/conform/test-texture-mipmap-get-set.c
+++ b/tests/conform/test-texture-mipmap-get-set.c
@@ -31,7 +31,6 @@ make_texture (void)
                                           TEXTURE_SIZE,
                                           TEST_UTILS_TEXTURE_NO_ATLAS,
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           TEXTURE_SIZE * 4,
                                           tex_data);
 
diff --git a/tests/conform/test-texture-no-allocate.c b/tests/conform/test-texture-no-allocate.c
index fb73e23..5bce8f6 100644
--- a/tests/conform/test-texture-no-allocate.c
+++ b/tests/conform/test-texture-no-allocate.c
@@ -32,8 +32,6 @@ test_texture_no_allocate (void)
                                       BIG_TEX_HEIGHT,
                                       /* format */
                                       COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                      /* internal format */
-                                      COGL_PIXEL_FORMAT_ANY,
                                       /* rowstride */
                                       BIG_TEX_WIDTH * 4,
                                       tex_data,
@@ -54,14 +52,12 @@ test_texture_no_allocate (void)
     cogl_texture_2d_sliced_new_with_size (test_ctx,
                                           BIG_TEX_WIDTH,
                                           BIG_TEX_HEIGHT,
-                                          COGL_TEXTURE_MAX_WASTE,
-                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+                                          COGL_TEXTURE_MAX_WASTE);
   cogl_object_unref (texture);
 
   /* 2D texture */
   texture_2d = cogl_texture_2d_new_with_size (test_ctx,
-                                              64, 64,
-                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+                                              64, 64);
   cogl_object_unref (texture_2d);
 
   /* 3D texture */
@@ -69,8 +65,7 @@ test_texture_no_allocate (void)
     {
       CoglTexture3D *texture_3d =
         cogl_texture_3d_new_with_size (test_ctx,
-                                       64, 64, 64,
-                                       COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+                                       64, 64, 64);
       cogl_object_unref (texture_3d);
     }
 
@@ -79,8 +74,7 @@ test_texture_no_allocate (void)
     {
       CoglTextureRectangle *texture_rect =
         cogl_texture_rectangle_new_with_size (test_ctx,
-                                              64, 64,
-                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+                                              64, 64);
       cogl_object_unref (texture_rect);
     }
 }
diff --git a/tests/conform/test-wrap-modes.c b/tests/conform/test-wrap-modes.c
index b5f11ac..5aea0eb 100644
--- a/tests/conform/test-wrap-modes.c
+++ b/tests/conform/test-wrap-modes.c
@@ -31,7 +31,6 @@ create_texture (TestUtilsTextureFlags flags)
   tex = test_utils_texture_new_from_data (test_ctx,
                                           TEX_SIZE, TEX_SIZE, flags,
                                           COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                          COGL_PIXEL_FORMAT_ANY,
                                           TEX_SIZE * 4,
                                           data);
   g_free (data);
diff --git a/tests/conform/test-wrap-rectangle-textures.c b/tests/conform/test-wrap-rectangle-textures.c
index 4274c98..73b3575 100644
--- a/tests/conform/test-wrap-rectangle-textures.c
+++ b/tests/conform/test-wrap-rectangle-textures.c
@@ -24,10 +24,7 @@ create_base_pipeline (void)
                                   2 * 3, /* rowstride */
                                   tex_data);
 
-  tex = cogl_texture_rectangle_new_from_bitmap (bmp,
-                                                /* internal format */
-                                                COGL_PIXEL_FORMAT_ANY,
-                                                NULL);
+  tex = cogl_texture_rectangle_new_from_bitmap (bmp);
 
   cogl_object_unref (bmp);
 
-- 
1.8.3.1



More information about the Cogl mailing list