[mutter/gbsneto/graphene-matrix: 11/41] clutter/util: Remove unused functions




commit c97752d098f947fb13f3796c3fd3b29a5e3b2f83
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Sep 9 20:14:05 2020 -0300

    clutter/util: Remove unused functions
    
    After transitioning to purely graphene-based matrix interpolation,
    these functions are unused.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439

 clutter/clutter/clutter-private.h |   9 --
 clutter/clutter/clutter-util.c    | 270 --------------------------------------
 2 files changed, 279 deletions(-)
---
diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h
index 687c4856e8..c4d3451f38 100644
--- a/clutter/clutter/clutter-private.h
+++ b/clutter/clutter/clutter-private.h
@@ -239,15 +239,6 @@ gboolean _clutter_util_rectangle_intersection (const cairo_rectangle_int_t *src1
 gboolean clutter_util_rectangle_equal (const cairo_rectangle_int_t *src1,
                                        const cairo_rectangle_int_t *src2);
 
-float   _clutter_util_matrix_determinant        (const CoglMatrix *matrix);
-
-gboolean        _clutter_util_matrix_decompose  (const CoglMatrix *src,
-                                                 graphene_point3d_t  *scale_p,
-                                                 float                shear_p[3],
-                                                 graphene_point3d_t  *rotate_p,
-                                                 graphene_point3d_t  *translate_p,
-                                                 graphene_vec4_t     *perspective_p);
-
 CLUTTER_EXPORT
 PangoDirection _clutter_pango_unichar_direction (gunichar ch);
 
diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c
index d1b01a882d..b35b8b0c11 100644
--- a/clutter/clutter/clutter-util.c
+++ b/clutter/clutter/clutter-util.c
@@ -232,276 +232,6 @@ clutter_util_rectangle_equal (const cairo_rectangle_int_t *src1,
           (src1->height == src2->height));
 }
 
-float
-_clutter_util_matrix_determinant (const CoglMatrix *matrix)
-{
-  return matrix->xw * matrix->yz * matrix->zy * matrix->wz
-       - matrix->xz * matrix->yw * matrix->zy * matrix->wz
-       - matrix->xw * matrix->yy * matrix->zz * matrix->wz
-       + matrix->xy * matrix->yw * matrix->zz * matrix->wz
-       + matrix->xz * matrix->yy * matrix->zw * matrix->wz
-       - matrix->xy * matrix->yz * matrix->zw * matrix->wz
-       - matrix->xw * matrix->yz * matrix->zx * matrix->wy
-       + matrix->xz * matrix->yw * matrix->zx * matrix->wy
-       + matrix->xw * matrix->yx * matrix->zz * matrix->wy
-       - matrix->xx * matrix->yw * matrix->zz * matrix->wy
-       - matrix->xz * matrix->yx * matrix->zw * matrix->wy
-       + matrix->xx * matrix->yz * matrix->zw * matrix->wy
-       + matrix->xw * matrix->yy * matrix->zx * matrix->wz
-       - matrix->xy * matrix->yw * matrix->zx * matrix->wz
-       - matrix->xw * matrix->yx * matrix->zy * matrix->wz
-       + matrix->xx * matrix->yw * matrix->zy * matrix->wz
-       + matrix->xy * matrix->yx * matrix->zw * matrix->wz
-       - matrix->xx * matrix->yy * matrix->zw * matrix->wz
-       - matrix->xz * matrix->yy * matrix->zx * matrix->ww
-       + matrix->xy * matrix->yz * matrix->zx * matrix->ww
-       + matrix->xz * matrix->yx * matrix->zy * matrix->ww
-       - matrix->xx * matrix->yz * matrix->zy * matrix->ww
-       - matrix->xy * matrix->yx * matrix->zz * matrix->ww
-       + matrix->xx * matrix->yy * matrix->zz * matrix->ww;
-}
-
-static void
-_clutter_util_matrix_transpose_vector4_transform (const CoglMatrix      *matrix,
-                                                  const graphene_vec4_t *point,
-                                                  graphene_vec4_t       *res)
-{
-  float point_x, point_y, point_z, point_w;
-  float x, y, z, w;
-
-  point_x = graphene_vec4_get_x (point);
-  point_y = graphene_vec4_get_y (point);
-  point_z = graphene_vec4_get_z (point);
-  point_w = graphene_vec4_get_w (point);
-
-  x = matrix->xx * point_x
-    + matrix->xy * point_y
-    + matrix->xz * point_z
-    + matrix->xw * point_w;
-
-  y = matrix->yx * point_x
-    + matrix->yy * point_y
-    + matrix->yz * point_z
-    + matrix->yw * point_w;
-
-  z = matrix->zx * point_x
-    + matrix->zy * point_y
-    + matrix->zz * point_z
-    + matrix->zw * point_w;
-
-  w = matrix->wz * point_x
-    + matrix->wy * point_w
-    + matrix->wz * point_z
-    + matrix->ww * point_w;
-
-  graphene_vec4_init (res, x, y, z, w);
-}
-
-static void
-_clutter_util_vertex_combine (const graphene_point3d_t *a,
-                              const graphene_point3d_t *b,
-                              double                    ascl,
-                              double                    bscl,
-                              graphene_point3d_t       *res)
-{
-  res->x = (ascl * a->x) + (bscl * b->x);
-  res->y = (ascl * a->y) + (bscl * b->y);
-  res->z = (ascl * a->z) + (bscl * b->z);
-}
-
-/*< private >
- * clutter_util_matrix_decompose:
- * @src: the matrix to decompose
- * @scale_p: (out caller-allocates): return location for a vertex containing
- *   the scaling factors
- * @shear_p: (out) (array length=3): return location for an array of 3
- *   elements containing the skew factors (XY, XZ, and YZ respectively)
- * @rotate_p: (out caller-allocates): return location for a vertex containing
- *   the Euler angles
- * @translate_p: (out caller-allocates): return location for a vertex
- *   containing the translation vector
- * @perspective_p: (out caller-allocates: return location for a 4D vertex
- *   containing the perspective
- *
- * Decomposes a #CoglMatrix into the transformations that compose it.
- *
- * This code is based on the matrix decomposition algorithm as published in
- * the CSS Transforms specification by the W3C CSS working group, available
- * at http://www.w3.org/TR/css3-transforms/.
- *
- * The algorithm, in turn, is based on the "unmatrix" method published in
- * "Graphics Gems II, edited by Jim Arvo", which is available at:
- * http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c
- *
- * Return value: %TRUE if the decomposition was successful, and %FALSE
- *   if the matrix is singular
- */
-gboolean
-_clutter_util_matrix_decompose (const CoglMatrix    *src,
-                                graphene_point3d_t  *scale_p,
-                                float                shear_p[3],
-                                graphene_point3d_t  *rotate_p,
-                                graphene_point3d_t  *translate_p,
-                                graphene_vec4_t     *perspective_p)
-{
-  CoglMatrix matrix = *src;
-  CoglMatrix perspective;
-  graphene_vec4_t vertex_tmp;
-  graphene_point3d_t row[3], pdum;
-  int i, j;
-
-#define XY_SHEAR        0
-#define XZ_SHEAR        1
-#define YZ_SHEAR        2
-#define MAT(m,r,c)      ((float *)(m))[(c) * 4 + (r)]
-
-  /* normalize the matrix */
-  if (matrix.ww == 0.f)
-    return FALSE;
-
-  for (i = 0; i < 4; i++)
-    {
-      for (j = 0; j < 4; j++)
-        {
-          MAT (&matrix, j, i) /= MAT (&matrix, 3, 3);
-        }
-    }
-
-  /* perspective is used to solve for perspective, but it also provides
-   * an easy way to test for singularity of the upper 3x3 component
-   */
-  perspective = matrix;
-
-  /* transpose */
-  MAT (&perspective, 3, 0) = 0.f;
-  MAT (&perspective, 3, 1) = 0.f;
-  MAT (&perspective, 3, 2) = 0.f;
-  MAT (&perspective, 3, 3) = 1.f;
-
-  if (_clutter_util_matrix_determinant (&perspective) == 0.f)
-    return FALSE;
-
-  if (MAT (&matrix, 3, 0) != 0.f ||
-      MAT (&matrix, 3, 1) != 0.f ||
-      MAT (&matrix, 3, 2) != 0.f)
-    {
-      CoglMatrix perspective_inv;
-      graphene_vec4_t p;
-
-      graphene_vec4_init (&vertex_tmp,
-                          MAT (&matrix, 3, 0),
-                          MAT (&matrix, 3, 1),
-                          MAT (&matrix, 3, 2),
-                          MAT (&matrix, 3, 3));
-
-      /* solve the equation by inverting perspective... */
-      cogl_matrix_get_inverse (&perspective, &perspective_inv);
-
-      /* ... and multiplying vertex_tmp by the inverse */
-      _clutter_util_matrix_transpose_vector4_transform (&perspective_inv,
-                                                        &vertex_tmp,
-                                                        &p);
-
-      *perspective_p = p;
-
-      /* clear the perspective part */
-      MAT (&matrix, 3, 0) = 0.0f;
-      MAT (&matrix, 3, 1) = 0.0f;
-      MAT (&matrix, 3, 2) = 0.0f;
-      MAT (&matrix, 3, 3) = 1.0f;
-    }
-  else
-    {
-      /* no perspective */
-      graphene_vec4_init_from_vec4 (perspective_p, graphene_vec4_zero ());
-    }
-
-  /* translation */
-  translate_p->x = MAT (&matrix, 0, 3);
-  MAT (&matrix, 0, 3) = 0.f;
-  translate_p->y = MAT (&matrix, 1, 3);
-  MAT (&matrix, 1, 3) = 0.f;
-  translate_p->z = MAT (&matrix, 2, 3);
-  MAT (&matrix, 2, 3) = 0.f;
-
-  /* scale and shear; we split the upper 3x3 matrix into rows */
-  for (i = 0; i < 3; i++)
-    {
-      row[i].x = MAT (&matrix, i, 0);
-      row[i].y = MAT (&matrix, i, 1);
-      row[i].z = MAT (&matrix, i, 2);
-    }
-
-  /* compute scale.x and normalize the first row */
-  scale_p->x = graphene_point3d_length (&row[0]);
-  graphene_point3d_normalize (&row[0], &row[0]);
-
-  /* compute XY shear and make the second row orthogonal to the first */
-  shear_p[XY_SHEAR] = graphene_point3d_dot (&row[0], &row[1]);
-  _clutter_util_vertex_combine (&row[1], &row[0],
-                                1.0, -shear_p[XY_SHEAR],
-                                &row[1]);
-
-  /* compute the Y scale and normalize the second row */
-  scale_p->y = graphene_point3d_length (&row[1]);
-  graphene_point3d_normalize (&row[1], &row[1]);
-  shear_p[XY_SHEAR] /= scale_p->y;
-
-  /* compute XZ and YZ shears, orthogonalize the third row */
-  shear_p[XZ_SHEAR] = graphene_point3d_dot (&row[0], &row[2]);
-  _clutter_util_vertex_combine (&row[2], &row[0],
-                                1.0, -shear_p[XZ_SHEAR],
-                                &row[2]);
-
-  shear_p[YZ_SHEAR] = graphene_point3d_dot (&row[1], &row[2]);
-  _clutter_util_vertex_combine (&row[2], &row[1],
-                                1.0, -shear_p[YZ_SHEAR],
-                                &row[2]);
-
-  /* get the Z scale and normalize the third row*/
-  scale_p->z = graphene_point3d_length (&row[2]);
-  graphene_point3d_normalize (&row[2], &row[2]);
-  shear_p[XZ_SHEAR] /= scale_p->z;
-  shear_p[YZ_SHEAR] /= scale_p->z;
-
-  /* at this point, the matrix (inside row[]) is orthonormal.
-   * check for a coordinate system flip; if the determinant
-   * is -1, then negate the matrix and scaling factors
-   */
-  graphene_point3d_cross (&row[1], &row[2], &pdum);
-  if (graphene_point3d_dot (&row[0], &pdum) < 0.f)
-    {
-      scale_p->x *= -1.f;
-
-      for (i = 0; i < 3; i++)
-        {
-          row[i].x *= -1.f;
-          row[i].y *= -1.f;
-          row[i].z *= -1.f;
-        }
-    }
-
-  /* now get the rotations out */
-  rotate_p->y = asinf (-row[0].z);
-  if (cosf (rotate_p->y) != 0.f)
-    {
-      rotate_p->x = atan2f (row[1].z, row[2].z);
-      rotate_p->z = atan2f (row[0].y, row[0].x);
-    }
-  else
-    {
-      rotate_p->x = atan2f (-row[2].x, row[1].y);
-      rotate_p->z = 0.f;
-    }
-
-#undef XY_SHEAR
-#undef XZ_SHEAR
-#undef YZ_SHEAR
-#undef MAT
-
-  return TRUE;
-}
-
 typedef struct
 {
   GType value_type;


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