summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/conform/test-atlas-migration.c2
-rw-r--r--tests/conform/test-backface-culling.c123
-rw-r--r--tests/conform/test-bitmask.c3
-rw-r--r--tests/conform/test-blend-strings.c38
-rw-r--r--tests/conform/test-color-mask.c34
-rw-r--r--tests/conform/test-conform-main.c108
-rw-r--r--tests/conform/test-custom-attributes.c95
-rw-r--r--tests/conform/test-depth-test.c79
-rw-r--r--tests/conform/test-fixed.c2
-rw-r--r--tests/conform/test-fixtures.c2
-rw-r--r--tests/conform/test-just-vertex-shader.c45
-rw-r--r--tests/conform/test-materials.c2
-rw-r--r--tests/conform/test-multitexture.c2
-rw-r--r--tests/conform/test-npot-texture.c2
-rw-r--r--tests/conform/test-object.c2
-rw-r--r--tests/conform/test-offscreen.c38
-rw-r--r--tests/conform/test-path.c35
-rw-r--r--tests/conform/test-pipeline-uniforms.c35
-rw-r--r--tests/conform/test-pipeline-user-matrix.c47
-rw-r--r--tests/conform/test-pixel-buffer.c38
-rw-r--r--tests/conform/test-point-size.c20
-rw-r--r--tests/conform/test-point-sprite.c38
-rw-r--r--tests/conform/test-premult.c2
-rw-r--r--tests/conform/test-primitive.c39
-rw-r--r--tests/conform/test-read-texture-formats.c6
-rw-r--r--tests/conform/test-readpixels.c2
-rw-r--r--tests/conform/test-snippets.c209
-rw-r--r--tests/conform/test-sparse-pipeline.c26
-rw-r--r--tests/conform/test-sub-texture.c77
-rw-r--r--tests/conform/test-texture-3d.c52
-rw-r--r--tests/conform/test-texture-get-set-data.c2
-rw-r--r--tests/conform/test-texture-mipmaps.c2
-rw-r--r--tests/conform/test-texture-pixmap-x11.c2
-rw-r--r--tests/conform/test-texture-rectangle.c2
-rw-r--r--tests/conform/test-utils.c76
-rw-r--r--tests/conform/test-utils.h43
-rw-r--r--tests/conform/test-vertex-buffer-contiguous.c2
-rw-r--r--tests/conform/test-vertex-buffer-interleved.c2
-rw-r--r--tests/conform/test-vertex-buffer-mutability.c2
-rw-r--r--tests/conform/test-viewport.c2
-rw-r--r--tests/conform/test-wrap-modes.c85
-rw-r--r--tests/conform/test-write-texture-formats.c6
42 files changed, 697 insertions, 732 deletions
diff --git a/tests/conform/test-atlas-migration.c b/tests/conform/test-atlas-migration.c
index 18fc8ff9..2e18b963 100644
--- a/tests/conform/test-atlas-migration.c
+++ b/tests/conform/test-atlas-migration.c
@@ -99,7 +99,7 @@ verify_texture (CoglHandle texture, int size)
}
void
-test_cogl_atlas_migration (TestUtilsGTestFixture *fixture,
+test_atlas_migration (TestUtilsGTestFixture *fixture,
void *data)
{
CoglHandle textures[N_TEXTURES];
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index 0fc0d4db..fe1eda5c 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -17,18 +17,18 @@
typedef struct _TestState
{
- CoglContext *ctx;
- CoglFramebuffer *fb;
- CoglHandle texture;
+ CoglTexture *texture;
CoglFramebuffer *offscreen;
- CoglHandle offscreen_tex;
+ CoglTexture *offscreen_tex;
int width, height;
} TestState;
static void
-validate_part (int xnum, int ynum, gboolean shown)
+validate_part (CoglFramebuffer *framebuffer,
+ int xnum, int ynum, gboolean shown)
{
- test_utils_check_region (xnum * TEXTURE_RENDER_SIZE + TEST_INSET,
+ test_utils_check_region (framebuffer,
+ xnum * TEXTURE_RENDER_SIZE + TEST_INSET,
ynum * TEXTURE_RENDER_SIZE + TEST_INSET,
TEXTURE_RENDER_SIZE - TEST_INSET * 2,
TEXTURE_RENDER_SIZE - TEST_INSET * 2,
@@ -44,18 +44,22 @@ validate_part (int xnum, int ynum, gboolean shown)
#define CULL_FACE_MODE(draw_num) (((draw_num) & 0x0c) >> 2)
static void
-paint_test_backface_culling (TestState *state)
+paint_test_backface_culling (TestState *state,
+ CoglFramebuffer *framebuffer)
{
int draw_num;
- CoglPipeline *base_pipeline = cogl_pipeline_new (state->ctx);
- CoglColor clear_color;
+ CoglPipeline *base_pipeline = cogl_pipeline_new (ctx);
- cogl_ortho (0, state->width, /* left, right */
- state->height, 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (framebuffer,
+ 0, 0,
+ state->width,
+ state->height,
+ -1,
+ 100);
- cogl_color_init_from_4ub (&clear_color, 0x00, 0x00, 0x00, 0xff);
- cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_STENCIL);
+ cogl_framebuffer_clear4f (framebuffer,
+ COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_STENCIL,
+ 0, 0, 0, 1);
cogl_pipeline_set_layer_texture (base_pipeline, 0, state->texture);
@@ -63,6 +67,8 @@ paint_test_backface_culling (TestState *state)
COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST);
+ cogl_push_framebuffer (framebuffer);
+
/* Render the scene sixteen times to test all of the combinations of
cull face mode, legacy state and winding orders */
for (draw_num = 0; draw_num < 16; draw_num++)
@@ -144,11 +150,13 @@ paint_test_backface_culling (TestState *state)
cogl_object_unref (pipeline);
}
+ cogl_pop_framebuffer ();
+
cogl_object_unref (base_pipeline);
}
static void
-validate_result (int y_offset)
+validate_result (CoglFramebuffer *framebuffer, int y_offset)
{
int draw_num;
@@ -193,26 +201,29 @@ validate_result (int y_offset)
}
/* Front-facing texture */
- validate_part (0, y_offset + draw_num, !cull_front);
+ validate_part (framebuffer,
+ 0, y_offset + draw_num, !cull_front);
/* Front-facing texture with flipped tex coords */
- validate_part (1, y_offset + draw_num, !cull_front);
+ validate_part (framebuffer,
+ 1, y_offset + draw_num, !cull_front);
/* Back-facing texture */
- validate_part (2, y_offset + draw_num, !cull_back);
+ validate_part (framebuffer,
+ 2, y_offset + draw_num, !cull_back);
/* Front-facing texture polygon */
- validate_part (3, y_offset + draw_num, !cull_front);
+ validate_part (framebuffer,
+ 3, y_offset + draw_num, !cull_front);
/* Back-facing texture polygon */
- validate_part (4, y_offset + draw_num, !cull_back);
+ validate_part (framebuffer,
+ 4, y_offset + draw_num, !cull_back);
}
}
static void
paint (TestState *state)
{
- float stage_viewport[4];
- CoglMatrix stage_projection;
- CoglMatrix stage_modelview;
+ CoglPipeline *pipeline;
- paint_test_backface_culling (state);
+ paint_test_backface_culling (state, fb);
/*
* Now repeat the test but rendered to an offscreen
@@ -220,40 +231,28 @@ paint (TestState *state)
* always run to an offscreen buffer but we might as well have this
* check anyway in case it is being run with COGL_TEST_ONSCREEN=1
*/
-
- cogl_get_viewport (stage_viewport);
- cogl_get_projection_matrix (&stage_projection);
- cogl_get_modelview_matrix (&stage_modelview);
-
- cogl_push_framebuffer (state->offscreen);
-
- cogl_set_viewport (stage_viewport[0],
- stage_viewport[1],
- stage_viewport[2],
- stage_viewport[3]);
- cogl_set_projection_matrix (&stage_projection);
- cogl_set_modelview_matrix (&stage_modelview);
-
- paint_test_backface_culling (state);
-
- cogl_pop_framebuffer ();
-
- /* Incase we want feedback of what was drawn offscreen we draw it
- * to the stage... */
- cogl_set_source_texture (state->offscreen_tex);
- cogl_rectangle (0, TEXTURE_RENDER_SIZE * 16,
- stage_viewport[2],
- stage_viewport[3] + TEXTURE_RENDER_SIZE * 16);
-
- validate_result (0);
- validate_result (16);
+ paint_test_backface_culling (state, state->offscreen);
+
+ /* Copy the result of the offscreen rendering for validation and
+ * also so we can have visual feedback. */
+ pipeline = cogl_pipeline_new (ctx);
+ cogl_pipeline_set_layer_texture (pipeline, 0, state->offscreen_tex);
+ cogl_framebuffer_draw_rectangle (fb,
+ pipeline,
+ 0, TEXTURE_RENDER_SIZE * 16,
+ state->width,
+ state->height + TEXTURE_RENDER_SIZE * 16);
+ cogl_object_unref (pipeline);
+
+ validate_result (fb, 0);
+ validate_result (fb, 16);
}
-static CoglHandle
+static CoglTexture *
make_texture (void)
{
guchar *tex_data, *p;
- CoglHandle tex;
+ CoglTexture *tex;
tex_data = g_malloc (TEXTURE_SIZE * TEXTURE_SIZE * 4);
@@ -279,19 +278,15 @@ make_texture (void)
}
void
-test_cogl_backface_culling (TestUtilsGTestFixture *fixture,
- void *data)
+test_backface_culling (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- CoglHandle tex;
+ CoglTexture *tex;
- state.ctx = shared_state->ctx;
- state.fb = shared_state->fb;
- state.width = cogl_framebuffer_get_width (shared_state->fb);
- state.height = cogl_framebuffer_get_height (shared_state->fb);
+ state.width = cogl_framebuffer_get_width (fb);
+ state.height = cogl_framebuffer_get_height (fb);
- state.offscreen = COGL_INVALID_HANDLE;
+ state.offscreen = NULL;
state.texture = make_texture ();
@@ -304,8 +299,8 @@ test_cogl_backface_culling (TestUtilsGTestFixture *fixture,
paint (&state);
cogl_object_unref (state.offscreen);
- cogl_handle_unref (state.offscreen_tex);
- cogl_handle_unref (state.texture);
+ cogl_object_unref (state.offscreen_tex);
+ cogl_object_unref (state.texture);
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/tests/conform/test-bitmask.c b/tests/conform/test-bitmask.c
index 2ac55a92..3e5e1737 100644
--- a/tests/conform/test-bitmask.c
+++ b/tests/conform/test-bitmask.c
@@ -91,8 +91,7 @@ verify_bits (const CoglBitmask *bitmask,
}
void
-test_cogl_bitmask (TestUtilsGTestFixture *fixture,
- void *data)
+test_bitmask (void)
{
CoglBitmask bitmask;
CoglBitmask other_bitmask;
diff --git a/tests/conform/test-blend-strings.c b/tests/conform/test-blend-strings.c
index 05f85352..4fcf85f9 100644
--- a/tests/conform/test-blend-strings.c
+++ b/tests/conform/test-blend-strings.c
@@ -60,7 +60,7 @@ test_blend (TestState *state,
int x_off;
/* First write out the destination color without any blending... */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, Dr, Dg, Db, Da);
cogl_pipeline_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL);
cogl_set_source (pipeline);
@@ -74,7 +74,7 @@ test_blend (TestState *state,
* Now blend a rectangle over our well defined destination:
*/
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, Sr, Sg, Sb, Sa);
status = cogl_pipeline_set_blend (pipeline, blend_string, &error);
@@ -118,7 +118,7 @@ test_blend (TestState *state,
g_print (" blend constant = UNUSED\n");
}
- test_utils_check_pixel (x_off, y_off, expected_result);
+ test_utils_check_pixel (fb, x_off, y_off, expected_result);
/*
@@ -171,10 +171,10 @@ test_blend (TestState *state,
/* See what we got... */
- test_utils_check_pixel (x_off, y_off, expected_result);
+ test_utils_check_pixel (fb, x_off, y_off, expected_result);
}
-static CoglHandle
+static CoglTexture *
make_texture (guint32 color)
{
guchar *tex_data, *p;
@@ -182,7 +182,7 @@ make_texture (guint32 color)
guint8 g = MASK_GREEN (color);
guint8 b = MASK_BLUE (color);
guint8 a = MASK_ALPHA (color);
- CoglHandle tex;
+ CoglTexture *tex;
tex_data = g_malloc (QUAD_WIDTH * QUAD_WIDTH * 4);
@@ -219,7 +219,7 @@ test_tex_combine (TestState *state,
const char *combine_string,
guint32 expected_result)
{
- CoglHandle tex0, tex1;
+ CoglTexture *tex0, *tex1;
/* combine constant - when applicable */
guint8 Cr = MASK_RED (combine_constant);
@@ -268,8 +268,8 @@ test_tex_combine (TestState *state,
y * QUAD_WIDTH + QUAD_WIDTH);
cogl_handle_unref (material);
- cogl_handle_unref (tex0);
- cogl_handle_unref (tex1);
+ cogl_object_unref (tex0);
+ cogl_object_unref (tex1);
/* See what we got... */
@@ -288,7 +288,7 @@ test_tex_combine (TestState *state,
g_print (" combine constant = UNUSED\n");
}
- test_utils_check_pixel (x_off, y_off, expected_result);
+ test_utils_check_pixel (fb, x_off, y_off, expected_result);
}
static void
@@ -408,19 +408,21 @@ paint (TestState *state)
}
void
-test_cogl_blend_strings (TestUtilsGTestFixture *fixture,
- void *data)
+test_blend_strings (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
-
- cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
- cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb, 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
+ /* XXX: we have to push/pop a framebuffer since this test currently
+ * uses the legacy cogl_rectangle() api. */
+ cogl_push_framebuffer (fb);
paint (&state);
+ cogl_pop_framebuffer ();
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/tests/conform/test-color-mask.c b/tests/conform/test-color-mask.c
index 6222927d..1e22cbcb 100644
--- a/tests/conform/test-color-mask.c
+++ b/tests/conform/test-color-mask.c
@@ -11,7 +11,7 @@ typedef struct _TestState
int width;
int height;
- CoglHandle tex[NUM_FBOS];
+ CoglTexture *tex[NUM_FBOS];
CoglFramebuffer *fbo[NUM_FBOS];
} TestState;
@@ -45,9 +45,12 @@ paint (TestState *state)
/* Render all of the textures to the screen */
for (i = 0; i < NUM_FBOS; i++)
{
- cogl_set_source_texture (state->tex[i]);
- cogl_rectangle (2.0f / NUM_FBOS * i - 1.0f, -1.0f,
- 2.0f / NUM_FBOS * (i + 1) - 1.0f, 1.0f);
+ CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ cogl_pipeline_set_layer_texture (pipeline, 0, state->tex[i]);
+ cogl_framebuffer_draw_rectangle (fb, pipeline,
+ 2.0f / NUM_FBOS * i - 1.0f, -1.0f,
+ 2.0f / NUM_FBOS * (i + 1) - 1.0f, 1.0f);
+ cogl_object_unref (pipeline);
}
/* Verify all of the fbos drew the right color */
@@ -58,7 +61,8 @@ paint (TestState *state)
{ 0x00, 0xff, 0x00, 0xff },
{ 0x00, 0x00, 0xff, 0xff } };
- test_utils_check_pixel_rgb (state->width * (i + 0.5f) / NUM_FBOS,
+ test_utils_check_pixel_rgb (fb,
+ state->width * (i + 0.5f) / NUM_FBOS,
state->height / 2,
expected_colors[i][0],
expected_colors[i][1],
@@ -67,18 +71,13 @@ paint (TestState *state)
}
void
-test_cogl_color_mask (TestUtilsGTestFixture *fixture,
- void *data)
+test_color_mask (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- CoglColor bg;
int i;
- state.width = cogl_framebuffer_get_width (shared_state->fb);
- state.height = cogl_framebuffer_get_height (shared_state->fb);
-
- cogl_color_init_from_4ub (&bg, 0, 0, 0, 255);
+ state.width = cogl_framebuffer_get_width (fb);
+ state.height = cogl_framebuffer_get_height (fb);
for (i = 0; i < NUM_FBOS; i++)
{
@@ -91,9 +90,8 @@ test_cogl_color_mask (TestUtilsGTestFixture *fixture,
cogl_offscreen_new_to_texture (state.tex[i]));
/* Clear the texture color bits */
- cogl_push_framebuffer (state.fbo[i]);
- cogl_clear (&bg, COGL_BUFFER_BIT_COLOR);
- cogl_pop_framebuffer ();
+ cogl_framebuffer_clear4f (state.fbo[i],
+ COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
cogl_framebuffer_set_color_mask (state.fbo[i],
i == 0 ? COGL_COLOR_MASK_RED :
@@ -101,7 +99,11 @@ test_cogl_color_mask (TestUtilsGTestFixture *fixture,
COGL_COLOR_MASK_BLUE);
}
+ /* XXX: we have to push/pop a framebuffer since this test currently
+ * uses the legacy cogl_rectangle() api. */
+ cogl_push_framebuffer (fb);
paint (&state);
+ cogl_pop_framebuffer ();
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 74f1ff03..ed5a6522 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -9,16 +9,14 @@
#include "test-utils.h"
-static TestUtilsSharedState *shared_state = NULL;
-
/* A bit of sugar for adding new conformance tests */
#define ADD_TEST(FUNC, REQUIREMENTS) G_STMT_START { \
- extern void FUNC (TestUtilsGTestFixture *, void *); \
+ extern void FUNC (void); \
if (strcmp (#FUNC, argv[1]) == 0) \
{ \
- test_utils_init (shared_state, REQUIREMENTS); \
- FUNC (NULL, shared_state); \
- test_utils_fini (shared_state); \
+ test_utils_init (REQUIREMENTS); \
+ FUNC (); \
+ test_utils_fini (); \
exit (0); \
} \
} G_STMT_END
@@ -45,65 +43,59 @@ main (int argc, char **argv)
argv[1][i] = '_';
}
- /* Initialise the state you need to share with everything.
- */
- shared_state = g_new0 (TestUtilsSharedState, 1);
- shared_state->argc_addr = &argc;
- shared_state->argv_addr = &argv;
-
/* This file is run through a sed script during the make step so the
* lines containing the tests need to be formatted on a single line
* each.
*/
- UNPORTED_TEST (test_cogl_object);
- UNPORTED_TEST (test_cogl_fixed);
- UNPORTED_TEST (test_cogl_materials);
- ADD_TEST (test_cogl_pipeline_user_matrix, 0);
- ADD_TEST (test_cogl_blend_strings, 0);
- UNPORTED_TEST (test_cogl_premult);
- UNPORTED_TEST (test_cogl_readpixels);
- ADD_TEST (test_cogl_path, 0);
- ADD_TEST (test_cogl_depth_test, 0);
- ADD_TEST (test_cogl_color_mask, 0);
- ADD_TEST (test_cogl_backface_culling, TEST_REQUIREMENT_NPOT);
-
- ADD_TEST (test_cogl_sparse_pipeline, 0);
-
- UNPORTED_TEST (test_cogl_npot_texture);
- UNPORTED_TEST (test_cogl_multitexture);
- UNPORTED_TEST (test_cogl_texture_mipmaps);
- ADD_TEST (test_cogl_sub_texture, 0);
- ADD_TEST (test_cogl_pixel_buffer, 0);
- UNPORTED_TEST (test_cogl_texture_rectangle);
- ADD_TEST (test_cogl_texture_3d, 0);
- ADD_TEST (test_cogl_wrap_modes, 0);
- UNPORTED_TEST (test_cogl_texture_pixmap_x11);
- UNPORTED_TEST (test_cogl_texture_get_set_data);
- UNPORTED_TEST (test_cogl_atlas_migration);
- ADD_TEST (test_cogl_read_texture_formats, 0);
- ADD_TEST (test_cogl_write_texture_formats, 0);
-
- UNPORTED_TEST (test_cogl_vertex_buffer_contiguous);
- UNPORTED_TEST (test_cogl_vertex_buffer_interleved);
- UNPORTED_TEST (test_cogl_vertex_buffer_mutability);
-
- ADD_TEST (test_cogl_primitive, 0);
-
- ADD_TEST (test_cogl_just_vertex_shader, 0);
- ADD_TEST (test_cogl_pipeline_uniforms, 0);
- ADD_TEST (test_cogl_snippets, 0);
- ADD_TEST (test_cogl_custom_attributes, 0);
-
- ADD_TEST (test_cogl_bitmask, 0);
-
- ADD_TEST (test_cogl_offscreen, 0);
-
- ADD_TEST (test_cogl_point_size, 0);
- ADD_TEST (test_cogl_point_sprite,
+ UNPORTED_TEST (test_object);
+ UNPORTED_TEST (test_fixed);
+ UNPORTED_TEST (test_materials);
+ ADD_TEST (test_pipeline_user_matrix, 0);
+ ADD_TEST (test_blend_strings, 0);
+ UNPORTED_TEST (test_premult);
+ UNPORTED_TEST (test_readpixels);
+ ADD_TEST (test_path, 0);
+ ADD_TEST (test_depth_test, 0);
+ ADD_TEST (test_color_mask, 0);
+ ADD_TEST (test_backface_culling, TEST_REQUIREMENT_NPOT);
+
+ ADD_TEST (test_sparse_pipeline, 0);
+
+ UNPORTED_TEST (test_npot_texture);
+ UNPORTED_TEST (test_multitexture);
+ UNPORTED_TEST (test_texture_mipmaps);
+ ADD_TEST (test_sub_texture, 0);
+ ADD_TEST (test_pixel_buffer, 0);
+ UNPORTED_TEST (test_texture_rectangle);
+ ADD_TEST (test_texture_3d, 0);
+ ADD_TEST (test_wrap_modes, 0);
+ UNPORTED_TEST (test_texture_pixmap_x11);
+ UNPORTED_TEST (test_texture_get_set_data);
+ UNPORTED_TEST (test_atlas_migration);
+ ADD_TEST (test_read_texture_formats, 0);
+ ADD_TEST (test_write_texture_formats, 0);
+
+ UNPORTED_TEST (test_vertex_buffer_contiguous);
+ UNPORTED_TEST (test_vertex_buffer_interleved);
+ UNPORTED_TEST (test_vertex_buffer_mutability);
+
+ ADD_TEST (test_primitive, 0);
+
+ ADD_TEST (test_just_vertex_shader, 0);
+ ADD_TEST (test_pipeline_uniforms, 0);
+ ADD_TEST (test_snippets, 0);
+ ADD_TEST (test_custom_attributes, 0);
+
+ ADD_TEST (test_bitmask, 0);
+
+ ADD_TEST (test_offscreen, 0);
+
+ ADD_TEST (test_point_size, 0);
+ ADD_TEST (test_point_sprite,
TEST_KNOWN_FAILURE | TEST_REQUIREMENT_POINT_SPRITE);
- UNPORTED_TEST (test_cogl_viewport);
+ UNPORTED_TEST (test_viewport);
g_printerr ("Unknown test name \"%s\"\n", argv[1]);
diff --git a/tests/conform/test-custom-attributes.c b/tests/conform/test-custom-attributes.c
index d9ceaac4..6af4fa2c 100644
--- a/tests/conform/test-custom-attributes.c
+++ b/tests/conform/test-custom-attributes.c
@@ -6,8 +6,6 @@
typedef struct _TestState
{
- CoglContext *ctx;
- CoglFramebuffer *fb;
CoglPipeline *pipeline;
} TestState;
@@ -45,7 +43,7 @@ test_float_verts (TestState *state, int offset_x, int offset_y)
{ 15, 0, /**/ 0, 1, 0, 1 }
};
- buffer = cogl_attribute_buffer_new (state->ctx,
+ buffer = cogl_attribute_buffer_new (ctx,
sizeof (float_verts), float_verts);
attributes[0] = cogl_attribute_new (buffer,
"cogl_position_in",
@@ -60,10 +58,10 @@ test_float_verts (TestState *state, int offset_x, int offset_y)
4, /* n_components */
COGL_ATTRIBUTE_TYPE_FLOAT);
- cogl_push_matrix ();
- cogl_translate (offset_x, offset_y, 0.0f);
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb, offset_x, offset_y, 0.0f);
- cogl_framebuffer_draw_attributes (state->fb,
+ cogl_framebuffer_draw_attributes (fb,
state->pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -71,14 +69,14 @@ test_float_verts (TestState *state, int offset_x, int offset_y)
attributes,
2 /* n_attributes */);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
cogl_object_unref (attributes[1]);
cogl_object_unref (attributes[0]);
cogl_object_unref (buffer);
- test_utils_check_pixel (offset_x + 5, offset_y + 5, 0xff0000ff);
- test_utils_check_pixel (offset_x + 15, offset_y + 5, 0x00ff00ff);
+ test_utils_check_pixel (fb, offset_x + 5, offset_y + 5, 0xff0000ff);
+ test_utils_check_pixel (fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
}
static void
@@ -105,7 +103,7 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
{ 0, 0, /**/ 0, 0, 1, 1 },
};
- buffer = cogl_attribute_buffer_new (state->ctx,
+ buffer = cogl_attribute_buffer_new (ctx,
sizeof (norm_verts), norm_verts);
attributes[0] = cogl_attribute_new (buffer,
"cogl_position_in",
@@ -121,10 +119,10 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
cogl_attribute_set_normalized (attributes[1], TRUE);
- cogl_push_matrix ();
- cogl_translate (offset_x, offset_y, 0.0f);
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb, offset_x, offset_y, 0.0f);
- cogl_framebuffer_draw_attributes (state->fb,
+ cogl_framebuffer_draw_attributes (fb,
state->pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -135,7 +133,7 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
cogl_object_unref (attributes[1]);
/* Test again with unnormalized attributes */
- unnorm_buffer = cogl_attribute_buffer_new (state->ctx,
+ unnorm_buffer = cogl_attribute_buffer_new (ctx,
sizeof (unnorm_verts),
unnorm_verts);
attributes[1] = cogl_attribute_new (unnorm_buffer,
@@ -145,9 +143,9 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
4, /* n_components */
COGL_ATTRIBUTE_TYPE_BYTE);
- cogl_translate (20, 0, 0);
+ cogl_framebuffer_translate (fb, 20, 0, 0);
- cogl_framebuffer_draw_attributes (state->fb,
+ cogl_framebuffer_draw_attributes (fb,
state->pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -155,16 +153,16 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
attributes,
2 /* n_attributes */);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
cogl_object_unref (attributes[0]);
cogl_object_unref (attributes[1]);
cogl_object_unref (buffer);
cogl_object_unref (unnorm_buffer);
- test_utils_check_pixel (offset_x + 5, offset_y + 5, 0xff0000ff);
- test_utils_check_pixel (offset_x + 15, offset_y + 5, 0x00ff00ff);
- test_utils_check_pixel (offset_x + 25, offset_y + 5, 0x0000ffff);
+ test_utils_check_pixel (fb, offset_x + 5, offset_y + 5, 0xff0000ff);
+ test_utils_check_pixel (fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
+ test_utils_check_pixel (fb, offset_x + 25, offset_y + 5, 0x0000ffff);
}
static void
@@ -182,7 +180,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
{ -5, -1 }
};
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
"attribute vec2 pos;",
NULL);
@@ -195,7 +193,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255);
- buffer = cogl_attribute_buffer_new (state->ctx,
+ buffer = cogl_attribute_buffer_new (ctx,
sizeof (short_verts), short_verts);
attributes[0] = cogl_attribute_new (buffer,
"pos",
@@ -204,10 +202,13 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
2, /* n_components */
COGL_ATTRIBUTE_TYPE_SHORT);
- cogl_push_matrix ();
- cogl_translate (offset_x + 10.0f, offset_y + 10.0f, 0.0f);
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb,
+ offset_x + 10.0f,
+ offset_y + 10.0f,
+ 0.0f);
- cogl_framebuffer_draw_attributes (state->fb,
+ cogl_framebuffer_draw_attributes (fb,
pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -215,7 +216,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
attributes,
1 /* n_attributes */);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
cogl_object_unref (attributes[0]);
@@ -230,10 +231,13 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
pipeline2 = cogl_pipeline_copy (pipeline);
cogl_pipeline_set_color4ub (pipeline2, 0, 255, 0, 255);
- cogl_push_matrix ();
- cogl_translate (offset_x + 10.0f - 65525.0f, offset_y - 65525, 0.0f);
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb,
+ offset_x + 10.0f - 65525.0f,
+ offset_y - 65525,
+ 0.0f);
- cogl_framebuffer_draw_attributes (state->fb,
+ cogl_framebuffer_draw_attributes (fb,
pipeline2,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -241,7 +245,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
attributes,
1 /* n_attributes */);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
cogl_object_unref (attributes[0]);
@@ -249,17 +253,14 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
cogl_object_unref (pipeline);
cogl_object_unref (buffer);
- test_utils_check_pixel (offset_x + 5, offset_y + 5, 0xff0000ff);
- test_utils_check_pixel (offset_x + 15, offset_y + 5, 0x00ff00ff);
+ test_utils_check_pixel (fb, offset_x + 5, offset_y + 5, 0xff0000ff);
+ test_utils_check_pixel (fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
}
static void
paint (TestState *state)
{
- CoglColor color;
-
- cogl_color_init_from_4ub (&color, 0, 0, 0, 255);
- cogl_clear (&color, COGL_BUFFER_BIT_COLOR);
+ cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
test_float_verts (state, 0, 0);
test_byte_verts (state, 0, 10);
@@ -267,28 +268,22 @@ paint (TestState *state)
}
void
-test_cogl_custom_attributes (TestUtilsGTestFixture *fixture,
- void *user_data)
+test_custom_attributes (void)
{
- TestUtilsSharedState *shared_state = user_data;
-
/* If shaders aren't supported then we can't run the test */
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
{
CoglSnippet *snippet;
TestState state;
- state.fb = shared_state->fb;
-
- state.ctx = shared_state->ctx;
- cogl_ortho (/* left, right */
- 0, cogl_framebuffer_get_width (shared_state->fb),
- /* bottom, top */
- cogl_framebuffer_get_height (shared_state->fb), 0,
- /* z near, far */
- -1, 100);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
- state.pipeline = cogl_pipeline_new (state.ctx);
+ state.pipeline = cogl_pipeline_new (ctx);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX,
"attribute vec4 color;",
"cogl_color_out = color;");
diff --git a/tests/conform/test-depth-test.c b/tests/conform/test-depth-test.c
index 301c2a24..76891db8 100644
--- a/tests/conform/test-depth-test.c
+++ b/tests/conform/test-depth-test.c
@@ -18,7 +18,7 @@
typedef struct _TestState
{
- CoglContext *ctx;
+ int padding;
} TestState;
typedef struct
@@ -36,13 +36,14 @@ static gboolean
draw_rectangle (TestState *state,
int x,
int y,
- TestDepthState *rect_state)
+ TestDepthState *rect_state,
+ gboolean legacy_mode)
{
guint8 Cr = MASK_RED (rect_state->color);
guint8 Cg = MASK_GREEN (rect_state->color);
guint8 Cb = MASK_BLUE (rect_state->color);
guint8 Ca = MASK_ALPHA (rect_state->color);
- CoglHandle pipeline;
+ CoglPipeline *pipeline;
CoglDepthState depth_state;
cogl_depth_state_init (&depth_state);
@@ -53,24 +54,40 @@ draw_rectangle (TestState *state,
rect_state->range_near,
rect_state->range_far);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
if (!cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL))
{
cogl_object_unref (pipeline);
return FALSE;
}
- cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
-
- cogl_set_source (pipeline);
-
- cogl_push_matrix ();
- cogl_translate (0, 0, rect_state->depth);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
- cogl_pop_matrix ();
+ if (!legacy_mode)
+ {
+ cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
+
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb, 0, 0, rect_state->depth);
+ cogl_framebuffer_draw_rectangle (fb,
+ pipeline,
+ x * QUAD_WIDTH,
+ y * QUAD_WIDTH,
+ x * QUAD_WIDTH + QUAD_WIDTH,
+ y * QUAD_WIDTH + QUAD_WIDTH);
+ cogl_framebuffer_pop_matrix (fb);
+ }
+ else
+ {
+ cogl_push_framebuffer (fb);
+ cogl_push_matrix ();
+ cogl_set_source_color4ub (Cr, Cg, Cb, Ca);
+ cogl_translate (0, 0, rect_state->depth);
+ cogl_rectangle (x * QUAD_WIDTH,
+ y * QUAD_WIDTH,
+ x * QUAD_WIDTH + QUAD_WIDTH,
+ y * QUAD_WIDTH + QUAD_WIDTH);
+ cogl_pop_matrix ();
+ cogl_pop_framebuffer ();
+ }
cogl_object_unref (pipeline);
@@ -84,23 +101,25 @@ test_depth (TestState *state,
TestDepthState *rect0_state,
TestDepthState *rect1_state,
TestDepthState *rect2_state,
+ gboolean legacy_mode,
guint32 expected_result)
{
gboolean missing_feature = FALSE;
if (rect0_state)
- missing_feature |= !draw_rectangle (state, x, y, rect0_state);
+ missing_feature |= !draw_rectangle (state, x, y, rect0_state, legacy_mode);
if (rect1_state)
- missing_feature |= !draw_rectangle (state, x, y, rect1_state);
+ missing_feature |= !draw_rectangle (state, x, y, rect1_state, legacy_mode);
if (rect2_state)
- missing_feature |= !draw_rectangle (state, x, y, rect2_state);
+ missing_feature |= !draw_rectangle (state, x, y, rect2_state, legacy_mode);
/* We don't consider it an error that we can't test something
* the driver doesn't support. */
if (missing_feature)
return;
- test_utils_check_pixel (x * QUAD_WIDTH + (QUAD_WIDTH / 2),
+ test_utils_check_pixel (fb,
+ x * QUAD_WIDTH + (QUAD_WIDTH / 2),
y * QUAD_WIDTH + (QUAD_WIDTH / 2),
expected_result);
}
@@ -142,27 +161,32 @@ paint (TestState *state)
test_depth (state, 0, 0, /* position */
&rect0_state, &rect1_state, &rect2_state,
+ FALSE, /* legacy mode */
0x00ff00ff); /* expected */
rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_ALWAYS;
test_depth (state, 1, 0, /* position */
&rect0_state, &rect1_state, &rect2_state,
+ FALSE, /* legacy mode */
0x0000ffff); /* expected */
rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_LESS;
test_depth (state, 2, 0, /* position */
&rect0_state, &rect1_state, &rect2_state,
+ FALSE, /* legacy mode */
0x0000ffff); /* expected */
rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_GREATER;
test_depth (state, 3, 0, /* position */
&rect0_state, &rect1_state, &rect2_state,
+ FALSE, /* legacy mode */
0x00ff00ff); /* expected */
rect0_state.test_enable = TRUE;
rect1_state.write_enable = FALSE;
test_depth (state, 4, 0, /* position */
&rect0_state, &rect1_state, &rect2_state,
+ FALSE, /* legacy mode */
0x0000ffff); /* expected */
}
@@ -191,6 +215,7 @@ paint (TestState *state)
test_depth (state, 0, 1, /* position */
&rect0_state, &rect1_state, NULL,
+ FALSE, /* legacy mode */
0xff0000ff); /* expected */
}
@@ -220,26 +245,26 @@ paint (TestState *state)
cogl_set_depth_test_enabled (TRUE);
test_depth (state, 0, 2, /* position */
&rect0_state, &rect1_state, NULL,
+ TRUE, /* legacy mode */
0xff0000ff); /* expected */
cogl_set_depth_test_enabled (FALSE);
test_depth (state, 1, 2, /* position */
&rect0_state, &rect1_state, NULL,
+ TRUE, /* legacy mode */
0x00ff00ff); /* expected */
}
}
void
-test_cogl_depth_test (TestUtilsGTestFixture *fixture,
- void *data)
+test_depth_test (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
-
- cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
- cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb, 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
paint (&state);
diff --git a/tests/conform/test-fixed.c b/tests/conform/test-fixed.c
index 78c34453..175b2d19 100644
--- a/tests/conform/test-fixed.c
+++ b/tests/conform/test-fixed.c
@@ -4,7 +4,7 @@
#include "test-conform-common.h"
void
-test_cogl_fixed (TestUtilsGTestFixture *fixture,
+test_fixed (TestUtilsGTestFixture *fixture,
void *data)
{
g_assert_cmpint (COGL_FIXED_1, ==, COGL_FIXED_FROM_FLOAT (1.0));
diff --git a/tests/conform/test-fixtures.c b/tests/conform/test-fixtures.c
index 24178d28..dfc20437 100644
--- a/tests/conform/test-fixtures.c
+++ b/tests/conform/test-fixtures.c
@@ -3,7 +3,7 @@
#include <cogl/cogl.h>
void
-test_cogl_simple_rig (void)
+test_simple_rig (void)
{
ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff };
stage = clutter_stage_get_default ();
diff --git a/tests/conform/test-just-vertex-shader.c b/tests/conform/test-just-vertex-shader.c
index ef0ecc2b..2e054803 100644
--- a/tests/conform/test-just-vertex-shader.c
+++ b/tests/conform/test-just-vertex-shader.c
@@ -6,10 +6,10 @@
typedef struct _TestState
{
- CoglContext *ctx;
+ int paddiing;
} TestState;
-static CoglHandle
+static CoglTexture *
create_dummy_texture (void)
{
/* Create a dummy 1x1 green texture to replace the color from the
@@ -28,7 +28,7 @@ static void
paint_legacy (TestState *state)
{
CoglHandle material = cogl_material_new ();
- CoglHandle tex;
+ CoglTexture *tex;
CoglColor color;
GError *error = NULL;
CoglHandle shader, program;
@@ -44,7 +44,7 @@ paint_legacy (TestState *state)
constant green color provided by a texture */
tex = create_dummy_texture ();
cogl_material_set_layer (material, 0, tex);
- cogl_handle_unref (tex);
+ cogl_object_unref (tex);
if (!cogl_material_set_layer_combine (material, 0,
"RGBA=REPLACE(TEXTURE)",
&error))
@@ -97,8 +97,8 @@ paint_legacy (TestState *state)
static void
paint (TestState *state)
{
- CoglPipeline *pipeline = cogl_pipeline_new (state->ctx);
- CoglHandle tex;
+ CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ CoglTexture *tex;
CoglColor color;
GError *error = NULL;
CoglHandle shader, program;
@@ -114,7 +114,7 @@ paint (TestState *state)
constant green color provided by a texture */
tex = create_dummy_texture ();
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
- cogl_handle_unref (tex);
+ cogl_object_unref (tex);
if (!cogl_pipeline_set_layer_combine (pipeline, 0,
"RGBA=REPLACE(TEXTURE)",
&error))
@@ -166,35 +166,40 @@ paint (TestState *state)
}
static void
-validate_result (void)
+validate_result (CoglFramebuffer *framebuffer)
{
/* Non-shader version */
- test_utils_check_pixel (25, 25, 0x00ff0000);
+ test_utils_check_pixel (framebuffer, 25, 25, 0x00ff0000);
/* Shader version */
- test_utils_check_pixel (75, 25, 0x00ff0000);
+ test_utils_check_pixel (framebuffer, 75, 25, 0x00ff0000);
}
void
-test_cogl_just_vertex_shader (TestUtilsGTestFixture *fixture,
- void *data)
+test_just_vertex_shader (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
-
- cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
- cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
/* If shaders aren't supported then we can't run the test */
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
{
+ /* XXX: we have to push/pop a framebuffer since this test currently
+ * uses the legacy cogl_rectangle() api. */
+ cogl_push_framebuffer (fb);
+
paint_legacy (&state);
- validate_result ();
+ validate_result (fb);
paint (&state);
- validate_result ();
+ validate_result (fb);
+
+ cogl_pop_framebuffer ();
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/tests/conform/test-materials.c b/tests/conform/test-materials.c
index cb4f2088..84b1444d 100644
--- a/tests/conform/test-materials.c
+++ b/tests/conform/test-materials.c
@@ -218,7 +218,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_materials (TestUtilsGTestFixture *fixture,
+test_materials (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-multitexture.c b/tests/conform/test-multitexture.c
index 4de5f97e..c0aa9c2b 100644
--- a/tests/conform/test-multitexture.c
+++ b/tests/conform/test-multitexture.c
@@ -173,7 +173,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_multitexture (TestUtilsGTestFixture *fixture,
+test_multitexture (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-npot-texture.c b/tests/conform/test-npot-texture.c
index c7551390..8687d632 100644
--- a/tests/conform/test-npot-texture.c
+++ b/tests/conform/test-npot-texture.c
@@ -188,7 +188,7 @@ make_texture (void)
}
void
-test_cogl_npot_texture (TestUtilsGTestFixture *fixture,
+test_npot_texture (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-object.c b/tests/conform/test-object.c
index b1493cc5..0a6dcab6 100644
--- a/tests/conform/test-object.c
+++ b/tests/conform/test-object.c
@@ -39,7 +39,7 @@ destroy2_cb (void *user_data)
}
void
-test_cogl_object (TestUtilsGTestFixture *fixture,
+test_object (TestUtilsGTestFixture *fixture,
void *data)
{
CoglPath *path;
diff --git a/tests/conform/test-offscreen.c b/tests/conform/test-offscreen.c
index 2a078808..0683a8ab 100644
--- a/tests/conform/test-offscreen.c
+++ b/tests/conform/test-offscreen.c
@@ -8,7 +8,6 @@
typedef struct _TestState
{
- CoglContext *context;
int fb_width;
int fb_height;
} TestState;
@@ -33,7 +32,7 @@ check_quadrant (TestState *state,
width -= 4;
height -= 4;
- test_utils_check_region (x, y, width, height, expected_rgba);
+ test_utils_check_region (fb, x, y, width, height, expected_rgba);
}
static void
@@ -41,9 +40,9 @@ test_paint (TestState *state)
{
CoglTexture2D *tex_2d;
CoglTexture *tex;
- CoglHandle offscreen;
+ CoglOffscreen *offscreen;
- tex_2d = cogl_texture_2d_new_with_size (state->context,
+ tex_2d = cogl_texture_2d_new_with_size (ctx,
state->fb_width,
state->fb_height,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
@@ -66,11 +65,11 @@ test_paint (TestState *state)
cogl_translate (0.5, 0.5, 0);
cogl_scale (-0.5, 0.5, 1);
- cogl_push_framebuffer (offscreen);
+ cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
/* Cogl should release the last reference when we call cogl_pop_framebuffer()
*/
- cogl_handle_unref (offscreen);
+ cogl_object_unref (offscreen);
/* Setup something other than the identity matrix for the modelview so we can
* verify it gets restored when we call cogl_pop_framebuffer () */
@@ -116,7 +115,7 @@ test_flush (TestState *state)
{
CoglTexture2D *tex_2d;
CoglTexture *tex;
- CoglHandle offscreen;
+ CoglOffscreen *offscreen;
CoglColor clear_color;
int i;
@@ -126,7 +125,7 @@ test_flush (TestState *state)
the contents of the texture will automatically flush the
journal */
- tex_2d = cogl_texture_2d_new_with_size (state->context,
+ tex_2d = cogl_texture_2d_new_with_size (ctx,
16, 16, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
NULL);
@@ -134,7 +133,7 @@ test_flush (TestState *state)
offscreen = cogl_offscreen_new_to_texture (tex);
- cogl_push_framebuffer (offscreen);
+ cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 255);
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
@@ -144,7 +143,8 @@ test_flush (TestState *state)
if (i == 0)
/* First time check using read pixels on the offscreen */
- test_utils_check_region (1, 1, 15, 15, 0xff0000ff);
+ test_utils_check_region (COGL_FRAMEBUFFER (offscreen),
+ 1, 1, 15, 15, 0xff0000ff);
else if (i == 1)
{
guint8 data[16 * 4 * 16];
@@ -169,30 +169,32 @@ test_flush (TestState *state)
/* Third time try drawing the texture to the screen */
cogl_set_source_texture (tex);
cogl_rectangle (-1, -1, 1, 1);
- test_utils_check_region (2, 2, /* x/y */
+ test_utils_check_region (fb,
+ 2, 2, /* x/y */
state->fb_width - 4,
state->fb_height - 4,
0xff0000ff);
}
cogl_object_unref (tex_2d);
- cogl_handle_unref (offscreen);
+ cogl_object_unref (offscreen);
}
}
void
-test_cogl_offscreen (TestUtilsGTestFixture *fixture,
- void *data)
+test_offscreen (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.context = shared_state->ctx;
- state.fb_width = cogl_framebuffer_get_width (shared_state->fb);
- state.fb_height = cogl_framebuffer_get_height (shared_state->fb);
+ state.fb_width = cogl_framebuffer_get_width (fb);
+ state.fb_height = cogl_framebuffer_get_height (fb);
+ /* XXX: we have to push/pop a framebuffer since this test currently
+ * uses the legacy cogl_rectangle() api. */
+ cogl_push_framebuffer (fb);
test_paint (&state);
test_flush (&state);
+ cogl_pop_framebuffer ();
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/tests/conform/test-path.c b/tests/conform/test-path.c
index 0310fd72..a7a6f3c6 100644
--- a/tests/conform/test-path.c
+++ b/tests/conform/test-path.c
@@ -17,10 +17,10 @@ typedef struct _TestState
static void
draw_path_at (int x, int y)
{
- cogl_push_matrix ();
- cogl_translate (x * BLOCK_SIZE, y * BLOCK_SIZE, 0.0f);
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb, x * BLOCK_SIZE, y * BLOCK_SIZE, 0.0f);
cogl_path_fill ();
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
}
static void
@@ -33,12 +33,12 @@ check_block (int block_x, int block_y, int block_mask)
filled. The bits from 0->3 represent the top left, top right,
bottom left and bottom right respectively */
- cogl_read_pixels (block_x * BLOCK_SIZE,
- block_y * BLOCK_SIZE,
- BLOCK_SIZE, BLOCK_SIZE,
- COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888_PRE,
- (guint8 *)data);
+ cogl_framebuffer_read_pixels (fb,
+ block_x * BLOCK_SIZE,
+ block_y * BLOCK_SIZE,
+ BLOCK_SIZE, BLOCK_SIZE,
+ COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+ (guint8 *)data);
for (qy = 0; qy < 2; qy++)
for (qx = 0; qx < 2; qx++)
@@ -188,17 +188,22 @@ validate_result ()
}
void
-test_cogl_path (TestUtilsGTestFixture *fixture,
- void *data)
+test_path (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
- cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
+ /* XXX: we have to push/pop a framebuffer since this test currently
+ * uses the legacy cogl_rectangle() api. */
+ cogl_push_framebuffer (fb);
paint (&state);
+ cogl_pop_framebuffer ();
validate_result ();
if (cogl_test_verbose ())
diff --git a/tests/conform/test-pipeline-uniforms.c b/tests/conform/test-pipeline-uniforms.c
index cfc62fb2..da7b86b4 100644
--- a/tests/conform/test-pipeline-uniforms.c
+++ b/tests/conform/test-pipeline-uniforms.c
@@ -8,8 +8,6 @@
typedef struct _TestState
{
- CoglContext *ctx;
-
CoglPipeline *pipeline_red;
CoglPipeline *pipeline_green;
CoglPipeline *pipeline_blue;
@@ -92,7 +90,7 @@ create_pipeline_for_shader (TestState *state, const char *shader_source)
CoglHandle shader;
CoglHandle program;
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
cogl_shader_source (shader, shader_source);
@@ -179,9 +177,8 @@ destroy_state (TestState *state)
static void
paint_pipeline (CoglPipeline *pipeline, int pos)
{
- cogl_push_source (pipeline);
- cogl_rectangle (pos * 10, 0, pos * 10 + 10, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline,
+ pos * 10, 0, pos * 10 + 10, 10);
}
static void
@@ -343,10 +340,7 @@ paint_long_pipeline (TestState *state)
static void
paint (TestState *state)
{
- CoglColor color;
-
- cogl_color_init_from_4ub (&color, 0, 0, 0, 255);
- cogl_clear (&color, COGL_BUFFER_BIT_COLOR);
+ cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
paint_color_pipelines (state);
paint_matrix_pipeline (state->matrix_pipeline);
@@ -357,7 +351,7 @@ paint (TestState *state)
static void
check_pos (int pos, guint32 color)
{
- test_utils_check_pixel (pos * 10 + 5, 5, color);
+ test_utils_check_pixel (fb, pos * 10 + 5, 5, color);
}
static void
@@ -387,26 +381,21 @@ validate_long_pipeline_result (void)
}
void
-test_cogl_pipeline_uniforms (TestUtilsGTestFixture *fixture,
- void *user_data)
+test_pipeline_uniforms (void)
{
- TestUtilsSharedState *shared_state = user_data;
-
/* If shaders aren't supported then we can't run the test */
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
{
TestState state;
- state.ctx = shared_state->ctx;
-
init_state (&state);
- cogl_ortho (/* left, right */
- 0, cogl_framebuffer_get_width (shared_state->fb),
- /* bottom, top */
- cogl_framebuffer_get_height (shared_state->fb), 0,
- /* z near, far */
- -1, 100);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
paint (&state);
validate_result ();
diff --git a/tests/conform/test-pipeline-user-matrix.c b/tests/conform/test-pipeline-user-matrix.c
index fa6e6dc5..6f1b34a0 100644
--- a/tests/conform/test-pipeline-user-matrix.c
+++ b/tests/conform/test-pipeline-user-matrix.c
@@ -6,7 +6,6 @@
typedef struct _TestState
{
- CoglContext *ctx;
int width;
int height;
} TestState;
@@ -23,10 +22,9 @@ validate_result (TestState *state)
verify this by reading back the entire stage */
pixels = g_malloc (state->width * state->height * 4);
- cogl_read_pixels (0, 0, state->width, state->height,
- COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888_PRE,
- (guint8 *)pixels);
+ cogl_framebuffer_read_pixels (fb, 0, 0, state->width, state->height,
+ COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+ (guint8 *)pixels);
for (p = pixels; p < pixels + state->width * state->height; p++)
{
@@ -53,21 +51,22 @@ paint (TestState *state)
0xff, 0x00, 0xff, /* magenta -> becomes bottom right */
0x00, 0xff, 0xff /* cyan -> becomes bottom left */
};
- CoglColor bg;
- CoglHandle tex0, tex1;
+ CoglTexture *tex0, *tex1;
CoglPipeline *pipeline;
CoglMatrix matrix;
GError *error = NULL;
- cogl_ortho (0, state->width, /* left, right */
- state->height, 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ state->width,
+ state->height,
+ -1,
+ 100);
- cogl_color_init_from_4ub (&bg, 0, 0, 0, 255);
- cogl_clear (&bg, COGL_BUFFER_BIT_COLOR);
+ cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
cogl_matrix_init_identity (&matrix);
- cogl_set_modelview_matrix (&matrix);
+ cogl_framebuffer_set_modelview_matrix (fb, &matrix);
tex0 = cogl_texture_new_from_data (2, 2,
COGL_TEXTURE_NO_ATLAS,
@@ -82,7 +81,7 @@ paint (TestState *state)
6,
data1);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
/* Set the two textures as layers */
cogl_pipeline_set_layer_texture (pipeline, 0, tex0);
@@ -115,25 +114,23 @@ paint (TestState *state)
cogl_matrix_scale (&matrix, -1.0f, 1.0f, 1.0f);
cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix);
- cogl_set_source (pipeline);
- cogl_rectangle (0, 0, state->width, state->height);
+ cogl_framebuffer_draw_rectangle (fb,
+ pipeline,
+ 0, 0,
+ state->width, state->height);
- cogl_handle_unref (tex1);
- cogl_handle_unref (tex0);
+ cogl_object_unref (tex1);
+ cogl_object_unref (tex0);
cogl_object_unref (pipeline);
}
void
-test_cogl_pipeline_user_matrix (TestUtilsGTestFixture *fixture,
- void *data)
+test_pipeline_user_matrix (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
-
- state.width = cogl_framebuffer_get_width (shared_state->fb);
- state.height = cogl_framebuffer_get_height (shared_state->fb);
+ state.width = cogl_framebuffer_get_width (fb);
+ state.height = cogl_framebuffer_get_height (fb);
paint (&state);
validate_result (&state);
diff --git a/tests/conform/test-pixel-buffer.c b/tests/conform/test-pixel-buffer.c
index 5368feb1..393f40a4 100644
--- a/tests/conform/test-pixel-buffer.c
+++ b/tests/conform/test-pixel-buffer.c
@@ -188,11 +188,15 @@ draw_frame (TestState *state)
/* Paint the textures */
for (i = 0; i < NB_TILES; i++)
{
- cogl_set_source_texture (state->tiles[i].texture);
- cogl_rectangle (state->tiles[i].x,
- state->tiles[i].y,
- state->tiles[i].x + TILE_SIZE,
- state->tiles[i].y + TILE_SIZE);
+ CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ cogl_pipeline_set_layer_texture (pipeline, 0, state->tiles[i].texture);
+ cogl_framebuffer_draw_rectangle (fb,
+ pipeline,
+ state->tiles[i].x,
+ state->tiles[i].y,
+ state->tiles[i].x + TILE_SIZE,
+ state->tiles[i].y + TILE_SIZE);
+ cogl_object_unref (pipeline);
}
}
@@ -201,7 +205,8 @@ static void
validate_tile (TestState *state,
TestTile *tile)
{
- test_utils_check_region (tile->x, tile->y,
+ test_utils_check_region (fb,
+ tile->x, tile->y,
TILE_SIZE, TILE_SIZE,
(tile->color[0] << 24) |
(tile->color[1] << 16) |
@@ -219,10 +224,8 @@ validate_result (TestState *state)
}
void
-test_cogl_pixel_buffer (TestUtilsGTestFixture *fixture,
- void *data)
+test_pixel_buffer (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
int i;
static TestTile tiles[NB_TILES] =
@@ -239,17 +242,20 @@ test_cogl_pixel_buffer (TestUtilsGTestFixture *fixture,
{ { 0x7e, 0xff, 0x7e, 0xff }, 0.0f, TILE_SIZE, NULL, NULL }
};
- state.width = cogl_framebuffer_get_width (shared_state->fb);
- state.height = cogl_framebuffer_get_height (shared_state->fb);
- cogl_ortho (0, state.width, /* left, right */
- state.height, 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ state.width = cogl_framebuffer_get_width (fb);
+ state.height = cogl_framebuffer_get_height (fb);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ state.width,
+ state.height,
+ -1,
+ 100);
- create_map_tile (shared_state->ctx, &tiles[TILE_MAP]);
+ create_map_tile (ctx, &tiles[TILE_MAP]);
#if 0
create_set_region_tile (shared_state->ctx, &tiles[TILE_SET_REGION]);
#endif
- create_set_data_tile (shared_state->ctx, &tiles[TILE_SET_DATA]);
+ create_set_data_tile (ctx, &tiles[TILE_SET_DATA]);
state.tiles = tiles;
diff --git a/tests/conform/test-point-size.c b/tests/conform/test-point-size.c
index 41861a48..6f114d3e 100644
--- a/tests/conform/test-point-size.c
+++ b/tests/conform/test-point-size.c
@@ -37,30 +37,28 @@ verify_point_size (CoglFramebuffer *fb,
gboolean in_point = x >= 1 && x <= 2 && y >= 1 && y <= 2;
guint32 expected_pixel = in_point ? 0x00ff00ff : 0xff0000ff;
- test_utils_check_pixel (calc_coord_offset (x_pos, x, point_size),
+ test_utils_check_pixel (fb,
+ calc_coord_offset (x_pos, x, point_size),
calc_coord_offset (y_pos, y, point_size),
expected_pixel);
}
}
void
-test_cogl_point_size (TestUtilsGTestFixture *fixture,
- void *data)
+test_point_size (void)
{
- TestUtilsSharedState *shared_state = data;
- CoglContext *ctx = shared_state->ctx;
- int fb_width = cogl_framebuffer_get_width (shared_state->fb);
- int fb_height = cogl_framebuffer_get_height (shared_state->fb);
+ int fb_width = cogl_framebuffer_get_width (fb);
+ int fb_height = cogl_framebuffer_get_height (fb);
int point_size;
int x_pos;
- cogl_framebuffer_orthographic (shared_state->fb,
+ cogl_framebuffer_orthographic (fb,
0, 0, /* x_1, y_1 */
fb_width, /* x_2 */
fb_height /* y_2 */,
-1, 100 /* near/far */);
- cogl_framebuffer_clear4f (shared_state->fb,
+ cogl_framebuffer_clear4f (fb,
COGL_BUFFER_BIT_COLOR,
1.0f, 0.0f, 0.0f, 1.0f);
@@ -81,7 +79,7 @@ test_cogl_point_size (TestUtilsGTestFixture *fixture,
cogl_pipeline_set_point_size (pipeline, point_size);
cogl_pipeline_set_color4ub (pipeline, 0, 255, 0, 255);
- cogl_framebuffer_draw_primitive (shared_state->fb,
+ cogl_framebuffer_draw_primitive (fb,
pipeline,
prim);
@@ -93,7 +91,7 @@ test_cogl_point_size (TestUtilsGTestFixture *fixture,
for (x_pos = 0, point_size = MAX_POINT_SIZE;
point_size >= 4;
x_pos += POINT_BOX_SIZE, point_size /= 2)
- verify_point_size (shared_state->fb,
+ verify_point_size (fb,
x_pos + POINT_BOX_SIZE / 2,
POINT_BOX_SIZE / 2,
point_size);
diff --git a/tests/conform/test-point-sprite.c b/tests/conform/test-point-sprite.c
index dc23e8ab..d8c450e5 100644
--- a/tests/conform/test-point-sprite.c
+++ b/tests/conform/test-point-sprite.c
@@ -19,26 +19,23 @@ tex_data[3 * 2 * 2] =
};
void
-test_cogl_point_sprite (TestUtilsGTestFixture *fixture,
- void *data)
+test_point_sprite (void)
{
- TestUtilsSharedState *shared_state = data;
- CoglContext *ctx = shared_state->ctx;
- int fb_width = cogl_framebuffer_get_width (shared_state->fb);
- int fb_height = cogl_framebuffer_get_height (shared_state->fb);
+ int fb_width = cogl_framebuffer_get_width (fb);
+ int fb_height = cogl_framebuffer_get_height (fb);
CoglPrimitive *prim;
GError *error = NULL;
CoglTexture2D *tex_2d;
CoglPipeline *pipeline, *solid_pipeline;
gboolean res;
- cogl_framebuffer_orthographic (shared_state->fb,
+ cogl_framebuffer_orthographic (fb,
0, 0, /* x_1, y_1 */
fb_width, /* x_2 */
fb_height /* y_2 */,
-1, 100 /* near/far */);
- cogl_framebuffer_clear4f (shared_state->fb,
+ cogl_framebuffer_clear4f (fb,
COGL_BUFFER_BIT_COLOR,
1.0f, 1.0f, 1.0f, 1.0f);
@@ -75,7 +72,7 @@ test_cogl_point_sprite (TestUtilsGTestFixture *fixture,
1, /* n_vertices */
&point);
- cogl_framebuffer_draw_primitive (shared_state->fb,
+ cogl_framebuffer_draw_primitive (fb,
pipeline,
prim);
@@ -88,38 +85,43 @@ test_cogl_point_sprite (TestUtilsGTestFixture *fixture,
/* enable */
FALSE,
&error);
- cogl_framebuffer_push_matrix (shared_state->fb);
- cogl_framebuffer_translate (shared_state->fb,
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb,
POINT_SIZE * 2, /* x */
0.0f, /* y */
0.0f /* z */);
- cogl_framebuffer_draw_primitive (shared_state->fb,
+ cogl_framebuffer_draw_primitive (fb,
solid_pipeline,
prim);
- cogl_framebuffer_pop_matrix (shared_state->fb);
+ cogl_framebuffer_pop_matrix (fb);
cogl_object_unref (prim);
cogl_object_unref (solid_pipeline);
cogl_object_unref (pipeline);
cogl_object_unref (tex_2d);
- test_utils_check_pixel (POINT_SIZE - POINT_SIZE / 4,
+ test_utils_check_pixel (fb,
+ POINT_SIZE - POINT_SIZE / 4,
POINT_SIZE - POINT_SIZE / 4,
0x0000ffff);
- test_utils_check_pixel (POINT_SIZE + POINT_SIZE / 4,
+ test_utils_check_pixel (fb,
+ POINT_SIZE + POINT_SIZE / 4,
POINT_SIZE - POINT_SIZE / 4,
0x00ff00ff);
- test_utils_check_pixel (POINT_SIZE - POINT_SIZE / 4,
+ test_utils_check_pixel (fb,
+ POINT_SIZE - POINT_SIZE / 4,
POINT_SIZE + POINT_SIZE / 4,
0x00ffffff);
- test_utils_check_pixel (POINT_SIZE + POINT_SIZE / 4,
+ test_utils_check_pixel (fb,
+ POINT_SIZE + POINT_SIZE / 4,
POINT_SIZE + POINT_SIZE / 4,
0xff0000ff);
/* When rendering without the point sprites all of the texture
coordinates should be 0,0 so it should get the top-left texel
which is blue */
- test_utils_check_region (POINT_SIZE * 3 - POINT_SIZE / 2 + 1,
+ test_utils_check_region (fb,
+ POINT_SIZE * 3 - POINT_SIZE / 2 + 1,
POINT_SIZE - POINT_SIZE / 2 + 1,
POINT_SIZE - 2, POINT_SIZE - 2,
0x0000ffff);
diff --git a/tests/conform/test-premult.c b/tests/conform/test-premult.c
index 8ea1168d..0326ce61 100644
--- a/tests/conform/test-premult.c
+++ b/tests/conform/test-premult.c
@@ -287,7 +287,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_premult (TestUtilsGTestFixture *fixture,
+test_premult (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-primitive.c b/tests/conform/test-primitive.c
index 1118d9d5..3dc58208 100644
--- a/tests/conform/test-primitive.c
+++ b/tests/conform/test-primitive.c
@@ -6,10 +6,8 @@
typedef struct _TestState
{
- CoglContext *ctx;
int fb_width;
int fb_height;
- CoglFramebuffer *fb;
} TestState;
#define PRIM_COLOR 0xff00ffff
@@ -178,7 +176,7 @@ test_paint (TestState *state)
COGL_PIXEL_FORMAT_ANY,
6, /* rowstride */
tex_data);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline,
(PRIM_COLOR >> 24) & 0xff,
(PRIM_COLOR >> 16) & 0xff,
@@ -192,14 +190,14 @@ test_paint (TestState *state)
CoglPrimitive *prim;
guint32 expected_color = PRIM_COLOR;
- prim = test_prim_funcs[i] (state->ctx, &expected_color);
+ prim = test_prim_funcs[i] (ctx, &expected_color);
- cogl_push_matrix ();
- cogl_translate (i * 10, 0, 0);
- cogl_framebuffer_draw_primitive (state->fb, pipeline, prim);
- cogl_pop_matrix ();
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb, i * 10, 0, 0);
+ cogl_framebuffer_draw_primitive (fb, pipeline, prim);
+ cogl_framebuffer_pop_matrix (fb);
- test_utils_check_pixel (i * 10 + 2, 2, expected_color);
+ test_utils_check_pixel (fb, i * 10 + 2, 2, expected_color);
cogl_object_unref (prim);
}
@@ -236,7 +234,7 @@ test_copy (TestState *state)
{
static const guint16 indices_data[2] = { 1, 2 };
CoglAttributeBuffer *buffer =
- cogl_attribute_buffer_new (state->ctx, 100, NULL);
+ cogl_attribute_buffer_new (ctx, 100, NULL);
CoglAttribute *attributes[N_ATTRIBS];
CoglAttribute *attributes_a[N_ATTRIBS], *attributes_b[N_ATTRIBS];
CoglAttribute **p;
@@ -261,7 +259,7 @@ test_copy (TestState *state)
attributes,
N_ATTRIBS);
- indices = cogl_indices_new (state->ctx,
+ indices = cogl_indices_new (ctx,
COGL_INDICES_TYPE_UNSIGNED_SHORT,
indices_data,
2 /* n_indices */);
@@ -314,20 +312,19 @@ test_copy (TestState *state)
}
void
-test_cogl_primitive (TestUtilsGTestFixture *fixture,
- void *data)
+test_primitive (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
- state.fb_width = cogl_framebuffer_get_width (shared_state->fb);
- state.fb_height = cogl_framebuffer_get_height (shared_state->fb);
- state.fb = shared_state->fb;
+ state.fb_width = cogl_framebuffer_get_width (fb);
+ state.fb_height = cogl_framebuffer_get_height (fb);
- cogl_ortho (0, state.fb_width, /* left, right */
- state.fb_height, 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ state.fb_width,
+ state.fb_height,
+ -1,
+ 100);
test_paint (&state);
test_copy (&state);
diff --git a/tests/conform/test-read-texture-formats.c b/tests/conform/test-read-texture-formats.c
index fe7c2629..7161d0f7 100644
--- a/tests/conform/test-read-texture-formats.c
+++ b/tests/conform/test-read-texture-formats.c
@@ -142,13 +142,11 @@ test_read_int (CoglTexture2D *tex_2d,
}
void
-test_cogl_read_texture_formats (TestUtilsGTestFixture *fixture,
- void *data)
+test_read_texture_formats (void)
{
- TestUtilsSharedState *shared_state = data;
CoglTexture2D *tex_2d;
- tex_2d = cogl_texture_2d_new_from_data (shared_state->ctx,
+ tex_2d = cogl_texture_2d_new_from_data (ctx,
1, 1, /* width / height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
diff --git a/tests/conform/test-readpixels.c b/tests/conform/test-readpixels.c
index eeb74994..c690a350 100644
--- a/tests/conform/test-readpixels.c
+++ b/tests/conform/test-readpixels.c
@@ -147,7 +147,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_readpixels (TestUtilsGTestFixture *fixture,
+test_readpixels (TestUtilsGTestFixture *fixture,
void *data)
{
unsigned int idle_source;
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index 041e2cc1..cf6d7788 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -6,8 +6,7 @@
typedef struct _TestState
{
- CoglContext *ctx;
- CoglFramebuffer *fb;
+ int padding;
} TestState;
typedef void (* SnippetTestFunc) (TestState *state);
@@ -16,7 +15,7 @@ static CoglPipeline *
create_texture_pipeline (TestState *state)
{
CoglPipeline *pipeline;
- CoglHandle tex;
+ CoglTexture *tex;
static const guint8 tex_data[] =
{
0xff, 0x00, 0x00, 0xff, /* red */ 0x00, 0xff, 0x00, 0xff, /* green */
@@ -30,7 +29,7 @@ create_texture_pipeline (TestState *state)
8, /* rowstride */
tex_data);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
@@ -38,7 +37,7 @@ create_texture_pipeline (TestState *state)
COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST);
- cogl_handle_unref (tex);
+ cogl_object_unref (tex);
return pipeline;
}
@@ -50,7 +49,7 @@ simple_fragment_snippet (TestState *state)
CoglSnippet *snippet;
/* Simple fragment snippet */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255);
@@ -60,13 +59,11 @@ simple_fragment_snippet (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (0, 0, 10, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (5, 5, 0xffff00ff);
+ test_utils_check_pixel (fb, 5, 5, 0xffff00ff);
}
static void
@@ -76,7 +73,7 @@ simple_vertex_snippet (TestState *state)
CoglSnippet *snippet;
/* Simple vertex snippet */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255);
@@ -86,13 +83,11 @@ simple_vertex_snippet (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (10, 0, 20, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 10, 0, 20, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (15, 5, 0xff00ffff);
+ test_utils_check_pixel (fb, 15, 5, 0xff00ffff);
}
static void
@@ -104,7 +99,7 @@ shared_uniform (TestState *state)
/* Snippets sharing a uniform across the vertex and fragment
hooks */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
location = cogl_pipeline_get_uniform_location (pipeline, "a_value");
cogl_pipeline_set_uniform_1f (pipeline, location, 0.25f);
@@ -122,13 +117,13 @@ shared_uniform (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (20, 0, 30, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb,
+ pipeline,
+ 20, 0, 30, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (25, 5, 0xff0080ff);
+ test_utils_check_pixel (fb, 25, 5, 0xff0080ff);
}
static void
@@ -140,7 +135,7 @@ lots_snippets (TestState *state)
int i;
/* Lots of snippets on one pipeline */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255);
@@ -168,13 +163,11 @@ lots_snippets (TestState *state)
g_free (declarations);
}
- cogl_push_source (pipeline);
- cogl_rectangle (30, 0, 40, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 30, 0, 40, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (35, 5, 0x19334cff);
+ test_utils_check_pixel (fb, 35, 5, 0x19334cff);
}
static void
@@ -185,7 +178,7 @@ shared_variable_pre_post (TestState *state)
/* Test that the pre string can declare variables used by the post
string */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 255, 255, 255);
@@ -196,13 +189,11 @@ shared_variable_pre_post (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (40, 0, 50, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 40, 0, 50, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (45, 5, 0xff0000ff);
+ test_utils_check_pixel (fb, 45, 5, 0xff0000ff);
}
static void
@@ -223,24 +214,20 @@ test_pipeline_caching (TestState *state)
" unrelated pipelines */",
"cogl_color_out = vec4 (0.0, 1.0, 0.0, 1.0);\n");
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (50, 0, 60, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 50, 0, 60, 10);
cogl_object_unref (pipeline);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (60, 0, 70, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 60, 0, 70, 10);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (55, 5, 0x00ff00ff);
- test_utils_check_pixel (65, 5, 0x00ff00ff);
+ test_utils_check_pixel (fb, 55, 5, 0x00ff00ff);
+ test_utils_check_pixel (fb, 65, 5, 0x00ff00ff);
}
static void
@@ -260,16 +247,14 @@ test_replace_string (TestState *state)
cogl_snippet_set_post (snippet,
"cogl_color_out += vec4 (0.5, 0.0, 0.0, 1.0);");
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (70, 0, 80, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 70, 0, 80, 10);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (75, 5, 0x808000ff);
+ test_utils_check_pixel (fb, 75, 5, 0x808000ff);
}
static void
@@ -288,15 +273,15 @@ test_texture_lookup_hook (TestState *state)
pipeline = create_texture_pipeline (state);
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
- cogl_push_source (pipeline);
- cogl_rectangle_with_texture_coords (80, 0, 90, 10,
- 0, 0, 0, 0);
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ 80, 0, 90, 10,
+ 0, 0, 0, 0);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (85, 5, 0x00ffffff);
+ test_utils_check_pixel (fb, 85, 5, 0x00ffffff);
}
static void
@@ -317,14 +302,12 @@ test_multiple_samples (TestState *state)
pipeline = create_texture_pipeline (state);
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (0, 0, 10, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (5, 5, 0xffff00ff);
+ test_utils_check_pixel (fb, 5, 5, 0xffff00ff);
}
static void
@@ -339,15 +322,15 @@ test_replace_lookup_hook (TestState *state)
pipeline = create_texture_pipeline (state);
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
- cogl_push_source (pipeline);
- cogl_rectangle_with_texture_coords (90, 0, 100, 10,
- 0, 0, 0, 0);
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ 90, 0, 100, 10,
+ 0, 0, 0, 0);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (95, 5, 0x0000ffff);
+ test_utils_check_pixel (fb, 95, 5, 0x0000ffff);
}
static void
@@ -372,13 +355,13 @@ test_replace_snippet (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle_with_texture_coords (100, 0, 110, 10,
- 0, 0, 0, 0);
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ 100, 0, 110, 10,
+ 0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (105, 5, 0xff0000ff);
+ test_utils_check_pixel (fb, 105, 5, 0xff0000ff);
}
static void
@@ -404,13 +387,13 @@ test_replace_fragment_layer (TestState *state)
"A = REPLACE(PREVIOUS)",
NULL);
- cogl_push_source (pipeline);
- cogl_rectangle_with_texture_coords (110, 0, 120, 10,
- 0, 0, 0, 0);
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ 110, 0, 120, 10,
+ 0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (115, 5, 0xff00ffff);
+ test_utils_check_pixel (fb, 115, 5, 0xff00ffff);
}
static void
@@ -420,7 +403,7 @@ test_modify_fragment_layer (TestState *state)
CoglSnippet *snippet;
/* Test modifying the fragment layer code */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_uniform_1f (pipeline,
cogl_pipeline_get_uniform_location (pipeline,
@@ -433,13 +416,13 @@ test_modify_fragment_layer (TestState *state)
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle_with_texture_coords (120, 0, 130, 10,
- 0, 0, 0, 0);
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ 120, 0, 130, 10,
+ 0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (125, 5, 0xff80ffff);
+ test_utils_check_pixel (fb, 125, 5, 0xff80ffff);
}
static void
@@ -462,13 +445,13 @@ test_modify_vertex_layer (TestState *state)
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle_with_texture_coords (130, 0, 140, 10,
- 0, 0, 0, 0);
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ 130, 0, 140, 10,
+ 0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (135, 5, 0xffff00ff);
+ test_utils_check_pixel (fb, 135, 5, 0xffff00ff);
}
static void
@@ -492,13 +475,13 @@ test_replace_vertex_layer (TestState *state)
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle_with_texture_coords (140, 0, 150, 10,
- 0, 0, 0, 0);
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ 140, 0, 150, 10,
+ 0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (145, 5, 0x00ff00ff);
+ test_utils_check_pixel (fb, 145, 5, 0x00ff00ff);
}
static void
@@ -514,7 +497,7 @@ test_vertex_transform_hook (TestState *state)
cogl_matrix_init_identity (&identity_matrix);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 255, 255);
@@ -527,7 +510,7 @@ test_vertex_transform_hook (TestState *state)
cogl_object_unref (snippet);
/* Copy the current projection matrix to a uniform */
- cogl_get_projection_matrix (&matrix);
+ cogl_framebuffer_get_projection_matrix (fb, &matrix);
location = cogl_pipeline_get_uniform_location (pipeline, "pmat");
cogl_pipeline_set_uniform_matrix (pipeline,
location,
@@ -538,17 +521,15 @@ test_vertex_transform_hook (TestState *state)
/* Replace the real projection matrix with the identity. This should
mess up the drawing unless the snippet replacement is working */
- cogl_set_projection_matrix (&identity_matrix);
+ cogl_framebuffer_set_projection_matrix (fb, &identity_matrix);
- cogl_push_source (pipeline);
- cogl_rectangle (150, 0, 160, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 150, 0, 160, 10);
cogl_object_unref (pipeline);
/* Restore the projection matrix */
- cogl_set_projection_matrix (&matrix);
+ cogl_framebuffer_set_projection_matrix (fb, &matrix);
- test_utils_check_pixel (155, 5, 0xff00ffff);
+ test_utils_check_pixel (fb, 155, 5, 0xff00ffff);
}
static void
@@ -564,7 +545,7 @@ test_snippet_order (TestState *state)
sections in the same order as they were added. Therefore the r
component should be taken from the the second snippet and the g
component from the first */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255);
@@ -583,12 +564,10 @@ test_snippet_order (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (160, 0, 170, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 160, 0, 170, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (165, 5, 0x80ff00ff);
+ test_utils_check_pixel (fb, 165, 5, 0x80ff00ff);
}
static void
@@ -609,26 +588,24 @@ test_naming_texture_units (TestState *state)
"texture2D (cogl_sampler100, vec2 (0.0, 0.0)) + "
"texture2D (cogl_sampler200, vec2 (0.0, 0.0));");
- tex1 = test_utils_create_color_texture (state->ctx, 0xff0000ff);
- tex2 = test_utils_create_color_texture (state->ctx, 0x00ff00ff);
+ tex1 = test_utils_create_color_texture (ctx, 0xff0000ff);
+ tex2 = test_utils_create_color_texture (ctx, 0x00ff00ff);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 100, tex1);
cogl_pipeline_set_layer_texture (pipeline, 200, tex2);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_push_source (pipeline);
- cogl_rectangle (0, 0, 10, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
cogl_object_unref (tex1);
cogl_object_unref (tex2);
- test_utils_check_pixel (5, 5, 0xffff00ff);
+ test_utils_check_pixel (fb, 5, 5, 0xffff00ff);
}
static void
@@ -703,7 +680,7 @@ run_tests (TestState *state)
for (i = 0; i < G_N_ELEMENTS (tests); i++)
{
- cogl_framebuffer_clear4f (state->fb,
+ cogl_framebuffer_clear4f (fb,
COGL_BUFFER_BIT_COLOR,
0, 0, 0, 1);
@@ -712,25 +689,19 @@ run_tests (TestState *state)
}
void
-test_cogl_snippets (TestUtilsGTestFixture *fixture,
- void *user_data)
+test_snippets (void)
{
- TestUtilsSharedState *shared_state = user_data;
-
/* If shaders aren't supported then we can't run the test */
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
{
TestState state;
- state.ctx = shared_state->ctx;
- state.fb = shared_state->fb;
-
- cogl_ortho (/* left, right */
- 0, cogl_framebuffer_get_width (shared_state->fb),
- /* bottom, top */
- cogl_framebuffer_get_height (shared_state->fb), 0,
- /* z near, far */
- -1, 100);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
run_tests (&state);
diff --git a/tests/conform/test-sparse-pipeline.c b/tests/conform/test-sparse-pipeline.c
index b6848b4a..a88f50b5 100644
--- a/tests/conform/test-sparse-pipeline.c
+++ b/tests/conform/test-sparse-pipeline.c
@@ -5,10 +5,8 @@
typedef struct _TestState
{
- CoglContext *ctx;
int fb_width;
int fb_height;
- CoglFramebuffer *fb;
} TestState;
static void
@@ -17,17 +15,17 @@ test_sparse_layer_combine (TestState *state)
CoglPipeline *pipeline;
CoglTexture *tex1, *tex2;
- cogl_framebuffer_clear4f (state->fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
/* This tests that the TEXTURE_* numbers used in the layer combine
string refer to the layer number rather than the unit numbers by
creating a pipeline with very large layer numbers. This should
end up being mapped to much smaller unit numbers */
- tex1 = test_utils_create_color_texture (state->ctx, 0xff0000ff);
- tex2 = test_utils_create_color_texture (state->ctx, 0x00ff00ff);
+ tex1 = test_utils_create_color_texture (ctx, 0xff0000ff);
+ tex2 = test_utils_create_color_texture (ctx, 0x00ff00ff);
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 50, tex1);
cogl_pipeline_set_layer_texture (pipeline, 100, tex2);
@@ -35,11 +33,9 @@ test_sparse_layer_combine (TestState *state)
"RGBA = ADD(TEXTURE_50, TEXTURE_100)",
NULL);
- cogl_push_source (pipeline);
- cogl_rectangle (-1, -1, 1, 1);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, -1, -1, 1, 1);
- test_utils_check_pixel (2, 2, 0xffff00ff);
+ test_utils_check_pixel (fb, 2, 2, 0xffff00ff);
cogl_object_unref (pipeline);
cogl_object_unref (tex1);
@@ -47,16 +43,12 @@ test_sparse_layer_combine (TestState *state)
}
void
-test_cogl_sparse_pipeline (TestUtilsGTestFixture *fixture,
- void *data)
+test_sparse_pipeline (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
- state.fb_width = cogl_framebuffer_get_width (shared_state->fb);
- state.fb_height = cogl_framebuffer_get_height (shared_state->fb);
- state.fb = shared_state->fb;
+ state.fb_width = cogl_framebuffer_get_width (fb);
+ state.fb_height = cogl_framebuffer_get_height (fb);
test_sparse_layer_combine (&state);
diff --git a/tests/conform/test-sub-texture.c b/tests/conform/test-sub-texture.c
index 5bb23e2f..261f4d72 100644
--- a/tests/conform/test-sub-texture.c
+++ b/tests/conform/test-sub-texture.c
@@ -22,7 +22,6 @@ corner_colors[SOURCE_DIVISIONS_X * SOURCE_DIVISIONS_Y] =
typedef struct _TestState
{
- CoglContext *ctx;
CoglTexture2D *tex;
} TestState;
@@ -56,7 +55,7 @@ create_source (TestState *state)
}
}
- tex = cogl_texture_2d_new_from_data (state->ctx,
+ tex = cogl_texture_2d_new_from_data (ctx,
SOURCE_SIZE, SOURCE_SIZE,
COGL_PIXEL_FORMAT_RGBA_8888,
COGL_PIXEL_FORMAT_ANY,
@@ -88,7 +87,7 @@ create_test_texture (TestState *state)
*(p++) = 255;
}
- tex = cogl_texture_2d_new_from_data (state->ctx,
+ tex = cogl_texture_2d_new_from_data (ctx,
256, 256,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_ANY,
@@ -107,9 +106,10 @@ paint (TestState *state)
{
CoglTexture2D *full_texture;
CoglSubTexture *sub_texture, *sub_sub_texture;
+ CoglPipeline *pipeline = cogl_pipeline_new (ctx);
/* Create a sub texture of the bottom right quarter of the texture */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (state->tex),
DIVISION_WIDTH,
DIVISION_HEIGHT,
@@ -117,40 +117,47 @@ paint (TestState *state)
DIVISION_HEIGHT);
/* Paint it */
- cogl_set_source_texture (COGL_TEXTURE (sub_texture));
- cogl_rectangle (0.0f, 0.0f, DIVISION_WIDTH, DIVISION_HEIGHT);
-
+ cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_object_unref (sub_texture);
+ cogl_framebuffer_draw_rectangle (fb, pipeline,
+ 0.0f, 0.0f, DIVISION_WIDTH, DIVISION_HEIGHT);
+
/* Repeat a sub texture of the top half of the full texture. This is
documented to be undefined so it doesn't technically have to work
but it will with the current implementation */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (state->tex),
0, 0,
SOURCE_SIZE,
DIVISION_HEIGHT);
- cogl_set_source_texture (COGL_TEXTURE (sub_texture));
- cogl_rectangle_with_texture_coords (0.0f, SOURCE_SIZE,
- SOURCE_SIZE * 2.0f, SOURCE_SIZE * 1.5f,
- 0.0f, 0.0f,
- 2.0f, 1.0f);
+ cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_object_unref (sub_texture);
+ cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
+ 0.0f,
+ SOURCE_SIZE,
+ SOURCE_SIZE * 2.0f,
+ SOURCE_SIZE * 1.5f,
+ 0.0f, 0.0f,
+ 2.0f, 1.0f);
/* Create a sub texture of a sub texture */
full_texture = create_test_texture (state);
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (full_texture),
20, 10, 30, 20);
- sub_sub_texture = cogl_sub_texture_new (state->ctx,
+ cogl_object_unref (full_texture);
+ sub_sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (sub_texture),
20, 10, 10, 10);
- cogl_set_source_texture (COGL_TEXTURE (sub_sub_texture));
- cogl_rectangle (0.0f, SOURCE_SIZE * 2.0f,
- 10.0f, SOURCE_SIZE * 2.0f + 10.0f);
- cogl_object_unref (sub_sub_texture);
cogl_object_unref (sub_texture);
- cogl_object_unref (full_texture);
+ cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_sub_texture));
+ cogl_object_unref (sub_sub_texture);
+ cogl_framebuffer_draw_rectangle (fb, pipeline,
+ 0.0f, SOURCE_SIZE * 2.0f,
+ 10.0f, SOURCE_SIZE * 2.0f + 10.0f);
+
+ cogl_object_unref (pipeline);
}
static void
@@ -158,7 +165,8 @@ validate_part (int xpos, int ypos,
int width, int height,
guint32 color)
{
- test_utils_check_region (xpos + TEST_INSET,
+ test_utils_check_region (fb,
+ xpos + TEST_INSET,
ypos + TEST_INSET,
width - TEST_INSET - 2,
height - TEST_INSET - 2,
@@ -212,10 +220,11 @@ validate_result (TestState *state)
/* Sub sub texture */
p = texture_data = g_malloc (10 * 10 * 4);
- cogl_read_pixels (0, SOURCE_SIZE * 2, 10, 10,
- COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888,
- p);
+ cogl_flush ();
+ cogl_framebuffer_read_pixels (fb,
+ 0, SOURCE_SIZE * 2, 10, 10,
+ COGL_PIXEL_FORMAT_RGBA_8888,
+ p);
for (y = 0; y < 10; y++)
for (x = 0; x < 10; x++)
{
@@ -226,7 +235,7 @@ validate_result (TestState *state)
g_free (texture_data);
/* Try reading back the texture data */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (state->tex),
SOURCE_SIZE / 4,
SOURCE_SIZE / 4,
@@ -257,7 +266,7 @@ validate_result (TestState *state)
/* Create a 256x256 test texture */
test_tex = create_test_texture (state);
/* Create a sub texture the views the center half of the texture */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (test_tex),
64, 64, 128, 128);
/* Update the center half of the sub texture */
@@ -299,18 +308,18 @@ validate_result (TestState *state)
}
void
-test_cogl_sub_texture (TestUtilsGTestFixture *fixture,
- void *data)
+test_sub_texture (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
state.tex = create_source (&state);
- cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
- cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
paint (&state);
validate_result (&state);
diff --git a/tests/conform/test-texture-3d.c b/tests/conform/test-texture-3d.c
index 5eab3b00..777d0230 100644
--- a/tests/conform/test-texture-3d.c
+++ b/tests/conform/test-texture-3d.c
@@ -13,10 +13,8 @@
typedef struct _TestState
{
- CoglContext *ctx;
int fb_width;
int fb_height;
- CoglFramebuffer *fb;
} TestState;
static CoglTexture3D *
@@ -75,8 +73,8 @@ create_texture_3d (CoglContext *context)
static void
draw_frame (TestState *state)
{
- CoglTexture *tex = COGL_TEXTURE (create_texture_3d (state->ctx));
- CoglPipeline *pipeline = cogl_pipeline_new (state->ctx);
+ CoglTexture *tex = COGL_TEXTURE (create_texture_3d (ctx));
+ CoglPipeline *pipeline = cogl_pipeline_new (ctx);
typedef struct { float x, y, s, t, r; } Vert;
CoglPrimitive *primitive;
CoglAttributeBuffer *attribute_buffer;
@@ -89,15 +87,13 @@ draw_frame (TestState *state)
cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST);
- cogl_push_source (pipeline);
/* Render the texture repeated horizontally twice using a regular
cogl rectangle. This should end up with the r texture coordinates
as zero */
- cogl_rectangle_with_texture_coords (0.0f, 0.0f, TEX_WIDTH * 2, TEX_HEIGHT,
- 0.0f, 0.0f, 2.0f, 1.0f);
-
- cogl_pop_source ();
+ cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
+ 0.0f, 0.0f, TEX_WIDTH * 2, TEX_HEIGHT,
+ 0.0f, 0.0f, 2.0f, 1.0f);
/* Render all of the images in the texture using coordinates from a
CoglPrimitive */
@@ -135,7 +131,7 @@ draw_frame (TestState *state)
v++;
}
- attribute_buffer = cogl_attribute_buffer_new (state->ctx,
+ attribute_buffer = cogl_attribute_buffer_new (ctx,
4 * TEX_DEPTH * sizeof (Vert),
verts);
attributes[0] = cogl_attribute_new (attribute_buffer,
@@ -156,11 +152,11 @@ draw_frame (TestState *state)
2 /* n_attributes */);
cogl_primitive_set_indices (primitive,
- cogl_get_rectangle_indices (state->ctx,
+ cogl_get_rectangle_indices (ctx,
TEX_DEPTH),
6 * TEX_DEPTH);
- cogl_framebuffer_draw_primitive (state->fb, pipeline, primitive);
+ cogl_framebuffer_draw_primitive (fb, pipeline, primitive);
g_free (verts);
@@ -178,7 +174,8 @@ validate_block (int block_x, int block_y, int z)
for (y = 0; y < TEX_HEIGHT; y++)
for (x = 0; x < TEX_WIDTH; x++)
- test_utils_check_pixel_rgb (block_x * TEX_WIDTH + x,
+ test_utils_check_pixel_rgb (fb,
+ block_x * TEX_WIDTH + x,
block_y * TEX_HEIGHT + y,
255 - x * 8,
y * 8,
@@ -204,20 +201,20 @@ test_multi_texture (TestState *state)
CoglTexture2D *tex_2d;
guint8 tex_data[4];
- cogl_framebuffer_clear4f (state->fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
/* Tests a pipeline that is using multi-texturing to combine a 3D
texture with a 2D texture. The texture from another layer is
sampled with TEXTURE_? just to pick up a specific bug that was
happening with the ARBfp fragend */
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
tex_data[0] = 0xff;
tex_data[1] = 0x00;
tex_data[2] = 0x00;
tex_data[3] = 0xff;
- tex_2d = cogl_texture_2d_new_from_data (state->ctx,
+ tex_2d = cogl_texture_2d_new_from_data (ctx,
1, 1, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
@@ -230,7 +227,7 @@ test_multi_texture (TestState *state)
tex_data[1] = 0xff;
tex_data[2] = 0x00;
tex_data[3] = 0xff;
- tex_3d = cogl_texture_3d_new_from_data (state->ctx,
+ tex_3d = cogl_texture_3d_new_from_data (ctx,
1, 1, 1, /* width/height/depth */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
@@ -247,11 +244,9 @@ test_multi_texture (TestState *state)
"RGBA = ADD(TEXTURE_0, TEXTURE_1)",
NULL);
- cogl_push_source (pipeline);
- cogl_rectangle (0, 0, 10, 10);
- cogl_pop_source ();
+ cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
- test_utils_check_pixel (5, 5, 0xffff00ff);
+ test_utils_check_pixel (fb, 5, 5, 0xffff00ff);
cogl_object_unref (tex_2d);
cogl_object_unref (tex_3d);
@@ -259,23 +254,18 @@ test_multi_texture (TestState *state)
}
void
-test_cogl_texture_3d (TestUtilsGTestFixture *fixture,
- void *data)
+test_texture_3d (void)
{
- TestUtilsSharedState *shared_state = data;
-
/* Check whether GL supports the rectangle extension. If not we'll
just assume the test passes */
- if (cogl_has_feature (shared_state->ctx, COGL_FEATURE_ID_TEXTURE_3D))
+ if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
{
TestState state;
- state.ctx = shared_state->ctx;
- state.fb_width = cogl_framebuffer_get_width (shared_state->fb);
- state.fb_height = cogl_framebuffer_get_height (shared_state->fb);
- state.fb = shared_state->fb;
+ state.fb_width = cogl_framebuffer_get_width (fb);
+ state.fb_height = cogl_framebuffer_get_height (fb);
- cogl_framebuffer_orthographic (shared_state->fb,
+ cogl_framebuffer_orthographic (fb,
0, 0, /* x_1, y_1 */
state.fb_width, /* x_2 */
state.fb_height /* y_2 */,
diff --git a/tests/conform/test-texture-get-set-data.c b/tests/conform/test-texture-get-set-data.c
index d92f2858..94e53a99 100644
--- a/tests/conform/test-texture-get-set-data.c
+++ b/tests/conform/test-texture-get-set-data.c
@@ -141,7 +141,7 @@ paint_cb (void)
}
void
-test_cogl_texture_get_set_data (TestUtilsGTestFixture *fixture,
+test_texture_get_set_data (TestUtilsGTestFixture *fixture,
void *data)
{
ClutterActor *stage;
diff --git a/tests/conform/test-texture-mipmaps.c b/tests/conform/test-texture-mipmaps.c
index b09dfed4..eda31ba0 100644
--- a/tests/conform/test-texture-mipmaps.c
+++ b/tests/conform/test-texture-mipmaps.c
@@ -103,7 +103,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_texture_mipmaps (TestUtilsGTestFixture *fixture,
+test_texture_mipmaps (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-texture-pixmap-x11.c b/tests/conform/test-texture-pixmap-x11.c
index ae11e5af..7f6d81c4 100644
--- a/tests/conform/test-texture-pixmap-x11.c
+++ b/tests/conform/test-texture-pixmap-x11.c
@@ -198,7 +198,7 @@ queue_redraw (gpointer stage)
#endif /* COGL_HAS_XLIB */
void
-test_cogl_texture_pixmap_x11 (TestUtilsGTestFixture *fixture,
+test_texture_pixmap_x11 (TestUtilsGTestFixture *fixture,
void *data)
{
#ifdef COGL_HAS_XLIB
diff --git a/tests/conform/test-texture-rectangle.c b/tests/conform/test-texture-rectangle.c
index 53b73100..d7cc354e 100644
--- a/tests/conform/test-texture-rectangle.c
+++ b/tests/conform/test-texture-rectangle.c
@@ -237,7 +237,7 @@ check_rectangle_extension (void)
}
void
-test_cogl_texture_rectangle (TestUtilsGTestFixture *fixture,
+test_texture_rectangle (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c
index 059c143d..22591736 100644
--- a/tests/conform/test-utils.c
+++ b/tests/conform/test-utils.c
@@ -9,9 +9,11 @@
static gboolean cogl_test_is_verbose;
+CoglContext *ctx;
+CoglFramebuffer *fb;
+
void
-test_utils_init (TestUtilsSharedState *state,
- TestFlags flags)
+test_utils_init (TestFlags flags)
{
static int counter = 0;
GError *error = NULL;
@@ -43,11 +45,11 @@ test_utils_init (TestUtilsSharedState *state,
g_setenv ("COGL_X11_SYNC", "1", 0);
- state->ctx = cogl_context_new (NULL, &error);
- if (!state->ctx)
+ ctx = cogl_context_new (NULL, &error);
+ if (!ctx)
g_critical ("Failed to create a CoglContext: %s", error->message);
- display = cogl_context_get_display (state->ctx);
+ display = cogl_context_get_display (ctx);
renderer = cogl_display_get_renderer (display);
if (flags & TEST_REQUIREMENT_GL &&
@@ -57,19 +59,19 @@ test_utils_init (TestUtilsSharedState *state,
}
if (flags & TEST_REQUIREMENT_NPOT &&
- !cogl_has_feature (state->ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
+ !cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
{
missing_requirement = TRUE;
}
if (flags & TEST_REQUIREMENT_TEXTURE_3D &&
- !cogl_has_feature (state->ctx, COGL_FEATURE_ID_TEXTURE_3D))
+ !cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
{
missing_requirement = TRUE;
}
if (flags & TEST_REQUIREMENT_POINT_SPRITE &&
- !cogl_has_feature (state->ctx, COGL_FEATURE_ID_POINT_SPRITE))
+ !cogl_has_feature (ctx, COGL_FEATURE_ID_POINT_SPRITE))
{
missing_requirement = TRUE;
}
@@ -81,13 +83,13 @@ test_utils_init (TestUtilsSharedState *state,
if (getenv ("COGL_TEST_ONSCREEN"))
{
- onscreen = cogl_onscreen_new (state->ctx, 640, 480);
- state->fb = COGL_FRAMEBUFFER (onscreen);
+ onscreen = cogl_onscreen_new (ctx, 640, 480);
+ fb = COGL_FRAMEBUFFER (onscreen);
}
else
{
CoglHandle offscreen;
- CoglHandle tex = cogl_texture_2d_new_with_size (state->ctx,
+ CoglHandle tex = cogl_texture_2d_new_with_size (ctx,
FB_WIDTH, FB_HEIGHT,
COGL_PIXEL_FORMAT_ANY,
&error);
@@ -95,37 +97,33 @@ test_utils_init (TestUtilsSharedState *state,
g_critical ("Failed to allocate texture: %s", error->message);
offscreen = cogl_offscreen_new_to_texture (tex);
- state->fb = COGL_FRAMEBUFFER (offscreen);
+ fb = COGL_FRAMEBUFFER (offscreen);
}
- if (!cogl_framebuffer_allocate (state->fb, &error))
+ if (!cogl_framebuffer_allocate (fb, &error))
g_critical ("Failed to allocate framebuffer: %s", error->message);
if (onscreen)
cogl_onscreen_show (onscreen);
- cogl_framebuffer_clear4f (state->fb,
+ cogl_framebuffer_clear4f (fb,
COGL_BUFFER_BIT_COLOR |
COGL_BUFFER_BIT_DEPTH |
COGL_BUFFER_BIT_STENCIL,
0, 0, 0, 1);
- cogl_push_framebuffer (state->fb);
-
if (missing_requirement)
g_print ("WARNING: Missing required feature[s] for this test\n");
}
void
-test_utils_fini (TestUtilsSharedState *state)
+test_utils_fini (void)
{
- cogl_pop_framebuffer ();
-
- if (state->fb)
- cogl_object_unref (state->fb);
+ if (fb)
+ cogl_object_unref (fb);
- if (state->ctx)
- cogl_object_unref (state->ctx);
+ if (ctx)
+ cogl_object_unref (ctx);
}
static gboolean
@@ -156,38 +154,42 @@ test_utils_compare_pixel (const guint8 *screen_pixel, guint32 expected_pixel)
}
void
-test_utils_check_pixel (int x, int y, guint32 expected_pixel)
+test_utils_check_pixel (CoglFramebuffer *fb,
+ int x, int y, guint32 expected_pixel)
{
guint8 pixel[4];
- cogl_read_pixels (x, y, 1, 1, COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888_PRE,
- pixel);
+ cogl_framebuffer_read_pixels (fb,
+ x, y, 1, 1,
+ COGL_PIXEL_FORMAT_RGBA_8888_PRE,
+ pixel);
test_utils_compare_pixel (pixel, expected_pixel);
}
void
-test_utils_check_pixel_rgb (int x, int y, int r, int g, int b)
+test_utils_check_pixel_rgb (CoglFramebuffer *fb,
+ int x, int y, int r, int g, int b)
{
- test_utils_check_pixel (x, y, (r << 24) | (g << 16) | (b << 8));
+ test_utils_check_pixel (fb, x, y, (r << 24) | (g << 16) | (b << 8));
}
void
-test_utils_check_region (int x, int y,
+test_utils_check_region (CoglFramebuffer *fb,
+ int x, int y,
int width, int height,
guint32 expected_rgba)
{
guint8 *pixels, *p;
pixels = p = g_malloc (width * height * 4);
- cogl_read_pixels (x,
- y,
- width,
- height,
- COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888,
- p);
+ cogl_framebuffer_read_pixels (fb,
+ x,
+ y,
+ width,
+ height,
+ COGL_PIXEL_FORMAT_RGBA_8888,
+ p);
/* Check whether the center of each division is the right color */
for (y = 0; y < height; y++)
diff --git a/tests/conform/test-utils.h b/tests/conform/test-utils.h
index 8dfd0841..727aea8c 100644
--- a/tests/conform/test-utils.h
+++ b/tests/conform/test-utils.h
@@ -16,77 +16,68 @@ typedef enum _TestFlags
TEST_REQUIREMENT_POINT_SPRITE = 1<<4
} TestFlags;
-/* For compatability since we used to use the glib gtester
- * infrastructure and all our unit tests have an entry
- * point with a first argument of this type... */
-typedef struct _TestUtilsGTestFixture TestUtilsGTestFixture;
-
-/* Stuff you put in here is setup once in main() and gets passed around to
- * all test functions and fixture setup/teardown functions in the data
- * argument */
-typedef struct _TestUtilsSharedState
-{
- int *argc_addr;
- char ***argv_addr;
-
- CoglContext *ctx;
- CoglFramebuffer *fb;
-} TestUtilsSharedState;
+extern CoglContext *ctx;
+extern CoglFramebuffer *fb;
void
-test_utils_init (TestUtilsSharedState *state,
- TestFlags flags);
+test_utils_init (TestFlags flags);
void
-test_utils_fini (TestUtilsSharedState *state);
+test_utils_fini (void);
/*
* test_utils_check_pixel:
+ * @framebuffer: The #CoglFramebuffer to read from
* @x: x co-ordinate of the pixel to test
* @y: y co-ordinate of the pixel to test
* @pixel: An integer of the form 0xRRGGBBAA representing the expected
* pixel value
*
- * This performs reads a pixel on the current cogl framebuffer and
+ * This performs reads a pixel on the given cogl @framebuffer and
* asserts that it matches the given color. The alpha channel of the
* color is ignored. The pixels are converted to a string and compared
* with g_assert_cmpstr so that if the comparison fails then the
* assert will display a meaningful message
*/
void
-test_utils_check_pixel (int x, int y, guint32 expected_pixel);
+test_utils_check_pixel (CoglFramebuffer *framebuffer,
+ int x, int y, guint32 expected_pixel);
/*
* test_utils_check_pixel:
+ * @framebuffer: The #CoglFramebuffer to read from
* @x: x co-ordinate of the pixel to test
* @y: y co-ordinate of the pixel to test
* @pixel: An integer of the form 0xrrggbb representing the expected pixel value
*
- * This performs reads a pixel on the current cogl framebuffer and
+ * This performs reads a pixel on the given cogl @framebuffer and
* asserts that it matches the given color. The alpha channel of the
* color is ignored. The pixels are converted to a string and compared
* with g_assert_cmpstr so that if the comparison fails then the
* assert will display a meaningful message
*/
void
-test_utils_check_pixel_rgb (int x, int y, int r, int g, int b);
+test_utils_check_pixel_rgb (CoglFramebuffer *framebuffer,
+ int x, int y, int r, int g, int b);
/*
* test_utils_check_region:
+ * @framebuffer: The #CoglFramebuffer to read from
* @x: x co-ordinate of the region to test
* @y: y co-ordinate of the region to test
* @width: width of the region to test
* @height: height of the region to test
* @pixel: An integer of the form 0xrrggbb representing the expected region color
*
- * Performs a read pixel on the specified region of the current cogl
- * framebuffer and asserts that it matches the given color. The alpha
+ * Performs a read pixel on the specified region of the given cogl
+ * @framebuffer and asserts that it matches the given color. The alpha
* channel of the color is ignored. The pixels are converted to a
* string and compared with g_assert_cmpstr so that if the comparison
* fails then the assert will display a meaningful message
*/
void
-test_utils_check_region (int x, int y,
+test_utils_check_region (CoglFramebuffer *framebuffer,
+ int x, int y,
int width, int height,
guint32 expected_rgba);
diff --git a/tests/conform/test-vertex-buffer-contiguous.c b/tests/conform/test-vertex-buffer-contiguous.c
index e0da81e7..12f44033 100644
--- a/tests/conform/test-vertex-buffer-contiguous.c
+++ b/tests/conform/test-vertex-buffer-contiguous.c
@@ -152,7 +152,7 @@ queue_redraw (gpointer stage)
void
-test_cogl_vertex_buffer_contiguous (TestUtilsGTestFixture *fixture,
+test_vertex_buffer_contiguous (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-vertex-buffer-interleved.c b/tests/conform/test-vertex-buffer-interleved.c
index d2cbb3a7..0cefb1c7 100644
--- a/tests/conform/test-vertex-buffer-interleved.c
+++ b/tests/conform/test-vertex-buffer-interleved.c
@@ -83,7 +83,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_vertex_buffer_interleved (TestUtilsGTestFixture *fixture,
+test_vertex_buffer_interleved (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-vertex-buffer-mutability.c b/tests/conform/test-vertex-buffer-mutability.c
index 1693a223..d742eb64 100644
--- a/tests/conform/test-vertex-buffer-mutability.c
+++ b/tests/conform/test-vertex-buffer-mutability.c
@@ -126,7 +126,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_vertex_buffer_mutability (TestUtilsGTestFixture *fixture,
+test_vertex_buffer_mutability (TestUtilsGTestFixture *fixture,
void *data)
{
TestState state;
diff --git a/tests/conform/test-viewport.c b/tests/conform/test-viewport.c
index a2d0f7b8..ef22d69c 100644
--- a/tests/conform/test-viewport.c
+++ b/tests/conform/test-viewport.c
@@ -385,7 +385,7 @@ queue_redraw (gpointer stage)
}
void
-test_cogl_viewport (TestUtilsGTestFixture *fixture,
+test_viewport (TestUtilsGTestFixture *fixture,
void *data)
{
unsigned int idle_source;
diff --git a/tests/conform/test-wrap-modes.c b/tests/conform/test-wrap-modes.c
index 655dc173..cb75705b 100644
--- a/tests/conform/test-wrap-modes.c
+++ b/tests/conform/test-wrap-modes.c
@@ -7,7 +7,6 @@
typedef struct _TestState
{
- CoglContext *ctx;
int width;
int height;
CoglTexture *texture;
@@ -46,7 +45,7 @@ create_pipeline (TestState *state,
{
CoglPipeline *pipeline;
- pipeline = cogl_pipeline_new (state->ctx);
+ pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, state->texture);
cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST,
@@ -58,7 +57,7 @@ create_pipeline (TestState *state,
}
static CoglPipelineWrapMode
-test_wrap_modes[] =
+wrap_modes[] =
{
COGL_PIPELINE_WRAP_MODE_REPEAT,
COGL_PIPELINE_WRAP_MODE_REPEAT,
@@ -84,22 +83,25 @@ draw_tests (TestState *state)
{
int i;
- for (i = 0; i < G_N_ELEMENTS (test_wrap_modes); i += 2)
+ for (i = 0; i < G_N_ELEMENTS (wrap_modes); i += 2)
{
CoglPipelineWrapMode wrap_mode_s, wrap_mode_t;
CoglPipeline *pipeline;
/* Create a separate pipeline for each pair of wrap modes so
that we can verify whether the batch splitting works */
- wrap_mode_s = test_wrap_modes[i];
- wrap_mode_t = test_wrap_modes[i + 1];
+ wrap_mode_s = wrap_modes[i];
+ wrap_mode_t = wrap_modes[i + 1];
pipeline = create_pipeline (state, wrap_mode_s, wrap_mode_t);
- cogl_set_source (pipeline);
- cogl_handle_unref (pipeline);
/* Render the pipeline at four times the size of the texture */
- cogl_rectangle_with_texture_coords (i * TEX_SIZE, 0,
- (i + 2) * TEX_SIZE, TEX_SIZE * 2,
- 0, 0, 2, 2);
+ cogl_framebuffer_draw_textured_rectangle (fb,
+ pipeline,
+ i * TEX_SIZE,
+ 0,
+ (i + 2) * TEX_SIZE,
+ TEX_SIZE * 2,
+ 0, 0, 2, 2);
+ cogl_object_unref (pipeline);
}
}
@@ -116,16 +118,16 @@ draw_tests_polygon (TestState *state)
{
int i;
- for (i = 0; i < G_N_ELEMENTS (test_wrap_modes); i += 2)
+ for (i = 0; i < G_N_ELEMENTS (wrap_modes); i += 2)
{
CoglPipelineWrapMode wrap_mode_s, wrap_mode_t;
CoglPipeline *pipeline;
- wrap_mode_s = test_wrap_modes[i];
- wrap_mode_t = test_wrap_modes[i + 1];
+ wrap_mode_s = wrap_modes[i];
+ wrap_mode_t = wrap_modes[i + 1];
pipeline = create_pipeline (state, wrap_mode_s, wrap_mode_t);
cogl_set_source (pipeline);
- cogl_handle_unref (pipeline);
+ cogl_object_unref (pipeline);
cogl_push_matrix ();
cogl_translate (TEX_SIZE * i, 0.0f, 0.0f);
/* Render the pipeline at four times the size of the texture */
@@ -151,16 +153,16 @@ draw_tests_vbo (TestState *state)
&vertices[0].tx);
cogl_vertex_buffer_submit (vbo);
- for (i = 0; i < G_N_ELEMENTS (test_wrap_modes); i += 2)
+ for (i = 0; i < G_N_ELEMENTS (wrap_modes); i += 2)
{
CoglPipelineWrapMode wrap_mode_s, wrap_mode_t;
CoglPipeline *pipeline;
- wrap_mode_s = test_wrap_modes[i];
- wrap_mode_t = test_wrap_modes[i + 1];
+ wrap_mode_s = wrap_modes[i];
+ wrap_mode_t = wrap_modes[i + 1];
pipeline = create_pipeline (state, wrap_mode_s, wrap_mode_t);
cogl_set_source (pipeline);
- cogl_handle_unref (pipeline);
+ cogl_object_unref (pipeline);
cogl_push_matrix ();
cogl_translate (TEX_SIZE * i, 0.0f, 0.0f);
/* Render the pipeline at four times the size of the texture */
@@ -177,18 +179,17 @@ validate_set (TestState *state, int offset)
guint8 data[TEX_SIZE * 2 * TEX_SIZE * 2 * 4], *p;
int x, y, i;
- for (i = 0; i < G_N_ELEMENTS (test_wrap_modes); i += 2)
+ for (i = 0; i < G_N_ELEMENTS (wrap_modes); i += 2)
{
CoglPipelineWrapMode wrap_mode_s, wrap_mode_t;
- wrap_mode_s = test_wrap_modes[i];
- wrap_mode_t = test_wrap_modes[i + 1];
+ wrap_mode_s = wrap_modes[i];
+ wrap_mode_t = wrap_modes[i + 1];
- cogl_read_pixels (i * TEX_SIZE, offset * TEX_SIZE * 2,
- TEX_SIZE * 2, TEX_SIZE * 2,
- COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888,
- data);
+ cogl_framebuffer_read_pixels (fb, i * TEX_SIZE, offset * TEX_SIZE * 2,
+ TEX_SIZE * 2, TEX_SIZE * 2,
+ COGL_PIXEL_FORMAT_RGBA_8888,
+ data);
p = data;
@@ -237,7 +238,7 @@ paint (TestState *state)
/* Draw the tests first with a non atlased texture */
state->texture = create_texture (COGL_TEXTURE_NO_ATLAS);
draw_tests (state);
- cogl_handle_unref (state->texture);
+ cogl_object_unref (state->texture);
/* Draw the tests again with a possible atlased texture. This should
end up testing software repeats */
@@ -246,7 +247,7 @@ paint (TestState *state)
cogl_translate (0.0f, TEX_SIZE * 2.0f, 0.0f);
draw_tests (state);
cogl_pop_matrix ();
- cogl_handle_unref (state->texture);
+ cogl_object_unref (state->texture);
/* Draw the tests using cogl_polygon */
state->texture = create_texture (COGL_TEXTURE_NO_ATLAS);
@@ -254,7 +255,7 @@ paint (TestState *state)
cogl_translate (0.0f, TEX_SIZE * 4.0f, 0.0f);
draw_tests_polygon (state);
cogl_pop_matrix ();
- cogl_handle_unref (state->texture);
+ cogl_object_unref (state->texture);
/* Draw the tests using a vertex buffer */
state->texture = create_texture (COGL_TEXTURE_NO_ATLAS);
@@ -262,27 +263,31 @@ paint (TestState *state)
cogl_translate (0.0f, TEX_SIZE * 6.0f, 0.0f);
draw_tests_vbo (state);
cogl_pop_matrix ();
- cogl_handle_unref (state->texture);
+ cogl_object_unref (state->texture);
validate_result (state);
}
void
-test_cogl_wrap_modes (TestUtilsGTestFixture *fixture,
- void *data)
+test_wrap_modes (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
- state.width = cogl_framebuffer_get_width (shared_state->fb);
- state.height = cogl_framebuffer_get_height (shared_state->fb);
+ state.width = cogl_framebuffer_get_width (fb);
+ state.height = cogl_framebuffer_get_height (fb);
- cogl_ortho (0, state.width, /* left, right */
- state.height, 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ state.width,
+ state.height,
+ -1,
+ 100);
+ /* XXX: we have to push/pop a framebuffer since this test currently
+ * uses the legacy cogl_vertex_buffer_draw() api. */
+ cogl_push_framebuffer (fb);
paint (&state);
+ cogl_pop_framebuffer ();
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/tests/conform/test-write-texture-formats.c b/tests/conform/test-write-texture-formats.c
index c794286d..3081182d 100644
--- a/tests/conform/test-write-texture-formats.c
+++ b/tests/conform/test-write-texture-formats.c
@@ -139,12 +139,8 @@ test_write_int (CoglContext *context,
}
void
-test_cogl_write_texture_formats (TestUtilsGTestFixture *fixture,
- void *data)
+test_write_texture_formats (void)
{
- TestUtilsSharedState *shared_state = data;
- CoglContext *ctx = shared_state->ctx;
-
test_write_byte (ctx, COGL_PIXEL_FORMAT_A_8, 0x34, 0x00000034);
#if 0
/* I'm not sure what's the right value to put here because Nvidia