[mutter/gbsneto/graphene-matrix: 10/73] cogl/matrix: Import skew functions from Clutter




commit 021f4b965bc94d64f7d7e312b5bf79cb03678dca
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Sep 9 19:10:09 2020 -0300

    cogl/matrix: Import skew functions from Clutter
    
    Graphene provides skewing as part of graphene_matrix_t API, and it'll
    be easier for the transition to just expose similar API surfaces.
    
    Move the matrix skew methods to CoglMatrix.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 clutter/clutter/clutter-cogl.c    |  6 +++---
 clutter/clutter/clutter-private.h |  7 ------
 clutter/clutter/clutter-util.c    | 30 --------------------------
 cogl/cogl/cogl-matrix.c           | 39 +++++++++++++++++++++++++++++++++
 cogl/cogl/cogl-matrix.h           | 45 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 87 insertions(+), 40 deletions(-)
---
diff --git a/clutter/clutter/clutter-cogl.c b/clutter/clutter/clutter-cogl.c
index 2ba1b16128..712bbe9131 100644
--- a/clutter/clutter/clutter-cogl.c
+++ b/clutter/clutter/clutter-cogl.c
@@ -83,15 +83,15 @@ cogl_matrix_progress (const GValue *a,
   /* skew */
   shear_res = shear1[2] + (shear2[2] - shear1[2]) * progress; /* YZ */
   if (shear_res != 0.f)
-    _clutter_util_matrix_skew_yz (&res, shear_res);
+    cogl_matrix_skew_yz (&res, shear_res);
 
   shear_res = shear1[1] + (shear2[1] - shear1[1]) * progress; /* XZ */
   if (shear_res != 0.f)
-    _clutter_util_matrix_skew_xz (&res, shear_res);
+    cogl_matrix_skew_xz (&res, shear_res);
 
   shear_res = shear1[0] + (shear2[0] - shear1[0]) * progress; /* XY */
   if (shear_res != 0.f)
-    _clutter_util_matrix_skew_xy (&res, shear_res);
+    cogl_matrix_skew_xy (&res, shear_res);
 
   /* scale */
   graphene_point3d_interpolate (&scale1, &scale2, progress, &scale_res);
diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h
index 7d4dfd04a5..27f7da3bee 100644
--- a/clutter/clutter/clutter-private.h
+++ b/clutter/clutter/clutter-private.h
@@ -257,13 +257,6 @@ _clutter_util_vertex4_interpolate (const ClutterVertex4 *a,
 
 float   _clutter_util_matrix_determinant        (const CoglMatrix *matrix);
 
-void    _clutter_util_matrix_skew_xy            (CoglMatrix *matrix,
-                                                 float       factor);
-void    _clutter_util_matrix_skew_xz            (CoglMatrix *matrix,
-                                                 float       factor);
-void    _clutter_util_matrix_skew_yz            (CoglMatrix *matrix,
-                                                 float       factor);
-
 gboolean        _clutter_util_matrix_decompose  (const CoglMatrix *src,
                                                  graphene_point3d_t  *scale_p,
                                                  float                shear_p[3],
diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c
index d18ac1977c..5128eed788 100644
--- a/clutter/clutter/clutter-util.c
+++ b/clutter/clutter/clutter-util.c
@@ -279,36 +279,6 @@ _clutter_util_matrix_transpose_vector4_transform (const CoglMatrix     *matrix,
          + matrix->ww * point->w;
 }
 
-void
-_clutter_util_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;
-}
-
-void
-_clutter_util_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;
-}
-
-void
-_clutter_util_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;
-}
-
 static void
 _clutter_util_vertex_combine (const graphene_point3d_t *a,
                               const graphene_point3d_t *b,
diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c
index 7bd2af0b08..17ee499dde 100644
--- a/cogl/cogl/cogl-matrix.c
+++ b/cogl/cogl/cogl-matrix.c
@@ -2246,3 +2246,42 @@ cogl_gtype_matrix_get_type (void)
 {
   return cogl_matrix_get_gtype ();
 }
+
+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;
+
+  matrix->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL);
+  _COGL_MATRIX_DEBUG_PRINT (matrix);
+}
+
+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;
+
+  matrix->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL);
+  _COGL_MATRIX_DEBUG_PRINT (matrix);
+}
+
+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;
+
+  matrix->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL);
+  _COGL_MATRIX_DEBUG_PRINT (matrix);
+}
diff --git a/cogl/cogl/cogl-matrix.h b/cogl/cogl/cogl-matrix.h
index e784b094ae..4b5eef699f 100644
--- a/cogl/cogl/cogl-matrix.h
+++ b/cogl/cogl/cogl-matrix.h
@@ -760,6 +760,51 @@ GType cogl_matrix_get_gtype (void);
 COGL_EXPORT GType
 cogl_gtype_matrix_get_type (void);
 
+
+/**
+ * cogl_matrix_determinant:
+ * @matrix: a #CoglMatrix
+ *
+ * Computes the determinant of the @matrix.
+ *
+ * Returns: the value of the determinant
+ */
+COGL_EXPORT float
+cogl_matrix_determinant (const CoglMatrix *matrix);
+
+/**
+ * cogl_matrix_skew_xy:
+ * @matrix: a #CoglMatrix
+ * @factor: skew factor
+ *
+ * Adds a skew of factor on the X and Y axis to @matrix.
+ */
+COGL_EXPORT void
+cogl_matrix_skew_xy (CoglMatrix *matrix,
+                     float       factor);
+
+/**
+ * cogl_matrix_skew_xz:
+ * @matrix: a #CoglMatrix
+ * @factor: skew factor
+ *
+ * Adds a skew of factor on the X and Z axis to @matrix.
+ */
+COGL_EXPORT void
+cogl_matrix_skew_xz (CoglMatrix *matrix,
+                     float       factor);
+
+/**
+ * cogl_matrix_skew_yz:
+ * @matrix: a #CoglMatrix
+ * @factor: skew factor
+ *
+ * Adds a skew of factor on the Y and Z axis to @matrix.
+ */
+COGL_EXPORT void
+cogl_matrix_skew_yz (CoglMatrix *matrix,
+                     float       factor);
+
 G_END_DECLS
 
 #endif /* __COGL_MATRIX_H */


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