cogl/tests: Use graphene APIs
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
This commit is contained in:
parent
a3cb1cabd3
commit
090973e538
@ -72,6 +72,7 @@ test_paint (TestState *state)
|
||||
* verify it gets restored when we call cogl_pop_framebuffer () */
|
||||
cogl_framebuffer_scale (test_fb, 2, 2, 1);
|
||||
|
||||
|
||||
opaque_pipeline = cogl_pipeline_new (test_ctx);
|
||||
/* red, top left */
|
||||
cogl_pipeline_set_color4ub (opaque_pipeline, 0xff, 0x00, 0x00, 0xff);
|
||||
|
@ -224,25 +224,27 @@ paint_matrix_pipeline (CoglPipeline *pipeline)
|
||||
int 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 */
|
||||
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 */
|
||||
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 */
|
||||
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
|
||||
uploaded as transposed so we need to transpose first to cancel
|
||||
that out */
|
||||
cogl_matrix_translate (matrices + 3, 0.0f, 0.0f, 1.0f);
|
||||
cogl_matrix_transpose (matrices + 3);
|
||||
graphene_matrix_translate (&matrices[3],
|
||||
&GRAPHENE_POINT3D_INIT (0.0f, 0.0f, 1.0f));
|
||||
graphene_matrix_transpose (&matrices[3], &matrices[3]);
|
||||
|
||||
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 */
|
||||
uniform_location =
|
||||
|
@ -66,7 +66,7 @@ paint (TestState *state)
|
||||
|
||||
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);
|
||||
|
||||
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 */
|
||||
cogl_matrix_init_identity (&matrix);
|
||||
cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f);
|
||||
cogl_matrix_scale (&matrix, 1.0f, -1.0f, 1.0f);
|
||||
graphene_matrix_init_scale (&matrix, 1.0f, -1.0f, 1.0f);
|
||||
graphene_matrix_translate (&matrix,
|
||||
&GRAPHENE_POINT3D_INIT (0.0f, 1.0f, 0.0f));
|
||||
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
||||
|
||||
/* Set a matrix on the second layer so that it will mirror about the x-axis */
|
||||
cogl_matrix_init_identity (&matrix);
|
||||
cogl_matrix_translate (&matrix, 1.0f, 0.0f, 0.0f);
|
||||
cogl_matrix_scale (&matrix, -1.0f, 1.0f, 1.0f);
|
||||
graphene_matrix_init_scale (&matrix, -1.0f, 1.0f, 1.0f);
|
||||
graphene_matrix_translate (&matrix,
|
||||
&GRAPHENE_POINT3D_INIT (1.0f, 0.0f, 0.0f));
|
||||
cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix);
|
||||
|
||||
cogl_framebuffer_draw_rectangle (test_fb,
|
||||
|
@ -18,13 +18,10 @@ setup_orthographic_modelview (void)
|
||||
* matrix we asked for. The matrix sets up an orthographic transform
|
||||
* in the modelview matrix */
|
||||
|
||||
cogl_matrix_init_identity (&matrix);
|
||||
cogl_matrix_orthographic (&matrix,
|
||||
0.0f, 0.0f, /* x_1 y_1 */
|
||||
fb_width,
|
||||
fb_height,
|
||||
-1.0f, /* nearval */
|
||||
1.0f /* farval */);
|
||||
graphene_matrix_init_ortho (&matrix,
|
||||
0.f, fb_width,
|
||||
fb_height, 0.f,
|
||||
-1.f, 1.f);
|
||||
cogl_framebuffer_set_modelview_matrix (test_fb, &matrix);
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ on_paint (ClutterActor *actor,
|
||||
cogl_get_projection_matrix (&saved_projection);
|
||||
cogl_push_matrix ();
|
||||
|
||||
cogl_matrix_init_identity (&projection);
|
||||
cogl_matrix_init_identity (&modelview);
|
||||
graphene_matrix_init_identity (&projection);
|
||||
graphene_matrix_init_identity (&modelview);
|
||||
|
||||
cogl_set_projection_matrix (&projection);
|
||||
cogl_set_modelview_matrix (&modelview);
|
||||
|
@ -436,8 +436,8 @@ test_modify_vertex_layer (TestState *state)
|
||||
/* Test modifying the vertex layer code */
|
||||
pipeline = create_texture_pipeline (state);
|
||||
|
||||
cogl_matrix_init_identity (&matrix);
|
||||
cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f);
|
||||
graphene_matrix_init_translate (&matrix,
|
||||
&GRAPHENE_POINT3D_INIT (0.0f, 1.0f, 0.0f));
|
||||
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
||||
|
||||
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 */
|
||||
pipeline = create_texture_pipeline (state);
|
||||
|
||||
cogl_matrix_init_identity (&matrix);
|
||||
cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f);
|
||||
graphene_matrix_init_translate (&matrix,
|
||||
&GRAPHENE_POINT3D_INIT (0.0f, 1.0f, 0.0f));
|
||||
cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
|
||||
|
||||
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 */
|
||||
|
||||
cogl_matrix_init_identity (&identity_matrix);
|
||||
graphene_matrix_init_identity (&identity_matrix);
|
||||
|
||||
pipeline = cogl_pipeline_new (test_ctx);
|
||||
|
||||
@ -514,7 +514,7 @@ test_vertex_transform_hook (TestState *state)
|
||||
/* Copy the current projection matrix to a uniform */
|
||||
cogl_framebuffer_get_projection_matrix (test_fb, &matrix);
|
||||
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,
|
||||
location,
|
||||
4, /* dimensions */
|
||||
|
@ -90,8 +90,8 @@ on_paint (ClutterActor *actor,
|
||||
cogl_get_projection_matrix (&saved_projection);
|
||||
cogl_push_matrix ();
|
||||
|
||||
cogl_matrix_init_identity (&projection);
|
||||
cogl_matrix_init_identity (&modelview);
|
||||
graphene_matrix_init_identity (&projection);
|
||||
graphene_matrix_init_identity (&modelview);
|
||||
|
||||
cogl_set_projection_matrix (&projection);
|
||||
cogl_set_modelview_matrix (&modelview);
|
||||
@ -354,8 +354,8 @@ on_paint (ClutterActor *actor,
|
||||
|
||||
/* Uncomment to display the last contents of the offscreen framebuffer */
|
||||
#if 1
|
||||
cogl_matrix_init_identity (&projection);
|
||||
cogl_matrix_init_identity (&modelview);
|
||||
graphene_matrix_init_identity (&projection);
|
||||
graphene_matrix_init_identity (&modelview);
|
||||
cogl_set_viewport (0, 0, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT);
|
||||
cogl_set_projection_matrix (&projection);
|
||||
cogl_set_modelview_matrix (&modelview);
|
||||
|
Loading…
Reference in New Issue
Block a user