cogl/tests: Remove testing of legacy API
Some tests just test that deprecated API still work as they should. Those APIs are being removed, so prepare by removing their tests. https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
This commit is contained in:
parent
294b4eda4c
commit
5e117b3f5a
@ -53,7 +53,6 @@ test_blend_paint (TestState *state,
|
||||
uint8_t Ba = MASK_ALPHA (blend_constant);
|
||||
CoglColor blend_const_color;
|
||||
|
||||
CoglHandle material;
|
||||
CoglPipeline *pipeline;
|
||||
gboolean status;
|
||||
GError *error = NULL;
|
||||
@ -120,59 +119,6 @@ test_blend_paint (TestState *state,
|
||||
}
|
||||
|
||||
test_utils_check_pixel (test_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_object_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_object_unref (material);
|
||||
|
||||
/* See what we got... */
|
||||
|
||||
test_utils_check_pixel (test_fb, x_off, y_off, expected_result);
|
||||
}
|
||||
|
||||
static CoglTexture *
|
||||
|
@ -244,43 +244,6 @@ paint (TestState *state)
|
||||
FALSE, /* legacy mode */
|
||||
0xff0000ff); /* expected */
|
||||
}
|
||||
|
||||
/* Test that the legacy cogl_set_depth_test_enabled() API still
|
||||
* works... */
|
||||
|
||||
{
|
||||
/* Nearest */
|
||||
TestDepthState rect0_state = {
|
||||
0xff0000ff, /* rgba color */
|
||||
-10, /* depth */
|
||||
FALSE, /* depth test enable */
|
||||
COGL_DEPTH_TEST_FUNCTION_LESS,
|
||||
TRUE, /* depth write enable */
|
||||
TRUE, /* FB depth write enable */
|
||||
0, 1 /* depth range */
|
||||
};
|
||||
/* Furthest */
|
||||
TestDepthState rect1_state = {
|
||||
0x00ff00ff, /* rgba color */
|
||||
-70, /* depth */
|
||||
FALSE, /* depth test enable */
|
||||
COGL_DEPTH_TEST_FUNCTION_LESS,
|
||||
TRUE, /* depth write enable */
|
||||
TRUE, /* FB depth write enable */
|
||||
0, 1 /* depth range */
|
||||
};
|
||||
|
||||
cogl_set_depth_test_enabled (TRUE);
|
||||
test_depth (state, 0, 2, /* position */
|
||||
&rect0_state, &rect1_state, NULL,
|
||||
TRUE, /* legacy mode */
|
||||
0xff0000ff); /* expected */
|
||||
cogl_set_depth_test_enabled (FALSE);
|
||||
test_depth (state, 1, 2, /* position */
|
||||
&rect0_state, &rect1_state, NULL,
|
||||
TRUE, /* legacy mode */
|
||||
0x00ff00ff); /* expected */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -27,76 +27,6 @@ create_dummy_texture (void)
|
||||
data);
|
||||
}
|
||||
|
||||
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_init_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_object_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 (NULL);
|
||||
|
||||
cogl_object_unref (material);
|
||||
cogl_object_unref (program);
|
||||
}
|
||||
|
||||
static void
|
||||
paint (TestState *state)
|
||||
{
|
||||
@ -193,9 +123,6 @@ test_just_vertex_shader (void)
|
||||
* uses the legacy cogl_rectangle() api. */
|
||||
cogl_push_framebuffer (test_fb);
|
||||
|
||||
paint_legacy (&state);
|
||||
validate_result (test_fb);
|
||||
|
||||
paint (&state);
|
||||
validate_result (test_fb);
|
||||
|
||||
|
@ -91,23 +91,11 @@ set_region (CoglTexture *tex,
|
||||
|
||||
static void
|
||||
check_texture (CoglPipeline *pipeline,
|
||||
CoglHandle material,
|
||||
int x,
|
||||
int y,
|
||||
CoglTexture *tex,
|
||||
uint32_t expected_result)
|
||||
{
|
||||
/* Legacy */
|
||||
cogl_push_framebuffer (test_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 (test_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, tex);
|
||||
cogl_framebuffer_draw_rectangle (test_fb, pipeline,
|
||||
@ -122,7 +110,6 @@ void
|
||||
test_premult (void)
|
||||
{
|
||||
CoglPipeline *pipeline;
|
||||
CoglHandle material;
|
||||
CoglTexture *tex;
|
||||
|
||||
cogl_framebuffer_orthographic (test_fb, 0, 0,
|
||||
@ -135,13 +122,6 @@ test_premult (void)
|
||||
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 (test_ctx);
|
||||
cogl_pipeline_set_blend (pipeline,
|
||||
@ -157,7 +137,7 @@ test_premult (void)
|
||||
tex = make_texture (0xff00ff80,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
|
||||
TEXTURE_FLAG_SET_UNPREMULTIPLIED);
|
||||
check_texture (pipeline, material, 0, 0, /* position */
|
||||
check_texture (pipeline, 0, 0, /* position */
|
||||
tex,
|
||||
0xff00ff80); /* expected */
|
||||
|
||||
@ -170,7 +150,7 @@ test_premult (void)
|
||||
tex = make_texture (0xff00ff80,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
|
||||
TEXTURE_FLAG_SET_PREMULTIPLIED);
|
||||
check_texture (pipeline, material, 1, 0, /* position */
|
||||
check_texture (pipeline, 1, 0, /* position */
|
||||
tex,
|
||||
0x80008080); /* expected */
|
||||
|
||||
@ -184,7 +164,7 @@ test_premult (void)
|
||||
tex = make_texture (0xff00ff80,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888, /* src format */
|
||||
0); /* default premultiplied status */
|
||||
check_texture (pipeline, material, 2, 0, /* position */
|
||||
check_texture (pipeline, 2, 0, /* position */
|
||||
tex,
|
||||
0x80008080); /* expected */
|
||||
|
||||
@ -198,7 +178,7 @@ test_premult (void)
|
||||
tex = make_texture (0x80008080,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
|
||||
TEXTURE_FLAG_SET_PREMULTIPLIED);
|
||||
check_texture (pipeline, material, 3, 0, /* position */
|
||||
check_texture (pipeline, 3, 0, /* position */
|
||||
tex,
|
||||
0x80008080); /* expected */
|
||||
|
||||
@ -211,7 +191,7 @@ test_premult (void)
|
||||
tex = make_texture (0x80008080,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
|
||||
TEXTURE_FLAG_SET_UNPREMULTIPLIED);
|
||||
check_texture (pipeline, material, 4, 0, /* position */
|
||||
check_texture (pipeline, 4, 0, /* position */
|
||||
tex,
|
||||
0xff00ff80); /* expected */
|
||||
|
||||
@ -225,7 +205,7 @@ test_premult (void)
|
||||
tex = make_texture (0x80008080,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* src format */
|
||||
0); /* default premultiplied status */
|
||||
check_texture (pipeline, material, 5, 0, /* position */
|
||||
check_texture (pipeline, 5, 0, /* position */
|
||||
tex,
|
||||
0x80008080); /* expected */
|
||||
|
||||
@ -242,7 +222,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 */
|
||||
|
||||
@ -258,7 +238,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 */
|
||||
|
||||
@ -273,7 +253,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 */
|
||||
|
||||
@ -291,7 +271,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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user