cogl/tests: Use graphene APIs

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
This commit is contained in:
Georges Basile Stavracas Neto 2020-09-11 19:46:31 -03:00
parent a3cb1cabd3
commit 090973e538
7 changed files with 33 additions and 33 deletions

View File

@ -72,6 +72,7 @@ test_paint (TestState *state)
* verify it gets restored when we call cogl_pop_framebuffer () */ * verify it gets restored when we call cogl_pop_framebuffer () */
cogl_framebuffer_scale (test_fb, 2, 2, 1); cogl_framebuffer_scale (test_fb, 2, 2, 1);
opaque_pipeline = cogl_pipeline_new (test_ctx); opaque_pipeline = cogl_pipeline_new (test_ctx);
/* red, top left */ /* red, top left */
cogl_pipeline_set_color4ub (opaque_pipeline, 0xff, 0x00, 0x00, 0xff); cogl_pipeline_set_color4ub (opaque_pipeline, 0xff, 0x00, 0x00, 0xff);

View File

@ -224,25 +224,27 @@ paint_matrix_pipeline (CoglPipeline *pipeline)
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
cogl_matrix_init_identity (matrices + i); graphene_matrix_init_identity (matrices + i);
/* Use the first matrix to make the color red */ /* Use the first matrix to make the color red */
cogl_matrix_translate (matrices + 0, 1.0f, 0.0f, 0.0f); graphene_matrix_translate (&matrices[0],
&GRAPHENE_POINT3D_INIT (1.0f, 0.0f, 0.0f));
/* Rotate the vertex so that it ends up green */ /* Rotate the vertex so that it ends up green */
cogl_matrix_rotate (matrices + 1, 90.0f, 0.0f, 0.0f, 1.0f); graphene_matrix_rotate (&matrices[1], 90.0f, graphene_vec3_z_axis ());
/* Scale the vertex so it ends up halved */ /* Scale the vertex so it ends up halved */
cogl_matrix_scale (matrices + 2, 0.5f, 0.5f, 0.5f); graphene_matrix_scale (&matrices[2], 0.5f, 0.5f, 0.5f);
/* Add a blue component in the final matrix. The final matrix is /* Add a blue component in the final matrix. The final matrix is
uploaded as transposed so we need to transpose first to cancel uploaded as transposed so we need to transpose first to cancel
that out */ that out */
cogl_matrix_translate (matrices + 3, 0.0f, 0.0f, 1.0f); graphene_matrix_translate (&matrices[3],
cogl_matrix_transpose (matrices + 3); &GRAPHENE_POINT3D_INIT (0.0f, 0.0f, 1.0f));
graphene_matrix_transpose (&matrices[3], &matrices[3]);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
cogl_matrix_to_float (&matrices[i], &matrix_floats[i * 16]); graphene_matrix_to_float (&matrices[i], &matrix_floats[i * 16]);
/* Set the first three matrices as transposed */ /* Set the first three matrices as transposed */
uniform_location = uniform_location =

View File

@ -66,7 +66,7 @@ paint (TestState *state)
cogl_framebuffer_clear4f (test_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); graphene_matrix_init_identity (&matrix);
cogl_framebuffer_set_modelview_matrix (test_fb, &matrix); cogl_framebuffer_set_modelview_matrix (test_fb, &matrix);
tex0 = cogl_texture_new_from_data (2, 2, tex0 = cogl_texture_new_from_data (2, 2,
@ -104,15 +104,15 @@ paint (TestState *state)
} }
/* Set a matrix on the first layer so that it will mirror about the y-axis */ /* Set a matrix on the first layer so that it will mirror about the y-axis */
cogl_matrix_init_identity (&matrix); graphene_matrix_init_scale (&matrix, 1.0f, -1.0f, 1.0f);
cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f); graphene_matrix_translate (&matrix,
cogl_matrix_scale (&matrix, 1.0f, -1.0f, 1.0f); &GRAPHENE_POINT3D_INIT (0.0f, 1.0f, 0.0f));
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix); cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
/* Set a matrix on the second layer so that it will mirror about the x-axis */ /* Set a matrix on the second layer so that it will mirror about the x-axis */
cogl_matrix_init_identity (&matrix); graphene_matrix_init_scale (&matrix, -1.0f, 1.0f, 1.0f);
cogl_matrix_translate (&matrix, 1.0f, 0.0f, 0.0f); graphene_matrix_translate (&matrix,
cogl_matrix_scale (&matrix, -1.0f, 1.0f, 1.0f); &GRAPHENE_POINT3D_INIT (1.0f, 0.0f, 0.0f));
cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix); cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix);
cogl_framebuffer_draw_rectangle (test_fb, cogl_framebuffer_draw_rectangle (test_fb,

View File

@ -18,13 +18,10 @@ setup_orthographic_modelview (void)
* matrix we asked for. The matrix sets up an orthographic transform * matrix we asked for. The matrix sets up an orthographic transform
* in the modelview matrix */ * in the modelview matrix */
cogl_matrix_init_identity (&matrix); graphene_matrix_init_ortho (&matrix,
cogl_matrix_orthographic (&matrix, 0.f, fb_width,
0.0f, 0.0f, /* x_1 y_1 */ fb_height, 0.f,
fb_width, -1.f, 1.f);
fb_height,
-1.0f, /* nearval */
1.0f /* farval */);
cogl_framebuffer_set_modelview_matrix (test_fb, &matrix); cogl_framebuffer_set_modelview_matrix (test_fb, &matrix);
} }

View File

@ -35,8 +35,8 @@ on_paint (ClutterActor *actor,
cogl_get_projection_matrix (&saved_projection); cogl_get_projection_matrix (&saved_projection);
cogl_push_matrix (); cogl_push_matrix ();
cogl_matrix_init_identity (&projection); graphene_matrix_init_identity (&projection);
cogl_matrix_init_identity (&modelview); graphene_matrix_init_identity (&modelview);
cogl_set_projection_matrix (&projection); cogl_set_projection_matrix (&projection);
cogl_set_modelview_matrix (&modelview); cogl_set_modelview_matrix (&modelview);

View File

@ -436,8 +436,8 @@ test_modify_vertex_layer (TestState *state)
/* Test modifying the vertex layer code */ /* Test modifying the vertex layer code */
pipeline = create_texture_pipeline (state); pipeline = create_texture_pipeline (state);
cogl_matrix_init_identity (&matrix); graphene_matrix_init_translate (&matrix,
cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f); &GRAPHENE_POINT3D_INIT (0.0f, 1.0f, 0.0f));
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix); cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM,
@ -465,8 +465,8 @@ test_replace_vertex_layer (TestState *state)
/* Test replacing the vertex layer code */ /* Test replacing the vertex layer code */
pipeline = create_texture_pipeline (state); pipeline = create_texture_pipeline (state);
cogl_matrix_init_identity (&matrix); graphene_matrix_init_translate (&matrix,
cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f); &GRAPHENE_POINT3D_INIT (0.0f, 1.0f, 0.0f));
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix); cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM,
@ -497,7 +497,7 @@ test_vertex_transform_hook (TestState *state)
/* Test the vertex transform hook */ /* Test the vertex transform hook */
cogl_matrix_init_identity (&identity_matrix); graphene_matrix_init_identity (&identity_matrix);
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
@ -514,7 +514,7 @@ test_vertex_transform_hook (TestState *state)
/* Copy the current projection matrix to a uniform */ /* Copy the current projection matrix to a uniform */
cogl_framebuffer_get_projection_matrix (test_fb, &matrix); cogl_framebuffer_get_projection_matrix (test_fb, &matrix);
location = cogl_pipeline_get_uniform_location (pipeline, "pmat"); location = cogl_pipeline_get_uniform_location (pipeline, "pmat");
cogl_matrix_to_float (&matrix, v); graphene_matrix_to_float (&matrix, v);
cogl_pipeline_set_uniform_matrix (pipeline, cogl_pipeline_set_uniform_matrix (pipeline,
location, location,
4, /* dimensions */ 4, /* dimensions */

View File

@ -90,8 +90,8 @@ on_paint (ClutterActor *actor,
cogl_get_projection_matrix (&saved_projection); cogl_get_projection_matrix (&saved_projection);
cogl_push_matrix (); cogl_push_matrix ();
cogl_matrix_init_identity (&projection); graphene_matrix_init_identity (&projection);
cogl_matrix_init_identity (&modelview); graphene_matrix_init_identity (&modelview);
cogl_set_projection_matrix (&projection); cogl_set_projection_matrix (&projection);
cogl_set_modelview_matrix (&modelview); cogl_set_modelview_matrix (&modelview);
@ -354,8 +354,8 @@ on_paint (ClutterActor *actor,
/* Uncomment to display the last contents of the offscreen framebuffer */ /* Uncomment to display the last contents of the offscreen framebuffer */
#if 1 #if 1
cogl_matrix_init_identity (&projection); graphene_matrix_init_identity (&projection);
cogl_matrix_init_identity (&modelview); graphene_matrix_init_identity (&modelview);
cogl_set_viewport (0, 0, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT); cogl_set_viewport (0, 0, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT);
cogl_set_projection_matrix (&projection); cogl_set_projection_matrix (&projection);
cogl_set_modelview_matrix (&modelview); cogl_set_modelview_matrix (&modelview);