From bb29fa68fe5c5efc9dcf31e515ecfd6eeee6119e Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 12 Jun 2024 00:25:12 +0200 Subject: [PATCH] cogl: Remove AtlasTexture.new_from_data Nothing uses it, allows to drop the corresponding test case as well Part-of: --- cogl/cogl/cogl-atlas-texture.c | 41 ------------ cogl/cogl/cogl-atlas-texture.h | 47 ------------- src/tests/cogl/conform/meson.build | 1 - .../cogl/conform/test-texture-no-allocate.c | 66 ------------------- 4 files changed, 155 deletions(-) delete mode 100644 src/tests/cogl/conform/test-texture-no-allocate.c diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c index 6d380e320..d622f73a4 100644 --- a/cogl/cogl/cogl-atlas-texture.c +++ b/cogl/cogl/cogl-atlas-texture.c @@ -928,47 +928,6 @@ cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp) loader); } -CoglTexture * -cogl_atlas_texture_new_from_data (CoglContext *ctx, - int width, - int height, - CoglPixelFormat format, - int rowstride, - const uint8_t *data, - GError **error) -{ - CoglBitmap *bmp; - CoglTexture *atlas_tex; - - g_return_val_if_fail (format != COGL_PIXEL_FORMAT_ANY, NULL); - g_return_val_if_fail (cogl_pixel_format_get_n_planes (format) == 1, NULL); - g_return_val_if_fail (data != NULL, NULL); - - /* Rowstride from width if not given */ - if (rowstride == 0) - rowstride = width * cogl_pixel_format_get_bytes_per_pixel (format, 0); - - /* Wrap the data into a bitmap */ - bmp = cogl_bitmap_new_for_data (ctx, - width, height, - format, - rowstride, - (uint8_t *) data); - - atlas_tex = cogl_atlas_texture_new_from_bitmap (bmp); - - g_object_unref (bmp); - - if (atlas_tex && - !cogl_texture_allocate (COGL_TEXTURE (atlas_tex), error)) - { - g_object_unref (atlas_tex); - return NULL; - } - - 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 086db3c0f..b5953585c 100644 --- a/cogl/cogl/cogl-atlas-texture.h +++ b/cogl/cogl/cogl-atlas-texture.h @@ -115,53 +115,6 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx, int width, int height); -/** - * cogl_atlas_texture_new_from_data: - * @ctx: A #CoglContext - * @width: width of texture in pixels - * @height: height of texture in pixels - * @format: the #CoglPixelFormat the buffer is stored in in RAM - * @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. - * @data: pointer to the memory region where the source buffer resides - * @error: A #GError to catch exceptional errors or %NULL - * - * Creates a new #CoglAtlasTexture texture based on data residing in - * memory. A #CoglAtlasTexture represents a sub-region within one of - * Cogl's shared texture atlases. - * - * This api will always immediately allocate GPU memory for the - * texture and upload the given data so that the @data pointer does - * not need to remain valid once this function returns. This means it - * is not possible to configure the texture before it is allocated. If - * you do need to configure the texture before allocation (to specify - * constraints on the internal format for example) then you can - * instead create a #CoglBitmap for your data and use - * cogl_atlas_texture_new_from_bitmap() or use - * cogl_atlas_texture_new_with_size() and then upload data using - * cogl_texture_set_data() - * - * 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 CoglTexture * -cogl_atlas_texture_new_from_data (CoglContext *ctx, - int width, - int height, - CoglPixelFormat format, - int rowstride, - const uint8_t *data, - GError **error); - /** * cogl_atlas_texture_new_from_bitmap: * @bmp: A #CoglBitmap diff --git a/src/tests/cogl/conform/meson.build b/src/tests/cogl/conform/meson.build index 2614be56e..84bf78e90 100644 --- a/src/tests/cogl/conform/meson.build +++ b/src/tests/cogl/conform/meson.build @@ -36,7 +36,6 @@ cogl_tests = [ [ 'test-primitive-and-journal', [] ], [ 'test-copy-replace-texture', [] ], [ 'test-pipeline-cache-unrefs-texture', [] ], - [ 'test-texture-no-allocate', [] ], [ 'test-pipeline-shader-state', [] ], [ 'test-texture-rg', [] ], [ 'test-fence', [] ], diff --git a/src/tests/cogl/conform/test-texture-no-allocate.c b/src/tests/cogl/conform/test-texture-no-allocate.c deleted file mode 100644 index cad6d1672..000000000 --- a/src/tests/cogl/conform/test-texture-no-allocate.c +++ /dev/null @@ -1,66 +0,0 @@ -#include - -#include "tests/cogl-test-utils.h" - -/* Tests that the various texture types can be freed without being - * allocated */ - -/* Texture size that is probably to big to fit within the texture - * limits */ -#define BIG_TEX_WIDTH 16384 -#define BIG_TEX_HEIGHT 128 - -static void -test_texture_no_allocate (void) -{ - uint8_t *tex_data; - CoglTexture *texture; - CoglTexture *texture_2d; - GError *error = NULL; - - tex_data = g_malloc (BIG_TEX_WIDTH * BIG_TEX_HEIGHT * 4); - - /* NB: if we make the atlas and sliced texture APIs public then this - * could changed to explicitly use that instead of the magic texture - * API */ - - /* Try to create an atlas texture that is too big so it will - * internally be freed without allocating */ - texture = - cogl_atlas_texture_new_from_data (test_ctx, - BIG_TEX_WIDTH, - BIG_TEX_HEIGHT, - /* format */ - COGL_PIXEL_FORMAT_RGBA_8888_PRE, - /* rowstride */ - BIG_TEX_WIDTH * 4, - tex_data, - &error); - - g_free (tex_data); - - /* It's ok if this causes an error, we just don't want it to - * crash */ - - if (texture == NULL) - g_error_free (error); - else - g_object_unref (texture); - - /* Try to create a sliced texture without allocating it */ - texture = - cogl_texture_2d_sliced_new_with_size (test_ctx, - BIG_TEX_WIDTH, - BIG_TEX_HEIGHT, - COGL_TEXTURE_MAX_WASTE); - g_object_unref (texture); - - /* 2D texture */ - texture_2d = cogl_texture_2d_new_with_size (test_ctx, - 64, 64); - g_object_unref (texture_2d); -} - -COGL_TEST_SUITE ( - g_test_add_func ("/texture/no-allocate", test_texture_no_allocate); -)