summaryrefslogtreecommitdiff
path: root/tests/conform
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2012-04-11 17:35:40 +0100
committerRobert Bragg <robert@linux.intel.com>2012-04-16 12:14:25 +0100
commitf951d0995f8a8de23264a985568b4cae7ac492f2 (patch)
treea5ca21a2f828bbb9e2dcb653aea40370ffaacecf /tests/conform
parente097e5181f9c19dbf09bfdb101cd27a1da8aa95e (diff)
downloadcogl-f951d0995f8a8de23264a985568b4cae7ac492f2.tar.gz
Start building parallel installable 2.0 api only
Since we are getting towards a complete Cogl 2.0 api this breaks 1.x api compatibility by no longer building a libcogl.so and instead building a libcogl2.so library. The headers are now installed into an include/cogl2 sub-directory that wont conflict with an installed cogl 1.x package. The cogl-2.0-experimental.pc pkg-config file is now named cogl2.pc and similarly the reference manual has been renamed from cogl-2.0-experimental to cogl2. The examples have not been namespaced and so they are not parallel installable. Since we haven't yet reached the 2.0 api yet the version has been bumped to 1.99.1 All of the conformance tests have been updated so they no longer test the 1.x apis, and since I was going through all the tests I took the opportunity to rename the global ctx and fb variables to test_ctx and test_fb. Reviewed-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'tests/conform')
-rw-r--r--tests/conform/Makefile.am3
-rw-r--r--tests/conform/test-backface-culling.c101
-rw-r--r--tests/conform/test-bitmask.c5
-rw-r--r--tests/conform/test-blend-strings.c132
-rw-r--r--tests/conform/test-color-mask.c46
-rw-r--r--tests/conform/test-custom-attributes.c70
-rw-r--r--tests/conform/test-depth-test.c20
-rw-r--r--tests/conform/test-just-vertex-shader.c158
-rw-r--r--tests/conform/test-offscreen.c99
-rw-r--r--tests/conform/test-path.c156
-rw-r--r--tests/conform/test-pipeline-uniforms.c137
-rw-r--r--tests/conform/test-pipeline-user-matrix.c17
-rw-r--r--tests/conform/test-pixel-buffer.c18
-rw-r--r--tests/conform/test-point-size.c22
-rw-r--r--tests/conform/test-point-sprite.c36
-rw-r--r--tests/conform/test-premult.c61
-rw-r--r--tests/conform/test-primitive.c24
-rw-r--r--tests/conform/test-read-texture-formats.c4
-rw-r--r--tests/conform/test-snippets.c120
-rw-r--r--tests/conform/test-sparse-pipeline.c18
-rw-r--r--tests/conform/test-sub-texture.c34
-rw-r--r--tests/conform/test-texture-3d.c36
-rw-r--r--tests/conform/test-utils.c37
-rw-r--r--tests/conform/test-utils.h4
-rw-r--r--tests/conform/test-wrap-modes.c100
-rw-r--r--tests/conform/test-write-texture-formats.c56
26 files changed, 596 insertions, 918 deletions
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
index 7de8305c..fca9d832 100644
--- a/tests/conform/Makefile.am
+++ b/tests/conform/Makefile.am
@@ -108,13 +108,12 @@ INCLUDES = \
-I$(top_builddir)/cogl
test_conformance_CPPFLAGS = \
- -DCOGL_ENABLE_EXPERIMENTAL_API \
-DCOGL_DISABLE_DEPRECATED \
-DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\" \
-DCLUTTER_COMPILATION
test_conformance_CFLAGS = -g3 -O0 $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS)
-test_conformance_LDADD = $(COGL_DEP_LIBS) $(top_builddir)/cogl/libcogl.la
+test_conformance_LDADD = $(COGL_DEP_LIBS) $(top_builddir)/cogl/libcogl2.la
test_conformance_LDFLAGS = -export-dynamic
test: wrappers
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index fe1eda5c..5f61a518 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -35,20 +35,19 @@ validate_part (CoglFramebuffer *framebuffer,
shown ? 0xff0000ff : 0x000000ff);
}
-/* We draw everything 16 times. The draw number is used as a bitmask
- to test all of the combinations of enabling legacy state, both
- winding orders and all four culling modes */
+/* We draw everything 8 times. The draw number is used as a bitmask
+ to test all of the combinations of both winding orders and all four
+ culling modes */
-#define USE_LEGACY_STATE(draw_num) (((draw_num) & 0x01) >> 0)
-#define FRONT_WINDING(draw_num) (((draw_num) & 0x02) >> 1)
-#define CULL_FACE_MODE(draw_num) (((draw_num) & 0x0c) >> 2)
+#define FRONT_WINDING(draw_num) (((draw_num) & 0x01) >> 1)
+#define CULL_FACE_MODE(draw_num) (((draw_num) & 0x06) >> 2)
static void
paint_test_backface_culling (TestState *state,
CoglFramebuffer *framebuffer)
{
int draw_num;
- CoglPipeline *base_pipeline = cogl_pipeline_new (ctx);
+ CoglPipeline *base_pipeline = cogl_pipeline_new (test_ctx);
cogl_framebuffer_orthographic (framebuffer,
0, 0,
@@ -67,8 +66,6 @@ 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++)
@@ -77,81 +74,42 @@ paint_test_backface_culling (TestState *state,
CoglTextureVertex verts[4];
CoglPipeline *pipeline;
- cogl_push_matrix ();
- cogl_translate (0, TEXTURE_RENDER_SIZE * draw_num, 0);
+ cogl_framebuffer_push_matrix (framebuffer);
+ cogl_framebuffer_translate (framebuffer,
+ 0, TEXTURE_RENDER_SIZE * draw_num, 0);
pipeline = cogl_pipeline_copy (base_pipeline);
- cogl_set_backface_culling_enabled (USE_LEGACY_STATE (draw_num));
cogl_pipeline_set_front_face_winding (pipeline, FRONT_WINDING (draw_num));
cogl_pipeline_set_cull_face_mode (pipeline, CULL_FACE_MODE (draw_num));
- cogl_push_source (pipeline);
-
memset (verts, 0, sizeof (verts));
x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
/* Draw a front-facing texture */
- cogl_rectangle (x1, y1, x2, y2);
+ cogl_framebuffer_draw_rectangle (framebuffer, pipeline, x1, y1, x2, y2);
x1 = x2;
x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
/* Draw a front-facing texture with flipped texcoords */
- cogl_rectangle_with_texture_coords (x1, y1, x2, y2,
- 1.0, 0.0, 0.0, 1.0);
+ cogl_framebuffer_draw_textured_rectangle (framebuffer,
+ pipeline,
+ x1, y1, x2, y2,
+ 1.0, 0.0, 0.0, 1.0);
x1 = x2;
x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
/* Draw a back-facing texture */
- cogl_rectangle (x2, y1, x1, y2);
-
- x1 = x2;
- x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
-
- /* If the texture is sliced then cogl_polygon doesn't work so
- we'll just use a solid color instead */
- if (cogl_texture_is_sliced (state->texture))
- cogl_set_source_color4ub (255, 0, 0, 255);
-
- /* Draw a front-facing polygon */
- verts[0].x = x1; verts[0].y = y2;
- verts[1].x = x2; verts[1].y = y2;
- verts[2].x = x2; verts[2].y = y1;
- verts[3].x = x1; verts[3].y = y1;
- verts[0].tx = 0; verts[0].ty = 0;
- verts[1].tx = 1.0; verts[1].ty = 0;
- verts[2].tx = 1.0; verts[2].ty = 1.0;
- verts[3].tx = 0; verts[3].ty = 1.0;
- cogl_polygon (verts, 4, FALSE);
-
- x1 = x2;
- x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
+ cogl_framebuffer_draw_rectangle (framebuffer, pipeline, x2, y1, x1, y2);
- /* Draw a back-facing polygon */
- verts[0].x = x1; verts[0].y = y1;
- verts[1].x = x2; verts[1].y = y1;
- verts[2].x = x2; verts[2].y = y2;
- verts[3].x = x1; verts[3].y = y2;
- verts[0].tx = 0; verts[0].ty = 0;
- verts[1].tx = 1.0; verts[1].ty = 0;
- verts[2].tx = 1.0; verts[2].ty = 1.0;
- verts[3].tx = 0; verts[3].ty = 1.0;
- cogl_polygon (verts, 4, FALSE);
+ cogl_framebuffer_pop_matrix (framebuffer);
- x1 = x2;
- x2 = x1 + (float)(TEXTURE_RENDER_SIZE);
-
- cogl_pop_matrix ();
-
- cogl_pop_source ();
cogl_object_unref (pipeline);
}
- cogl_pop_framebuffer ();
-
cogl_object_unref (base_pipeline);
}
@@ -160,15 +118,12 @@ validate_result (CoglFramebuffer *framebuffer, int y_offset)
{
int draw_num;
- for (draw_num = 0; draw_num < 16; draw_num++)
+ for (draw_num = 0; draw_num < 8; draw_num++)
{
gboolean cull_front, cull_back;
CoglPipelineCullFaceMode cull_mode;
- if (USE_LEGACY_STATE (draw_num))
- cull_mode = COGL_PIPELINE_CULL_FACE_MODE_BACK;
- else
- cull_mode = CULL_FACE_MODE (draw_num);
+ cull_mode = CULL_FACE_MODE (draw_num);
switch (cull_mode)
{
@@ -209,12 +164,6 @@ validate_result (CoglFramebuffer *framebuffer, int y_offset)
/* Back-facing texture */
validate_part (framebuffer,
2, y_offset + draw_num, !cull_back);
- /* Front-facing texture polygon */
- validate_part (framebuffer,
- 3, y_offset + draw_num, !cull_front);
- /* Back-facing texture polygon */
- validate_part (framebuffer,
- 4, y_offset + draw_num, !cull_back);
}
}
@@ -223,7 +172,7 @@ paint (TestState *state)
{
CoglPipeline *pipeline;
- paint_test_backface_culling (state, fb);
+ paint_test_backface_culling (state, test_fb);
/*
* Now repeat the test but rendered to an offscreen
@@ -235,17 +184,17 @@ paint (TestState *state)
/* Copy the result of the offscreen rendering for validation and
* also so we can have visual feedback. */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, state->offscreen_tex);
- cogl_framebuffer_draw_rectangle (fb,
+ cogl_framebuffer_draw_rectangle (test_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);
+ validate_result (test_fb, 0);
+ validate_result (test_fb, 16);
}
static CoglTexture *
@@ -283,8 +232,8 @@ test_backface_culling (void)
TestState state;
CoglTexture *tex;
- state.width = cogl_framebuffer_get_width (fb);
- state.height = cogl_framebuffer_get_height (fb);
+ state.width = cogl_framebuffer_get_width (test_fb);
+ state.height = cogl_framebuffer_get_height (test_fb);
state.offscreen = NULL;
diff --git a/tests/conform/test-bitmask.c b/tests/conform/test-bitmask.c
index 3e5e1737..f9765514 100644
--- a/tests/conform/test-bitmask.c
+++ b/tests/conform/test-bitmask.c
@@ -9,6 +9,11 @@
within Cogl. Cogl doesn't export the symbols for this data type so
we just directly include the source instead */
+/* we undef these to avoid them being redefined by config.h when
+ * including cogl-bitmask.c */
+#undef COGL_ENABLE_EXPERIMENTAL_2_0_API
+#undef COGL_ENABLE_EXPERIMENTAL_API
+
#include <cogl/cogl-bitmask.h>
#include <cogl/cogl-bitmask.c>
#define _COGL_IN_TEST_BITMASK
diff --git a/tests/conform/test-blend-strings.c b/tests/conform/test-blend-strings.c
index 4fcf85f9..84fa6d88 100644
--- a/tests/conform/test-blend-strings.c
+++ b/tests/conform/test-blend-strings.c
@@ -21,7 +21,7 @@
typedef struct _TestState
{
- CoglContext *ctx;
+ int padding;
} TestState;
@@ -52,7 +52,6 @@ test_blend (TestState *state,
guint8 Ba = MASK_ALPHA (blend_constant);
CoglColor blend_const_color;
- CoglHandle material;
CoglPipeline *pipeline;
gboolean status;
GError *error = NULL;
@@ -60,21 +59,22 @@ test_blend (TestState *state,
int x_off;
/* First write out the destination color without any blending... */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_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);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
+ cogl_framebuffer_draw_rectangle (test_fb,
+ pipeline,
+ x * QUAD_WIDTH,
+ y * QUAD_WIDTH,
+ x * QUAD_WIDTH + QUAD_WIDTH,
+ y * QUAD_WIDTH + QUAD_WIDTH);
cogl_object_unref (pipeline);
/*
* Now blend a rectangle over our well defined destination:
*/
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, Sr, Sg, Sb, Sa);
status = cogl_pipeline_set_blend (pipeline, blend_string, &error);
@@ -94,11 +94,12 @@ test_blend (TestState *state,
cogl_color_init_from_4ub (&blend_const_color, Br, Bg, Bb, Ba);
cogl_pipeline_set_blend_constant (pipeline, &blend_const_color);
- cogl_set_source (pipeline);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
+ cogl_framebuffer_draw_rectangle (test_fb,
+ pipeline,
+ x * QUAD_WIDTH,
+ y * QUAD_WIDTH,
+ x * QUAD_WIDTH + QUAD_WIDTH,
+ y * QUAD_WIDTH + QUAD_WIDTH);
cogl_object_unref (pipeline);
/* See what we got... */
@@ -118,60 +119,7 @@ test_blend (TestState *state,
g_print (" blend constant = UNUSED\n");
}
- test_utils_check_pixel (fb, x_off, y_off, expected_result);
-
-
- /*
- * Test with legacy API
- */
-
- /* Clear previous work */
- cogl_set_source_color4ub (0, 0, 0, 0xff);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
-
- /* First write out the destination color without any blending... */
- material = cogl_material_new ();
- cogl_material_set_color4ub (material, Dr, Dg, Db, Da);
- cogl_material_set_blend (material, "RGBA = ADD (SRC_COLOR, 0)", NULL);
- cogl_set_source (material);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
- cogl_handle_unref (material);
-
- /*
- * Now blend a rectangle over our well defined destination:
- */
-
- material = cogl_material_new ();
- cogl_material_set_color4ub (material, Sr, Sg, Sb, Sa);
-
- status = cogl_material_set_blend (material, blend_string, &error);
- if (!status)
- {
- /* This is a failure as it must be equivalent to the new API */
- g_warning ("Error setting blend string %s: %s",
- blend_string, error->message);
- g_assert_not_reached ();
- }
-
- cogl_color_init_from_4ub (&blend_const_color, Br, Bg, Bb, Ba);
- cogl_material_set_blend_constant (material, &blend_const_color);
-
- cogl_set_source (material);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
- cogl_handle_unref (material);
-
- /* See what we got... */
-
- test_utils_check_pixel (fb, x_off, y_off, expected_result);
+ test_utils_check_pixel (test_fb, x_off, y_off, expected_result);
}
static CoglTexture *
@@ -228,7 +176,7 @@ test_tex_combine (TestState *state,
guint8 Ca = MASK_ALPHA (combine_constant);
CoglColor combine_const_color;
- CoglHandle material;
+ CoglPipeline *pipeline;
gboolean status;
GError *error = NULL;
int y_off;
@@ -238,17 +186,17 @@ test_tex_combine (TestState *state,
tex0 = make_texture (tex0_color);
tex1 = make_texture (tex1_color);
- material = cogl_material_new ();
+ pipeline = cogl_pipeline_new (test_ctx);
- cogl_material_set_color4ub (material, 0x80, 0x80, 0x80, 0x80);
- cogl_material_set_blend (material, "RGBA = ADD (SRC_COLOR, 0)", NULL);
+ cogl_pipeline_set_color4ub (pipeline, 0x80, 0x80, 0x80, 0x80);
+ cogl_pipeline_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL);
- cogl_material_set_layer (material, 0, tex0);
- cogl_material_set_layer_combine (material, 0,
+ cogl_pipeline_set_layer_texture (pipeline, 0, tex0);
+ cogl_pipeline_set_layer_combine (pipeline, 0,
"RGBA = REPLACE (TEXTURE)", NULL);
- cogl_material_set_layer (material, 1, tex1);
- status = cogl_material_set_layer_combine (material, 1,
+ cogl_pipeline_set_layer_texture (pipeline, 1, tex1);
+ status = cogl_pipeline_set_layer_combine (pipeline, 1,
combine_string, &error);
if (!status)
{
@@ -259,15 +207,15 @@ test_tex_combine (TestState *state,
}
cogl_color_init_from_4ub (&combine_const_color, Cr, Cg, Cb, Ca);
- cogl_material_set_layer_combine_constant (material, 1, &combine_const_color);
-
- cogl_set_source (material);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
-
- cogl_handle_unref (material);
+ cogl_pipeline_set_layer_combine_constant (pipeline, 1, &combine_const_color);
+
+ cogl_framebuffer_draw_rectangle (test_fb,
+ pipeline,
+ x * QUAD_WIDTH,
+ y * QUAD_WIDTH,
+ x * QUAD_WIDTH + QUAD_WIDTH,
+ y * QUAD_WIDTH + QUAD_WIDTH);
+ cogl_object_unref (pipeline);
cogl_object_unref (tex0);
cogl_object_unref (tex1);
@@ -288,7 +236,7 @@ test_tex_combine (TestState *state,
g_print (" combine constant = UNUSED\n");
}
- test_utils_check_pixel (fb, x_off, y_off, expected_result);
+ test_utils_check_pixel (test_fb, x_off, y_off, expected_result);
}
static void
@@ -350,7 +298,7 @@ paint (TestState *state)
"A = MODULATE (PREVIOUS, TEXTURE)", /* tex combine */
0xffffff20); /* expected */
- /* XXX: we are assuming test_tex_combine creates a material with
+ /* XXX: we are assuming test_tex_combine creates a pipeline with
* a color of 0x80808080 (i.e. the "PRIMARY" color) */
test_tex_combine (state, 7, 0, /* position */
0xffffff80, /* texture 0 color (alpha = 0.5) */
@@ -412,17 +360,13 @@ test_blend_strings (void)
{
TestState state;
- cogl_framebuffer_orthographic (fb, 0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_orthographic (test_fb, 0, 0,
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_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 1e22cbcb..f49d9dd5 100644
--- a/tests/conform/test-color-mask.c
+++ b/tests/conform/test-color-mask.c
@@ -18,36 +18,36 @@ typedef struct _TestState
static void
paint (TestState *state)
{
- CoglColor bg;
+ CoglPipeline *white = cogl_pipeline_new (test_ctx);
int i;
- cogl_set_source_color4ub (255, 255, 255, 255);
+ cogl_pipeline_set_color4f (white, 1, 1, 1, 1);
- /* We push the third framebuffer first so that later we can switch
- back to it by popping to test that that works */
- cogl_push_framebuffer (state->fbo[2]);
- cogl_push_framebuffer (state->fbo[0]);
- cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
- cogl_pop_framebuffer ();
+ cogl_framebuffer_draw_rectangle (state->fbo[0],
+ white,
+ -1.0, -1.0, 1.0, 1.0);
- cogl_push_framebuffer (state->fbo[1]);
- cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
- cogl_pop_framebuffer ();
+ cogl_framebuffer_draw_rectangle (state->fbo[1],
+ white,
+ -1.0, -1.0, 1.0, 1.0);
- /* We should now be back on the third framebuffer */
- cogl_rectangle (-1.0, -1.0, 1.0, 1.0);
- cogl_pop_framebuffer ();
+ cogl_framebuffer_draw_rectangle (state->fbo[2],
+ white,
+ -1.0, -1.0, 1.0, 1.0);
- cogl_color_init_from_4ub (&bg, 128, 128, 128, 255);
- cogl_clear (&bg, COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_DEPTH);
+ cogl_object_unref (white);
+
+ cogl_framebuffer_clear4f (test_fb,
+ COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_DEPTH,
+ 0.5, 0.5, 0.5, 1.0);
/* Render all of the textures to the screen */
for (i = 0; i < NUM_FBOS; i++)
{
- CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, state->tex[i]);
- cogl_framebuffer_draw_rectangle (fb, pipeline,
+ cogl_framebuffer_draw_rectangle (test_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);
@@ -61,7 +61,7 @@ paint (TestState *state)
{ 0x00, 0xff, 0x00, 0xff },
{ 0x00, 0x00, 0xff, 0xff } };
- test_utils_check_pixel_rgb (fb,
+ test_utils_check_pixel_rgb (test_fb,
state->width * (i + 0.5f) / NUM_FBOS,
state->height / 2,
expected_colors[i][0],
@@ -76,8 +76,8 @@ test_color_mask (void)
TestState state;
int i;
- state.width = cogl_framebuffer_get_width (fb);
- state.height = cogl_framebuffer_get_height (fb);
+ state.width = cogl_framebuffer_get_width (test_fb);
+ state.height = cogl_framebuffer_get_height (test_fb);
for (i = 0; i < NUM_FBOS; i++)
{
@@ -99,11 +99,7 @@ test_color_mask (void)
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-custom-attributes.c b/tests/conform/test-custom-attributes.c
index 6af4fa2c..44327d3e 100644
--- a/tests/conform/test-custom-attributes.c
+++ b/tests/conform/test-custom-attributes.c
@@ -43,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 (ctx,
+ buffer = cogl_attribute_buffer_new (test_ctx,
sizeof (float_verts), float_verts);
attributes[0] = cogl_attribute_new (buffer,
"cogl_position_in",
@@ -58,10 +58,10 @@ test_float_verts (TestState *state, int offset_x, int offset_y)
4, /* n_components */
COGL_ATTRIBUTE_TYPE_FLOAT);
- cogl_framebuffer_push_matrix (fb);
- cogl_framebuffer_translate (fb, offset_x, offset_y, 0.0f);
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb, offset_x, offset_y, 0.0f);
- cogl_framebuffer_draw_attributes (fb,
+ cogl_framebuffer_draw_attributes (test_fb,
state->pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -69,14 +69,14 @@ test_float_verts (TestState *state, int offset_x, int offset_y)
attributes,
2 /* n_attributes */);
- cogl_framebuffer_pop_matrix (fb);
+ cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (attributes[1]);
cogl_object_unref (attributes[0]);
cogl_object_unref (buffer);
- 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 (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
+ test_utils_check_pixel (test_fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
}
static void
@@ -103,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 (ctx,
+ buffer = cogl_attribute_buffer_new (test_ctx,
sizeof (norm_verts), norm_verts);
attributes[0] = cogl_attribute_new (buffer,
"cogl_position_in",
@@ -119,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_framebuffer_push_matrix (fb);
- cogl_framebuffer_translate (fb, offset_x, offset_y, 0.0f);
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb, offset_x, offset_y, 0.0f);
- cogl_framebuffer_draw_attributes (fb,
+ cogl_framebuffer_draw_attributes (test_fb,
state->pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -133,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 (ctx,
+ unnorm_buffer = cogl_attribute_buffer_new (test_ctx,
sizeof (unnorm_verts),
unnorm_verts);
attributes[1] = cogl_attribute_new (unnorm_buffer,
@@ -143,9 +143,9 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
4, /* n_components */
COGL_ATTRIBUTE_TYPE_BYTE);
- cogl_framebuffer_translate (fb, 20, 0, 0);
+ cogl_framebuffer_translate (test_fb, 20, 0, 0);
- cogl_framebuffer_draw_attributes (fb,
+ cogl_framebuffer_draw_attributes (test_fb,
state->pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -153,16 +153,16 @@ test_byte_verts (TestState *state, int offset_x, int offset_y)
attributes,
2 /* n_attributes */);
- cogl_framebuffer_pop_matrix (fb);
+ cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (attributes[0]);
cogl_object_unref (attributes[1]);
cogl_object_unref (buffer);
cogl_object_unref (unnorm_buffer);
- 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);
+ test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
+ test_utils_check_pixel (test_fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
+ test_utils_check_pixel (test_fb, offset_x + 25, offset_y + 5, 0x0000ffff);
}
static void
@@ -180,7 +180,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
{ -5, -1 }
};
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
"attribute vec2 pos;",
NULL);
@@ -193,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 (ctx,
+ buffer = cogl_attribute_buffer_new (test_ctx,
sizeof (short_verts), short_verts);
attributes[0] = cogl_attribute_new (buffer,
"pos",
@@ -202,13 +202,13 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
2, /* n_components */
COGL_ATTRIBUTE_TYPE_SHORT);
- cogl_framebuffer_push_matrix (fb);
- cogl_framebuffer_translate (fb,
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb,
offset_x + 10.0f,
offset_y + 10.0f,
0.0f);
- cogl_framebuffer_draw_attributes (fb,
+ cogl_framebuffer_draw_attributes (test_fb,
pipeline,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -216,7 +216,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
attributes,
1 /* n_attributes */);
- cogl_framebuffer_pop_matrix (fb);
+ cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (attributes[0]);
@@ -231,13 +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_framebuffer_push_matrix (fb);
- cogl_framebuffer_translate (fb,
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb,
offset_x + 10.0f - 65525.0f,
offset_y - 65525,
0.0f);
- cogl_framebuffer_draw_attributes (fb,
+ cogl_framebuffer_draw_attributes (test_fb,
pipeline2,
COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */
@@ -245,7 +245,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
attributes,
1 /* n_attributes */);
- cogl_framebuffer_pop_matrix (fb);
+ cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (attributes[0]);
@@ -253,14 +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 (fb, offset_x + 5, offset_y + 5, 0xff0000ff);
- test_utils_check_pixel (fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
+ test_utils_check_pixel (test_fb, offset_x + 5, offset_y + 5, 0xff0000ff);
+ test_utils_check_pixel (test_fb, offset_x + 15, offset_y + 5, 0x00ff00ff);
}
static void
paint (TestState *state)
{
- cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
test_float_verts (state, 0, 0);
test_byte_verts (state, 0, 10);
@@ -276,14 +276,14 @@ test_custom_attributes (void)
CoglSnippet *snippet;
TestState state;
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_fb),
-1,
100);
- state.pipeline = cogl_pipeline_new (ctx);
+ state.pipeline = cogl_pipeline_new (test_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 76891db8..41bdc58d 100644
--- a/tests/conform/test-depth-test.c
+++ b/tests/conform/test-depth-test.c
@@ -54,7 +54,7 @@ draw_rectangle (TestState *state,
rect_state->range_near,
rect_state->range_far);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
if (!cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL))
{
cogl_object_unref (pipeline);
@@ -65,19 +65,19 @@ draw_rectangle (TestState *state,
{
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,
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb, 0, 0, rect_state->depth);
+ cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
x * QUAD_WIDTH,
y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH);
- cogl_framebuffer_pop_matrix (fb);
+ cogl_framebuffer_pop_matrix (test_fb);
}
else
{
- cogl_push_framebuffer (fb);
+ cogl_push_framebuffer (test_fb);
cogl_push_matrix ();
cogl_set_source_color4ub (Cr, Cg, Cb, Ca);
cogl_translate (0, 0, rect_state->depth);
@@ -118,7 +118,7 @@ test_depth (TestState *state,
if (missing_feature)
return;
- test_utils_check_pixel (fb,
+ test_utils_check_pixel (test_fb,
x * QUAD_WIDTH + (QUAD_WIDTH / 2),
y * QUAD_WIDTH + (QUAD_WIDTH / 2),
expected_result);
@@ -260,9 +260,9 @@ test_depth_test (void)
{
TestState state;
- cogl_framebuffer_orthographic (fb, 0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_orthographic (test_fb, 0, 0,
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_fb),
-1,
100);
diff --git a/tests/conform/test-just-vertex-shader.c b/tests/conform/test-just-vertex-shader.c
index 2e054803..0aa6f3ee 100644
--- a/tests/conform/test-just-vertex-shader.c
+++ b/tests/conform/test-just-vertex-shader.c
@@ -25,90 +25,17 @@ create_dummy_texture (void)
}
static void
-paint_legacy (TestState *state)
-{
- CoglHandle material = cogl_material_new ();
- CoglTexture *tex;
- CoglColor color;
- GError *error = NULL;
- CoglHandle shader, program;
-
- cogl_color_init_from_4ub (&color, 0, 0, 0, 255);
- cogl_clear (&color, COGL_BUFFER_BIT_COLOR);
-
- /* Set the primary vertex color as red */
- cogl_color_set_from_4ub (&color, 0xff, 0x00, 0x00, 0xff);
- cogl_material_set_color (material, &color);
-
- /* Override the vertex color in the texture environment with a
- constant green color provided by a texture */
- tex = create_dummy_texture ();
- cogl_material_set_layer (material, 0, tex);
- cogl_object_unref (tex);
- if (!cogl_material_set_layer_combine (material, 0,
- "RGBA=REPLACE(TEXTURE)",
- &error))
- {
- g_warning ("Error setting layer combine: %s", error->message);
- g_assert_not_reached ();
- }
-
- /* Set up a dummy vertex shader that does nothing but the usual
- fixed function transform */
- shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX);
- cogl_shader_source (shader,
- "void\n"
- "main ()\n"
- "{\n"
- " cogl_position_out = "
- "cogl_modelview_projection_matrix * "
- "cogl_position_in;\n"
- " cogl_color_out = cogl_color_in;\n"
- " cogl_tex_coord_out[0] = cogl_tex_coord_in;\n"
- "}\n");
- cogl_shader_compile (shader);
- if (!cogl_shader_is_compiled (shader))
- {
- char *log = cogl_shader_get_info_log (shader);
- g_warning ("Shader compilation failed:\n%s", log);
- g_free (log);
- g_assert_not_reached ();
- }
-
- program = cogl_create_program ();
- cogl_program_attach_shader (program, shader);
- cogl_program_link (program);
-
- cogl_handle_unref (shader);
-
- /* Draw something using the material */
- cogl_set_source (material);
- cogl_rectangle (0, 0, 50, 50);
-
- /* Draw it again using the program. It should look exactly the same */
- cogl_program_use (program);
- cogl_rectangle (50, 0, 100, 50);
- cogl_program_use (COGL_INVALID_HANDLE);
-
- cogl_handle_unref (material);
- cogl_handle_unref (program);
-}
-
-static void
paint (TestState *state)
{
- CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
CoglTexture *tex;
- CoglColor color;
GError *error = NULL;
- CoglHandle shader, program;
+ CoglSnippet *snippet;
- cogl_color_init_from_4ub (&color, 0, 0, 0, 255);
- cogl_clear (&color, COGL_BUFFER_BIT_COLOR);
+ cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
/* Set the primary vertex color as red */
- cogl_color_set_from_4ub (&color, 0xff, 0x00, 0x00, 0xff);
- cogl_pipeline_set_color (pipeline, &color);
+ cogl_pipeline_set_color4f (pipeline, 1, 0, 0, 1);
/* Override the vertex color in the texture environment with a
constant green color provided by a texture */
@@ -124,43 +51,25 @@ paint (TestState *state)
}
/* Set up a dummy vertex shader that does nothing but the usual
- fixed function transform */
- shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX);
- cogl_shader_source (shader,
- "void\n"
- "main ()\n"
- "{\n"
- " cogl_position_out = "
- "cogl_modelview_projection_matrix * "
- "cogl_position_in;\n"
- " cogl_color_out = cogl_color_in;\n"
- " cogl_tex_coord_out[0] = cogl_tex_coord_in;\n"
- "}\n");
- cogl_shader_compile (shader);
- if (!cogl_shader_is_compiled (shader))
- {
- char *log = cogl_shader_get_info_log (shader);
- g_warning ("Shader compilation failed:\n%s", log);
- g_free (log);
- g_assert_not_reached ();
- }
-
- program = cogl_create_program ();
- cogl_program_attach_shader (program, shader);
- cogl_program_link (program);
-
- cogl_handle_unref (shader);
-
- /* Draw something without the program */
- cogl_set_source (pipeline);
- cogl_rectangle (0, 0, 50, 50);
-
- /* Draw it again using the program. It should look exactly the same */
- cogl_pipeline_set_user_program (pipeline, program);
- cogl_handle_unref (program);
-
- cogl_rectangle (50, 0, 100, 50);
- cogl_pipeline_set_user_program (pipeline, COGL_INVALID_HANDLE);
+ modelview-projection transform */
+ snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX,
+ NULL, /* no declarations */
+ NULL); /* no "post" code */
+ cogl_snippet_set_replace (snippet,
+ " cogl_position_out = "
+ "cogl_modelview_projection_matrix * "
+ "cogl_position_in;\n"
+ " cogl_color_out = cogl_color_in;\n"
+ " cogl_tex_coord_out[0] = cogl_tex_coord_in;\n");
+
+ /* Draw something without the snippet */
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 50, 50);
+
+ /* Draw it again using the snippet. It should look exactly the same */
+ cogl_pipeline_add_snippet (pipeline, snippet);
+ cogl_object_unref (snippet);
+
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 50, 0, 100, 50);
cogl_object_unref (pipeline);
}
@@ -179,27 +88,18 @@ test_just_vertex_shader (void)
{
TestState state;
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_fb),
-1,
100);
- /* If shaders aren't supported then we can't run the test */
- if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
+ /* If GLSL isn't supported then we can't run the test */
+ if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_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 (fb);
-
paint (&state);
- validate_result (fb);
-
- cogl_pop_framebuffer ();
+ validate_result (test_fb);
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/tests/conform/test-offscreen.c b/tests/conform/test-offscreen.c
index 0683a8ab..6e7d3cc8 100644
--- a/tests/conform/test-offscreen.c
+++ b/tests/conform/test-offscreen.c
@@ -32,7 +32,7 @@ check_quadrant (TestState *state,
width -= 4;
height -= 4;
- test_utils_check_region (fb, x, y, width, height, expected_rgba);
+ test_utils_check_region (test_fb, x, y, width, height, expected_rgba);
}
static void
@@ -40,16 +40,18 @@ test_paint (TestState *state)
{
CoglTexture2D *tex_2d;
CoglTexture *tex;
- CoglOffscreen *offscreen;
+ CoglFramebuffer *offscreen;
+ CoglPipeline *color;
+ CoglPipeline *textured;
- tex_2d = cogl_texture_2d_new_with_size (ctx,
+ tex_2d = cogl_texture_2d_new_with_size (test_ctx,
state->fb_width,
state->fb_height,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
NULL);
tex = COGL_TEXTURE (tex_2d);
- offscreen = cogl_offscreen_new_to_texture (tex);
+ offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_to_texture (tex));
/* Set a scale and translate transform on the window framebuffer
* before switching to the offscreen framebuffer so we can verify it
@@ -61,41 +63,39 @@ test_paint (TestState *state)
* quarter of the window size and slide it to the top right of the
* window.
*/
- cogl_push_matrix ();
- cogl_translate (0.5, 0.5, 0);
- cogl_scale (-0.5, 0.5, 1);
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb, 0.5, 0.5, 0);
+ cogl_framebuffer_scale (test_fb, -0.5, 0.5, 1);
- cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
+ /* Use something other than the identity matrix for the modelview so we can
+ * verify it gets restored when we switch back to test_fb */
+ cogl_framebuffer_scale (offscreen, 2, 2, 1);
- /* Cogl should release the last reference when we call cogl_pop_framebuffer()
- */
- 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 () */
- cogl_scale (2, 2, 1);
+ color = cogl_pipeline_new (test_ctx);
/* red, top left */
- cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
- cogl_rectangle (-0.5, 0.5, 0, 0);
+ cogl_pipeline_set_color4f (color, 1, 0, 0, 1);
+ cogl_framebuffer_draw_rectangle (offscreen, color, -0.5, 0.5, 0, 0);
/* green, top right */
- cogl_set_source_color4ub (0x00, 0xff, 0x00, 0xff);
- cogl_rectangle (0, 0.5, 0.5, 0);
+ cogl_pipeline_set_color4f (color, 0, 1, 0, 1);
+ cogl_framebuffer_draw_rectangle (offscreen, color, 0, 0.5, 0.5, 0);
/* blue, bottom left */
- cogl_set_source_color4ub (0x00, 0x00, 0xff, 0xff);
- cogl_rectangle (-0.5, 0, 0, -0.5);
+ cogl_pipeline_set_color4f (color, 0, 0, 1, 1);
+ cogl_framebuffer_draw_rectangle (offscreen, color, -0.5, 0, 0, -0.5);
/* white, bottom right */
- cogl_set_source_color4ub (0xff, 0xff, 0xff, 0xff);
- cogl_rectangle (0, 0, 0.5, -0.5);
+ cogl_pipeline_set_color4f (color, 1, 1, 1, 1);
+ cogl_framebuffer_draw_rectangle (offscreen, color, 0, 0, 0.5, -0.5);
- cogl_pop_framebuffer ();
+ cogl_object_unref (offscreen);
- cogl_set_source_texture (tex);
- cogl_rectangle (-1, 1, 1, -1);
+ textured = cogl_pipeline_new (test_ctx);
+ cogl_pipeline_set_layer_texture (textured, 0, tex);
+ cogl_framebuffer_draw_rectangle (test_fb, textured, -1, 1, 1, -1);
+ cogl_object_unref (textured);
cogl_object_unref (tex_2d);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (test_fb);
/* NB: The texture is drawn flipped horizontally and scaled to fit in the
* top right corner of the window. */
@@ -115,35 +115,38 @@ test_flush (TestState *state)
{
CoglTexture2D *tex_2d;
CoglTexture *tex;
- CoglOffscreen *offscreen;
- CoglColor clear_color;
+ CoglFramebuffer *offscreen;
int i;
for (i = 0; i < 3; i++)
{
+ CoglPipeline *red;
+
/* This tests that rendering to a framebuffer and then reading back
the contents of the texture will automatically flush the
journal */
- tex_2d = cogl_texture_2d_new_with_size (ctx,
+ tex_2d = cogl_texture_2d_new_with_size (test_ctx,
16, 16, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
NULL);
tex = COGL_TEXTURE (tex_2d);
- offscreen = cogl_offscreen_new_to_texture (tex);
-
- cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
+ offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_to_texture (tex));
- cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 255);
- cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
+ cogl_framebuffer_clear4f (offscreen, COGL_BUFFER_BIT_COLOR,
+ 0, 0, 0, 1);
- cogl_set_source_color4ub (255, 0, 0, 255);
- cogl_rectangle (-1, -1, 1, 1);
+ red = cogl_pipeline_new (test_ctx);
+ cogl_pipeline_set_color4f (red, 1, 0, 0, 1);
+ cogl_framebuffer_draw_rectangle (offscreen,
+ red,
+ -1, -1, 1, 1);
+ cogl_object_unref (red);
if (i == 0)
/* First time check using read pixels on the offscreen */
- test_utils_check_region (COGL_FRAMEBUFFER (offscreen),
+ test_utils_check_region (offscreen,
1, 1, 15, 15, 0xff0000ff);
else if (i == 1)
{
@@ -162,14 +165,16 @@ test_flush (TestState *state)
0xff0000ff);
}
- cogl_pop_framebuffer ();
-
if (i == 2)
{
+ CoglPipeline *textured = cogl_pipeline_new (test_ctx);
+ cogl_pipeline_set_layer_texture (textured, 0, tex);
/* Third time try drawing the texture to the screen */
- cogl_set_source_texture (tex);
- cogl_rectangle (-1, -1, 1, 1);
- test_utils_check_region (fb,
+ cogl_framebuffer_draw_rectangle (test_fb,
+ textured,
+ -1, -1, 1, 1);
+ cogl_object_unref (textured);
+ test_utils_check_region (test_fb,
2, 2, /* x/y */
state->fb_width - 4,
state->fb_height - 4,
@@ -186,15 +191,11 @@ test_offscreen (void)
{
TestState state;
- state.fb_width = cogl_framebuffer_get_width (fb);
- state.fb_height = cogl_framebuffer_get_height (fb);
+ state.fb_width = cogl_framebuffer_get_width (test_fb);
+ state.fb_height = cogl_framebuffer_get_height (test_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 a7a6f3c6..67f433ef 100644
--- a/tests/conform/test-path.c
+++ b/tests/conform/test-path.c
@@ -15,12 +15,17 @@ typedef struct _TestState
} TestState;
static void
-draw_path_at (int x, int y)
+draw_path_at (CoglPath *path, int x, int y)
{
- cogl_framebuffer_push_matrix (fb);
- cogl_framebuffer_translate (fb, x * BLOCK_SIZE, y * BLOCK_SIZE, 0.0f);
- cogl_path_fill ();
- cogl_framebuffer_pop_matrix (fb);
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb, x * BLOCK_SIZE, y * BLOCK_SIZE, 0.0f);
+
+ /* FIXME: we need some cogl_framebuffer_fill_path() api */
+ cogl_push_framebuffer (test_fb);
+ cogl_path_fill (path);
+ cogl_pop_framebuffer ();
+
+ cogl_framebuffer_pop_matrix (test_fb);
}
static void
@@ -33,7 +38,7 @@ 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_framebuffer_read_pixels (fb,
+ cogl_framebuffer_read_pixels (test_fb,
block_x * BLOCK_SIZE,
block_y * BLOCK_SIZE,
BLOCK_SIZE, BLOCK_SIZE,
@@ -64,110 +69,111 @@ check_block (int block_x, int block_y, int block_mask)
static void
paint (TestState *state)
{
- CoglHandle path_a, path_b, path_c;
+ CoglPath *path_a, *path_b, *path_c;
+ CoglPipeline *white = cogl_pipeline_new (test_ctx);
- cogl_set_source_color4ub (255, 255, 255, 255);
+ cogl_pipeline_set_color4f (white, 1, 1, 1, 1);
/* Create a path filling just a quarter of a block. It will use two
rectangles so that we have a sub path in the path */
- cogl_path_new ();
- cogl_path_rectangle (BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2,
+ path_a = cogl_path_new ();
+ cogl_path_rectangle (path_a,
+ BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2,
BLOCK_SIZE, BLOCK_SIZE);
- cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2,
+ cogl_path_rectangle (path_a,
+ BLOCK_SIZE / 2, BLOCK_SIZE / 2,
BLOCK_SIZE * 3 / 4, BLOCK_SIZE);
- path_a = cogl_handle_ref (cogl_get_path ());
- draw_path_at (0, 0);
+ draw_path_at (path_a, 0, 0);
/* Create another path filling the whole block */
- cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE);
- path_b = cogl_handle_ref (cogl_get_path ());
- draw_path_at (1, 0);
+ path_b = cogl_path_new ();
+ cogl_path_rectangle (path_b, 0, 0, BLOCK_SIZE, BLOCK_SIZE);
+ draw_path_at (path_b, 1, 0);
/* Draw the first path again */
- cogl_set_path (path_a);
- draw_path_at (2, 0);
+ draw_path_at (path_a, 2, 0);
/* Draw a copy of path a */
path_c = cogl_path_copy (path_a);
- cogl_set_path (path_c);
- draw_path_at (3, 0);
+ draw_path_at (path_c, 3, 0);
/* Add another rectangle to path a. We'll use line_to's instead of
cogl_rectangle so that we don't create another sub-path because
that is more likely to break the copy */
- cogl_set_path (path_a);
- cogl_path_line_to (0, BLOCK_SIZE / 2);
- cogl_path_line_to (0, 0);
- cogl_path_line_to (BLOCK_SIZE / 2, 0);
- cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2);
- draw_path_at (4, 0);
+ cogl_path_line_to (path_a, 0, BLOCK_SIZE / 2);
+ cogl_path_line_to (path_a, 0, 0);
+ cogl_path_line_to (path_a, BLOCK_SIZE / 2, 0);
+ cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
+ draw_path_at (path_a, 4, 0);
/* Draw the copy again. It should not have changed */
- cogl_set_path (path_c);
- draw_path_at (5, 0);
+ draw_path_at (path_c, 5, 0);
/* Add another rectangle to path c. It will be added in two halves,
one as an extension of the previous path and the other as a new
sub path */
- cogl_set_path (path_c);
- cogl_path_line_to (BLOCK_SIZE / 2, 0);
- cogl_path_line_to (BLOCK_SIZE * 3 / 4, 0);
- cogl_path_line_to (BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2);
- cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2);
- cogl_path_rectangle (BLOCK_SIZE * 3 / 4, 0, BLOCK_SIZE, BLOCK_SIZE / 2);
- draw_path_at (6, 0);
+ cogl_path_line_to (path_c, BLOCK_SIZE / 2, 0);
+ cogl_path_line_to (path_c, BLOCK_SIZE * 3 / 4, 0);
+ cogl_path_line_to (path_c, BLOCK_SIZE * 3 / 4, BLOCK_SIZE / 2);
+ cogl_path_line_to (path_c, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
+ cogl_path_rectangle (path_c,
+ BLOCK_SIZE * 3 / 4, 0, BLOCK_SIZE, BLOCK_SIZE / 2);
+ draw_path_at (path_c, 6, 0);
/* Draw the original path again. It should not have changed */
- cogl_set_path (path_a);
- draw_path_at (7, 0);
+ draw_path_at (path_a, 7, 0);
- cogl_handle_unref (path_a);
- cogl_handle_unref (path_b);
- cogl_handle_unref (path_c);
+ cogl_object_unref (path_a);
+ cogl_object_unref (path_b);
+ cogl_object_unref (path_c);
/* Draw a self-intersecting path. The part that intersects should be
inverted */
- cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE);
- cogl_path_line_to (0, BLOCK_SIZE / 2);
- cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2);
- cogl_path_line_to (BLOCK_SIZE / 2, 0);
- cogl_path_close ();
- draw_path_at (8, 0);
+ path_a = cogl_path_new ();
+ cogl_path_rectangle (path_a, 0, 0, BLOCK_SIZE, BLOCK_SIZE);
+ cogl_path_line_to (path_a, 0, BLOCK_SIZE / 2);
+ cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
+ cogl_path_line_to (path_a, BLOCK_SIZE / 2, 0);
+ cogl_path_close (path_a);
+ draw_path_at (path_a, 8, 0);
+ cogl_object_unref (path_a);
/* Draw two sub paths. Where the paths intersect it should be
inverted */
- cogl_path_rectangle (0, 0, BLOCK_SIZE, BLOCK_SIZE);
- cogl_path_rectangle (BLOCK_SIZE / 2, BLOCK_SIZE / 2, BLOCK_SIZE, BLOCK_SIZE);
- draw_path_at (9, 0);
+ path_a = cogl_path_new ();
+ cogl_path_rectangle (path_a, 0, 0, BLOCK_SIZE, BLOCK_SIZE);
+ cogl_path_rectangle (path_a,
+ BLOCK_SIZE / 2, BLOCK_SIZE / 2, BLOCK_SIZE, BLOCK_SIZE);
+ draw_path_at (path_a, 9, 0);
+ cogl_object_unref (path_a);
/* Draw a clockwise outer path */
- cogl_path_move_to (0, 0);
- cogl_path_line_to (BLOCK_SIZE, 0);
- cogl_path_line_to (BLOCK_SIZE, BLOCK_SIZE);
- cogl_path_line_to (0, BLOCK_SIZE);
- cogl_path_close ();
+ path_a = cogl_path_new ();
+ cogl_path_move_to (path_a, 0, 0);
+ cogl_path_line_to (path_a, BLOCK_SIZE, 0);
+ cogl_path_line_to (path_a, BLOCK_SIZE, BLOCK_SIZE);
+ cogl_path_line_to (path_a, 0, BLOCK_SIZE);
+ cogl_path_close (path_a);
/* Add a clockwise sub path in the upper left quadrant */
- cogl_path_move_to (0, 0);
- cogl_path_line_to (BLOCK_SIZE / 2, 0);
- cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2);
- cogl_path_line_to (0, BLOCK_SIZE / 2);
- cogl_path_close ();
+ cogl_path_move_to (path_a, 0, 0);
+ cogl_path_line_to (path_a, BLOCK_SIZE / 2, 0);
+ cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
+ cogl_path_line_to (path_a, 0, BLOCK_SIZE / 2);
+ cogl_path_close (path_a);
/* Add a counter-clockwise sub path in the upper right quadrant */
- cogl_path_move_to (BLOCK_SIZE / 2, 0);
- cogl_path_line_to (BLOCK_SIZE / 2, BLOCK_SIZE / 2);
- cogl_path_line_to (BLOCK_SIZE, BLOCK_SIZE / 2);
- cogl_path_line_to (BLOCK_SIZE, 0);
- cogl_path_close ();
+ cogl_path_move_to (path_a, BLOCK_SIZE / 2, 0);
+ cogl_path_line_to (path_a, BLOCK_SIZE / 2, BLOCK_SIZE / 2);
+ cogl_path_line_to (path_a, BLOCK_SIZE, BLOCK_SIZE / 2);
+ cogl_path_line_to (path_a, BLOCK_SIZE, 0);
+ cogl_path_close (path_a);
/* Retain the path for the next test */
- path_a = cogl_handle_ref (cogl_get_path ());
- draw_path_at (10, 0);
+ draw_path_at (path_a, 10, 0);
/* Draw the same path again with the other fill rule */
- cogl_set_path (path_a);
- cogl_path_set_fill_rule (COGL_PATH_FILL_RULE_NON_ZERO);
- draw_path_at (11, 0);
+ cogl_path_set_fill_rule (path_a, COGL_PATH_FILL_RULE_NON_ZERO);
+ draw_path_at (path_a, 11, 0);
- cogl_handle_unref (path_a);
+ cogl_object_unref (path_a);
}
static void
@@ -192,18 +198,14 @@ test_path (void)
{
TestState state;
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_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 da7b86b4..1f865695 100644
--- a/tests/conform/test-pipeline-uniforms.c
+++ b/tests/conform/test-pipeline-uniforms.c
@@ -20,88 +20,69 @@ typedef struct _TestState
int long_uniform_locations[LONG_ARRAY_SIZE];
} TestState;
-static const char
-color_source[] =
- "uniform float red, green, blue;\n"
- "\n"
- "void\n"
- "main ()\n"
- "{\n"
- " cogl_color_out = vec4 (red, green, blue, 1.0);\n"
- "}\n";
-
-static const char
-matrix_source[] =
- "uniform mat4 matrix_array[4];\n"
- "\n"
- "void\n"
- "main ()\n"
- "{\n"
+static const char *
+color_declarations = "uniform float red, green, blue;\n";
+
+static const char *
+color_fragment_source = " cogl_color_out = vec4 (red, green, blue, 1.0);\n";
+
+static const char *
+matrix_declarations = "uniform mat4 matrix_array[4];\n";
+
+static const char *
+matrix_fragment_source =
" vec4 color = vec4 (0.0, 0.0, 0.0, 1.0);\n"
" int i;\n"
"\n"
" for (i = 0; i < 4; i++)\n"
" color = matrix_array[i] * color;\n"
"\n"
- " cogl_color_out = color;\n"
- "}\n";
+ " cogl_color_out = color;\n";
-static const char
-vector_source[] =
+static const char *
+vector_declarations =
"uniform vec4 vector_array[2];\n"
- "uniform vec3 short_vector;\n"
- "\n"
- "void\n"
- "main ()\n"
- "{\n"
+ "uniform vec3 short_vector;\n";
+
+static const char *
+vector_fragment_source =
" cogl_color_out = (vector_array[0] +\n"
" vector_array[1] +\n"
- " vec4 (short_vector, 1.0));\n"
- "}\n";
+ " vec4 (short_vector, 1.0));\n";
-static const char
-int_source[] =
+static const char *
+int_declarations =
"uniform ivec4 vector_array[2];\n"
- "uniform int single_value;\n"
- "\n"
- "void\n"
- "main ()\n"
- "{\n"
+ "uniform int single_value;\n";
+
+static const char *
+int_fragment_source =
" cogl_color_out = (vec4 (vector_array[0]) +\n"
" vec4 (vector_array[1]) +\n"
- " vec4 (float (single_value), 0.0, 0.0, 255.0)) / 255.0;\n"
- "}\n";
+ " vec4 (float (single_value), 0.0, 0.0, 255.0)) / 255.0;\n";
-static const char
-long_source[] =
+static const char *
+long_declarations =
"uniform int long_array[" G_STRINGIFY (LONG_ARRAY_SIZE) "];\n"
- "const int last_index = " G_STRINGIFY (LONG_ARRAY_SIZE) " - 1;\n"
- "\n"
- "void\n"
- "main ()\n"
- "{\n"
- " cogl_color_out = vec4 (float (long_array[last_index]), 0.0, 0.0, 1.0);\n"
- "}\n";
+ "const int last_index = " G_STRINGIFY (LONG_ARRAY_SIZE) " - 1;\n";
+
+static const char *
+long_fragment_source =
+ " cogl_color_out = vec4 (float (long_array[last_index]), 0.0, 0.0, 1.0);\n";
static CoglPipeline *
-create_pipeline_for_shader (TestState *state, const char *shader_source)
+create_pipeline_for_shader (TestState *state,
+ const char *declarations,
+ const char *fragment_source)
{
- CoglPipeline *pipeline;
- CoglHandle shader;
- CoglHandle program;
-
- pipeline = cogl_pipeline_new (ctx);
-
- shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
- cogl_shader_source (shader, shader_source);
-
- program = cogl_create_program ();
- cogl_program_attach_shader (program, shader);
-
- cogl_pipeline_set_user_program (pipeline, program);
+ CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
+ CoglSnippet *snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
+ declarations,
+ NULL);
+ cogl_snippet_set_replace (snippet, fragment_source);
- cogl_handle_unref (shader);
- cogl_handle_unref (program);
+ cogl_pipeline_add_snippet (pipeline, snippet);
+ cogl_object_unref (snippet);
return pipeline;
}
@@ -111,7 +92,9 @@ init_state (TestState *state)
{
int uniform_location;
- state->pipeline_red = create_pipeline_for_shader (state, color_source);
+ state->pipeline_red = create_pipeline_for_shader (state,
+ color_declarations,
+ color_fragment_source);
uniform_location =
cogl_pipeline_get_uniform_location (state->pipeline_red, "red");
@@ -133,9 +116,15 @@ init_state (TestState *state)
cogl_pipeline_get_uniform_location (state->pipeline_blue, "blue");
cogl_pipeline_set_uniform_1f (state->pipeline_blue, uniform_location, 1.0f);
- state->matrix_pipeline = create_pipeline_for_shader (state, matrix_source);
- state->vector_pipeline = create_pipeline_for_shader (state, vector_source);
- state->int_pipeline = create_pipeline_for_shader (state, int_source);
+ state->matrix_pipeline = create_pipeline_for_shader (state,
+ matrix_declarations,
+ matrix_fragment_source);
+ state->vector_pipeline = create_pipeline_for_shader (state,
+ vector_declarations,
+ vector_fragment_source);
+ state->int_pipeline = create_pipeline_for_shader (state,
+ int_declarations,
+ int_fragment_source);
state->long_pipeline = NULL;
}
@@ -145,7 +134,9 @@ init_long_pipeline_state (TestState *state)
{
int i;
- state->long_pipeline = create_pipeline_for_shader (state, long_source);
+ state->long_pipeline = create_pipeline_for_shader (state,
+ long_declarations,
+ long_fragment_source);
/* This tries to lookup a large number of uniform names to make sure
that the bitmask of overriden uniforms flows over the size of a
@@ -177,7 +168,7 @@ destroy_state (TestState *state)
static void
paint_pipeline (CoglPipeline *pipeline, int pos)
{
- cogl_framebuffer_draw_rectangle (fb, pipeline,
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline,
pos * 10, 0, pos * 10 + 10, 10);
}
@@ -340,7 +331,7 @@ paint_long_pipeline (TestState *state)
static void
paint (TestState *state)
{
- cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
paint_color_pipelines (state);
paint_matrix_pipeline (state->matrix_pipeline);
@@ -351,7 +342,7 @@ paint (TestState *state)
static void
check_pos (int pos, guint32 color)
{
- test_utils_check_pixel (fb, pos * 10 + 5, 5, color);
+ test_utils_check_pixel (test_fb, pos * 10 + 5, 5, color);
}
static void
@@ -390,10 +381,10 @@ test_pipeline_uniforms (void)
init_state (&state);
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_fb),
-1,
100);
diff --git a/tests/conform/test-pipeline-user-matrix.c b/tests/conform/test-pipeline-user-matrix.c
index 6f1b34a0..7b4199ad 100644
--- a/tests/conform/test-pipeline-user-matrix.c
+++ b/tests/conform/test-pipeline-user-matrix.c
@@ -22,7 +22,8 @@ validate_result (TestState *state)
verify this by reading back the entire stage */
pixels = g_malloc (state->width * state->height * 4);
- cogl_framebuffer_read_pixels (fb, 0, 0, state->width, state->height,
+ cogl_framebuffer_read_pixels (test_fb,
+ 0, 0, state->width, state->height,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
(guint8 *)pixels);
@@ -56,17 +57,17 @@ paint (TestState *state)
CoglMatrix matrix;
GError *error = NULL;
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
state->width,
state->height,
-1,
100);
- cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
cogl_matrix_init_identity (&matrix);
- cogl_framebuffer_set_modelview_matrix (fb, &matrix);
+ cogl_framebuffer_set_modelview_matrix (test_fb, &matrix);
tex0 = cogl_texture_new_from_data (2, 2,
COGL_TEXTURE_NO_ATLAS,
@@ -81,7 +82,7 @@ paint (TestState *state)
6,
data1);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
/* Set the two textures as layers */
cogl_pipeline_set_layer_texture (pipeline, 0, tex0);
@@ -114,7 +115,7 @@ paint (TestState *state)
cogl_matrix_scale (&matrix, -1.0f, 1.0f, 1.0f);
cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix);
- cogl_framebuffer_draw_rectangle (fb,
+ cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
0, 0,
state->width, state->height);
@@ -129,8 +130,8 @@ test_pipeline_user_matrix (void)
{
TestState state;
- state.width = cogl_framebuffer_get_width (fb);
- state.height = cogl_framebuffer_get_height (fb);
+ state.width = cogl_framebuffer_get_width (test_fb);
+ state.height = cogl_framebuffer_get_height (test_fb);
paint (&state);
validate_result (&state);
diff --git a/tests/conform/test-pixel-buffer.c b/tests/conform/test-pixel-buffer.c
index 393f40a4..af4baef6 100644
--- a/tests/conform/test-pixel-buffer.c
+++ b/tests/conform/test-pixel-buffer.c
@@ -188,9 +188,9 @@ draw_frame (TestState *state)
/* Paint the textures */
for (i = 0; i < NB_TILES; i++)
{
- CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, state->tiles[i].texture);
- cogl_framebuffer_draw_rectangle (fb,
+ cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
state->tiles[i].x,
state->tiles[i].y,
@@ -205,7 +205,7 @@ static void
validate_tile (TestState *state,
TestTile *tile)
{
- test_utils_check_region (fb,
+ test_utils_check_region (test_fb,
tile->x, tile->y,
TILE_SIZE, TILE_SIZE,
(tile->color[0] << 24) |
@@ -242,20 +242,20 @@ test_pixel_buffer (void)
{ { 0x7e, 0xff, 0x7e, 0xff }, 0.0f, TILE_SIZE, NULL, NULL }
};
- state.width = cogl_framebuffer_get_width (fb);
- state.height = cogl_framebuffer_get_height (fb);
- cogl_framebuffer_orthographic (fb,
+ state.width = cogl_framebuffer_get_width (test_fb);
+ state.height = cogl_framebuffer_get_height (test_fb);
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
state.width,
state.height,
-1,
100);
- create_map_tile (ctx, &tiles[TILE_MAP]);
+ create_map_tile (test_ctx, &tiles[TILE_MAP]);
#if 0
- create_set_region_tile (shared_state->ctx, &tiles[TILE_SET_REGION]);
+ create_set_region_tile (test_ctx, &tiles[TILE_SET_REGION]);
#endif
- create_set_data_tile (ctx, &tiles[TILE_SET_DATA]);
+ create_set_data_tile (test_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 6f114d3e..84d5b321 100644
--- a/tests/conform/test-point-size.c
+++ b/tests/conform/test-point-size.c
@@ -1,4 +1,4 @@
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include "test-utils.h"
@@ -24,7 +24,7 @@ calc_coord_offset (int pos, int pos_index, int point_size)
}
static void
-verify_point_size (CoglFramebuffer *fb,
+verify_point_size (CoglFramebuffer *test_fb,
int x_pos,
int y_pos,
int point_size)
@@ -37,7 +37,7 @@ 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 (fb,
+ test_utils_check_pixel (test_fb,
calc_coord_offset (x_pos, x, point_size),
calc_coord_offset (y_pos, y, point_size),
expected_pixel);
@@ -47,18 +47,18 @@ verify_point_size (CoglFramebuffer *fb,
void
test_point_size (void)
{
- int fb_width = cogl_framebuffer_get_width (fb);
- int fb_height = cogl_framebuffer_get_height (fb);
+ int fb_width = cogl_framebuffer_get_width (test_fb);
+ int fb_height = cogl_framebuffer_get_height (test_fb);
int point_size;
int x_pos;
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0, /* x_1, y_1 */
fb_width, /* x_2 */
fb_height /* y_2 */,
-1, 100 /* near/far */);
- cogl_framebuffer_clear4f (fb,
+ cogl_framebuffer_clear4f (test_fb,
COGL_BUFFER_BIT_COLOR,
1.0f, 0.0f, 0.0f, 1.0f);
@@ -68,18 +68,18 @@ test_point_size (void)
point_size >= 4;
x_pos += POINT_BOX_SIZE, point_size /= 2)
{
- CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
CoglVertexP2 point = { x_pos + POINT_BOX_SIZE / 2,
POINT_BOX_SIZE / 2 };
CoglPrimitive *prim =
- cogl_primitive_new_p2 (ctx,
+ cogl_primitive_new_p2 (test_ctx,
COGL_VERTICES_MODE_POINTS,
1, /* n_vertices */
&point);
cogl_pipeline_set_point_size (pipeline, point_size);
cogl_pipeline_set_color4ub (pipeline, 0, 255, 0, 255);
- cogl_framebuffer_draw_primitive (fb,
+ cogl_framebuffer_draw_primitive (test_fb,
pipeline,
prim);
@@ -91,7 +91,7 @@ test_point_size (void)
for (x_pos = 0, point_size = MAX_POINT_SIZE;
point_size >= 4;
x_pos += POINT_BOX_SIZE, point_size /= 2)
- verify_point_size (fb,
+ verify_point_size (test_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 d8c450e5..fd1b698e 100644
--- a/tests/conform/test-point-sprite.c
+++ b/tests/conform/test-point-sprite.c
@@ -1,4 +1,4 @@
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include "test-utils.h"
@@ -21,25 +21,25 @@ tex_data[3 * 2 * 2] =
void
test_point_sprite (void)
{
- int fb_width = cogl_framebuffer_get_width (fb);
- int fb_height = cogl_framebuffer_get_height (fb);
+ int fb_width = cogl_framebuffer_get_width (test_fb);
+ int fb_height = cogl_framebuffer_get_height (test_fb);
CoglPrimitive *prim;
GError *error = NULL;
CoglTexture2D *tex_2d;
CoglPipeline *pipeline, *solid_pipeline;
gboolean res;
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0, /* x_1, y_1 */
fb_width, /* x_2 */
fb_height /* y_2 */,
-1, 100 /* near/far */);
- cogl_framebuffer_clear4f (fb,
+ cogl_framebuffer_clear4f (test_fb,
COGL_BUFFER_BIT_COLOR,
1.0f, 1.0f, 1.0f, 1.0f);
- tex_2d = cogl_texture_2d_new_from_data (ctx,
+ tex_2d = cogl_texture_2d_new_from_data (test_ctx,
2, 2, /* width/height */
COGL_PIXEL_FORMAT_RGB_888,
COGL_PIXEL_FORMAT_ANY,
@@ -49,7 +49,7 @@ test_point_sprite (void)
g_assert (tex_2d != NULL);
g_assert (error == NULL);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex_2d));
res = cogl_pipeline_set_layer_point_sprite_coords_enabled (pipeline,
@@ -67,12 +67,12 @@ test_point_sprite (void)
COGL_PIPELINE_FILTER_NEAREST);
cogl_pipeline_set_point_size (pipeline, POINT_SIZE);
- prim = cogl_primitive_new_p2t2 (ctx,
+ prim = cogl_primitive_new_p2t2 (test_ctx,
COGL_VERTICES_MODE_POINTS,
1, /* n_vertices */
&point);
- cogl_framebuffer_draw_primitive (fb,
+ cogl_framebuffer_draw_primitive (test_fb,
pipeline,
prim);
@@ -85,34 +85,34 @@ test_point_sprite (void)
/* enable */
FALSE,
&error);
- cogl_framebuffer_push_matrix (fb);
- cogl_framebuffer_translate (fb,
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb,
POINT_SIZE * 2, /* x */
0.0f, /* y */
0.0f /* z */);
- cogl_framebuffer_draw_primitive (fb,
+ cogl_framebuffer_draw_primitive (test_fb,
solid_pipeline,
prim);
- cogl_framebuffer_pop_matrix (fb);
+ cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (prim);
cogl_object_unref (solid_pipeline);
cogl_object_unref (pipeline);
cogl_object_unref (tex_2d);
- test_utils_check_pixel (fb,
+ test_utils_check_pixel (test_fb,
POINT_SIZE - POINT_SIZE / 4,
POINT_SIZE - POINT_SIZE / 4,
0x0000ffff);
- test_utils_check_pixel (fb,
+ test_utils_check_pixel (test_fb,
POINT_SIZE + POINT_SIZE / 4,
POINT_SIZE - POINT_SIZE / 4,
0x00ff00ff);
- test_utils_check_pixel (fb,
+ test_utils_check_pixel (test_fb,
POINT_SIZE - POINT_SIZE / 4,
POINT_SIZE + POINT_SIZE / 4,
0x00ffffff);
- test_utils_check_pixel (fb,
+ test_utils_check_pixel (test_fb,
POINT_SIZE + POINT_SIZE / 4,
POINT_SIZE + POINT_SIZE / 4,
0xff0000ff);
@@ -120,7 +120,7 @@ test_point_sprite (void)
/* 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 (fb,
+ test_utils_check_region (test_fb,
POINT_SIZE * 3 - POINT_SIZE / 2 + 1,
POINT_SIZE - POINT_SIZE / 2 + 1,
POINT_SIZE - 2, POINT_SIZE - 2,
diff --git a/tests/conform/test-premult.c b/tests/conform/test-premult.c
index b8fb6fd4..8344cfa0 100644
--- a/tests/conform/test-premult.c
+++ b/tests/conform/test-premult.c
@@ -46,7 +46,7 @@ make_texture (guint32 color,
CoglTexture2D *tex_2d;
guchar *tex_data = gen_tex_data (color);
- tex_2d = cogl_texture_2d_new_from_data (ctx,
+ tex_2d = cogl_texture_2d_new_from_data (test_ctx,
QUAD_WIDTH,
QUAD_WIDTH,
src_format,
@@ -79,59 +79,40 @@ set_region (CoglTexture *tex,
static void
check_texture (CoglPipeline *pipeline,
- CoglHandle material,
int x,
int y,
CoglTexture *tex,
guint32 expected_result)
{
- /* Legacy */
- cogl_push_framebuffer (fb);
- cogl_material_set_layer (material, 0, tex);
- cogl_set_source (material);
- cogl_rectangle (x * QUAD_WIDTH,
- y * QUAD_WIDTH,
- x * QUAD_WIDTH + QUAD_WIDTH,
- y * QUAD_WIDTH + QUAD_WIDTH);
- test_utils_check_pixel (fb, x * QUAD_WIDTH + QUAD_WIDTH / 2, y * QUAD_WIDTH + QUAD_WIDTH / 2, expected_result);
- cogl_pop_framebuffer ();
-
- /* New API */
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex));
- cogl_framebuffer_draw_rectangle (fb, pipeline,
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline,
x * QUAD_WIDTH,
y * QUAD_WIDTH,
x * QUAD_WIDTH + QUAD_WIDTH,
y * QUAD_WIDTH + QUAD_WIDTH);
- test_utils_check_pixel (fb, x * QUAD_WIDTH + QUAD_WIDTH / 2, y * QUAD_WIDTH + QUAD_WIDTH / 2, expected_result);
+ test_utils_check_pixel (test_fb,
+ x * QUAD_WIDTH + QUAD_WIDTH / 2,
+ y * QUAD_WIDTH + QUAD_WIDTH / 2,
+ expected_result);
}
void
test_premult (void)
{
CoglPipeline *pipeline;
- CoglHandle material;
CoglTexture *tex;
- cogl_framebuffer_orthographic (fb, 0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_orthographic (test_fb, 0, 0,
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_fb),
-1,
100);
- cogl_framebuffer_clear4f (fb,
+ cogl_framebuffer_clear4f (test_fb,
COGL_BUFFER_BIT_COLOR,
1.0f, 1.0f, 1.0f, 1.0f);
- /* Legacy */
- material = cogl_material_new ();
- cogl_material_set_blend (material,
- "RGBA = ADD (SRC_COLOR, 0)", NULL);
- cogl_material_set_layer_combine (material, 0,
- "RGBA = REPLACE (TEXTURE)", NULL);
-
- /* New API */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_blend (pipeline,
"RGBA = ADD (SRC_COLOR, 0)", NULL);
cogl_pipeline_set_layer_combine (pipeline, 0,
@@ -145,7 +126,7 @@ test_premult (void)
tex = make_texture (0xff00ff80,
COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
COGL_PIXEL_FORMAT_RGBA_8888); /* internal format */
- check_texture (pipeline, material, 0, 0, /* position */
+ check_texture (pipeline, 0, 0, /* position */
tex,
0xff00ff80); /* expected */
@@ -158,7 +139,7 @@ test_premult (void)
tex = make_texture (0xff00ff80,
COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
COGL_PIXEL_FORMAT_RGBA_8888_PRE); /* internal format */
- check_texture (pipeline, material, 1, 0, /* position */
+ check_texture (pipeline, 1, 0, /* position */
tex,
0x80008080); /* expected */
@@ -172,7 +153,7 @@ test_premult (void)
tex = make_texture (0xff00ff80,
COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
COGL_PIXEL_FORMAT_ANY); /* internal format */
- check_texture (pipeline, material, 2, 0, /* position */
+ check_texture (pipeline, 2, 0, /* position */
tex,
0x80008080); /* expected */
@@ -186,7 +167,7 @@ test_premult (void)
tex = make_texture (0x80008080,
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
COGL_PIXEL_FORMAT_RGBA_8888_PRE); /* internal format */
- check_texture (pipeline, material, 3, 0, /* position */
+ check_texture (pipeline, 3, 0, /* position */
tex,
0x80008080); /* expected */
@@ -199,7 +180,7 @@ test_premult (void)
tex = make_texture (0x80008080,
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
COGL_PIXEL_FORMAT_RGBA_8888); /* internal format */
- check_texture (pipeline, material, 4, 0, /* position */
+ check_texture (pipeline, 4, 0, /* position */
tex,
0xff00ff80); /* expected */
@@ -213,7 +194,7 @@ test_premult (void)
tex = make_texture (0x80008080,
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
COGL_PIXEL_FORMAT_ANY); /* internal format */
- check_texture (pipeline, material, 5, 0, /* position */
+ check_texture (pipeline, 5, 0, /* position */
tex,
0x80008080); /* expected */
@@ -230,7 +211,7 @@ test_premult (void)
if (cogl_test_verbose ())
g_print ("set_region (0xff00ff80, RGBA_8888)\n");
set_region (tex, 0xff00ff80, COGL_PIXEL_FORMAT_RGBA_8888);
- check_texture (pipeline, material, 6, 0, /* position */
+ check_texture (pipeline, 6, 0, /* position */
tex,
0xff00ff80); /* expected */
@@ -246,7 +227,7 @@ test_premult (void)
if (cogl_test_verbose ())
g_print ("set_region (0x80008080, RGBA_8888_PRE)\n");
set_region (tex, 0x80008080, COGL_PIXEL_FORMAT_RGBA_8888_PRE);
- check_texture (pipeline, material, 7, 0, /* position */
+ check_texture (pipeline, 7, 0, /* position */
tex,
0xff00ff80); /* expected */
@@ -261,7 +242,7 @@ test_premult (void)
if (cogl_test_verbose ())
g_print ("set_region (0x80008080, RGBA_8888_PRE)\n");
set_region (tex, 0x80008080, COGL_PIXEL_FORMAT_RGBA_8888_PRE);
- check_texture (pipeline, material, 8, 0, /* position */
+ check_texture (pipeline, 8, 0, /* position */
tex,
0x80008080); /* expected */
@@ -279,7 +260,7 @@ test_premult (void)
if (cogl_test_verbose ())
g_print ("set_region (0xff00ff80, RGBA_8888)\n");
set_region (tex, 0xff00ff80, COGL_PIXEL_FORMAT_RGBA_8888);
- check_texture (pipeline, material, 9, 0, /* position */
+ check_texture (pipeline, 9, 0, /* position */
tex,
0x80008080); /* expected */
diff --git a/tests/conform/test-primitive.c b/tests/conform/test-primitive.c
index 3dc58208..9b6eb2a2 100644
--- a/tests/conform/test-primitive.c
+++ b/tests/conform/test-primitive.c
@@ -176,7 +176,7 @@ test_paint (TestState *state)
COGL_PIXEL_FORMAT_ANY,
6, /* rowstride */
tex_data);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline,
(PRIM_COLOR >> 24) & 0xff,
(PRIM_COLOR >> 16) & 0xff,
@@ -190,14 +190,14 @@ test_paint (TestState *state)
CoglPrimitive *prim;
guint32 expected_color = PRIM_COLOR;
- prim = test_prim_funcs[i] (ctx, &expected_color);
+ prim = test_prim_funcs[i] (test_ctx, &expected_color);
- 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);
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb, i * 10, 0, 0);
+ cogl_framebuffer_draw_primitive (test_fb, pipeline, prim);
+ cogl_framebuffer_pop_matrix (test_fb);
- test_utils_check_pixel (fb, i * 10 + 2, 2, expected_color);
+ test_utils_check_pixel (test_fb, i * 10 + 2, 2, expected_color);
cogl_object_unref (prim);
}
@@ -234,7 +234,7 @@ test_copy (TestState *state)
{
static const guint16 indices_data[2] = { 1, 2 };
CoglAttributeBuffer *buffer =
- cogl_attribute_buffer_new (ctx, 100, NULL);
+ cogl_attribute_buffer_new (test_ctx, 100, NULL);
CoglAttribute *attributes[N_ATTRIBS];
CoglAttribute *attributes_a[N_ATTRIBS], *attributes_b[N_ATTRIBS];
CoglAttribute **p;
@@ -259,7 +259,7 @@ test_copy (TestState *state)
attributes,
N_ATTRIBS);
- indices = cogl_indices_new (ctx,
+ indices = cogl_indices_new (test_ctx,
COGL_INDICES_TYPE_UNSIGNED_SHORT,
indices_data,
2 /* n_indices */);
@@ -316,10 +316,10 @@ test_primitive (void)
{
TestState state;
- state.fb_width = cogl_framebuffer_get_width (fb);
- state.fb_height = cogl_framebuffer_get_height (fb);
+ state.fb_width = cogl_framebuffer_get_width (test_fb);
+ state.fb_height = cogl_framebuffer_get_height (test_fb);
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
state.fb_width,
state.fb_height,
diff --git a/tests/conform/test-read-texture-formats.c b/tests/conform/test-read-texture-formats.c
index 7161d0f7..92aa6d3e 100644
--- a/tests/conform/test-read-texture-formats.c
+++ b/tests/conform/test-read-texture-formats.c
@@ -1,4 +1,4 @@
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include <stdarg.h>
#include "test-utils.h"
@@ -146,7 +146,7 @@ test_read_texture_formats (void)
{
CoglTexture2D *tex_2d;
- tex_2d = cogl_texture_2d_new_from_data (ctx,
+ tex_2d = cogl_texture_2d_new_from_data (test_ctx,
1, 1, /* width / height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index cf6d7788..ca80063d 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -29,7 +29,7 @@ create_texture_pipeline (TestState *state)
8, /* rowstride */
tex_data);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
@@ -49,7 +49,7 @@ simple_fragment_snippet (TestState *state)
CoglSnippet *snippet;
/* Simple fragment snippet */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255);
@@ -59,11 +59,11 @@ simple_fragment_snippet (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 5, 5, 0xffff00ff);
+ test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff);
}
static void
@@ -73,7 +73,7 @@ simple_vertex_snippet (TestState *state)
CoglSnippet *snippet;
/* Simple vertex snippet */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255);
@@ -83,11 +83,11 @@ simple_vertex_snippet (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 10, 0, 20, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 10, 0, 20, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 15, 5, 0xff00ffff);
+ test_utils_check_pixel (test_fb, 15, 5, 0xff00ffff);
}
static void
@@ -99,7 +99,7 @@ shared_uniform (TestState *state)
/* Snippets sharing a uniform across the vertex and fragment
hooks */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
location = cogl_pipeline_get_uniform_location (pipeline, "a_value");
cogl_pipeline_set_uniform_1f (pipeline, location, 0.25f);
@@ -117,13 +117,13 @@ shared_uniform (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_rectangle (fb,
+ cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
20, 0, 30, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 25, 5, 0xff0080ff);
+ test_utils_check_pixel (test_fb, 25, 5, 0xff0080ff);
}
static void
@@ -135,7 +135,7 @@ lots_snippets (TestState *state)
int i;
/* Lots of snippets on one pipeline */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255);
@@ -163,11 +163,11 @@ lots_snippets (TestState *state)
g_free (declarations);
}
- cogl_framebuffer_draw_rectangle (fb, pipeline, 30, 0, 40, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 30, 0, 40, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 35, 5, 0x19334cff);
+ test_utils_check_pixel (test_fb, 35, 5, 0x19334cff);
}
static void
@@ -178,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 (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 255, 255, 255);
@@ -189,11 +189,11 @@ shared_variable_pre_post (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 40, 0, 50, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 40, 0, 50, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 45, 5, 0xff0000ff);
+ test_utils_check_pixel (test_fb, 45, 5, 0xff0000ff);
}
static void
@@ -214,20 +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 (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 50, 0, 60, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 50, 0, 60, 10);
cogl_object_unref (pipeline);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 60, 0, 70, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 60, 0, 70, 10);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (fb, 55, 5, 0x00ff00ff);
- test_utils_check_pixel (fb, 65, 5, 0x00ff00ff);
+ test_utils_check_pixel (test_fb, 55, 5, 0x00ff00ff);
+ test_utils_check_pixel (test_fb, 65, 5, 0x00ff00ff);
}
static void
@@ -247,14 +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 (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 70, 0, 80, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 70, 0, 80, 10);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (fb, 75, 5, 0x808000ff);
+ test_utils_check_pixel (test_fb, 75, 5, 0x808000ff);
}
static void
@@ -273,7 +273,7 @@ test_texture_lookup_hook (TestState *state)
pipeline = create_texture_pipeline (state);
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
80, 0, 90, 10,
0, 0, 0, 0);
@@ -281,7 +281,7 @@ test_texture_lookup_hook (TestState *state)
cogl_object_unref (snippet);
- test_utils_check_pixel (fb, 85, 5, 0x00ffffff);
+ test_utils_check_pixel (test_fb, 85, 5, 0x00ffffff);
}
static void
@@ -302,12 +302,12 @@ test_multiple_samples (TestState *state)
pipeline = create_texture_pipeline (state);
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10);
cogl_object_unref (pipeline);
cogl_object_unref (snippet);
- test_utils_check_pixel (fb, 5, 5, 0xffff00ff);
+ test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff);
}
static void
@@ -322,7 +322,7 @@ test_replace_lookup_hook (TestState *state)
pipeline = create_texture_pipeline (state);
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
90, 0, 100, 10,
0, 0, 0, 0);
@@ -330,7 +330,7 @@ test_replace_lookup_hook (TestState *state)
cogl_object_unref (snippet);
- test_utils_check_pixel (fb, 95, 5, 0x0000ffff);
+ test_utils_check_pixel (test_fb, 95, 5, 0x0000ffff);
}
static void
@@ -355,13 +355,13 @@ test_replace_snippet (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
100, 0, 110, 10,
0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 105, 5, 0xff0000ff);
+ test_utils_check_pixel (test_fb, 105, 5, 0xff0000ff);
}
static void
@@ -387,13 +387,13 @@ test_replace_fragment_layer (TestState *state)
"A = REPLACE(PREVIOUS)",
NULL);
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
110, 0, 120, 10,
0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 115, 5, 0xff00ffff);
+ test_utils_check_pixel (test_fb, 115, 5, 0xff00ffff);
}
static void
@@ -403,7 +403,7 @@ test_modify_fragment_layer (TestState *state)
CoglSnippet *snippet;
/* Test modifying the fragment layer code */
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_uniform_1f (pipeline,
cogl_pipeline_get_uniform_location (pipeline,
@@ -416,13 +416,13 @@ test_modify_fragment_layer (TestState *state)
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
120, 0, 130, 10,
0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 125, 5, 0xff80ffff);
+ test_utils_check_pixel (test_fb, 125, 5, 0xff80ffff);
}
static void
@@ -445,13 +445,13 @@ test_modify_vertex_layer (TestState *state)
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
130, 0, 140, 10,
0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 135, 5, 0xffff00ff);
+ test_utils_check_pixel (test_fb, 135, 5, 0xffff00ff);
}
static void
@@ -475,13 +475,13 @@ test_replace_vertex_layer (TestState *state)
cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
140, 0, 150, 10,
0, 0, 0, 0);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 145, 5, 0x00ff00ff);
+ test_utils_check_pixel (test_fb, 145, 5, 0x00ff00ff);
}
static void
@@ -497,7 +497,7 @@ test_vertex_transform_hook (TestState *state)
cogl_matrix_init_identity (&identity_matrix);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 255, 255);
@@ -510,7 +510,7 @@ test_vertex_transform_hook (TestState *state)
cogl_object_unref (snippet);
/* Copy the current projection matrix to a uniform */
- cogl_framebuffer_get_projection_matrix (fb, &matrix);
+ cogl_framebuffer_get_projection_matrix (test_fb, &matrix);
location = cogl_pipeline_get_uniform_location (pipeline, "pmat");
cogl_pipeline_set_uniform_matrix (pipeline,
location,
@@ -521,15 +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_framebuffer_set_projection_matrix (fb, &identity_matrix);
+ cogl_framebuffer_set_projection_matrix (test_fb, &identity_matrix);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 150, 0, 160, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 150, 0, 160, 10);
cogl_object_unref (pipeline);
/* Restore the projection matrix */
- cogl_framebuffer_set_projection_matrix (fb, &matrix);
+ cogl_framebuffer_set_projection_matrix (test_fb, &matrix);
- test_utils_check_pixel (fb, 155, 5, 0xff00ffff);
+ test_utils_check_pixel (test_fb, 155, 5, 0xff00ffff);
}
static void
@@ -545,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 (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255);
@@ -564,10 +564,10 @@ test_snippet_order (TestState *state)
cogl_pipeline_add_snippet (pipeline, snippet);
cogl_object_unref (snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 160, 0, 170, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 160, 0, 170, 10);
cogl_object_unref (pipeline);
- test_utils_check_pixel (fb, 165, 5, 0x80ff00ff);
+ test_utils_check_pixel (test_fb, 165, 5, 0x80ff00ff);
}
static void
@@ -588,24 +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 (ctx, 0xff0000ff);
- tex2 = test_utils_create_color_texture (ctx, 0x00ff00ff);
+ tex1 = test_utils_create_color_texture (test_ctx, 0xff0000ff);
+ tex2 = test_utils_create_color_texture (test_ctx, 0x00ff00ff);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 100, tex1);
cogl_pipeline_set_layer_texture (pipeline, 200, tex2);
cogl_pipeline_add_snippet (pipeline, snippet);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
+ cogl_framebuffer_draw_rectangle (test_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 (fb, 5, 5, 0xffff00ff);
+ test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff);
}
static void
@@ -680,7 +680,7 @@ run_tests (TestState *state)
for (i = 0; i < G_N_ELEMENTS (tests); i++)
{
- cogl_framebuffer_clear4f (fb,
+ cogl_framebuffer_clear4f (test_fb,
COGL_BUFFER_BIT_COLOR,
0, 0, 0, 1);
@@ -696,10 +696,10 @@ test_snippets (void)
{
TestState state;
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_fb),
-1,
100);
diff --git a/tests/conform/test-sparse-pipeline.c b/tests/conform/test-sparse-pipeline.c
index a88f50b5..2b618dc5 100644
--- a/tests/conform/test-sparse-pipeline.c
+++ b/tests/conform/test-sparse-pipeline.c
@@ -1,4 +1,4 @@
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include <string.h>
#include "test-utils.h"
@@ -15,17 +15,17 @@ test_sparse_layer_combine (TestState *state)
CoglPipeline *pipeline;
CoglTexture *tex1, *tex2;
- cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ cogl_framebuffer_clear4f (test_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 (ctx, 0xff0000ff);
- tex2 = test_utils_create_color_texture (ctx, 0x00ff00ff);
+ tex1 = test_utils_create_color_texture (test_ctx, 0xff0000ff);
+ tex2 = test_utils_create_color_texture (test_ctx, 0x00ff00ff);
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 50, tex1);
cogl_pipeline_set_layer_texture (pipeline, 100, tex2);
@@ -33,9 +33,9 @@ test_sparse_layer_combine (TestState *state)
"RGBA = ADD(TEXTURE_50, TEXTURE_100)",
NULL);
- cogl_framebuffer_draw_rectangle (fb, pipeline, -1, -1, 1, 1);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, -1, -1, 1, 1);
- test_utils_check_pixel (fb, 2, 2, 0xffff00ff);
+ test_utils_check_pixel (test_fb, 2, 2, 0xffff00ff);
cogl_object_unref (pipeline);
cogl_object_unref (tex1);
@@ -47,8 +47,8 @@ test_sparse_pipeline (void)
{
TestState state;
- state.fb_width = cogl_framebuffer_get_width (fb);
- state.fb_height = cogl_framebuffer_get_height (fb);
+ state.fb_width = cogl_framebuffer_get_width (test_fb);
+ state.fb_height = cogl_framebuffer_get_height (test_fb);
test_sparse_layer_combine (&state);
diff --git a/tests/conform/test-sub-texture.c b/tests/conform/test-sub-texture.c
index 261f4d72..ca2cca4a 100644
--- a/tests/conform/test-sub-texture.c
+++ b/tests/conform/test-sub-texture.c
@@ -55,7 +55,7 @@ create_source (TestState *state)
}
}
- tex = cogl_texture_2d_new_from_data (ctx,
+ tex = cogl_texture_2d_new_from_data (test_ctx,
SOURCE_SIZE, SOURCE_SIZE,
COGL_PIXEL_FORMAT_RGBA_8888,
COGL_PIXEL_FORMAT_ANY,
@@ -87,7 +87,7 @@ create_test_texture (TestState *state)
*(p++) = 255;
}
- tex = cogl_texture_2d_new_from_data (ctx,
+ tex = cogl_texture_2d_new_from_data (test_ctx,
256, 256,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_ANY,
@@ -106,10 +106,10 @@ paint (TestState *state)
{
CoglTexture2D *full_texture;
CoglSubTexture *sub_texture, *sub_sub_texture;
- CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
/* Create a sub texture of the bottom right quarter of the texture */
- sub_texture = cogl_sub_texture_new (ctx,
+ sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (state->tex),
DIVISION_WIDTH,
DIVISION_HEIGHT,
@@ -119,21 +119,21 @@ paint (TestState *state)
/* Paint it */
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_object_unref (sub_texture);
- cogl_framebuffer_draw_rectangle (fb, pipeline,
+ cogl_framebuffer_draw_rectangle (test_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 (ctx,
+ sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (state->tex),
0, 0,
SOURCE_SIZE,
DIVISION_HEIGHT);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_object_unref (sub_texture);
- cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
+ cogl_framebuffer_draw_textured_rectangle (test_fb, pipeline,
0.0f,
SOURCE_SIZE,
SOURCE_SIZE * 2.0f,
@@ -143,17 +143,17 @@ paint (TestState *state)
/* Create a sub texture of a sub texture */
full_texture = create_test_texture (state);
- sub_texture = cogl_sub_texture_new (ctx,
+ sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (full_texture),
20, 10, 30, 20);
cogl_object_unref (full_texture);
- sub_sub_texture = cogl_sub_texture_new (ctx,
+ sub_sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (sub_texture),
20, 10, 10, 10);
cogl_object_unref (sub_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,
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline,
0.0f, SOURCE_SIZE * 2.0f,
10.0f, SOURCE_SIZE * 2.0f + 10.0f);
@@ -165,7 +165,7 @@ validate_part (int xpos, int ypos,
int width, int height,
guint32 color)
{
- test_utils_check_region (fb,
+ test_utils_check_region (test_fb,
xpos + TEST_INSET,
ypos + TEST_INSET,
width - TEST_INSET - 2,
@@ -221,7 +221,7 @@ validate_result (TestState *state)
/* Sub sub texture */
p = texture_data = g_malloc (10 * 10 * 4);
cogl_flush ();
- cogl_framebuffer_read_pixels (fb,
+ cogl_framebuffer_read_pixels (test_fb,
0, SOURCE_SIZE * 2, 10, 10,
COGL_PIXEL_FORMAT_RGBA_8888,
p);
@@ -235,7 +235,7 @@ validate_result (TestState *state)
g_free (texture_data);
/* Try reading back the texture data */
- sub_texture = cogl_sub_texture_new (ctx,
+ sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (state->tex),
SOURCE_SIZE / 4,
SOURCE_SIZE / 4,
@@ -266,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 (ctx,
+ sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (test_tex),
64, 64, 128, 128);
/* Update the center half of the sub texture */
@@ -314,10 +314,10 @@ test_sub_texture (void)
state.tex = create_source (&state);
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0,
- cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb),
+ cogl_framebuffer_get_width (test_fb),
+ cogl_framebuffer_get_height (test_fb),
-1,
100);
diff --git a/tests/conform/test-texture-3d.c b/tests/conform/test-texture-3d.c
index 777d0230..fb9d3f55 100644
--- a/tests/conform/test-texture-3d.c
+++ b/tests/conform/test-texture-3d.c
@@ -1,4 +1,4 @@
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include <string.h>
#include "test-utils.h"
@@ -73,8 +73,8 @@ create_texture_3d (CoglContext *context)
static void
draw_frame (TestState *state)
{
- CoglTexture *tex = COGL_TEXTURE (create_texture_3d (ctx));
- CoglPipeline *pipeline = cogl_pipeline_new (ctx);
+ CoglTexture *tex = COGL_TEXTURE (create_texture_3d (test_ctx));
+ CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
typedef struct { float x, y, s, t, r; } Vert;
CoglPrimitive *primitive;
CoglAttributeBuffer *attribute_buffer;
@@ -91,7 +91,7 @@ draw_frame (TestState *state)
/* Render the texture repeated horizontally twice using a regular
cogl rectangle. This should end up with the r texture coordinates
as zero */
- cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
+ cogl_framebuffer_draw_textured_rectangle (test_fb, pipeline,
0.0f, 0.0f, TEX_WIDTH * 2, TEX_HEIGHT,
0.0f, 0.0f, 2.0f, 1.0f);
@@ -131,7 +131,7 @@ draw_frame (TestState *state)
v++;
}
- attribute_buffer = cogl_attribute_buffer_new (ctx,
+ attribute_buffer = cogl_attribute_buffer_new (test_ctx,
4 * TEX_DEPTH * sizeof (Vert),
verts);
attributes[0] = cogl_attribute_new (attribute_buffer,
@@ -152,11 +152,11 @@ draw_frame (TestState *state)
2 /* n_attributes */);
cogl_primitive_set_indices (primitive,
- cogl_get_rectangle_indices (ctx,
+ cogl_get_rectangle_indices (test_ctx,
TEX_DEPTH),
6 * TEX_DEPTH);
- cogl_framebuffer_draw_primitive (fb, pipeline, primitive);
+ cogl_framebuffer_draw_primitive (test_fb, pipeline, primitive);
g_free (verts);
@@ -174,7 +174,7 @@ 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 (fb,
+ test_utils_check_pixel_rgb (test_fb,
block_x * TEX_WIDTH + x,
block_y * TEX_HEIGHT + y,
255 - x * 8,
@@ -201,20 +201,20 @@ test_multi_texture (TestState *state)
CoglTexture2D *tex_2d;
guint8 tex_data[4];
- cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ cogl_framebuffer_clear4f (test_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 (ctx);
+ pipeline = cogl_pipeline_new (test_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 (ctx,
+ tex_2d = cogl_texture_2d_new_from_data (test_ctx,
1, 1, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
@@ -227,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 (ctx,
+ tex_3d = cogl_texture_3d_new_from_data (test_ctx,
1, 1, 1, /* width/height/depth */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
@@ -244,9 +244,9 @@ test_multi_texture (TestState *state)
"RGBA = ADD(TEXTURE_0, TEXTURE_1)",
NULL);
- cogl_framebuffer_draw_rectangle (fb, pipeline, 0, 0, 10, 10);
+ cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10);
- test_utils_check_pixel (fb, 5, 5, 0xffff00ff);
+ test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff);
cogl_object_unref (tex_2d);
cogl_object_unref (tex_3d);
@@ -258,14 +258,14 @@ test_texture_3d (void)
{
/* Check whether GL supports the rectangle extension. If not we'll
just assume the test passes */
- if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
+ if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_3D))
{
TestState state;
- state.fb_width = cogl_framebuffer_get_width (fb);
- state.fb_height = cogl_framebuffer_get_height (fb);
+ state.fb_width = cogl_framebuffer_get_width (test_fb);
+ state.fb_height = cogl_framebuffer_get_height (test_fb);
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_fb,
0, 0, /* x_1, y_1 */
state.fb_width, /* x_2 */
state.fb_height /* y_2 */,
diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c
index 22591736..97f06fab 100644
--- a/tests/conform/test-utils.c
+++ b/tests/conform/test-utils.c
@@ -1,4 +1,3 @@
-#define COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl/cogl.h>
#include <stdlib.h>
@@ -9,8 +8,8 @@
static gboolean cogl_test_is_verbose;
-CoglContext *ctx;
-CoglFramebuffer *fb;
+CoglContext *test_ctx;
+CoglFramebuffer *test_fb;
void
test_utils_init (TestFlags flags)
@@ -45,11 +44,11 @@ test_utils_init (TestFlags flags)
g_setenv ("COGL_X11_SYNC", "1", 0);
- ctx = cogl_context_new (NULL, &error);
- if (!ctx)
+ test_ctx = cogl_context_new (NULL, &error);
+ if (!test_ctx)
g_critical ("Failed to create a CoglContext: %s", error->message);
- display = cogl_context_get_display (ctx);
+ display = cogl_context_get_display (test_ctx);
renderer = cogl_display_get_renderer (display);
if (flags & TEST_REQUIREMENT_GL &&
@@ -59,19 +58,19 @@ test_utils_init (TestFlags flags)
}
if (flags & TEST_REQUIREMENT_NPOT &&
- !cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
+ !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
{
missing_requirement = TRUE;
}
if (flags & TEST_REQUIREMENT_TEXTURE_3D &&
- !cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
+ !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_3D))
{
missing_requirement = TRUE;
}
if (flags & TEST_REQUIREMENT_POINT_SPRITE &&
- !cogl_has_feature (ctx, COGL_FEATURE_ID_POINT_SPRITE))
+ !cogl_has_feature (test_ctx, COGL_FEATURE_ID_POINT_SPRITE))
{
missing_requirement = TRUE;
}
@@ -83,13 +82,13 @@ test_utils_init (TestFlags flags)
if (getenv ("COGL_TEST_ONSCREEN"))
{
- onscreen = cogl_onscreen_new (ctx, 640, 480);
- fb = COGL_FRAMEBUFFER (onscreen);
+ onscreen = cogl_onscreen_new (test_ctx, 640, 480);
+ test_fb = COGL_FRAMEBUFFER (onscreen);
}
else
{
CoglHandle offscreen;
- CoglHandle tex = cogl_texture_2d_new_with_size (ctx,
+ CoglHandle tex = cogl_texture_2d_new_with_size (test_ctx,
FB_WIDTH, FB_HEIGHT,
COGL_PIXEL_FORMAT_ANY,
&error);
@@ -97,16 +96,16 @@ test_utils_init (TestFlags flags)
g_critical ("Failed to allocate texture: %s", error->message);
offscreen = cogl_offscreen_new_to_texture (tex);
- fb = COGL_FRAMEBUFFER (offscreen);
+ test_fb = COGL_FRAMEBUFFER (offscreen);
}
- if (!cogl_framebuffer_allocate (fb, &error))
+ if (!cogl_framebuffer_allocate (test_fb, &error))
g_critical ("Failed to allocate framebuffer: %s", error->message);
if (onscreen)
cogl_onscreen_show (onscreen);
- cogl_framebuffer_clear4f (fb,
+ cogl_framebuffer_clear4f (test_fb,
COGL_BUFFER_BIT_COLOR |
COGL_BUFFER_BIT_DEPTH |
COGL_BUFFER_BIT_STENCIL,
@@ -119,11 +118,11 @@ test_utils_init (TestFlags flags)
void
test_utils_fini (void)
{
- if (fb)
- cogl_object_unref (fb);
+ if (test_fb)
+ cogl_object_unref (test_fb);
- if (ctx)
- cogl_object_unref (ctx);
+ if (test_ctx)
+ cogl_object_unref (test_ctx);
}
static gboolean
diff --git a/tests/conform/test-utils.h b/tests/conform/test-utils.h
index 727aea8c..c6909d79 100644
--- a/tests/conform/test-utils.h
+++ b/tests/conform/test-utils.h
@@ -16,8 +16,8 @@ typedef enum _TestFlags
TEST_REQUIREMENT_POINT_SPRITE = 1<<4
} TestFlags;
-extern CoglContext *ctx;
-extern CoglFramebuffer *fb;
+extern CoglContext *test_ctx;
+extern CoglFramebuffer *test_fb;
void
test_utils_init (TestFlags flags);
diff --git a/tests/conform/test-wrap-modes.c b/tests/conform/test-wrap-modes.c
index cb75705b..b26a3ec3 100644
--- a/tests/conform/test-wrap-modes.c
+++ b/tests/conform/test-wrap-modes.c
@@ -45,7 +45,7 @@ create_pipeline (TestState *state,
{
CoglPipeline *pipeline;
- pipeline = cogl_pipeline_new (ctx);
+ pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, state->texture);
cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST,
@@ -94,7 +94,7 @@ draw_tests (TestState *state)
wrap_mode_t = wrap_modes[i + 1];
pipeline = create_pipeline (state, wrap_mode_s, wrap_mode_t);
/* Render the pipeline at four times the size of the texture */
- cogl_framebuffer_draw_textured_rectangle (fb,
+ cogl_framebuffer_draw_textured_rectangle (test_fb,
pipeline,
i * TEX_SIZE,
0,
@@ -114,66 +114,6 @@ static const CoglTextureVertex vertices[4] =
};
static void
-draw_tests_polygon (TestState *state)
-{
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (wrap_modes); i += 2)
- {
- CoglPipelineWrapMode wrap_mode_s, wrap_mode_t;
- CoglPipeline *pipeline;
-
- 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_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 */
- cogl_polygon (vertices, G_N_ELEMENTS (vertices), FALSE);
- cogl_pop_matrix ();
- }
-}
-
-static void
-draw_tests_vbo (TestState *state)
-{
- CoglHandle vbo;
- int i;
-
- vbo = cogl_vertex_buffer_new (4);
- cogl_vertex_buffer_add (vbo, "gl_Vertex", 3,
- COGL_ATTRIBUTE_TYPE_FLOAT, FALSE,
- sizeof (vertices[0]),
- &vertices[0].x);
- cogl_vertex_buffer_add (vbo, "gl_MultiTexCoord0", 2,
- COGL_ATTRIBUTE_TYPE_FLOAT, FALSE,
- sizeof (vertices[0]),
- &vertices[0].tx);
- cogl_vertex_buffer_submit (vbo);
-
- for (i = 0; i < G_N_ELEMENTS (wrap_modes); i += 2)
- {
- CoglPipelineWrapMode wrap_mode_s, wrap_mode_t;
- CoglPipeline *pipeline;
-
- 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_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 */
- cogl_vertex_buffer_draw (vbo, COGL_VERTICES_MODE_TRIANGLE_FAN, 0, 4);
- cogl_pop_matrix ();
- }
-
- cogl_handle_unref (vbo);
-}
-
-static void
validate_set (TestState *state, int offset)
{
guint8 data[TEX_SIZE * 2 * TEX_SIZE * 2 * 4], *p;
@@ -186,7 +126,7 @@ validate_set (TestState *state, int offset)
wrap_mode_s = wrap_modes[i];
wrap_mode_t = wrap_modes[i + 1];
- cogl_framebuffer_read_pixels (fb, i * TEX_SIZE, offset * TEX_SIZE * 2,
+ cogl_framebuffer_read_pixels (test_fb, i * TEX_SIZE, offset * TEX_SIZE * 2,
TEX_SIZE * 2, TEX_SIZE * 2,
COGL_PIXEL_FORMAT_RGBA_8888,
data);
@@ -228,8 +168,6 @@ validate_result (TestState *state)
#if 0 /* this doesn't currently work */
validate_set (state, 1); /* atlased rectangle */
#endif
- validate_set (state, 2); /* cogl_polygon */
- validate_set (state, 3); /* vertex buffer */
}
static void
@@ -243,26 +181,10 @@ paint (TestState *state)
/* Draw the tests again with a possible atlased texture. This should
end up testing software repeats */
state->texture = create_texture (COGL_TEXTURE_NONE);
- cogl_push_matrix ();
- cogl_translate (0.0f, TEX_SIZE * 2.0f, 0.0f);
+ cogl_framebuffer_push_matrix (test_fb);
+ cogl_framebuffer_translate (test_fb, 0.0f, TEX_SIZE * 2.0f, 0.0f);
draw_tests (state);
- cogl_pop_matrix ();
- cogl_object_unref (state->texture);
-
- /* Draw the tests using cogl_polygon */
- state->texture = create_texture (COGL_TEXTURE_NO_ATLAS);
- cogl_push_matrix ();
- cogl_translate (0.0f, TEX_SIZE * 4.0f, 0.0f);
- draw_tests_polygon (state);
- cogl_pop_matrix ();
- cogl_object_unref (state->texture);
-
- /* Draw the tests using a vertex buffer */
- state->texture = create_texture (COGL_TEXTURE_NO_ATLAS);
- cogl_push_matrix ();
- cogl_translate (0.0f, TEX_SIZE * 6.0f, 0.0f);
- draw_tests_vbo (state);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (test_fb);
cogl_object_unref (state->texture);
validate_result (state);
@@ -273,21 +195,17 @@ test_wrap_modes (void)
{
TestState state;
- state.width = cogl_framebuffer_get_width (fb);
- state.height = cogl_framebuffer_get_height (fb);
+ state.width = cogl_framebuffer_get_width (test_fb);
+ state.height = cogl_framebuffer_get_height (test_fb);
- cogl_framebuffer_orthographic (fb,
+ cogl_framebuffer_orthographic (test_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 3081182d..de40af9e 100644
--- a/tests/conform/test-write-texture-formats.c
+++ b/tests/conform/test-write-texture-formats.c
@@ -1,4 +1,4 @@
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include <stdarg.h>
#include "test-utils.h"
@@ -31,12 +31,11 @@ test_color (CoglTexture *texture,
}
static void
-test_write_byte (CoglContext *context,
- CoglPixelFormat format,
+test_write_byte (CoglPixelFormat format,
guint8 byte,
guint32 expected_pixel)
{
- CoglTexture *texture = test_utils_create_color_texture (context, 0);
+ CoglTexture *texture = test_utils_create_color_texture (test_ctx, 0);
cogl_texture_set_region (texture,
0, 0, /* src_x / src_y */
@@ -53,12 +52,11 @@ test_write_byte (CoglContext *context,
}
static void
-test_write_short (CoglContext *context,
- CoglPixelFormat format,
+test_write_short (CoglPixelFormat format,
guint16 value,
guint32 expected_pixel)
{
- CoglTexture *texture = test_utils_create_color_texture (context, 0);
+ CoglTexture *texture = test_utils_create_color_texture (test_ctx, 0);
cogl_texture_set_region (texture,
0, 0, /* src_x / src_y */
@@ -75,12 +73,11 @@ test_write_short (CoglContext *context,
}
static void
-test_write_bytes (CoglContext *context,
- CoglPixelFormat format,
+test_write_bytes (CoglPixelFormat format,
guint32 value,
guint32 expected_pixel)
{
- CoglTexture *texture = test_utils_create_color_texture (context, 0);
+ CoglTexture *texture = test_utils_create_color_texture (test_ctx, 0);
value = GUINT32_TO_BE (value);
@@ -99,8 +96,7 @@ test_write_bytes (CoglContext *context,
}
static void
-test_write_int (CoglContext *context,
- CoglPixelFormat format,
+test_write_int (CoglPixelFormat format,
guint32 expected_pixel,
...)
{
@@ -108,7 +104,7 @@ test_write_int (CoglContext *context,
int bits;
guint32 tex_data = 0;
int bits_sum = 0;
- CoglTexture *texture = test_utils_create_color_texture (context, 0);
+ CoglTexture *texture = test_utils_create_color_texture (test_ctx, 0);
va_start (ap, expected_pixel);
@@ -141,43 +137,39 @@ test_write_int (CoglContext *context,
void
test_write_texture_formats (void)
{
- test_write_byte (ctx, COGL_PIXEL_FORMAT_A_8, 0x34, 0x00000034);
+ test_write_byte (COGL_PIXEL_FORMAT_A_8, 0x34, 0x00000034);
#if 0
/* I'm not sure what's the right value to put here because Nvidia
and Mesa seem to behave differently so one of them must be
wrong. */
- test_write_byte (ctx, COGL_PIXEL_FORMAT_G_8, 0x34, 0x340000ff);
+ test_write_byte (test_ctx, COGL_PIXEL_FORMAT_G_8, 0x34, 0x340000ff);
#endif
- test_write_short (ctx, COGL_PIXEL_FORMAT_RGB_565, 0x0843, 0x080819ff);
- test_write_short (ctx, COGL_PIXEL_FORMAT_RGBA_4444_PRE, 0x1234, 0x11223344);
- test_write_short (ctx, COGL_PIXEL_FORMAT_RGBA_5551_PRE, 0x0887, 0x081019ff);
+ test_write_short (COGL_PIXEL_FORMAT_RGB_565, 0x0843, 0x080819ff);
+ test_write_short (COGL_PIXEL_FORMAT_RGBA_4444_PRE, 0x1234, 0x11223344);
+ test_write_short (COGL_PIXEL_FORMAT_RGBA_5551_PRE, 0x0887, 0x081019ff);
- test_write_bytes (ctx, COGL_PIXEL_FORMAT_RGB_888, 0x123456ff, 0x123456ff);
- test_write_bytes (ctx, COGL_PIXEL_FORMAT_BGR_888, 0x563412ff, 0x123456ff);
+ test_write_bytes (COGL_PIXEL_FORMAT_RGB_888, 0x123456ff, 0x123456ff);
+ test_write_bytes (COGL_PIXEL_FORMAT_BGR_888, 0x563412ff, 0x123456ff);
- test_write_bytes (ctx, COGL_PIXEL_FORMAT_RGBA_8888_PRE,
- 0x12345678, 0x12345678);
- test_write_bytes (ctx, COGL_PIXEL_FORMAT_BGRA_8888_PRE,
- 0x56341278, 0x12345678);
- test_write_bytes (ctx, COGL_PIXEL_FORMAT_ARGB_8888_PRE,
- 0x78123456, 0x12345678);
- test_write_bytes (ctx, COGL_PIXEL_FORMAT_ABGR_8888_PRE,
- 0x78563412, 0x12345678);
+ test_write_bytes (COGL_PIXEL_FORMAT_RGBA_8888_PRE, 0x12345678, 0x12345678);
+ test_write_bytes (COGL_PIXEL_FORMAT_BGRA_8888_PRE, 0x56341278, 0x12345678);
+ test_write_bytes (COGL_PIXEL_FORMAT_ARGB_8888_PRE, 0x78123456, 0x12345678);
+ test_write_bytes (COGL_PIXEL_FORMAT_ABGR_8888_PRE, 0x78563412, 0x12345678);
- test_write_int (ctx, COGL_PIXEL_FORMAT_RGBA_1010102_PRE,
+ test_write_int (COGL_PIXEL_FORMAT_RGBA_1010102_PRE,
0x123456ff,
10, 0x12, 10, 0x34, 10, 0x56, 2, 0xff,
-1);
- test_write_int (ctx, COGL_PIXEL_FORMAT_BGRA_1010102_PRE,
+ test_write_int (COGL_PIXEL_FORMAT_BGRA_1010102_PRE,
0x123456ff,
10, 0x56, 10, 0x34, 10, 0x12, 2, 0xff,
-1);
- test_write_int (ctx, COGL_PIXEL_FORMAT_ARGB_2101010_PRE,
+ test_write_int (COGL_PIXEL_FORMAT_ARGB_2101010_PRE,
0x123456ff,
2, 0xff, 10, 0x12, 10, 0x34, 10, 0x56,
-1);
- test_write_int (ctx, COGL_PIXEL_FORMAT_ABGR_2101010_PRE,
+ test_write_int (COGL_PIXEL_FORMAT_ABGR_2101010_PRE,
0x123456ff,
2, 0xff, 10, 0x56, 10, 0x34, 10, 0x12,
-1);