Convert the test-atlas-migration test to a standalone Cogl test

This updates test-atlas-migration from being a Clutter-based test to a
Cogl-based test.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 32c5a3ed546effd2e2946f22f173a20cf36b2fdf)
This commit is contained in:
Neil Roberts 2012-05-16 12:57:32 +01:00 committed by Robert Bragg
parent 3f2cb89a76
commit f729798f03
3 changed files with 29 additions and 16 deletions

View File

@ -22,13 +22,13 @@ unported_test_sources = \
test-texture-mipmaps.c \ test-texture-mipmaps.c \
test-texture-pixmap-x11.c \ test-texture-pixmap-x11.c \
test-texture-rectangle.c \ test-texture-rectangle.c \
test-atlas-migration.c \
test-vertex-buffer-contiguous.c \ test-vertex-buffer-contiguous.c \
test-vertex-buffer-interleved.c \ test-vertex-buffer-interleved.c \
test-vertex-buffer-mutability.c \ test-vertex-buffer-mutability.c \
$(NULL) $(NULL)
test_sources = \ test_sources = \
test-atlas-migration.c \
test-bitmask.c \ test-bitmask.c \
test-blend-strings.c \ test-blend-strings.c \
test-depth-test.c \ test-depth-test.c \

View File

@ -1,6 +1,6 @@
#include <clutter/clutter.h> #include <cogl/cogl.h>
#include "test-conform-common.h" #include "test-utils.h"
#define N_TEXTURES 128 #define N_TEXTURES 128
@ -10,16 +10,21 @@
#define COLOR_FOR_SIZE(size) \ #define COLOR_FOR_SIZE(size) \
(colors + (size) % 3) (colors + (size) % 3)
static const ClutterColor colors[] = typedef struct
{
uint8_t red, green, blue, alpha;
} TestColor;
static const TestColor colors[] =
{ { 0xff, 0x00, 0x00, 0xff }, { { 0xff, 0x00, 0x00, 0xff },
{ 0x00, 0xff, 0x00, 0xff }, { 0x00, 0xff, 0x00, 0xff },
{ 0x00, 0x00, 0xff, 0xff } }; { 0x00, 0x00, 0xff, 0xff } };
static CoglHandle static CoglTexture *
create_texture (int size) create_texture (int size)
{ {
CoglHandle texture; CoglTexture *texture;
const ClutterColor *color; const TestColor *color;
uint8_t *data, *p; uint8_t *data, *p;
int x, y; int x, y;
@ -65,11 +70,11 @@ create_texture (int size)
} }
static void static void
verify_texture (CoglHandle texture, int size) verify_texture (CoglTexture *texture, int size)
{ {
uint8_t *data, *p; uint8_t *data, *p;
int x, y; int x, y;
const ClutterColor *color; const TestColor *color;
color = COLOR_FOR_SIZE (size); color = COLOR_FOR_SIZE (size);
@ -86,9 +91,18 @@ verify_texture (CoglHandle texture, int size)
for (x = 0; x < size; x++) for (x = 0; x < size; x++)
{ {
g_assert_cmpint (p[0], ==, color->red * opacity / 255); TestColor real_color =
g_assert_cmpint (p[1], ==, color->green * opacity / 255); {
g_assert_cmpint (p[2], ==, color->blue * opacity / 255); color->red * opacity / 255,
color->green * opacity / 255,
color->blue * opacity / 255
};
test_utils_compare_pixel (p,
(real_color.red << 24) |
(real_color.green << 16) |
(real_color.blue << 8) |
opacity);
g_assert_cmpint (p[3], ==, opacity); g_assert_cmpint (p[3], ==, opacity);
p += 4; p += 4;
@ -99,10 +113,9 @@ verify_texture (CoglHandle texture, int size)
} }
void void
test_atlas_migration (TestUtilsGTestFixture *fixture, test_atlas_migration (void)
void *data)
{ {
CoglHandle textures[N_TEXTURES]; CoglTexture *textures[N_TEXTURES];
int i, tex_num; int i, tex_num;
/* Create and destroy all of the textures a few times to increase /* Create and destroy all of the textures a few times to increase

View File

@ -72,7 +72,7 @@ main (int argc, char **argv)
ADD_TEST (test_wrap_modes, 0); ADD_TEST (test_wrap_modes, 0);
UNPORTED_TEST (test_texture_pixmap_x11); UNPORTED_TEST (test_texture_pixmap_x11);
UNPORTED_TEST (test_texture_get_set_data); UNPORTED_TEST (test_texture_get_set_data);
UNPORTED_TEST (test_atlas_migration); ADD_TEST (test_atlas_migration, 0);
ADD_TEST (test_read_texture_formats, 0); ADD_TEST (test_read_texture_formats, 0);
ADD_TEST (test_write_texture_formats, 0); ADD_TEST (test_write_texture_formats, 0);