From a761caf07978681398271b3ef3333d1a21443a39 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 8 Sep 2020 20:16:26 -0300 Subject: [PATCH] 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 695887a70..7bd2af0b0 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 5e0a5498e..2cfd95bbb 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