[mutter/gbsneto/graphene-matrix: 16/18] cogl/tests: Use graphene APIs




commit 240383566a3890cb4678cc002fcadfae02e62e42
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Sep 11 19:46:31 2020 -0300

    cogl/tests: Use graphene APIs
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 cogl/tests/conform/test-euler.c                 | 14 +++++++-------
 cogl/tests/conform/test-offscreen.c             |  1 +
 cogl/tests/conform/test-pipeline-uniforms.c     | 16 +++++++++-------
 cogl/tests/conform/test-pipeline-user-matrix.c  | 14 +++++++-------
 cogl/tests/conform/test-primitive-and-journal.c | 11 ++++-------
 cogl/tests/conform/test-readpixels.c            |  4 ++--
 cogl/tests/conform/test-snippets.c              | 12 ++++++------
 cogl/tests/conform/test-viewport.c              |  8 ++++----
 8 files changed, 40 insertions(+), 40 deletions(-)
---
diff --git a/cogl/tests/conform/test-euler.c b/cogl/tests/conform/test-euler.c
index c156f62973..40e0a600cd 100644
--- a/cogl/tests/conform/test-euler.c
+++ b/cogl/tests/conform/test-euler.c
@@ -25,8 +25,8 @@
     float af[16], bf[16];                       \
     int i;                                      \
                                                 \
-    cogl_matrix_to_float (a, af);               \
-    cogl_matrix_to_float (b, bf);               \
+    graphene_matrix_to_float (a, af);           \
+    graphene_matrix_to_float (b, bf);           \
                                                 \
     for (i = 0; i < 16; i++)                    \
       COMPARE_ELEMENT (af, bf, i);              \
@@ -39,14 +39,14 @@ test_euler (void)
   graphene_matrix_t matrix_a, matrix_b;
 
   /* Try doing the rotation with three separate rotations */
-  cogl_matrix_init_identity (&matrix_a);
-  cogl_matrix_rotate (&matrix_a, -30.0f, 0.0f, 1.0f, 0.0f);
-  cogl_matrix_rotate (&matrix_a, 40.0f, 1.0f, 0.0f, 0.0f);
-  cogl_matrix_rotate (&matrix_a, 50.0f, 0.0f, 0.0f, 1.0f);
+  graphene_matrix_init_identity (&matrix_a);
+  graphene_matrix_rotate (&matrix_a, -30.0f, graphene_vec3_y_axis ());
+  graphene_matrix_rotate (&matrix_a, 40.0f, graphene_vec3_x_axis ());
+  graphene_matrix_rotate (&matrix_a, 50.0f, graphene_vec3_z_axis ());
 
   /* And try the same rotation with a euler */
   graphene_euler_init_with_order (&euler, 40, -30, 50, GRAPHENE_EULER_ORDER_RYXZ);
-  cogl_matrix_init_from_euler (&matrix_b, &euler);
+  graphene_euler_to_matrix (&euler, &matrix_b);
 
   /* Verify that the matrices are approximately the same */
   COMPARE_MATRICES (&matrix_a, &matrix_b);
diff --git a/cogl/tests/conform/test-offscreen.c b/cogl/tests/conform/test-offscreen.c
index d5f7799472..a5de870e55 100644
--- a/cogl/tests/conform/test-offscreen.c
+++ b/cogl/tests/conform/test-offscreen.c
@@ -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);
diff --git a/cogl/tests/conform/test-pipeline-uniforms.c b/cogl/tests/conform/test-pipeline-uniforms.c
index 90d3ee17da..299985fecb 100644
--- a/cogl/tests/conform/test-pipeline-uniforms.c
+++ b/cogl/tests/conform/test-pipeline-uniforms.c
@@ -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 =
diff --git a/cogl/tests/conform/test-pipeline-user-matrix.c b/cogl/tests/conform/test-pipeline-user-matrix.c
index aa66d8030b..689eeeae98 100644
--- a/cogl/tests/conform/test-pipeline-user-matrix.c
+++ b/cogl/tests/conform/test-pipeline-user-matrix.c
@@ -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,
diff --git a/cogl/tests/conform/test-primitive-and-journal.c b/cogl/tests/conform/test-primitive-and-journal.c
index 8a394f3afd..343812ca20 100644
--- a/cogl/tests/conform/test-primitive-and-journal.c
+++ b/cogl/tests/conform/test-primitive-and-journal.c
@@ -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);
 }
 
diff --git a/cogl/tests/conform/test-readpixels.c b/cogl/tests/conform/test-readpixels.c
index dc4811a62e..64824b0aa9 100644
--- a/cogl/tests/conform/test-readpixels.c
+++ b/cogl/tests/conform/test-readpixels.c
@@ -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);
diff --git a/cogl/tests/conform/test-snippets.c b/cogl/tests/conform/test-snippets.c
index 1b70a5a4ca..5ed3d8d0f4 100644
--- a/cogl/tests/conform/test-snippets.c
+++ b/cogl/tests/conform/test-snippets.c
@@ -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 */
diff --git a/cogl/tests/conform/test-viewport.c b/cogl/tests/conform/test-viewport.c
index 120712e38c..3b58a2351f 100644
--- a/cogl/tests/conform/test-viewport.c
+++ b/cogl/tests/conform/test-viewport.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]