summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2020-09-11 09:33:43 -0300
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2020-10-06 15:34:47 +0000
commit2e986ed3e8c1bd266b0242bd90af9e343851f774 (patch)
tree7708c20d50a020de565d1109973b207600b3c4b3
parent6c695ec39d2098e7a331c8f5fd9d840ff876c2e0 (diff)
downloadmutter-2e986ed3e8c1bd266b0242bd90af9e343851f774.tar.gz
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
-rw-r--r--clutter/clutter/clutter-cogl.c14
-rw-r--r--cogl/cogl/cogl-matrix.c6
-rw-r--r--cogl/cogl/cogl-matrix.h12
3 files changed, 23 insertions, 9 deletions
diff --git a/clutter/clutter/clutter-cogl.c b/clutter/clutter/clutter-cogl.c
index 9663f904d..c36f72604 100644
--- a/clutter/clutter/clutter-cogl.c
+++ b/clutter/clutter/clutter-cogl.c
@@ -37,18 +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 fm1[16];
- float fm2[16];
float v[16];
- cogl_matrix_to_float (matrix1, fm1);
- cogl_matrix_to_float (matrix2, fm2);
-
- graphene_matrix_init_from_float (&m1, fm1);
- graphene_matrix_init_from_float (&m2, fm2);
- 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 2bdda114b..91ea3e951 100644
--- a/cogl/cogl/cogl-matrix.c
+++ b/cogl/cogl/cogl-matrix.c
@@ -810,3 +810,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 4a3d6156e..347584dfe 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 */