[Cogl] [PATCH 08/11] tests: stop using cogl-auto-texture apis

Robert Bragg robert at sixbynine.org
Thu Jun 27 09:22:15 PDT 2013


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

The plan is to remove the cogl-auto-texture apis since they hide a bit
too much from developers but currently the conformance tests depend on
these apis in numerous places.

For the conformance tests it makes some sense to continue using high
level texture apis similar to the auto-texture apis since we may want
to make broad variations to how textures are allocated as part of the
testing running if that might help exercise more code paths.

This patch copies much of the auto-texture functionality into some
slightly more special purpose utilities in test-utils.c/h. Minor changes
include being constrained to the public Cogl api and they also don't
let you catch CoglErrors and just assume they should abort on error.
---
 test-fixtures/test-utils.c                  | 182 ++++++++++++++++++++++++++++
 test-fixtures/test-utils.h                  | 111 +++++++++++++++++
 tests/conform/test-atlas-migration.c        |  23 ++--
 tests/conform/test-backface-culling.c       |  26 ++--
 tests/conform/test-blend-strings.c          |  17 ++-
 tests/conform/test-color-mask.c             |   4 +-
 tests/conform/test-just-vertex-shader.c     |  15 ++-
 tests/conform/test-materials.c              |   4 +-
 tests/conform/test-multitexture.c           |   4 +-
 tests/conform/test-npot-texture.c           |  17 ++-
 tests/conform/test-primitive.c              |  15 ++-
 tests/conform/test-readpixels.c             |   4 +-
 tests/conform/test-snippets.c               |  15 ++-
 tests/conform/test-texture-get-set-data.c   |  23 ++--
 tests/conform/test-texture-mipmap-get-set.c |  17 ++-
 tests/conform/test-texture-mipmaps.c        |   2 +-
 tests/conform/test-texture-no-allocate.c    |  35 +++---
 tests/conform/test-texture-rectangle.c      |   4 +-
 tests/conform/test-viewport.c               |   4 +-
 tests/conform/test-wrap-modes.c             |  19 ++-
 20 files changed, 413 insertions(+), 128 deletions(-)

diff --git a/test-fixtures/test-utils.c b/test-fixtures/test-utils.c
index 6c4291f..a2706a9 100644
--- a/test-fixtures/test-utils.c
+++ b/test-fixtures/test-utils.c
@@ -349,3 +349,185 @@ cogl_test_verbose (void)
 {
   return cogl_test_is_verbose;
 }
+
+static void
+set_auto_mipmap_cb (CoglTexture *sub_texture,
+                    const float *sub_texture_coords,
+                    const float *meta_coords,
+                    void *user_data)
+{
+  cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (sub_texture),
+                                          FALSE);
+}
+
+CoglTexture *
+test_utils_texture_new_with_size (CoglContext *ctx,
+                                  int width,
+                                  int height,
+                                  TestUtilsTextureFlags flags,
+                                  CoglPixelFormat internal_format)
+{
+  CoglTexture *tex;
+  CoglError *skip_error = NULL;
+
+  if ((test_utils_is_pot (width) && test_utils_is_pot (height)) ||
+      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
+       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
+    {
+      /* First try creating a fast-path non-sliced texture */
+      tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
+                                                         width, height,
+                                                         internal_format));
+
+      if (!cogl_texture_allocate (tex, &skip_error))
+        {
+          cogl_error_free (skip_error);
+          cogl_object_unref (tex);
+          tex = NULL;
+        }
+    }
+  else
+    tex = NULL;
+
+  if (!tex)
+    {
+      /* If it fails resort to sliced textures */
+      int max_waste = flags & TEST_UTILS_TEXTURE_NO_SLICING ?
+        -1 : COGL_TEXTURE_MAX_WASTE;
+      CoglTexture2DSliced *tex_2ds =
+        cogl_texture_2d_sliced_new_with_size (ctx,
+                                              width,
+                                              height,
+                                              max_waste,
+                                              internal_format);
+      tex = COGL_TEXTURE (tex_2ds);
+    }
+
+  if (flags & TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP)
+    {
+      /* To be able to iterate the slices of a #CoglTexture2DSliced we
+       * need to ensure the texture is allocated... */
+      cogl_texture_allocate (tex, NULL); /* don't catch exceptions */
+
+      cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
+                                           0, 0, 1, 1,
+                                           COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
+                                           COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
+                                           set_auto_mipmap_cb,
+                                           NULL); /* don't catch exceptions */
+    }
+
+  cogl_texture_allocate (tex, NULL);
+
+  return tex;
+}
+
+CoglTexture *
+test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
+                                    TestUtilsTextureFlags flags,
+                                    CoglPixelFormat internal_format)
+{
+  CoglAtlasTexture *atlas_tex;
+  CoglTexture *tex;
+  CoglError *internal_error = NULL;
+
+  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);
+        }
+
+      cogl_error_free (internal_error);
+      internal_error = NULL;
+    }
+
+  /* If that doesn't work try a fast path 2D texture */
+  if ((test_utils_is_pot (cogl_bitmap_get_width (bitmap)) &&
+       test_utils_is_pot (cogl_bitmap_get_height (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));
+
+      if (cogl_error_matches (internal_error,
+                              COGL_SYSTEM_ERROR,
+                              COGL_SYSTEM_ERROR_NO_MEMORY))
+        {
+          g_assert_not_reached ();
+          return NULL;
+        }
+
+      if (!tex)
+        {
+          cogl_error_free (internal_error);
+          internal_error = NULL;
+        }
+    }
+  else
+    tex = NULL;
+
+  if (!tex)
+    {
+      /* Otherwise create a sliced texture */
+      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 */
+      tex = COGL_TEXTURE (tex_2ds);
+    }
+
+  if (flags & TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP)
+    {
+      cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
+                                           0, 0, 1, 1,
+                                           COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
+                                           COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
+                                           set_auto_mipmap_cb,
+                                           NULL); /* don't catch exceptions */
+    }
+
+  cogl_texture_allocate (tex, NULL);
+
+  return tex;
+}
+
+CoglTexture *
+test_utils_texture_new_from_data (CoglContext *ctx,
+                                  int width,
+                                  int height,
+                                  TestUtilsTextureFlags flags,
+                                  CoglPixelFormat format,
+                                  CoglPixelFormat internal_format,
+                                  int rowstride,
+                                  const uint8_t *data)
+{
+  CoglBitmap *bmp;
+  CoglTexture *tex;
+
+  g_assert_cmpint (format, !=, COGL_PIXEL_FORMAT_ANY);
+  g_assert (data != NULL);
+
+  /* Wrap the data into a bitmap */
+  bmp = cogl_bitmap_new_for_data (ctx,
+                                  width, height,
+                                  format,
+                                  rowstride,
+                                  (uint8_t *) data);
+
+  tex = test_utils_texture_new_from_bitmap (bmp, flags, internal_format);
+
+  cogl_object_unref (bmp);
+
+  return tex;
+}
diff --git a/test-fixtures/test-utils.h b/test-fixtures/test-utils.h
index f7cb748..5a3ef26 100644
--- a/test-fixtures/test-utils.h
+++ b/test-fixtures/test-utils.h
@@ -26,6 +26,27 @@ typedef enum _TestFlags
   TEST_REQUIREMENT_PER_VERTEX_POINT_SIZE = 1<<11
 } TestFlags;
 
+ /**
+ * TestUtilsTextureFlags:
+ * @TEST_UTILS_TEXTURE_NONE: No flags specified
+ * @TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP: Disables the automatic generation of
+ *   the mipmap pyramid from the base level image whenever it is
+ *   updated. The mipmaps are only generated when the texture is
+ *   rendered with a mipmap filter so it should be free to leave out
+ *   this flag when using other filtering modes
+ * @TEST_UTILS_TEXTURE_NO_SLICING: Disables the slicing of the texture
+ * @TEST_UTILS_TEXTURE_NO_ATLAS: Disables the insertion of the texture inside
+ *   the texture atlas used by Cogl
+ *
+ * Flags to pass to the test_utils_texture_new_* family of functions.
+ */
+typedef enum {
+  TEST_UTILS_TEXTURE_NONE           = 0,
+  TEST_UTILS_TEXTURE_NO_AUTO_MIPMAP = 1 << 0,
+  TEST_UTILS_TEXTURE_NO_SLICING     = 1 << 1,
+  TEST_UTILS_TEXTURE_NO_ATLAS       = 1 << 2
+} TestUtilsTextureFlags;
+
 extern CoglContext *test_ctx;
 extern CoglFramebuffer *test_fb;
 
@@ -37,6 +58,84 @@ void
 test_utils_fini (void);
 
 /*
+ * test_utils_texture_new_with_size:
+ * @context: A #CoglContext
+ * @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.
+ *
+ * Creates a new #CoglTexture with the specified dimensions and pixel format.
+ *
+ * The storage for the texture is not necesarily created before this
+ * function returns. The storage can be explicitly allocated using
+ * cogl_texture_allocate() or preferably you can let Cogl
+ * automatically allocate the storage lazily when uploading data when
+ * Cogl may know more about how the texture will be used and can
+ * optimize how it is allocated.
+ *
+ * Return value: A newly created #CoglTexture
+ */
+CoglTexture *
+test_utils_texture_new_with_size (CoglContext *ctx,
+                                  int width,
+                                  int height,
+                                  TestUtilsTextureFlags flags,
+                                  CoglPixelFormat internal_format);
+
+/*
+ * test_utils_texture_new_from_data:
+ * @context: A #CoglContext
+ * @width: width of texture in pixels
+ * @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
+ * @error: A #CoglError to catch exceptional errors or %NULL
+ *
+ * Creates a new #CoglTexture based on data residing in memory.
+ *
+ * Return value: A newly created #CoglTexture or %NULL on failure
+ */
+CoglTexture *
+test_utils_texture_new_from_data (CoglContext *ctx,
+                                  int width,
+                                  int height,
+                                  TestUtilsTextureFlags flags,
+                                  CoglPixelFormat format,
+                                  CoglPixelFormat internal_format,
+                                  int rowstride,
+                                  const uint8_t *data);
+
+/*
+ * 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
+ *
+ * Creates a #CoglTexture from a #CoglBitmap.
+ *
+ * Return value: A newly created #CoglTexture or %NULL on failure
+ */
+CoglTexture *
+test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
+                                    TestUtilsTextureFlags flags,
+                                    CoglPixelFormat internal_format);
+
+/*
  * test_utils_check_pixel:
  * @framebuffer: The #CoglFramebuffer to read from
  * @x: x co-ordinate of the pixel to test
@@ -154,4 +253,16 @@ test_utils_create_color_texture (CoglContext *context,
 CoglBool
 cogl_test_verbose (void);
 
+/* test_util_is_pot:
+ * @number: A number to test
+ *
+ * Returns whether the given integer is a power of two
+ */
+static inline CoglBool
+test_utils_is_pot (unsigned int number)
+{
+  /* Make sure there is only one bit set */
+  return (number & (number - 1)) == 0;
+}
+
 #endif /* _TEST_UTILS_H_ */
diff --git a/tests/conform/test-atlas-migration.c b/tests/conform/test-atlas-migration.c
index 21f375a..f8435bc 100644
--- a/tests/conform/test-atlas-migration.c
+++ b/tests/conform/test-atlas-migration.c
@@ -53,18 +53,17 @@ create_texture (int size)
         }
     }
 
-  texture = cogl_texture_new_from_data (test_ctx,
-                                        size, /* width */
-                                        size, /* height */
-                                        COGL_TEXTURE_NONE, /* flags */
-                                        /* format */
-                                        COGL_PIXEL_FORMAT_RGBA_8888,
-                                        /* internal format */
-                                        COGL_PIXEL_FORMAT_RGBA_8888,
-                                        /* rowstride */
-                                        size * 4,
-                                        data,
-                                        NULL); /* don't catch errors */
+  texture = test_utils_texture_new_from_data (test_ctx,
+                                              size, /* width */
+                                              size, /* height */
+                                              TEST_UTILS_TEXTURE_NONE, /* flags */
+                                              /* format */
+                                              COGL_PIXEL_FORMAT_RGBA_8888,
+                                              /* internal format */
+                                              COGL_PIXEL_FORMAT_RGBA_8888,
+                                              /* rowstride */
+                                              size * 4,
+                                              data);
 
   g_free (data);
 
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index 479eb17..723ea12 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -210,15 +210,14 @@ make_texture (void)
       *(--p) = 255;
     }
 
-  tex = cogl_texture_new_from_data (test_ctx,
-                                    TEXTURE_SIZE,
-                                    TEXTURE_SIZE,
-                                    COGL_TEXTURE_NO_ATLAS,
-                                    COGL_PIXEL_FORMAT_RGBA_8888,
-                                    COGL_PIXEL_FORMAT_ANY,
-                                    TEXTURE_SIZE * 4,
-                                    tex_data,
-                                    NULL); /* don't catch errors */
+  tex = test_utils_texture_new_from_data (test_ctx,
+                                          TEXTURE_SIZE,
+                                          TEXTURE_SIZE,
+                                          TEST_UTILS_TEXTURE_NO_ATLAS,
+                                          COGL_PIXEL_FORMAT_RGBA_8888,
+                                          COGL_PIXEL_FORMAT_ANY,
+                                          TEXTURE_SIZE * 4,
+                                          tex_data);
 
   g_free (tex_data);
 
@@ -238,10 +237,11 @@ test_backface_culling (void)
 
   state.texture = make_texture ();
 
-  tex = cogl_texture_new_with_size (test_ctx,
-                                    state.width, state.height,
-                                    COGL_TEXTURE_NO_SLICING,
-                                    COGL_PIXEL_FORMAT_ANY); /* internal fmt */
+  tex = test_utils_texture_new_with_size (test_ctx,
+                                          state.width, state.height,
+                                          TEST_UTILS_TEXTURE_NO_SLICING,
+                                          COGL_PIXEL_FORMAT_ANY); /* internal
+                                                                     format */
   state.offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_to_texture (tex));
   state.offscreen_tex = tex;
 
diff --git a/tests/conform/test-blend-strings.c b/tests/conform/test-blend-strings.c
index 0cabc55..34049d5 100644
--- a/tests/conform/test-blend-strings.c
+++ b/tests/conform/test-blend-strings.c
@@ -144,15 +144,14 @@ make_texture (uint32_t color)
 
   /* 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. */
-  tex = cogl_texture_new_from_data (test_ctx,
-                                    QUAD_WIDTH,
-                                    QUAD_WIDTH,
-                                    COGL_TEXTURE_NONE,
-                                    COGL_PIXEL_FORMAT_RGBA_8888,
-                                    COGL_PIXEL_FORMAT_RGBA_8888,
-                                    QUAD_WIDTH * 4,
-                                    tex_data,
-                                    NULL); /* don't catch errors */
+  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,
+                                          QUAD_WIDTH * 4,
+                                          tex_data);
 
   g_free (tex_data);
 
diff --git a/tests/conform/test-color-mask.c b/tests/conform/test-color-mask.c
index 62fe353..a6689d1 100644
--- a/tests/conform/test-color-mask.c
+++ b/tests/conform/test-color-mask.c
@@ -81,8 +81,8 @@ test_color_mask (void)
 
   for (i = 0; i < NUM_FBOS; i++)
     {
-      state.tex[i] = cogl_texture_new_with_size (test_ctx, 128, 128,
-                                                 COGL_TEXTURE_NO_ATLAS,
+      state.tex[i] = test_utils_texture_new_with_size (test_ctx, 128, 128,
+                                                 TEST_UTILS_TEXTURE_NO_ATLAS,
                                                  COGL_PIXEL_FORMAT_RGB_888);
 
 
diff --git a/tests/conform/test-just-vertex-shader.c b/tests/conform/test-just-vertex-shader.c
index 3aba7ab..355b57d 100644
--- a/tests/conform/test-just-vertex-shader.c
+++ b/tests/conform/test-just-vertex-shader.c
@@ -16,14 +16,13 @@ create_dummy_texture (void)
      vertex shader */
   static const uint8_t data[4] = { 0x00, 0xff, 0x00, 0xff };
 
-  return cogl_texture_new_from_data (test_ctx,
-                                     1, 1, /* size */
-                                     COGL_TEXTURE_NONE,
-                                     COGL_PIXEL_FORMAT_RGB_888,
-                                     COGL_PIXEL_FORMAT_ANY,
-                                     4, /* rowstride */
-                                     data,
-                                     NULL); /* don't catch errors */
+  return test_utils_texture_new_from_data (test_ctx,
+                                           1, 1, /* size */
+                                           TEST_UTILS_TEXTURE_NONE,
+                                           COGL_PIXEL_FORMAT_RGB_888,
+                                           COGL_PIXEL_FORMAT_ANY,
+                                           4, /* rowstride */
+                                           data);
 }
 
 static void
diff --git a/tests/conform/test-materials.c b/tests/conform/test-materials.c
index 7c1da2f..69c9c74 100644
--- a/tests/conform/test-materials.c
+++ b/tests/conform/test-materials.c
@@ -111,11 +111,11 @@ test_using_all_layers (TestState *state, int x, int y)
      will use a red texture. The layers will all be modulated together
      so the final fragment should be red. */
 
-  white_texture = cogl_texture_new_from_data (1, 1, COGL_TEXTURE_NONE,
+  white_texture = test_utils_texture_new_from_data (1, 1, TEST_UTILS_TEXTURE_NONE,
                                               COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                               COGL_PIXEL_FORMAT_ANY,
                                               4, white_pixel);
-  red_texture = cogl_texture_new_from_data (1, 1, COGL_TEXTURE_NONE,
+  red_texture = test_utils_texture_new_from_data (1, 1, TEST_UTILS_TEXTURE_NONE,
                                             COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                             COGL_PIXEL_FORMAT_ANY,
                                             4, red_pixel);
diff --git a/tests/conform/test-multitexture.c b/tests/conform/test-multitexture.c
index 6eab806..da38766 100644
--- a/tests/conform/test-multitexture.c
+++ b/tests/conform/test-multitexture.c
@@ -85,9 +85,9 @@ make_texture (guchar ref)
 
   /* 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. */
-  tex = cogl_texture_new_from_data (QUAD_WIDTH * 2,
+  tex = test_utils_texture_new_from_data (QUAD_WIDTH * 2,
                                     QUAD_WIDTH * 2,
-                                    COGL_TEXTURE_NONE,
+                                    TEST_UTILS_TEXTURE_NONE,
                                     COGL_PIXEL_FORMAT_RGBA_8888,
                                     COGL_PIXEL_FORMAT_RGBA_8888,
                                     QUAD_WIDTH * 8,
diff --git a/tests/conform/test-npot-texture.c b/tests/conform/test-npot-texture.c
index d22ba65..3460fed 100644
--- a/tests/conform/test-npot-texture.c
+++ b/tests/conform/test-npot-texture.c
@@ -87,15 +87,14 @@ make_texture (void)
         }
     }
 
-  tex = cogl_texture_new_from_data (test_ctx,
-                                    TEXTURE_SIZE,
-                                    TEXTURE_SIZE,
-                                    COGL_TEXTURE_NO_ATLAS,
-                                    COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                    COGL_PIXEL_FORMAT_ANY,
-                                    TEXTURE_SIZE * 4,
-                                    tex_data,
-                                    NULL); /* ignore errors */
+  tex = test_utils_texture_new_from_data (test_ctx,
+                                          TEXTURE_SIZE,
+                                          TEXTURE_SIZE,
+                                          TEST_UTILS_TEXTURE_NO_ATLAS,
+                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+                                          COGL_PIXEL_FORMAT_ANY,
+                                          TEXTURE_SIZE * 4,
+                                          tex_data);
 
   g_free (tex_data);
 
diff --git a/tests/conform/test-primitive.c b/tests/conform/test-primitive.c
index c446bf9..3d5bdc3 100644
--- a/tests/conform/test-primitive.c
+++ b/tests/conform/test-primitive.c
@@ -170,14 +170,13 @@ test_paint (TestState *state)
   tex_data[3] = (TEX_COLOR >> 24) & 0xff;
   tex_data[4] = (TEX_COLOR >> 16) & 0xff;
   tex_data[5] = (TEX_COLOR >> 8) & 0xff;
-  tex = cogl_texture_new_from_data (test_ctx,
-                                    2, 1, /* size */
-                                    COGL_TEXTURE_NO_ATLAS,
-                                    COGL_PIXEL_FORMAT_RGB_888,
-                                    COGL_PIXEL_FORMAT_ANY,
-                                    6, /* rowstride */
-                                    tex_data,
-                                    NULL); /* don't catch errors */
+  tex = test_utils_texture_new_from_data (test_ctx,
+                                          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);
   cogl_pipeline_set_color4ub (pipeline,
                               (PRIM_COLOR >> 24) & 0xff,
diff --git a/tests/conform/test-readpixels.c b/tests/conform/test-readpixels.c
index 83a1712..f543fb0 100644
--- a/tests/conform/test-readpixels.c
+++ b/tests/conform/test-readpixels.c
@@ -44,8 +44,8 @@ on_paint (ClutterActor *actor, void *state)
    */
 
   data = g_malloc (FRAMEBUFFER_WIDTH * 4 * FRAMEBUFFER_HEIGHT);
-  tex = cogl_texture_new_from_data (FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
-                                    COGL_TEXTURE_NO_SLICING,
+  tex = test_utils_texture_new_from_data (FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
+                                    TEST_UTILS_TEXTURE_NO_SLICING,
                                     COGL_PIXEL_FORMAT_RGBA_8888, /* data fmt */
                                     COGL_PIXEL_FORMAT_ANY, /* internal fmt */
                                     FRAMEBUFFER_WIDTH * 4, /* rowstride */
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index 07a99a1..e8a0125 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -22,14 +22,13 @@ create_texture_pipeline (TestState *state)
       0x00, 0x00, 0xff, 0xff, /* blue */ 0xff, 0xff, 0x00, 0xff, /* yellow */
     };
 
-  tex = cogl_texture_new_from_data (test_ctx,
-                                    2, 2, /* width/height */
-                                    COGL_TEXTURE_NO_ATLAS,
-                                    COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                    COGL_PIXEL_FORMAT_ANY,
-                                    8, /* rowstride */
-                                    tex_data,
-                                    NULL); /* don't catch errors */
+  tex = test_utils_texture_new_from_data (test_ctx,
+                                          2, 2, /* width/height */
+                                          TEST_UTILS_TEXTURE_NO_ATLAS,
+                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+                                          COGL_PIXEL_FORMAT_ANY,
+                                          8, /* rowstride */
+                                          tex_data);
 
   pipeline = cogl_pipeline_new (test_ctx);
 
diff --git a/tests/conform/test-texture-get-set-data.c b/tests/conform/test-texture-get-set-data.c
index cf24e4d..4c66f27 100644
--- a/tests/conform/test-texture-get-set-data.c
+++ b/tests/conform/test-texture-get-set-data.c
@@ -5,7 +5,7 @@
 #include "test-utils.h"
 
 static void
-check_texture (int width, int height, CoglTextureFlags flags)
+check_texture (int width, int height, TestUtilsTextureFlags flags)
 {
   CoglTexture *tex;
   uint8_t *data, *p;
@@ -22,14 +22,13 @@ check_texture (int width, int height, CoglTextureFlags flags)
         *(p++) = (x ^ y);
       }
 
-  tex = cogl_texture_new_from_data (test_ctx,
-                                    width, height,
-                                    flags,
-                                    COGL_PIXEL_FORMAT_RGBA_8888,
-                                    COGL_PIXEL_FORMAT_RGBA_8888,
-                                    width * 4,
-                                    data,
-                                    NULL); /* abort on error */
+  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);
 
   /* Replace the bottom right quarter of the data with negated data to
      test set_region */
@@ -129,13 +128,13 @@ void
 test_texture_get_set_data (void)
 {
   /* First try without atlasing */
-  check_texture (256, 256, COGL_TEXTURE_NO_ATLAS);
+  check_texture (256, 256, TEST_UTILS_TEXTURE_NO_ATLAS);
   /* Try again with atlasing. This should end up testing the atlas
      backend and the sub texture backend */
   check_texture (256, 256, 0);
   /* Try with a really big texture in the hope that it will end up
      sliced. */
-  check_texture (4, 5128, COGL_TEXTURE_NO_ATLAS);
+  check_texture (4, 5128, TEST_UTILS_TEXTURE_NO_ATLAS);
   /* And in the other direction. */
-  check_texture (5128, 4, COGL_TEXTURE_NO_ATLAS);
+  check_texture (5128, 4, TEST_UTILS_TEXTURE_NO_ATLAS);
 }
diff --git a/tests/conform/test-texture-mipmap-get-set.c b/tests/conform/test-texture-mipmap-get-set.c
index 12d0f6b..7d4e541 100644
--- a/tests/conform/test-texture-mipmap-get-set.c
+++ b/tests/conform/test-texture-mipmap-get-set.c
@@ -26,15 +26,14 @@ make_texture (void)
         }
     }
 
-  tex = cogl_texture_new_from_data (test_ctx,
-                                    TEXTURE_SIZE,
-                                    TEXTURE_SIZE,
-                                    COGL_TEXTURE_NO_ATLAS,
-                                    COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                    COGL_PIXEL_FORMAT_ANY,
-                                    TEXTURE_SIZE * 4,
-                                    tex_data,
-                                    NULL); /* ignore errors */
+  tex = test_utils_texture_new_from_data (test_ctx,
+                                          TEXTURE_SIZE,
+                                          TEXTURE_SIZE,
+                                          TEST_UTILS_TEXTURE_NO_ATLAS,
+                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+                                          COGL_PIXEL_FORMAT_ANY,
+                                          TEXTURE_SIZE * 4,
+                                          tex_data);
 
   cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (tex), FALSE);
 
diff --git a/tests/conform/test-texture-mipmaps.c b/tests/conform/test-texture-mipmaps.c
index b6cd421..3118ba8 100644
--- a/tests/conform/test-texture-mipmaps.c
+++ b/tests/conform/test-texture-mipmaps.c
@@ -33,7 +33,7 @@ make_texture (void)
         p += 3;
       }
 
-  tex = cogl_texture_new_from_data (TEX_SIZE, TEX_SIZE, COGL_TEXTURE_NONE,
+  tex = test_utils_texture_new_from_data (TEX_SIZE, TEX_SIZE, TEST_UTILS_TEXTURE_NONE,
                                     COGL_PIXEL_FORMAT_RGB_888,
                                     COGL_PIXEL_FORMAT_ANY,
                                     TEX_SIZE * 3,
diff --git a/tests/conform/test-texture-no-allocate.c b/tests/conform/test-texture-no-allocate.c
index 56cca44..b2152c5 100644
--- a/tests/conform/test-texture-no-allocate.c
+++ b/tests/conform/test-texture-no-allocate.c
@@ -26,18 +26,18 @@ test_texture_no_allocate (void)
 
   /* Try to create an atlas texture that is too big so it will
    * internally be freed without allocating */
-  texture = cogl_texture_new_from_data (test_ctx,
-                                        BIG_TEX_WIDTH,
-                                        BIG_TEX_HEIGHT,
-                                        COGL_TEXTURE_NONE, /* flags */
-                                        /* format */
-                                        COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                        /* internal format */
-                                        COGL_PIXEL_FORMAT_ANY,
-                                        /* rowstride */
-                                        BIG_TEX_WIDTH * 4,
-                                        tex_data,
-                                        &error);
+  texture = COGL_TEXTURE (
+    cogl_atlas_texture_new_from_data (test_ctx,
+                                      BIG_TEX_WIDTH,
+                                      BIG_TEX_HEIGHT,
+                                      /* format */
+                                      COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+                                      /* internal format */
+                                      COGL_PIXEL_FORMAT_ANY,
+                                      /* rowstride */
+                                      BIG_TEX_WIDTH * 4,
+                                      tex_data,
+                                      &error));
 
   g_free (tex_data);
 
@@ -50,11 +50,12 @@ test_texture_no_allocate (void)
     cogl_object_unref (texture);
 
   /* Try to create a sliced texture without allocating it */
-  texture = cogl_texture_new_with_size (test_ctx,
-                                        BIG_TEX_WIDTH,
-                                        BIG_TEX_HEIGHT,
-                                        COGL_TEXTURE_NO_ATLAS,
-                                        COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+  texture = COGL_TEXTURE (
+    cogl_texture_2d_sliced_new_with_size (test_ctx,
+                                          BIG_TEX_WIDTH,
+                                          BIG_TEX_HEIGHT,
+                                          COGL_TEXTURE_MAX_WASTE,
+                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE));
   cogl_object_unref (texture);
 
   /* 2D texture */
diff --git a/tests/conform/test-texture-rectangle.c b/tests/conform/test-texture-rectangle.c
index 7766297..3784cdc 100644
--- a/tests/conform/test-texture-rectangle.c
+++ b/tests/conform/test-texture-rectangle.c
@@ -69,7 +69,7 @@ create_source_rect (void)
 
   g_free (data);
 
-  tex = cogl_texture_new_from_foreign (gl_tex,
+  tex = test_utils_texture_new_from_foreign (gl_tex,
                                        GL_TEXTURE_RECTANGLE_ARB,
                                        256, 256, 0, 0,
                                        COGL_PIXEL_FORMAT_RGBA_8888);
@@ -99,7 +99,7 @@ create_source_2d (void)
         *(p++) = 255;
       }
 
-  tex = cogl_texture_new_from_data (256, 256, COGL_TEXTURE_NONE,
+  tex = test_utils_texture_new_from_data (256, 256, TEST_UTILS_TEXTURE_NONE,
                                     COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                     COGL_PIXEL_FORMAT_ANY,
                                     256 * 4,
diff --git a/tests/conform/test-viewport.c b/tests/conform/test-viewport.c
index 3e610e8..c437ec7 100644
--- a/tests/conform/test-viewport.c
+++ b/tests/conform/test-viewport.c
@@ -210,8 +210,8 @@ on_paint (ClutterActor *actor, void *state)
    * Next test offscreen drawing...
    */
   data = g_malloc (FRAMEBUFFER_WIDTH * 4 * FRAMEBUFFER_HEIGHT);
-  tex = cogl_texture_new_from_data (FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
-                                    COGL_TEXTURE_NO_SLICING,
+  tex = test_utils_texture_new_from_data (FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,
+                                    TEST_UTILS_TEXTURE_NO_SLICING,
                                     COGL_PIXEL_FORMAT_RGBA_8888, /* data fmt */
                                     COGL_PIXEL_FORMAT_ANY, /* internal fmt */
                                     FRAMEBUFFER_WIDTH * 4, /* rowstride */
diff --git a/tests/conform/test-wrap-modes.c b/tests/conform/test-wrap-modes.c
index d59b71d..b5f11ac 100644
--- a/tests/conform/test-wrap-modes.c
+++ b/tests/conform/test-wrap-modes.c
@@ -13,7 +13,7 @@ typedef struct _TestState
 } TestState;
 
 static CoglTexture *
-create_texture (CoglTextureFlags flags)
+create_texture (TestUtilsTextureFlags flags)
 {
   uint8_t *data = g_malloc (TEX_SIZE * TEX_SIZE * 4), *p = data;
   CoglTexture *tex;
@@ -28,13 +28,12 @@ create_texture (CoglTextureFlags flags)
         *(p++) = 255;
       }
 
-  tex = cogl_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,
-                                    NULL); /* don't catch errors */
+  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);
 
   return tex;
@@ -168,13 +167,13 @@ static void
 paint (TestState *state)
 {
   /* Draw the tests first with a non atlased texture */
-  state->texture = create_texture (COGL_TEXTURE_NO_ATLAS);
+  state->texture = create_texture (TEST_UTILS_TEXTURE_NO_ATLAS);
   draw_tests (state);
   cogl_object_unref (state->texture);
 
   /* Draw the tests again with a possible atlased texture. This should
      end up testing software repeats */
-  state->texture = create_texture (COGL_TEXTURE_NONE);
+  state->texture = create_texture (TEST_UTILS_TEXTURE_NONE);
   cogl_framebuffer_push_matrix (test_fb);
   cogl_framebuffer_translate (test_fb, 0.0f, TEX_SIZE * 2.0f, 0.0f);
   draw_tests (state);
-- 
1.8.2.1



More information about the Cogl mailing list