diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-11-21 22:12:54 +0000 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2012-11-27 19:40:46 +0000 |
commit | 40defa3dbd355754d0f7611d3c50de35db514e4a (patch) | |
tree | 03785b1a16cea507b4cb7de73eb4c6fedcf51085 /tests | |
parent | 3a336a8adcd406b53731a6de0e7d97ba7932c1a8 (diff) | |
download | cogl-40defa3dbd355754d0f7611d3c50de35db514e4a.tar.gz |
tests: port test-texture-get-set-data to be standalone
This ports the test-texture-get-set-data clutter test to be a standalone
Cogl test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conform/Makefile.am | 2 | ||||
-rw-r--r-- | tests/conform/test-conform-main.c | 2 | ||||
-rw-r--r-- | tests/conform/test-texture-get-set-data.c | 69 |
3 files changed, 24 insertions, 49 deletions
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am index c002f6a2..2463d7df 100644 --- a/tests/conform/Makefile.am +++ b/tests/conform/Makefile.am @@ -17,7 +17,6 @@ unported_test_sources = \ test-npot-texture.c \ test-object.c \ test-readpixels.c \ - test-texture-get-set-data.c \ test-texture-mipmaps.c \ test-texture-pixmap-x11.c \ test-texture-rectangle.c \ @@ -59,6 +58,7 @@ test_sources = \ test-map-buffer-range.c \ test-npot-texture.c \ test-alpha-textures.c \ + test-texture-get-set-data.c \ $(NULL) test_conformance_SOURCES = $(common_sources) $(test_sources) diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index 4b7b6985..c43a68d7 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -72,7 +72,7 @@ main (int argc, char **argv) ADD_TEST (test_texture_3d, TEST_REQUIREMENT_TEXTURE_3D, 0); ADD_TEST (test_wrap_modes, 0, 0); UNPORTED_TEST (test_texture_pixmap_x11); - UNPORTED_TEST (test_texture_get_set_data); + ADD_TEST (test_texture_get_set_data, 0, TEST_REQUIREMENT_NPOT); ADD_TEST (test_atlas_migration, 0, 0); ADD_TEST (test_read_texture_formats, 0, 0); ADD_TEST (test_write_texture_formats, 0, 0); diff --git a/tests/conform/test-texture-get-set-data.c b/tests/conform/test-texture-get-set-data.c index 6cb4f99c..cf24e4d7 100644 --- a/tests/conform/test-texture-get-set-data.c +++ b/tests/conform/test-texture-get-set-data.c @@ -1,15 +1,16 @@ -#include <clutter/clutter.h> -#include <glib.h> +#include <cogl/cogl.h> + #include <string.h> -#include "test-conform-common.h" +#include "test-utils.h" static void check_texture (int width, int height, CoglTextureFlags flags) { - CoglHandle tex; + CoglTexture *tex; uint8_t *data, *p; int y, x; + int rowstride; p = data = g_malloc (width * height * 4); for (y = 0; y < height; y++) @@ -21,16 +22,19 @@ check_texture (int width, int height, CoglTextureFlags flags) *(p++) = (x ^ y); } - tex = cogl_texture_new_from_data (width, height, + tex = cogl_texture_new_from_data (test_ctx, + width, height, flags, COGL_PIXEL_FORMAT_RGBA_8888, COGL_PIXEL_FORMAT_RGBA_8888, width * 4, - data); + data, + NULL); /* abort on error */ /* Replace the bottom right quarter of the data with negated data to test set_region */ - p = data + (height + 1) * width * 2; + rowstride = width * 4; + p = data + (height / 2) * rowstride + rowstride / 2; for (y = 0; y < height / 2; y++) { for (x = 0; x < width / 2; x++) @@ -44,17 +48,15 @@ check_texture (int width, int height, CoglTextureFlags flags) p += width * 2; } cogl_texture_set_region (tex, - width / 2, /* src_x */ - height / 2, /* src_y */ - width / 2, /* dst_x */ - height / 2, /* dst_y */ - width / 2, /* dst_width */ - height / 2, /* dst_height */ - width, - height, + width / 2, /* region width */ + height / 2, /* region height */ COGL_PIXEL_FORMAT_RGBA_8888, - width * 4, /* rowstride */ - data); + rowstride, + data + (height / 2) * rowstride + rowstride / 2, + width / 2, /* dest x */ + height / 2, /* dest y */ + 0, /* mipmap level 0 */ + NULL); /* abort on error */ /* Check passing a NULL pointer and a zero rowstride. The texture should calculate the needed data size and return it */ @@ -119,12 +121,12 @@ check_texture (int width, int height, CoglTextureFlags flags) p += 4; } - cogl_handle_unref (tex); + cogl_object_unref (tex); g_free (data); } -static void -paint_cb (void) +void +test_texture_get_set_data (void) { /* First try without atlasing */ check_texture (256, 256, COGL_TEXTURE_NO_ATLAS); @@ -136,31 +138,4 @@ paint_cb (void) check_texture (4, 5128, COGL_TEXTURE_NO_ATLAS); /* And in the other direction. */ check_texture (5128, 4, COGL_TEXTURE_NO_ATLAS); - - clutter_main_quit (); -} - -void -test_texture_get_set_data (TestUtilsGTestFixture *fixture, - void *data) -{ - ClutterActor *stage; - unsigned int paint_handler; - - /* We create a stage even though we don't usually need it so that if - the draw-and-read texture fallback is needed then it will have - something to draw to */ - stage = clutter_stage_get_default (); - - paint_handler = g_signal_connect_after (stage, "paint", - G_CALLBACK (paint_cb), NULL); - - clutter_actor_show (stage); - - clutter_main (); - - g_signal_handler_disconnect (stage, paint_handler); - - if (cogl_test_verbose ()) - g_print ("OK\n"); } |