[mutter/gbsneto/graphene-matrix: 12/42] cogl/matrix: Add graphene_matrix_t utility function




commit ed2280cc25051a42359ade7f5e5297336cb619c0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Sep 11 09:33:43 2020 -0300

    cogl/matrix: Add graphene_matrix_t utility function
    
    CoglMatrix doesn't have a 1:1 mapping of graphene functions, and
    sometimes it's just not worth adding wrappers over it. It is easier
    to expose the internal graphene_matrix_t and let callers use it
    directly.
    
    Add new cogl_matrix_get_graphene_matrix() helper function, and
    simplify Clutter's matrix progress function.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 clutter/clutter/clutter-cogl.c |  9 +++++----
 cogl/cogl/cogl-matrix.c        |  6 ++++++
 cogl/cogl/cogl-matrix.h        | 12 ++++++++++++
 3 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter/clutter-cogl.c b/clutter/clutter/clutter-cogl.c
index 631ffdedf2..c36f726045 100644
--- a/clutter/clutter/clutter-cogl.c
+++ b/clutter/clutter/clutter-cogl.c
@@ -37,13 +37,14 @@ cogl_matrix_progress (const GValue *a,
 {
   const CoglMatrix *matrix1 = g_value_get_boxed (a);
   const CoglMatrix *matrix2 = g_value_get_boxed (b);
-  graphene_matrix_t m1, m2, interpolated;
+  graphene_matrix_t interpolated;
   CoglMatrix res;
   float v[16];
 
-  graphene_matrix_init_from_float (&m1, cogl_matrix_get_array (matrix1));
-  graphene_matrix_init_from_float (&m2, cogl_matrix_get_array (matrix2));
-  graphene_matrix_interpolate (&m1, &m2, progress, &interpolated);
+  graphene_matrix_interpolate (cogl_matrix_get_graphene_matrix (matrix1),
+                               cogl_matrix_get_graphene_matrix (matrix2),
+                               progress,
+                               &interpolated);
   graphene_matrix_to_float (&interpolated, v);
 
   cogl_matrix_init_from_array (&res, v);
diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c
index 043ca9da7b..c2086d4615 100644
--- a/cogl/cogl/cogl-matrix.c
+++ b/cogl/cogl/cogl-matrix.c
@@ -801,3 +801,9 @@ cogl_matrix_skew_yz (CoglMatrix *matrix,
   matrix->flags |= COGL_MATRIX_FLAG_DIRTY_INVERSE;
   _COGL_MATRIX_DEBUG_PRINT (matrix);
 }
+
+const graphene_matrix_t *
+cogl_matrix_get_graphene_matrix (const CoglMatrix *matrix)
+{
+  return &matrix->m;
+}
diff --git a/cogl/cogl/cogl-matrix.h b/cogl/cogl/cogl-matrix.h
index 4a3d6156e9..347584dfe5 100644
--- a/cogl/cogl/cogl-matrix.h
+++ b/cogl/cogl/cogl-matrix.h
@@ -777,6 +777,18 @@ COGL_EXPORT void
 cogl_matrix_skew_yz (CoglMatrix *matrix,
                      float       factor);
 
+/**
+ * cogl_matrix_get_graphene_matrix:
+ * @matrix: a #CoglMatrix
+ *
+ * Retrieves the internal #graphene_matrix_t of @matrix. It should not
+ * be modified, and must be considered read-only.
+ *
+ * Returns: (transfer none): a #graphene_matrix_t
+ */
+COGL_EXPORT const graphene_matrix_t *
+cogl_matrix_get_graphene_matrix (const CoglMatrix *matrix);
+
 G_END_DECLS
 
 #endif /* __COGL_MATRIX_H */


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