From 5d84f73aa06ee4cd45a3bea8262488e752d1d09e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 10 Sep 2020 11:59:46 -0300 Subject: [PATCH] cogl/matrix: Skew using graphene matrices https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439 --- cogl/cogl/cogl-matrix.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c index 4060199a4..f0be09496 100644 --- a/cogl/cogl/cogl-matrix.c +++ b/cogl/cogl/cogl-matrix.c @@ -1946,12 +1946,15 @@ void cogl_matrix_skew_xy (CoglMatrix *matrix, float factor) { - matrix->yx += matrix->xx * factor; - matrix->yy += matrix->xy * factor; - matrix->yz += matrix->xz * factor; - matrix->yw += matrix->xw * factor; + graphene_matrix_t skew; + graphene_matrix_t m; + + cogl_matrix_to_graphene_matrix (matrix, &m); + graphene_matrix_init_identity (&skew); + graphene_matrix_skew_xy (&skew, factor); + graphene_matrix_multiply (&skew, &m, &m); + graphene_matrix_to_cogl_matrix (&m, matrix); - matrix->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL); _COGL_MATRIX_DEBUG_PRINT (matrix); } @@ -1959,12 +1962,15 @@ void cogl_matrix_skew_xz (CoglMatrix *matrix, float factor) { - matrix->zx += matrix->xx * factor; - matrix->zy += matrix->xy * factor; - matrix->zz += matrix->xz * factor; - matrix->zw += matrix->xw * factor; + graphene_matrix_t skew; + graphene_matrix_t m; + + cogl_matrix_to_graphene_matrix (matrix, &m); + graphene_matrix_init_identity (&skew); + graphene_matrix_skew_xz (&skew, factor); + graphene_matrix_multiply (&skew, &m, &m); + graphene_matrix_to_cogl_matrix (&m, matrix); - matrix->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL); _COGL_MATRIX_DEBUG_PRINT (matrix); } @@ -1972,11 +1978,14 @@ void cogl_matrix_skew_yz (CoglMatrix *matrix, float factor) { - matrix->zx += matrix->yx * factor; - matrix->zy += matrix->yy * factor; - matrix->zz += matrix->yz * factor; - matrix->zw += matrix->yw * factor; + graphene_matrix_t skew; + graphene_matrix_t m; + + cogl_matrix_to_graphene_matrix (matrix, &m); + graphene_matrix_init_identity (&skew); + graphene_matrix_skew_yz (&skew, factor); + graphene_matrix_multiply (&skew, &m, &m); + graphene_matrix_to_cogl_matrix (&m, matrix); - matrix->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL); _COGL_MATRIX_DEBUG_PRINT (matrix); }