summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2020-09-09 19:10:09 -0300
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2020-09-20 18:39:25 -0300
commit8902416dd9af9076a4883be4bccd679f71e00496 (patch)
tree92a34645d2359fb0a8dd623b9e29dcffa93540c0 /cogl
parentfccaf188d7b07ab4729726e37ed55d34b862cfec (diff)
downloadmutter-8902416dd9af9076a4883be4bccd679f71e00496.tar.gz
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
Diffstat (limited to 'cogl')
-rw-r--r--cogl/cogl/cogl-matrix.c39
-rw-r--r--cogl/cogl/cogl-matrix.h45
2 files changed, 84 insertions, 0 deletions
diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c
index 7bd2af0b0..17ee499dd 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 e784b094a..4b5eef699 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 */