mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
937337993d
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. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 911df79776ce6f695351c15e9872b4f1479d30bf) Conflicts: tests/conform/test-atlas-migration.c tests/conform/test-backface-culling.c tests/conform/test-blend-strings.c tests/conform/test-color-mask.c tests/conform/test-just-vertex-shader.c tests/conform/test-npot-texture.c tests/conform/test-primitive.c tests/conform/test-snippets.c tests/conform/test-texture-get-set-data.c tests/conform/test-texture-mipmap-get-set.c tests/conform/test-texture-no-allocate.c tests/conform/test-wrap-modes.c
88 lines
2.9 KiB
C
88 lines
2.9 KiB
C
#include <cogl/cogl.h>
|
|
|
|
#include "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
|
|
|
|
void
|
|
test_texture_no_allocate (void)
|
|
{
|
|
uint8_t *tex_data;
|
|
CoglTexture *texture;
|
|
CoglTexture2D *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_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);
|
|
|
|
/* It's ok if this causes an error, we just don't want it to
|
|
* crash */
|
|
|
|
if (texture == NULL)
|
|
cogl_error_free (error);
|
|
else
|
|
cogl_object_unref (texture);
|
|
|
|
/* Try to create a sliced texture without allocating it */
|
|
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 */
|
|
texture_2d = cogl_texture_2d_new_with_size (test_ctx,
|
|
64, 64,
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
|
|
cogl_object_unref (texture_2d);
|
|
|
|
/* 3D texture */
|
|
if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_3D))
|
|
{
|
|
CoglTexture3D *texture_3d =
|
|
cogl_texture_3d_new_with_size (test_ctx,
|
|
64, 64, 64,
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
|
|
cogl_object_unref (texture_3d);
|
|
}
|
|
|
|
/* Rectangle texture */
|
|
if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
|
|
{
|
|
CoglTextureRectangle *texture_rect =
|
|
cogl_texture_rectangle_new_with_size (test_ctx,
|
|
64, 64,
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
|
NULL /* error */);
|
|
cogl_object_unref (texture_rect);
|
|
}
|
|
}
|