diff options
author | Neil Roberts <neil@linux.intel.com> | 2012-02-10 16:57:24 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2012-02-13 17:29:28 +0000 |
commit | d7164f9579d92f383fb6e7db26cfcd92a93f63b6 (patch) | |
tree | 6927a4866aaa4897ee9f81aeb33e31230fe27508 | |
parent | 39b9e717f5e91e04fcf6bf1dd0c8d5646871dedb (diff) | |
download | cogl-d7164f9579d92f383fb6e7db26cfcd92a93f63b6.tar.gz |
tests: Move the create_color_texture function to test-utils
This adds a shared utility function to create a 1x1 texture with a
given color.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r-- | tests/conform/test-sparse-pipeline.c | 23 | ||||
-rw-r--r-- | tests/conform/test-utils.c | 17 | ||||
-rw-r--r-- | tests/conform/test-utils.h | 11 |
3 files changed, 30 insertions, 21 deletions
diff --git a/tests/conform/test-sparse-pipeline.c b/tests/conform/test-sparse-pipeline.c index 433c0baa..ec8c987e 100644 --- a/tests/conform/test-sparse-pipeline.c +++ b/tests/conform/test-sparse-pipeline.c @@ -11,25 +11,6 @@ typedef struct _TestState CoglFramebuffer *fb; } TestState; -static CoglTexture * -create_color_texture (CoglContext *context, - guint32 color) -{ - CoglTexture2D *tex_2d; - - color = GUINT32_TO_BE (color); - - tex_2d = cogl_texture_2d_new_from_data (context, - 1, 1, /* width/height */ - COGL_PIXEL_FORMAT_RGBA_8888_PRE, - COGL_PIXEL_FORMAT_RGBA_8888_PRE, - 4, /* rowstride */ - (guint8 *) &color, - NULL); - - return COGL_TEXTURE (tex_2d); -} - static void test_sparse_layer_combine (TestState *state) { @@ -43,8 +24,8 @@ test_sparse_layer_combine (TestState *state) creating a pipeline with very large layer numbers. This should end up being mapped to much smaller unit numbers */ - tex1 = create_color_texture (state->context, 0xff0000ff); - tex2 = create_color_texture (state->context, 0x00ff00ff); + tex1 = test_utils_create_color_texture (state->context, 0xff0000ff); + tex2 = test_utils_create_color_texture (state->context, 0x00ff00ff); pipeline = cogl_pipeline_new (); diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c index a5ba8915..61e5c011 100644 --- a/tests/conform/test-utils.c +++ b/tests/conform/test-utils.c @@ -151,4 +151,21 @@ test_utils_check_region (int x, int y, g_free (pixels); } +CoglTexture * +test_utils_create_color_texture (CoglContext *context, + guint32 color) +{ + CoglTexture2D *tex_2d; + + color = GUINT32_TO_BE (color); + tex_2d = cogl_texture_2d_new_from_data (context, + 1, 1, /* width/height */ + COGL_PIXEL_FORMAT_RGBA_8888_PRE, + COGL_PIXEL_FORMAT_RGBA_8888_PRE, + 4, /* rowstride */ + (guint8 *) &color, + NULL); + + return COGL_TEXTURE (tex_2d); +} diff --git a/tests/conform/test-utils.h b/tests/conform/test-utils.h index c5303746..9bc8e20f 100644 --- a/tests/conform/test-utils.h +++ b/tests/conform/test-utils.h @@ -101,4 +101,15 @@ test_utils_check_region (int x, int y, void test_utils_compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel); +/* + * test_utils_create_color_texture: + * @context: A #CoglContext + * @color: A color to put in the texture + * + * Creates a 1x1-pixel RGBA texture filled with the given color. + */ +CoglTexture * +test_utils_create_color_texture (CoglContext *context, + guint32 color); + #endif /* _TEST_UTILS_H_ */ |