diff --git a/cogl/cogl-matrix.c b/cogl/cogl-matrix.c index 85abab7f8..dc5578cc9 100644 --- a/cogl/cogl-matrix.c +++ b/cogl/cogl-matrix.c @@ -353,6 +353,21 @@ cogl_matrix_equal (gconstpointer v1, gconstpointer v2) return FALSE; } +CoglMatrix * +cogl_matrix_copy (const CoglMatrix *matrix) +{ + if (G_LIKELY (matrix)) + return g_slice_dup (CoglMatrix, matrix); + + return NULL; +} + +void +cogl_matrix_free (CoglMatrix *matrix) +{ + g_slice_free (CoglMatrix, matrix); +} + const float * cogl_matrix_get_array (const CoglMatrix *matrix) { diff --git a/cogl/cogl-matrix.h b/cogl/cogl-matrix.h index 8904d881b..b54f4b948 100644 --- a/cogl/cogl-matrix.h +++ b/cogl/cogl-matrix.h @@ -292,6 +292,33 @@ cogl_matrix_get_array (const CoglMatrix *matrix); gboolean cogl_matrix_equal (gconstpointer v1, gconstpointer v2); +/** + * cogl_matrix_copy: + * @matrix: A 4x4 transformation matrix you want to copy + * + * Allocates a new #CoglMatrix on the heap and initializes it with + * the same values as @matrix. + * + * Returns: A newly allocated #CoglMatrix which should be freed using + * cogl_matrix_free() + * + * Since: 1.6 + */ +CoglMatrix * +cogl_matrix_copy (const CoglMatrix *matrix); + +/** + * cogl_matrix_free: + * @matrix: A 4x4 transformation matrix you want to free + * + * Frees a #CoglMatrix that was previously allocated via a call to + * cogl_matrix_copy(). + * + * Since: 1.6 + */ +void +cogl_matrix_free (CoglMatrix *matrix); + /** * cogl_matrix_get_inverse: * @matrix: A 4x4 transformation matrix