[mutter/gbsneto/graphene-matrix: 20/87] cogl/matrix: Add cogl_matrix_init_from_matrix initializer




commit 79a3567f10ac2df969bae2ec5f374d8ba872a90b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Sep 8 20:16:26 2020 -0300

    cogl/matrix: Add cogl_matrix_init_from_matrix initializer
    
    It does a simple memcpy() to clone the entire structure. This will
    be necessary for a smoother removal of ClutterMatrix.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 cogl/cogl/cogl-matrix.c |  7 +++++++
 cogl/cogl/cogl-matrix.h | 11 +++++++++++
 2 files changed, 18 insertions(+)
---
diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c
index 695887a70a..7bd2af0b08 100644
--- a/cogl/cogl/cogl-matrix.c
+++ b/cogl/cogl/cogl-matrix.c
@@ -1700,6 +1700,13 @@ cogl_matrix_init_from_array (CoglMatrix *matrix, const float *array)
   _COGL_MATRIX_DEBUG_PRINT (matrix);
 }
 
+void
+cogl_matrix_init_from_matrix (CoglMatrix       *matrix,
+                              const CoglMatrix *source)
+{
+  memcpy (matrix, source, sizeof (CoglMatrix));
+}
+
 void
 _cogl_matrix_init_from_matrix_without_inverse (CoglMatrix *matrix,
                                                const CoglMatrix *src)
diff --git a/cogl/cogl/cogl-matrix.h b/cogl/cogl/cogl-matrix.h
index 5e0a5498ea..2cfd95bbb2 100644
--- a/cogl/cogl/cogl-matrix.h
+++ b/cogl/cogl/cogl-matrix.h
@@ -463,6 +463,17 @@ COGL_EXPORT void
 cogl_matrix_init_from_array (CoglMatrix *matrix,
                              const float *array);
 
+/**
+ * cogl_matrix_init_from_matrix:
+ * @matrix: A 4x4 transformation matrix
+ * @source: the #CoglMatrix to copy
+ *
+ * Initializes @matrix with the contents of @source
+ */
+COGL_EXPORT void
+cogl_matrix_init_from_matrix (CoglMatrix       *matrix,
+                              const CoglMatrix *source);
+
 /**
  * cogl_matrix_get_array:
  * @matrix: A 4x4 transformation matrix


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