cogl: Remove AtlasTexture.new_from_data
Nothing uses it, allows to drop the corresponding test case as well Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3804>
This commit is contained in:
parent
94c2c41b66
commit
bb29fa68fe
@ -928,47 +928,6 @@ cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp)
|
|||||||
loader);
|
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
|
void
|
||||||
_cogl_atlas_texture_add_reorganize_callback (CoglContext *ctx,
|
_cogl_atlas_texture_add_reorganize_callback (CoglContext *ctx,
|
||||||
GHookFunc callback,
|
GHookFunc callback,
|
||||||
|
@ -115,53 +115,6 @@ cogl_atlas_texture_new_with_size (CoglContext *ctx,
|
|||||||
int width,
|
int width,
|
||||||
int height);
|
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:
|
* cogl_atlas_texture_new_from_bitmap:
|
||||||
* @bmp: A #CoglBitmap
|
* @bmp: A #CoglBitmap
|
||||||
|
@ -36,7 +36,6 @@ cogl_tests = [
|
|||||||
[ 'test-primitive-and-journal', [] ],
|
[ 'test-primitive-and-journal', [] ],
|
||||||
[ 'test-copy-replace-texture', [] ],
|
[ 'test-copy-replace-texture', [] ],
|
||||||
[ 'test-pipeline-cache-unrefs-texture', [] ],
|
[ 'test-pipeline-cache-unrefs-texture', [] ],
|
||||||
[ 'test-texture-no-allocate', [] ],
|
|
||||||
[ 'test-pipeline-shader-state', [] ],
|
[ 'test-pipeline-shader-state', [] ],
|
||||||
[ 'test-texture-rg', [] ],
|
[ 'test-texture-rg', [] ],
|
||||||
[ 'test-fence', [] ],
|
[ 'test-fence', [] ],
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
#include <cogl/cogl.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
)
|
|
Loading…
x
Reference in New Issue
Block a user