[mutter/gbsneto/graphene-matrix: 8/57] cogl/matrix: Skew using graphene matrices




commit 933b64d2a7ec6174dc03e976318bb5bc858bb91d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Sep 10 11:59:46 2020 -0300

    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 4060199a47..f0be094966 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);
 }


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