[mutter/gbsneto/graphene-matrix: 8/41] clutter/util: Replace ClutterVertex4 with graphene_vec4_t in public API
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene-matrix: 8/41] clutter/util: Replace ClutterVertex4 with graphene_vec4_t in public API
- Date: Fri, 11 Sep 2020 12:50:07 +0000 (UTC)
commit cec352c16c361355adc26dcc8f004598c3561a15
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Sep 9 19:42:12 2020 -0300
clutter/util: Replace ClutterVertex4 with graphene_vec4_t in public API
Soon, ClutterVertex4 will be internal to clutter-util.c, and only for the
_clutter_util_fully_transform_vertices() function, so remove it from all
public API.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
clutter/clutter/clutter-cogl.c | 16 ++++-----
clutter/clutter/clutter-private.h | 2 +-
clutter/clutter/clutter-util.c | 74 ++++++++++++++++++++++-----------------
3 files changed, 50 insertions(+), 42 deletions(-)
---
diff --git a/clutter/clutter/clutter-cogl.c b/clutter/clutter/clutter-cogl.c
index 712bbe9131..61c3166f3e 100644
--- a/clutter/clutter/clutter-cogl.c
+++ b/clutter/clutter/clutter-cogl.c
@@ -41,17 +41,17 @@ cogl_matrix_progress (const GValue *a,
float shear1[3] = { 0.f, 0.f, 0.f };
graphene_point3d_t rotate1 = GRAPHENE_POINT3D_INIT_ZERO;
graphene_point3d_t translate1 = GRAPHENE_POINT3D_INIT_ZERO;
- ClutterVertex4 perspective1 = { 0.f, 0.f, 0.f, 0.f };
+ graphene_vec4_t perspective1;
graphene_point3d_t scale2 = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
float shear2[3] = { 0.f, 0.f, 0.f };
graphene_point3d_t rotate2 = GRAPHENE_POINT3D_INIT_ZERO;
graphene_point3d_t translate2 = GRAPHENE_POINT3D_INIT_ZERO;
- ClutterVertex4 perspective2 = { 0.f, 0.f, 0.f, 0.f };
+ graphene_vec4_t perspective2;
graphene_point3d_t scale_res = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
float shear_res = 0.f;
graphene_point3d_t rotate_res = GRAPHENE_POINT3D_INIT_ZERO;
graphene_point3d_t translate_res = GRAPHENE_POINT3D_INIT_ZERO;
- ClutterVertex4 perspective_res = { 0.f, 0.f, 0.f, 0.f };
+ graphene_vec4_t perspective_res;
CoglMatrix res;
cogl_matrix_init_identity (&res);
@@ -64,11 +64,11 @@ cogl_matrix_progress (const GValue *a,
&perspective2);
/* perspective */
- _clutter_util_vertex4_interpolate (&perspective1, &perspective2, progress, &perspective_res);
- res.wx = perspective_res.x;
- res.wy = perspective_res.y;
- res.wz = perspective_res.z;
- res.ww = perspective_res.w;
+ graphene_vec4_interpolate (&perspective1, &perspective2, progress, &perspective_res);
+ res.wx = graphene_vec4_get_x (&perspective_res);
+ res.wy = graphene_vec4_get_y (&perspective_res);
+ res.wz = graphene_vec4_get_z (&perspective_res);
+ res.ww = graphene_vec4_get_w (&perspective_res);
/* translation */
graphene_point3d_interpolate (&translate1, &translate2, progress, &translate_res);
diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h
index 27f7da3bee..22050f24c3 100644
--- a/clutter/clutter/clutter-private.h
+++ b/clutter/clutter/clutter-private.h
@@ -262,7 +262,7 @@ gboolean _clutter_util_matrix_decompose (const CoglMatrix *src,
float shear_p[3],
graphene_point3d_t *rotate_p,
graphene_point3d_t *translate_p,
- ClutterVertex4 *perspective_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 5128eed788..2b0f8a7da8 100644
--- a/clutter/clutter/clutter-util.c
+++ b/clutter/clutter/clutter-util.c
@@ -254,29 +254,39 @@ _clutter_util_matrix_determinant (const CoglMatrix *matrix)
}
static void
-_clutter_util_matrix_transpose_vector4_transform (const CoglMatrix *matrix,
- const ClutterVertex4 *point,
- ClutterVertex4 *res)
+_clutter_util_matrix_transpose_vector4_transform (const CoglMatrix *matrix,
+ const graphene_vec4_t *point,
+ graphene_vec4_t *res)
{
- res->x = matrix->xx * point->x
- + matrix->xy * point->y
- + matrix->xz * point->z
- + matrix->xw * point->w;
-
- res->y = matrix->yx * point->x
- + matrix->yy * point->y
- + matrix->yz * point->z
- + matrix->yw * point->w;
-
- res->z = matrix->zx * point->x
- + matrix->zy * point->y
- + matrix->zz * point->z
- + matrix->zw * point->w;
-
- res->w = matrix->wz * point->x
- + matrix->wy * point->w
- + matrix->wz * point->z
- + matrix->ww * point->w;
+ 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
@@ -336,11 +346,11 @@ _clutter_util_matrix_decompose (const CoglMatrix *src,
float shear_p[3],
graphene_point3d_t *rotate_p,
graphene_point3d_t *translate_p,
- ClutterVertex4 *perspective_p)
+ graphene_vec4_t *perspective_p)
{
CoglMatrix matrix = *src;
CoglMatrix perspective;
- ClutterVertex4 vertex_tmp;
+ graphene_vec4_t vertex_tmp;
graphene_point3d_t row[3], pdum;
int i, j;
@@ -380,12 +390,13 @@ _clutter_util_matrix_decompose (const CoglMatrix *src,
MAT (&matrix, 3, 2) != 0.f)
{
CoglMatrix perspective_inv;
- ClutterVertex4 p;
+ graphene_vec4_t p;
- vertex_tmp.x = MAT (&matrix, 3, 0);
- vertex_tmp.y = MAT (&matrix, 3, 1);
- vertex_tmp.z = MAT (&matrix, 3, 2);
- vertex_tmp.w = MAT (&matrix, 3, 3);
+ 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);
@@ -406,10 +417,7 @@ _clutter_util_matrix_decompose (const CoglMatrix *src,
else
{
/* no perspective */
- perspective_p->x = 0.0f;
- perspective_p->y = 0.0f;
- perspective_p->z = 0.0f;
- perspective_p->w = 1.0f;
+ graphene_vec4_init_from_vec4 (perspective_p, graphene_vec4_zero ());
}
/* translation */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]