diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c
index 4ecf2abf8..fbf8ce6fd 100644
--- a/cogl/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl/cogl-atlas-texture.c
@@ -956,28 +956,6 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
return atlas_tex;
}
-CoglAtlasTexture *
-cogl_atlas_texture_new_from_file (CoglContext *ctx,
- const char *filename,
- GError **error)
-{
- CoglBitmap *bmp;
- CoglAtlasTexture *atlas_tex = NULL;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- bmp = cogl_bitmap_new_from_file (filename, error);
- if (bmp == NULL)
- return NULL;
-
- atlas_tex = _cogl_atlas_texture_new_from_bitmap (bmp,
- TRUE); /* convert in-place */
-
- cogl_object_unref (bmp);
-
- return atlas_tex;
-}
-
void
_cogl_atlas_texture_add_reorganize_callback (CoglContext *ctx,
GHookFunc callback,
diff --git a/cogl/cogl/cogl-atlas-texture.h b/cogl/cogl/cogl-atlas-texture.h
index e79665980..512f75087 100644
--- a/cogl/cogl/cogl-atlas-texture.h
+++ b/cogl/cogl/cogl-atlas-texture.h
@@ -111,42 +111,6 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
int width,
int height);
-/**
- * cogl_atlas_texture_new_from_file:
- * @ctx: A #CoglContext
- * @filename: the file to load
- * @error: A #GError 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
- * atlases.
- *
- * The storage for the texture is not allocated before this function
- * returns. You can call cogl_texture_allocate() to explicitly
- * allocate the underlying storage or let Cogl automatically allocate
- * storage lazily.
- *
- * The texture is still configurable until it has been allocated so
- * for example you can influence the internal format of the texture
- * using cogl_texture_set_components() and
- * cogl_texture_set_premultiplied().
- *
- * Allocate call can fail if Cogl considers the internal
- * format to be incompatible with the format of its internal
- * atlases.
- *
- * The returned #CoglAtlasTexture is a high-level meta-texture
- * with some limitations. See the documentation for #CoglMetaTexture
- * for more details.
- *
- * Return value: (transfer full): A new #CoglAtlasTexture object or
- * %NULL on failure and @error will be updated.
- */
-COGL_EXPORT CoglAtlasTexture *
-cogl_atlas_texture_new_from_file (CoglContext *ctx,
- const char *filename,
- GError **error);
-
/**
* cogl_atlas_texture_new_from_data:
* @ctx: A #CoglContext
diff --git a/cogl/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl/cogl-bitmap-pixbuf.c
deleted file mode 100644
index 19fd8d179..000000000
--- a/cogl/cogl/cogl-bitmap-pixbuf.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Cogl
- *
- * A Low Level GPU Graphics and Utilities API
- *
- * Copyright (C) 2007,2008,2009 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- *
- */
-
-#include "cogl-config.h"
-
-#include "cogl/cogl-util.h"
-#include "cogl/cogl-bitmap-private.h"
-#include "cogl/cogl-context-private.h"
-#include "cogl/cogl-private.h"
-
-#include
-
-#include
-
-gboolean
-_cogl_bitmap_get_size_from_file (const char *filename,
- int *width,
- int *height)
-{
- g_return_val_if_fail (filename != NULL, FALSE);
-
- if (gdk_pixbuf_get_file_info (filename, width, height) != NULL)
- return TRUE;
-
- return FALSE;
-}
-
-CoglBitmap *
-_cogl_bitmap_from_file (CoglContext *ctx,
- const char *filename,
- GError **error)
-{
- static CoglUserDataKey pixbuf_key;
- GdkPixbuf *pixbuf;
- gboolean has_alpha;
- GdkColorspace color_space;
- CoglPixelFormat pixel_format;
- int width;
- int height;
- int rowstride;
- int bits_per_sample;
- int n_channels;
- CoglBitmap *bmp;
- GError *glib_error = NULL;
-
- /* Load from file using GdkPixbuf */
- pixbuf = gdk_pixbuf_new_from_file (filename, &glib_error);
- if (pixbuf == NULL)
- {
- g_propagate_error (error, glib_error);
- return FALSE;
- }
-
- /* Get pixbuf properties */
- has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
- color_space = gdk_pixbuf_get_colorspace (pixbuf);
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
- n_channels = gdk_pixbuf_get_n_channels (pixbuf);
-
- /* According to current docs this should be true and so
- * the translation to cogl pixel format below valid */
- g_assert (bits_per_sample == 8);
-
- if (has_alpha)
- g_assert (n_channels == 4);
- else
- g_assert (n_channels == 3);
-
- /* Translate to cogl pixel format */
- switch (color_space)
- {
- case GDK_COLORSPACE_RGB:
- /* The only format supported by GdkPixbuf so far */
- pixel_format = has_alpha ?
- COGL_PIXEL_FORMAT_RGBA_8888 :
- COGL_PIXEL_FORMAT_RGB_888;
- break;
-
- default:
- /* Ouch, spec changed! */
- g_object_unref (pixbuf);
- return FALSE;
- }
-
- /* We just use the data directly from the pixbuf so that we don't
- have to copy to a separate buffer. Note that Cogl is expected not
- to read past the end of bpp*width on the last row even if the
- rowstride is much larger so we don't need to worry about
- GdkPixbuf's semantics that it may under-allocate the buffer. */
- bmp = cogl_bitmap_new_for_data (ctx,
- width,
- height,
- pixel_format,
- rowstride,
- gdk_pixbuf_get_pixels (pixbuf));
-
- cogl_object_set_user_data (COGL_OBJECT (bmp),
- &pixbuf_key,
- pixbuf,
- g_object_unref);
-
- return bmp;
-}
diff --git a/cogl/cogl/cogl-bitmap-private.h b/cogl/cogl/cogl-bitmap-private.h
index 238a78aa8..31a259a34 100644
--- a/cogl/cogl/cogl-bitmap-private.h
+++ b/cogl/cogl/cogl-bitmap-private.h
@@ -113,11 +113,6 @@ _cogl_bitmap_convert_into_bitmap (CoglBitmap *src_bmp,
CoglBitmap *dst_bmp,
GError **error);
-CoglBitmap *
-_cogl_bitmap_from_file (CoglContext *ctx,
- const char *filename,
- GError **error);
-
gboolean
_cogl_bitmap_unpremult (CoglBitmap *dst_bmp,
GError **error);
@@ -147,11 +142,6 @@ CoglBitmap *
_cogl_bitmap_copy (CoglBitmap *src_bmp,
GError **error);
-gboolean
-_cogl_bitmap_get_size_from_file (const char *filename,
- int *width,
- int *height);
-
void
_cogl_bitmap_set_format (CoglBitmap *bitmap,
CoglPixelFormat format);
diff --git a/cogl/cogl/cogl-bitmap.c b/cogl/cogl/cogl-bitmap.c
index 2b988cba9..4f1d7442f 100644
--- a/cogl/cogl/cogl-bitmap.c
+++ b/cogl/cogl/cogl-bitmap.c
@@ -165,14 +165,6 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
return succeeded;
}
-gboolean
-cogl_bitmap_get_size_from_file (const char *filename,
- int *width,
- int *height)
-{
- return _cogl_bitmap_get_size_from_file (filename, width, height);
-}
-
CoglBitmap *
cogl_bitmap_new_for_data (CoglContext *context,
int width,
@@ -267,18 +259,6 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
return bmp;
}
-CoglBitmap *
-cogl_bitmap_new_from_file (const char *filename,
- GError **error)
-{
- _COGL_GET_CONTEXT (ctx, NULL);
-
- g_return_val_if_fail (filename != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- return _cogl_bitmap_from_file (ctx, filename, error);
-}
-
CoglBitmap *
cogl_bitmap_new_from_buffer (CoglBuffer *buffer,
CoglPixelFormat format,
diff --git a/cogl/cogl/cogl-bitmap.h b/cogl/cogl/cogl-bitmap.h
index 134ac9916..3a80a1969 100644
--- a/cogl/cogl/cogl-bitmap.h
+++ b/cogl/cogl/cogl-bitmap.h
@@ -67,21 +67,6 @@ GType cogl_bitmap_get_gtype (void);
*/
-/**
- * cogl_bitmap_new_from_file:
- * @filename: the file to load.
- * @error: a #GError or %NULL.
- *
- * Loads an image file from disk. This function can be safely called from
- * within a thread.
- *
- * Return value: (transfer full): a #CoglBitmap to the new loaded
- * image data, or %NULL if loading the image failed.
- */
-COGL_EXPORT CoglBitmap *
-cogl_bitmap_new_from_file (const char *filename,
- GError **error);
-
/**
* cogl_bitmap_new_from_buffer: (skip)
* @buffer: A #CoglBuffer containing image data
@@ -207,29 +192,11 @@ cogl_bitmap_get_rowstride (CoglBitmap *bitmap);
* @bitmap: A #CoglBitmap
*
* Return value: (transfer none): the #CoglPixelBuffer that this
- * buffer uses for storage. Note that if the bitmap was created with
- * cogl_bitmap_new_from_file() then it will not actually be using a
- * pixel buffer and this function will return %NULL.
+ * buffer uses for storage.
*/
COGL_EXPORT CoglPixelBuffer *
cogl_bitmap_get_buffer (CoglBitmap *bitmap);
-/**
- * cogl_bitmap_get_size_from_file:
- * @filename: the file to check
- * @width: (out): return location for the bitmap width, or %NULL
- * @height: (out): return location for the bitmap height, or %NULL
- *
- * Parses an image file enough to extract the width and height
- * of the bitmap.
- *
- * Return value: %TRUE if the image was successfully parsed
- */
-COGL_EXPORT gboolean
-cogl_bitmap_get_size_from_file (const char *filename,
- int *width,
- int *height);
-
/**
* cogl_is_bitmap:
* @object: a #CoglObject pointer
@@ -257,10 +224,7 @@ cogl_is_bitmap (void *object);
* @COGL_BITMAP_ERROR_CORRUPT_IMAGE: An image file was broken somehow.
*
* Error codes that can be thrown when performing bitmap
- * operations. Note that gdk_pixbuf_new_from_file() can also throw
- * errors directly from the underlying image loading library. For
- * example, if GdkPixbuf is used then errors #GdkPixbufErrors
- * will be used directly.
+ * operations.
*/
typedef enum
{
diff --git a/cogl/cogl/cogl-texture-2d-sliced.c b/cogl/cogl/cogl-texture-2d-sliced.c
index 14c6f198c..bd1436244 100644
--- a/cogl/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl/cogl-texture-2d-sliced.c
@@ -958,30 +958,6 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
return tex_2ds;
}
-CoglTexture2DSliced *
-cogl_texture_2d_sliced_new_from_file (CoglContext *ctx,
- const char *filename,
- int max_waste,
- GError **error)
-{
- CoglBitmap *bmp;
- CoglTexture2DSliced *tex_2ds = NULL;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- bmp = _cogl_bitmap_from_file (ctx, filename, error);
- if (bmp == NULL)
- return NULL;
-
- tex_2ds = _cogl_texture_2d_sliced_new_from_bitmap (bmp,
- max_waste,
- TRUE); /* can convert in-place */
-
- cogl_object_unref (bmp);
-
- return tex_2ds;
-}
-
static gboolean
allocate_with_size (CoglTexture2DSliced *tex_2ds,
CoglTextureLoader *loader,
diff --git a/cogl/cogl/cogl-texture-2d-sliced.h b/cogl/cogl/cogl-texture-2d-sliced.h
index 9c9c5c28d..7baf60587 100644
--- a/cogl/cogl/cogl-texture-2d-sliced.h
+++ b/cogl/cogl/cogl-texture-2d-sliced.h
@@ -121,52 +121,6 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
int height,
int max_waste);
-/**
- * cogl_texture_2d_sliced_new_from_file: (skip)
- * @ctx: A #CoglContext
- * @filename: the file to load
- * @max_waste: The threshold of how wide a strip of wasted texels
- * 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.
- * @error: A #GError to catch exceptional errors or %NULL
- *
- * Creates a #CoglTexture2DSliced from an image file.
- *
- * A #CoglTexture2DSliced may internally be comprised of 1 or more
- * #CoglTexture2D textures depending on GPU limitations. For example
- * if the GPU only supports power-of-two sized textures then a sliced
- * texture will turn a non-power-of-two size into a combination of
- * smaller power-of-two sized textures. If the requested texture size
- * is larger than is supported by the hardware then the texture will
- * be sliced into smaller textures that can be accessed by the
- * hardware.
- *
- * @max_waste is used as a threshold for recursively slicing the
- * right-most or bottom-most slices into smaller sizes until the
- * wasted padding at the bottom and right of the textures is less than
- * specified. A negative @max_waste will disable slicing.
- *
- * The storage for the texture is not allocated before this function
- * returns. You can call cogl_texture_allocate() to explicitly
- * allocate the underlying storage or let Cogl automatically allocate
- * storage lazily.
- *
- * It's possible for the allocation of a sliced texture to fail
- * later due to impossible slicing constraints if a negative
- * @max_waste value is given. If the given virtual texture size is
- * larger than is supported by the hardware but slicing is disabled
- * the texture size would be too large to handle.
- *
- * Return value: (transfer full): A newly created #CoglTexture2DSliced
- * or %NULL on failure and @error will be updated.
- */
-COGL_EXPORT CoglTexture2DSliced *
-cogl_texture_2d_sliced_new_from_file (CoglContext *ctx,
- const char *filename,
- int max_waste,
- GError **error);
-
/**
* cogl_texture_2d_sliced_new_from_data: (skip)
* @ctx: A #CoglContext
diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c
index e205da388..20f24bb40 100644
--- a/cogl/cogl/cogl-texture-2d.c
+++ b/cogl/cogl/cogl-texture-2d.c
@@ -186,28 +186,6 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp)
FALSE); /* can't convert in place */
}
-CoglTexture2D *
-cogl_texture_2d_new_from_file (CoglContext *ctx,
- const char *filename,
- GError **error)
-{
- CoglBitmap *bmp;
- CoglTexture2D *tex_2d = NULL;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- bmp = _cogl_bitmap_from_file (ctx, filename, error);
- if (bmp == NULL)
- return NULL;
-
- tex_2d = _cogl_texture_2d_new_from_bitmap (bmp,
- TRUE); /* can convert in-place */
-
- cogl_object_unref (bmp);
-
- return tex_2d;
-}
-
CoglTexture2D *
cogl_texture_2d_new_from_data (CoglContext *ctx,
int width,
diff --git a/cogl/cogl/cogl-texture-2d.h b/cogl/cogl/cogl-texture-2d.h
index 07cd45069..bc76695d2 100644
--- a/cogl/cogl/cogl-texture-2d.h
+++ b/cogl/cogl/cogl-texture-2d.h
@@ -144,33 +144,6 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
int width,
int height);
-/**
- * cogl_texture_2d_new_from_file: (skip)
- * @ctx: A #CoglContext
- * @filename: the file to load
- * @error: A #GError to catch exceptional errors or %NULL
- *
- * Creates a low-level #CoglTexture2D texture from an image file.
- *
- * The storage for the texture is not allocated before this function
- * returns. You can call cogl_texture_allocate() to explicitly
- * allocate the underlying storage or preferably let Cogl
- * automatically allocate storage lazily when it may know more about
- * how the texture is being used and can optimize how it is allocated.
- *
- * The texture is still configurable until it has been allocated so
- * for example you can influence the internal format of the texture
- * using cogl_texture_set_components() and
- * cogl_texture_set_premultiplied().
- *
- * Return value: (transfer full): A newly created #CoglTexture2D or %NULL on failure
- * and @error will be updated.
- */
-COGL_EXPORT CoglTexture2D *
-cogl_texture_2d_new_from_file (CoglContext *ctx,
- const char *filename,
- GError **error);
-
/**
* cogl_texture_2d_new_from_data: (skip)
* @ctx: A #CoglContext
diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build
index 84ec3f1f0..e30e48fcf 100644
--- a/cogl/cogl/meson.build
+++ b/cogl/cogl/meson.build
@@ -230,7 +230,6 @@ cogl_sources = [
'cogl-bitmap-packing.h',
'cogl-primitives-private.h',
'cogl-primitives.c',
- 'cogl-bitmap-pixbuf.c',
'cogl-clip-stack.h',
'cogl-clip-stack.c',
'cogl-feature-private.h',
diff --git a/cogl/meson.build b/cogl/meson.build
index 1fc26fe25..ac3aa0839 100644
--- a/cogl/meson.build
+++ b/cogl/meson.build
@@ -24,7 +24,6 @@ cogl_pkg_deps = [
cogl_pkg_private_deps = [
cairo_dep,
gmodule_no_export_dep,
- gdk_pixbuf_dep,
libmutter_mtk_dep,
#uprof_dep,
]
diff --git a/src/tests/clutter/interactive/test-cogl-multitexture.c b/src/tests/clutter/interactive/test-cogl-multitexture.c
index c32f0516b..5cdf7510e 100644
--- a/src/tests/clutter/interactive/test-cogl-multitexture.c
+++ b/src/tests/clutter/interactive/test-cogl-multitexture.c
@@ -9,6 +9,7 @@
#include
#include
+#include "clutter/test-utils.h"
#include "tests/clutter-test-utils.h"
typedef struct _TestMultiLayerPipelineState
@@ -152,19 +153,19 @@ test_cogl_multitexture_main (int argc, char *argv[])
files[3] = NULL;
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
- state->alpha_tex = cogl_texture_2d_new_from_file (ctx, files[0], &error);
+ state->alpha_tex = clutter_test_texture_2d_new_from_file (ctx, files[0], &error);
if (!state->alpha_tex)
g_critical ("Failed to load redhand_alpha.png: %s", error->message);
- state->redhand_tex = cogl_texture_2d_new_from_file (ctx, files[1], &error);
+ state->redhand_tex = clutter_test_texture_2d_new_from_file (ctx, files[1], &error);
if (!state->redhand_tex)
g_critical ("Failed to load redhand.png: %s", error->message);
- state->light_tex0 = cogl_texture_2d_new_from_file (ctx, files[2], &error);
+ state->light_tex0 = clutter_test_texture_2d_new_from_file (ctx, files[2], &error);
if (!state->light_tex0)
g_critical ("Failed to load light0.png: %s", error->message);
- state->light_tex1 = cogl_texture_2d_new_from_file (ctx, files[2], &error);
+ state->light_tex1 = clutter_test_texture_2d_new_from_file (ctx, files[2], &error);
if (!state->light_tex1)
g_critical ("Failed to load light0.png: %s", error->message);
diff --git a/src/tests/clutter/interactive/test-cogl-offscreen.c b/src/tests/clutter/interactive/test-cogl-offscreen.c
index 3cd366da6..4659f1af6 100644
--- a/src/tests/clutter/interactive/test-cogl-offscreen.c
+++ b/src/tests/clutter/interactive/test-cogl-offscreen.c
@@ -4,6 +4,7 @@
#include
#include
+#include "clutter/test-utils.h"
#include "tests/clutter-test-utils.h"
/* Coglbox declaration
@@ -233,7 +234,7 @@ test_coglbox_init (TestCoglbox *self)
printf ("Loading redhand.png\n");
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
- self->texhand_id = cogl_texture_2d_new_from_file (ctx, file, &error);
+ self->texhand_id = clutter_test_texture_2d_new_from_file (ctx, file, &error);
if (error)
g_warning ("Error loading redhand.png: %s", error->message);
g_free (file);
diff --git a/src/tests/clutter/interactive/test-cogl-shader-glsl.c b/src/tests/clutter/interactive/test-cogl-shader-glsl.c
index e96160de2..b797e0397 100644
--- a/src/tests/clutter/interactive/test-cogl-shader-glsl.c
+++ b/src/tests/clutter/interactive/test-cogl-shader-glsl.c
@@ -5,6 +5,7 @@
#include
#include
+#include "clutter/test-utils.h"
#include "tests/clutter-test-utils.h"
typedef struct
@@ -326,7 +327,7 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
error = NULL;
- redhand = cogl_texture_2d_new_from_file (ctx, file, &error);
+ redhand = clutter_test_texture_2d_new_from_file (ctx, file, &error);
if (redhand == NULL)
g_error ("image load failed: %s", error->message);
diff --git a/src/tests/clutter/interactive/test-cogl-tex-polygon.c b/src/tests/clutter/interactive/test-cogl-tex-polygon.c
index 86e72086d..d57537abe 100644
--- a/src/tests/clutter/interactive/test-cogl-tex-polygon.c
+++ b/src/tests/clutter/interactive/test-cogl-tex-polygon.c
@@ -4,6 +4,7 @@
#include
#include
+#include "clutter/test-utils.h"
#include "tests/clutter-test-utils.h"
/* Coglbox declaration
@@ -237,9 +238,8 @@ test_coglbox_init (TestCoglbox *self)
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
self->sliced_tex =
- cogl_texture_2d_sliced_new_from_file (ctx, file,
- COGL_TEXTURE_MAX_WASTE,
- &error);
+ clutter_test_texture_2d_sliced_new_from_file (ctx, file,
+ &error);
if (self->sliced_tex == NULL)
{
if (error)
@@ -252,7 +252,7 @@ test_coglbox_init (TestCoglbox *self)
g_warning ("Texture loading failed: ");
}
- self->not_sliced_tex = cogl_texture_2d_new_from_file (ctx, file, &error);
+ self->not_sliced_tex = clutter_test_texture_2d_new_from_file (ctx, file, &error);
if (self->not_sliced_tex == NULL)
{
if (error)
diff --git a/src/tests/clutter/interactive/test-cogl-tex-tile.c b/src/tests/clutter/interactive/test-cogl-tex-tile.c
index b79fd5b67..d8a57d15b 100644
--- a/src/tests/clutter/interactive/test-cogl-tex-tile.c
+++ b/src/tests/clutter/interactive/test-cogl-tex-tile.c
@@ -5,6 +5,7 @@
#include
#include
+#include "clutter/test-utils.h"
#include "tests/clutter-test-utils.h"
/* Coglbox declaration
@@ -106,7 +107,7 @@ test_coglbox_init (TestCoglbox *self)
gchar *file;
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
- self->cogl_tex_id = cogl_texture_2d_new_from_file (ctx, file, &error);
+ self->cogl_tex_id = clutter_test_texture_2d_new_from_file (ctx, file, &error);
if (error)
g_warning ("Error loading redhand.png: %s", error->message);
g_free (file);
diff --git a/src/tests/clutter/test-utils.h b/src/tests/clutter/test-utils.h
index 6ed1a938b..62f394336 100644
--- a/src/tests/clutter/test-utils.h
+++ b/src/tests/clutter/test-utils.h
@@ -28,3 +28,125 @@ clutter_test_utils_create_texture_from_file (const char *filename,
"content", image,
NULL);
}
+
+static inline CoglBitmap *
+clutter_test_create_bitmap_from_file (CoglContext *ctx,
+ const char *filename,
+ GError **error)
+{
+ static CoglUserDataKey pixbuf_key;
+ GdkPixbuf *pixbuf;
+ gboolean has_alpha;
+ GdkColorspace color_space;
+ CoglPixelFormat pixel_format;
+ int width;
+ int height;
+ int rowstride;
+ int bits_per_sample;
+ int n_channels;
+ CoglBitmap *bmp;
+ GError *glib_error = NULL;
+
+ /* Load from file using GdkPixbuf */
+ pixbuf = gdk_pixbuf_new_from_file (filename, &glib_error);
+ if (pixbuf == NULL)
+ {
+ g_propagate_error (error, glib_error);
+ return FALSE;
+ }
+
+ /* Get pixbuf properties */
+ has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+ color_space = gdk_pixbuf_get_colorspace (pixbuf);
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
+ n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+
+ /* According to current docs this should be true and so
+ * the translation to cogl pixel format below valid */
+ g_assert (bits_per_sample == 8);
+
+ if (has_alpha)
+ g_assert (n_channels == 4);
+ else
+ g_assert (n_channels == 3);
+
+ /* Translate to cogl pixel format */
+ switch (color_space)
+ {
+ case GDK_COLORSPACE_RGB:
+ /* The only format supported by GdkPixbuf so far */
+ pixel_format = has_alpha ?
+ COGL_PIXEL_FORMAT_RGBA_8888 :
+ COGL_PIXEL_FORMAT_RGB_888;
+ break;
+
+ default:
+ /* Ouch, spec changed! */
+ g_object_unref (pixbuf);
+ return FALSE;
+ }
+
+ /* We just use the data directly from the pixbuf so that we don't
+ have to copy to a separate buffer. Note that Cogl is expected not
+ to read past the end of bpp*width on the last row even if the
+ rowstride is much larger so we don't need to worry about
+ GdkPixbuf's semantics that it may under-allocate the buffer. */
+ bmp = cogl_bitmap_new_for_data (ctx,
+ width,
+ height,
+ pixel_format,
+ rowstride,
+ gdk_pixbuf_get_pixels (pixbuf));
+
+ cogl_object_set_user_data (COGL_OBJECT (bmp),
+ &pixbuf_key,
+ pixbuf,
+ g_object_unref);
+
+ return bmp;
+}
+
+static inline CoglTexture2DSliced *
+clutter_test_texture_2d_sliced_new_from_file (CoglContext *ctx,
+ const char *filename,
+ GError **error)
+{
+ CoglBitmap *bmp;
+ CoglTexture2DSliced *tex_2ds = NULL;
+
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ bmp = clutter_test_create_bitmap_from_file (ctx, filename, error);
+ if (bmp == NULL)
+ return NULL;
+
+ tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, COGL_TEXTURE_MAX_WASTE);
+
+ cogl_object_unref (bmp);
+
+ return tex_2ds;
+}
+
+static inline CoglTexture2D *
+clutter_test_texture_2d_new_from_file (CoglContext *ctx,
+ const char *filename,
+ GError **error)
+{
+ CoglBitmap *bmp;
+ CoglTexture2D *tex_2d = NULL;
+
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ bmp = clutter_test_create_bitmap_from_file (ctx, filename, error);
+ if (bmp == NULL)
+ return NULL;
+
+ tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
+
+ cogl_object_unref (bmp);
+
+ return tex_2d;
+}