tests: Rename 'material' variables to 'pipeline'

This should replace all usages of the material variable to
the pipeline variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
This commit is contained in:
Fernando Monteiro 2021-10-18 23:11:38 +01:00 committed by Marge Bot
parent 9f9e64f077
commit 0c5cf1ec58
7 changed files with 83 additions and 70 deletions

View File

@ -104,7 +104,7 @@ on_paint (ClutterActor *actor,
TestState *state) TestState *state)
{ {
CoglHandle tex0, tex1; CoglHandle tex0, tex1;
CoglHandle material; CoglPipeline *pipeline;
gboolean status; gboolean status;
GError *error = NULL; GError *error = NULL;
float tex_coords[] = { float tex_coords[] = {
@ -115,27 +115,27 @@ on_paint (ClutterActor *actor,
tex0 = make_texture (0x00); tex0 = make_texture (0x00);
tex1 = make_texture (0x11); tex1 = make_texture (0x11);
material = cogl_material_new (); pipeline = cogl_pipeline_new ();
/* An arbitrary color which should be replaced by the first texture layer */ /* An arbitrary color which should be replaced by the first texture layer */
cogl_material_set_color4ub (material, 0x80, 0x80, 0x80, 0x80); cogl_pipeline_set_color4ub (pipeline, 0x80, 0x80, 0x80, 0x80);
cogl_material_set_blend (material, "RGBA = ADD (SRC_COLOR, 0)", NULL); cogl_pipekine_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL);
cogl_material_set_layer (material, 0, tex0); cogl_pipeline_set_layer_texture (pipeline, 0, tex0);
cogl_material_set_layer_combine (material, 0, cogl_pipeline_set_layer_combine (pipeline, 0,
"RGBA = REPLACE (TEXTURE)", NULL); "RGBA = REPLACE (TEXTURE)", NULL);
/* We'll use nearest filtering mode on the textures, otherwise the /* We'll use nearest filtering mode on the textures, otherwise the
edge of the quad can pull in texels from the neighbouring edge of the quad can pull in texels from the neighbouring
quarters of the texture due to imprecision */ quarters of the texture due to imprecision */
cogl_pipeline_set_layer_filters (material, 0, cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST); COGL_PIPELINE_FILTER_NEAREST);
cogl_material_set_layer (material, 1, tex1); cogl_pipeline_set_layer (pipeline, 1, tex1);
cogl_pipeline_set_layer_filters (material, 1, cogl_pipeline_set_layer_filters (pipeline, 1,
COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST); COGL_PIPELINE_FILTER_NEAREST);
status = cogl_material_set_layer_combine (material, 1, status = cogl_pipeline_set_layer_combine (pipeline, 1,
"RGBA = ADD (PREVIOUS, TEXTURE)", "RGBA = ADD (PREVIOUS, TEXTURE)",
&error); &error);
if (!status) if (!status)
@ -147,11 +147,11 @@ on_paint (ClutterActor *actor,
error->message); error->message);
} }
cogl_set_source (material); cogl_set_source (pipeline);
cogl_rectangle_with_multitexture_coords (0, 0, QUAD_WIDTH, QUAD_WIDTH, cogl_rectangle_with_multitexture_coords (0, 0, QUAD_WIDTH, QUAD_WIDTH,
tex_coords, 8); tex_coords, 8);
cogl_object_unref (material); cogl_object_unref (pipeline);
cogl_object_unref (tex0); cogl_object_unref (tex0);
cogl_object_unref (tex1); cogl_object_unref (tex1);

View File

@ -50,27 +50,27 @@ on_paint (ClutterActor *actor,
TestState *state) TestState *state)
{ {
CoglHandle tex; CoglHandle tex;
CoglHandle material; CoglPipeline *pipeline;
uint8_t pixels[8]; uint8_t pixels[8];
tex = make_texture (); tex = make_texture ();
material = cogl_material_new (); pipeline = cogl_pipeline_new ();
cogl_material_set_layer (material, 0, tex); cogl_pipeline_set_layer (pipeline, 0, tex);
cogl_object_unref (tex); cogl_object_unref (tex);
/* Render a 1x1 pixel quad without mipmaps */ /* Render a 1x1 pixel quad without mipmaps */
cogl_set_source (material); cogl_set_source (pipeline);
cogl_pipeline_set_layer_filters (material, 0, cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST); COGL_PIPELINE_FILTER_NEAREST);
cogl_rectangle (0, 0, 1, 1); cogl_rectangle (0, 0, 1, 1);
/* Then with mipmaps */ /* Then with mipmaps */
cogl_pipeline_set_layer_filters (material, 0, cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST, COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST,
COGL_PIPELINE_FILTER_NEAREST); COGL_PIPELINE_FILTER_NEAREST);
cogl_rectangle (1, 0, 2, 1); cogl_rectangle (1, 0, 2, 1);
cogl_object_unref (material); cogl_object_unref (pipeline);
/* Read back the two pixels we rendered */ /* Read back the two pixels we rendered */
cogl_read_pixels (0, 0, 2, 1, cogl_read_pixels (0, 0, 2, 1,

View File

@ -144,23 +144,23 @@ on_after_paint (ClutterActor *actor,
ClutterPaintContext *paint_context, ClutterPaintContext *paint_context,
TestState *state) TestState *state)
{ {
CoglHandle material; CoglPipeline *pipeline;
material = cogl_material_new (); pipeline = cogl_pipeline_new ();
cogl_material_set_layer (material, 0, state->tfp); cogl_pipeline_set_layer (pipeline, 0, state->tfp);
if (state->frame_count == FRAME_COUNT_MIPMAP) if (state->frame_count == FRAME_COUNT_MIPMAP)
{ {
const CoglMaterialFilter min_filter = const CoglPipelineFilter min_filter =
COGL_MATERIAL_FILTER_NEAREST_MIPMAP_NEAREST; COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST;;
cogl_pipeline_set_layer_filters (material, 0, cogl_pipeline_set_layer_filters (pipeline, 0,
min_filter, min_filter,
COGL_PIPELINE_FILTER_NEAREST); COGL_PIPELINE_FILTER_NEAREST);
} }
else else
cogl_pipeline_set_layer_filters (material, 0, cogl_pipeline_set_layer_filters (pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST); COGL_PIPELINE_FILTER_NEAREST);
cogl_set_source (material); cogl_set_source (pipeline);
cogl_rectangle (0, 0, PIXMAP_WIDTH, PIXMAP_HEIGHT); cogl_rectangle (0, 0, PIXMAP_WIDTH, PIXMAP_HEIGHT);

View File

@ -11,7 +11,7 @@
#include "tests/clutter-test-utils.h" #include "tests/clutter-test-utils.h"
typedef struct _TestMultiLayerMaterialState typedef struct _TestMultiLayerPipelineState
{ {
ClutterActor *group; ClutterActor *group;
CoglHandle alpha_tex; CoglHandle alpha_tex;
@ -20,17 +20,17 @@ typedef struct _TestMultiLayerMaterialState
ClutterTimeline *timeline; ClutterTimeline *timeline;
CoglHandle material0; CoglPipeline *pipeline0;
graphene_matrix_t tex_matrix0; graphene_matrix_t tex_matrix0;
graphene_matrix_t rot_matrix0; graphene_matrix_t rot_matrix0;
CoglHandle light_tex0; CoglHandle light_tex0;
CoglHandle material1; CoglPipeline *pipeline1;
graphene_matrix_t tex_matrix1; graphene_matrix_t tex_matrix1;
graphene_matrix_t rot_matrix1; graphene_matrix_t rot_matrix1;
CoglHandle light_tex1; CoglHandle light_tex1;
} TestMultiLayerMaterialState; } TestMultiLayerPipelineState;
int int
test_cogl_multitexture_main (int argc, char *argv[]); test_cogl_multitexture_main (int argc, char *argv[]);
@ -43,17 +43,17 @@ frame_cb (ClutterTimeline *timeline,
gint frame_no, gint frame_no,
gpointer data) gpointer data)
{ {
TestMultiLayerMaterialState *state = data; TestMultiLayerPipelineState *state = data;
graphene_matrix_multiply (&state->rot_matrix0, graphene_matrix_multiply (&state->rot_matrix0,
&state->tex_matrix0, &state->tex_matrix0,
&state->tex_matrix0); &state->tex_matrix0);
cogl_pipeline_set_layer_matrix (state->material0, 2, &state->tex_matrix0); cogl_pipeline_set_layer_matrix (state->pipeline0, 2, &state->tex_matrix0);
graphene_matrix_multiply (&state->rot_matrix1, graphene_matrix_multiply (&state->rot_matrix1,
&state->tex_matrix1, &state->tex_matrix1,
&state->tex_matrix1); &state->tex_matrix1);
cogl_pipeline_set_layer_matrix (state->material1, 2, &state->tex_matrix1); cogl_pipeline_set_layer_matrix (state->pipeline1, 2, &state->tex_matrix1);
} }
static void static void
@ -61,7 +61,7 @@ material_rectangle_paint (ClutterActor *actor,
ClutterPaintContext *paint_context, ClutterPaintContext *paint_context,
gpointer data) gpointer data)
{ {
TestMultiLayerMaterialState *state = data; TestMultiLayerPipelineState *state = data;
CoglFramebuffer *framebuffer = CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context); clutter_paint_context_get_framebuffer (paint_context);
@ -70,13 +70,13 @@ material_rectangle_paint (ClutterActor *actor,
cogl_framebuffer_translate (framebuffer, 150, 15, 0); cogl_framebuffer_translate (framebuffer, 150, 15, 0);
cogl_framebuffer_draw_multitextured_rectangle (framebuffer, cogl_framebuffer_draw_multitextured_rectangle (framebuffer,
COGL_FRAMEBUFFER (state->material0), COGL_FRAMEBUFFER (state->pipeline0),
0, 0, 200, 213, 0, 0, 200, 213,
state->tex_coords, state->tex_coords,
12); 12);
cogl_framebuffer_translate (framebuffer, -300, -30, 0); cogl_framebuffer_translate (framebuffer, -300, -30, 0);
cogl_framebuffer_draw_multitextured_rectangle (framebuffer, cogl_framebuffer_draw_multitextured_rectangle (framebuffer,
COGL_FRAMEBUFFER (state->material1), COGL_FRAMEBUFFER (state->pipeline1),
0, 0, 200, 213, 0, 0, 200, 213,
state->tex_coords, state->tex_coords,
12); 12);
@ -86,7 +86,7 @@ material_rectangle_paint (ClutterActor *actor,
static void static void
animation_completed_cb (ClutterAnimation *animation, animation_completed_cb (ClutterAnimation *animation,
TestMultiLayerMaterialState *state) TestMultiLayerPipelineState *state)
{ {
static gboolean go_back = FALSE; static gboolean go_back = FALSE;
gdouble new_rotation_y; gdouble new_rotation_y;
@ -114,7 +114,7 @@ test_cogl_multitexture_main (int argc, char *argv[])
GError *error = NULL; GError *error = NULL;
ClutterActor *stage; ClutterActor *stage;
ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff }; ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff };
g_autofree TestMultiLayerMaterialState *state = g_new0 (TestMultiLayerMaterialState, 1); g_autofree TestMultiLayerPipelineState *state = g_new0 (TestMultiLayerPipelineState, 1);
gfloat stage_w, stage_h; gfloat stage_w, stage_h;
gchar **files; gchar **files;
gfloat tex_coords[] = gfloat tex_coords[] =
@ -184,15 +184,15 @@ test_cogl_multitexture_main (int argc, char *argv[])
g_strfreev (files); g_strfreev (files);
state->material0 = cogl_material_new (); state->pipeline0 = cogl_pipeline_new ();
cogl_material_set_layer (state->material0, 0, state->alpha_tex); cogl_pipeline_set_layer (state->pipeline0, 0, state->alpha_tex);
cogl_material_set_layer (state->material0, 1, state->redhand_tex); cogl_pipeline_set_layer (state->pipeline0, 1, state->redhand_tex);
cogl_material_set_layer (state->material0, 2, state->light_tex0); cogl_pipeline_set_layer (state->pipeline0, 2, state->light_tex0);
state->material1 = cogl_material_new (); state->pipeline1 = cogl_pipeline_new ();
cogl_material_set_layer (state->material1, 0, state->alpha_tex); cogl_pipeline_set_layer (state->pipeline1, 0, state->alpha_tex);
cogl_material_set_layer (state->material1, 1, state->redhand_tex); cogl_pipeline_set_layer (state->pipeline1, 1, state->redhand_tex);
cogl_material_set_layer (state->material1, 2, state->light_tex1); cogl_pipeline_set_layer (state->pipeline1, 2, state->light_tex1);
state->tex_coords = tex_coords; state->tex_coords = tex_coords;
@ -236,8 +236,8 @@ test_cogl_multitexture_main (int argc, char *argv[])
clutter_test_main (); clutter_test_main ();
cogl_object_unref (state->material1); cogl_object_unref (state->pipeline1);
cogl_object_unref (state->material0); cogl_object_unref (state->pipeline0);
cogl_object_unref (state->alpha_tex); cogl_object_unref (state->alpha_tex);
cogl_object_unref (state->redhand_tex); cogl_object_unref (state->redhand_tex);
cogl_object_unref (state->light_tex0); cogl_object_unref (state->light_tex0);

View File

@ -50,7 +50,7 @@ struct _Data
Spark sparks[N_SPARKS]; Spark sparks[N_SPARKS];
GTimer *last_spark_time; GTimer *last_spark_time;
CoglMaterial *material; CoglPipeline *pipeline;
}; };
int int
@ -217,22 +217,24 @@ test_cogl_point_sprites_main (int argc, char *argv[])
{ {
ClutterActor *stage; ClutterActor *stage;
CoglHandle tex; CoglHandle tex;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
Data data; Data data;
GError *error = NULL; GError *error = NULL;
int i; int i;
clutter_test_init (&argc, &argv); clutter_test_init (&argc, &argv);
data.material = cogl_material_new (); data.pipeline = cogl_pipeline_new (ctx);
data.last_spark_time = g_timer_new (); data.last_spark_time = g_timer_new ();
data.next_spark_num = 0; data.next_spark_num = 0;
cogl_material_set_point_size (data.material, TEXTURE_SIZE); cogl_pipeline_set_point_size (data.pipeline, TEXTURE_SIZE);
tex = generate_round_texture (); tex = generate_round_texture ();
cogl_material_set_layer (data.material, 0, tex); cogl_pipeline_set_layer_texture (data.pipeline, 0, tex);
cogl_object_unref (tex); cogl_object_unref (tex);
if (!cogl_pipeline_set_layer_point_sprite_coords_enabled (data.material, if (!cogl_pipeline_set_layer_point_sprite_coords_enabled (data.pipeline,
0, TRUE, 0, TRUE,
&error)) &error))
{ {
@ -266,7 +268,7 @@ test_cogl_point_sprites_main (int argc, char *argv[])
clutter_test_main (); clutter_test_main ();
cogl_object_unref (data.material); cogl_object_unref (data.pipeline);
g_timer_destroy (data.last_spark_time); g_timer_destroy (data.last_spark_time);
for (i = 0; i < N_FIREWORKS; i++) for (i = 0; i < N_FIREWORKS; i++)

View File

@ -161,7 +161,7 @@ static ShaderSource shaders[]=
}; };
static CoglHandle redhand; static CoglHandle redhand;
static CoglMaterial *material; static CoglPipeline *pipeline;
static unsigned int timeout_id = 0; static unsigned int timeout_id = 0;
static int shader_no = 0; static int shader_no = 0;
@ -176,7 +176,7 @@ on_after_paint (ClutterActor *actor,
float image_width = cogl_texture_get_width (redhand); float image_width = cogl_texture_get_width (redhand);
float image_height = cogl_texture_get_height (redhand); float image_height = cogl_texture_get_height (redhand);
cogl_framebuffer_draw_rectangle (framebuffer, COGL_PIPELINE (material), cogl_framebuffer_draw_rectangle (framebuffer, pipeline,
stage_width / 2.0f - image_width / 2.0f, stage_width / 2.0f - image_width / 2.0f,
stage_height / 2.0f - image_height / 2.0f, stage_height / 2.0f - image_height / 2.0f,
stage_width / 2.0f + image_width / 2.0f, stage_width / 2.0f + image_width / 2.0f,
@ -188,6 +188,9 @@ set_shader_num (int new_no)
{ {
CoglHandle shader; CoglHandle shader;
CoglHandle program; CoglHandle program;
CoglPipeline *pipeline;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
int image_width = cogl_texture_get_width (redhand); int image_width = cogl_texture_get_width (redhand);
int image_height = cogl_texture_get_height (redhand); int image_height = cogl_texture_get_height (redhand);
int uniform_no; int uniform_no;
@ -196,6 +199,8 @@ set_shader_num (int new_no)
new_no, new_no,
shaders[new_no].name); shaders[new_no].name);
pipeline = cogl_pipeline_new (ctx);
shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
cogl_shader_source (shader, shaders[new_no].source); cogl_shader_source (shader, shaders[new_no].source);
@ -218,7 +223,7 @@ set_shader_num (int new_no)
uniform_no = cogl_program_get_uniform_location (program, "y_step"); uniform_no = cogl_program_get_uniform_location (program, "y_step");
cogl_program_set_uniform_1f (program, uniform_no, 1.0f / image_height); cogl_program_set_uniform_1f (program, uniform_no, 1.0f / image_height);
cogl_material_set_user_program (material, program); cogl_pipeline_set_user_program (pipeline, program);
cogl_object_unref (program); cogl_object_unref (program);
shader_no = new_no; shader_no = new_no;
@ -305,6 +310,9 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
char *file; char *file;
GError *error; GError *error;
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
CoglPipeline *pipeline;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
clutter_test_init (&argc, &argv); clutter_test_init (&argc, &argv);
@ -322,8 +330,8 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
if (redhand == NULL) if (redhand == NULL)
g_error ("image load failed: %s", error->message); g_error ("image load failed: %s", error->message);
material = cogl_material_new (); pipeline = cogl_pipeline_new (ctx);
cogl_material_set_layer (material, 0, redhand); cogl_pipeline_set_layer_texture (pipeline, 0, redhand);
set_shader_num (0); set_shader_num (0);
g_signal_connect (CLUTTER_STAGE (stage), "after-paint", G_CALLBACK (on_after_paint), NULL); g_signal_connect (CLUTTER_STAGE (stage), "after-paint", G_CALLBACK (on_after_paint), NULL);

View File

@ -149,7 +149,7 @@ test_coglbox_fade_texture (CoglFramebuffer *framebuffer,
static void static void
test_coglbox_triangle_texture (CoglFramebuffer *framebuffer, test_coglbox_triangle_texture (CoglFramebuffer *framebuffer,
CoglHandle material, CoglPipeline *pipeline,
int tex_width, int tex_width,
int tex_height, int tex_height,
float x, float x,
@ -186,7 +186,7 @@ test_coglbox_triangle_texture (CoglFramebuffer *framebuffer,
COGL_VERTICES_MODE_TRIANGLE_FAN, COGL_VERTICES_MODE_TRIANGLE_FAN,
3, 3,
vertices); vertices);
cogl_primitive_draw (primitive, framebuffer, material); cogl_primitive_draw (primitive, framebuffer, pipeline);
cogl_object_unref (primitive); cogl_object_unref (primitive);
} }
@ -199,13 +199,16 @@ test_coglbox_paint (ClutterActor *self,
: priv->not_sliced_tex; : priv->not_sliced_tex;
int tex_width = cogl_texture_get_width (tex_handle); int tex_width = cogl_texture_get_width (tex_handle);
int tex_height = cogl_texture_get_height (tex_handle); int tex_height = cogl_texture_get_height (tex_handle);
CoglPipeline *pipeline;
CoglFramebuffer *framebuffer = CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context); clutter_paint_context_get_framebuffer (paint_context);
CoglHandle material = cogl_pipeline_new (); CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
cogl_pipeline_set_layer (material, 0, tex_handle); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, tex_handle);
cogl_pipeline_set_layer_filters (material, 0, cogl_pipeline_set_layer_filters (pipeline, 0,
priv->use_linear_filtering priv->use_linear_filtering
? COGL_PIPELINE_FILTER_LINEAR : ? COGL_PIPELINE_FILTER_LINEAR :
COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST,
@ -219,10 +222,10 @@ test_coglbox_paint (ClutterActor *self,
cogl_framebuffer_translate (framebuffer, -tex_width / 2, 0, 0); cogl_framebuffer_translate (framebuffer, -tex_width / 2, 0, 0);
/* Draw a hand and reflect it */ /* Draw a hand and reflect it */
cogl_framebuffer_draw_textured_rectangle (framebuffer, material, cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline,
0, 0, tex_width, tex_height, 0, 0, tex_width, tex_height,
0, 0, 1, 1); 0, 0, 1, 1);
test_coglbox_fade_texture (framebuffer, material, test_coglbox_fade_texture (framebuffer, pipeline,
0, tex_height, 0, tex_height,
tex_width, (tex_height * 3 / 2), tex_width, (tex_height * 3 / 2),
0.0, 1.0, 0.0, 1.0,
@ -236,13 +239,13 @@ test_coglbox_paint (ClutterActor *self,
cogl_framebuffer_translate (framebuffer, -tex_width / 2 - 10, 0, 0); cogl_framebuffer_translate (framebuffer, -tex_width / 2 - 10, 0, 0);
/* Draw the texture split into two triangles */ /* Draw the texture split into two triangles */
test_coglbox_triangle_texture (framebuffer, material, test_coglbox_triangle_texture (framebuffer, pipeline,
tex_width, tex_height, tex_width, tex_height,
0, 0, 0, 0,
0, 0, 0, 0,
0, 1, 0, 1,
1, 1); 1, 1);
test_coglbox_triangle_texture (framebuffer, material, test_coglbox_triangle_texture (framebuffer, pipeline,
tex_width, tex_height, tex_width, tex_height,
20, 0, 20, 0,
0, 0, 0, 0,
@ -251,7 +254,7 @@ test_coglbox_paint (ClutterActor *self,
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);
cogl_object_unref (material); cogl_object_unref (pipeline);
} }
static void static void