[mutter/gbsneto/graphene-matrix: 18/71] cogl/matrix: Scale using graphene matrices
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene-matrix: 18/71] cogl/matrix: Scale using graphene matrices
- Date: Sun, 20 Sep 2020 21:39:39 +0000 (UTC)
commit 37f9171df04ce97ebcc05be2dfae3760eeebbddd
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Sep 10 10:47:39 2020 -0300
cogl/matrix: Scale using graphene matrices
Boring.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
cogl/cogl/cogl-matrix.c | 45 +++++++++++++++++++--------------------------
1 file changed, 19 insertions(+), 26 deletions(-)
---
diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c
index 25858c7d0b..540774d81f 100644
--- a/cogl/cogl/cogl-matrix.c
+++ b/cogl/cogl/cogl-matrix.c
@@ -1315,38 +1315,31 @@ cogl_matrix_orthographic (CoglMatrix *matrix,
_COGL_MATRIX_DEBUG_PRINT (matrix);
}
-/*
- * Multiply a matrix with a general scaling matrix.
- *
- * Multiplies in-place the elements of matrix by the scale factors. Checks if
- * the scales factors are roughly the same, marking the MAT_FLAG_UNIFORM_SCALE
- * flag, or MAT_FLAG_GENERAL_SCALE. Marks the MAT_DIRTY_TYPE and
- * MAT_DIRTY_INVERSE dirty flags.
- */
-static void
-_cogl_matrix_scale (CoglMatrix *matrix, float x, float y, float z)
-{
- float *m = (float *)matrix;
- m[0] *= x; m[4] *= y; m[8] *= z;
- m[1] *= x; m[5] *= y; m[9] *= z;
- m[2] *= x; m[6] *= y; m[10] *= z;
- m[3] *= x; m[7] *= y; m[11] *= z;
-
- if (fabsf (x - y) < 1e-8 && fabsf (x - z) < 1e-8)
- matrix->flags |= MAT_FLAG_UNIFORM_SCALE;
- else
- matrix->flags |= MAT_FLAG_GENERAL_SCALE;
-
- matrix->flags |= (MAT_DIRTY_TYPE | MAT_DIRTY_INVERSE);
-}
-
void
cogl_matrix_scale (CoglMatrix *matrix,
float sx,
float sy,
float sz)
{
- _cogl_matrix_scale (matrix, sx, sy, sz);
+ graphene_matrix_t scale;
+ graphene_matrix_t m;
+ unsigned long flags;
+
+ flags = matrix->flags;
+
+ cogl_matrix_to_graphene_matrix (matrix, &m);
+ graphene_matrix_init_scale (&scale, sx, sy, sz);
+ graphene_matrix_multiply (&scale, &m, &m);
+ graphene_matrix_to_cogl_matrix (&m, matrix);
+
+ if (fabsf (sx - sy) < 1e-8 && fabsf (sx - sz) < 1e-8)
+ flags |= MAT_FLAG_UNIFORM_SCALE;
+ else
+ flags |= MAT_FLAG_GENERAL_SCALE;
+
+ flags |= (MAT_DIRTY_TYPE | MAT_DIRTY_INVERSE);
+ matrix->flags = flags;
+
_COGL_MATRIX_DEBUG_PRINT (matrix);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]