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
This commit is contained in:
Georges Basile Stavracas Neto 2020-09-09 19:42:12 -03:00
parent fe0a325e9f
commit eed3c62751
3 changed files with 47 additions and 39 deletions

View File

@ -41,17 +41,17 @@ cogl_matrix_progress (const GValue *a,
float shear1[3] = { 0.f, 0.f, 0.f }; float shear1[3] = { 0.f, 0.f, 0.f };
graphene_point3d_t rotate1 = GRAPHENE_POINT3D_INIT_ZERO; graphene_point3d_t rotate1 = GRAPHENE_POINT3D_INIT_ZERO;
graphene_point3d_t translate1 = 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); graphene_point3d_t scale2 = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
float shear2[3] = { 0.f, 0.f, 0.f }; float shear2[3] = { 0.f, 0.f, 0.f };
graphene_point3d_t rotate2 = GRAPHENE_POINT3D_INIT_ZERO; graphene_point3d_t rotate2 = GRAPHENE_POINT3D_INIT_ZERO;
graphene_point3d_t translate2 = 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); graphene_point3d_t scale_res = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
float shear_res = 0.f; float shear_res = 0.f;
graphene_point3d_t rotate_res = GRAPHENE_POINT3D_INIT_ZERO; graphene_point3d_t rotate_res = GRAPHENE_POINT3D_INIT_ZERO;
graphene_point3d_t translate_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; CoglMatrix res;
cogl_matrix_init_identity (&res); cogl_matrix_init_identity (&res);
@ -64,11 +64,11 @@ cogl_matrix_progress (const GValue *a,
&perspective2); &perspective2);
/* perspective */ /* perspective */
_clutter_util_vertex4_interpolate (&perspective1, &perspective2, progress, &perspective_res); graphene_vec4_interpolate (&perspective1, &perspective2, progress, &perspective_res);
res.wx = perspective_res.x; res.wx = graphene_vec4_get_x (&perspective_res);
res.wy = perspective_res.y; res.wy = graphene_vec4_get_y (&perspective_res);
res.wz = perspective_res.z; res.wz = graphene_vec4_get_z (&perspective_res);
res.ww = perspective_res.w; res.ww = graphene_vec4_get_w (&perspective_res);
/* translation */ /* translation */
graphene_point3d_interpolate (&translate1, &translate2, progress, &translate_res); graphene_point3d_interpolate (&translate1, &translate2, progress, &translate_res);

View File

@ -262,7 +262,7 @@ gboolean _clutter_util_matrix_decompose (const CoglMatrix *src,
float shear_p[3], float shear_p[3],
graphene_point3d_t *rotate_p, graphene_point3d_t *rotate_p,
graphene_point3d_t *translate_p, graphene_point3d_t *translate_p,
ClutterVertex4 *perspective_p); graphene_vec4_t *perspective_p);
CLUTTER_EXPORT CLUTTER_EXPORT
PangoDirection _clutter_pango_unichar_direction (gunichar ch); PangoDirection _clutter_pango_unichar_direction (gunichar ch);

View File

@ -261,28 +261,38 @@ _clutter_util_matrix_determinant (const CoglMatrix *matrix)
static void static void
_clutter_util_matrix_transpose_vector4_transform (const CoglMatrix *matrix, _clutter_util_matrix_transpose_vector4_transform (const CoglMatrix *matrix,
const ClutterVertex4 *point, const graphene_vec4_t *point,
ClutterVertex4 *res) graphene_vec4_t *res)
{ {
res->x = matrix->xx * point->x float point_x, point_y, point_z, point_w;
+ matrix->xy * point->y float x, y, z, w;
+ matrix->xz * point->z
+ matrix->xw * point->w;
res->y = matrix->yx * point->x point_x = graphene_vec4_get_x (point);
+ matrix->yy * point->y point_y = graphene_vec4_get_y (point);
+ matrix->yz * point->z point_z = graphene_vec4_get_z (point);
+ matrix->yw * point->w; point_w = graphene_vec4_get_w (point);
res->z = matrix->zx * point->x x = matrix->xx * point_x
+ matrix->zy * point->y + matrix->xy * point_y
+ matrix->zz * point->z + matrix->xz * point_z
+ matrix->zw * point->w; + matrix->xw * point_w;
res->w = matrix->wz * point->x y = matrix->yx * point_x
+ matrix->wy * point->w + matrix->yy * point_y
+ matrix->wz * point->z + matrix->yz * point_z
+ matrix->ww * point->w; + 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 static void
@ -342,11 +352,11 @@ _clutter_util_matrix_decompose (const CoglMatrix *src,
float shear_p[3], float shear_p[3],
graphene_point3d_t *rotate_p, graphene_point3d_t *rotate_p,
graphene_point3d_t *translate_p, graphene_point3d_t *translate_p,
ClutterVertex4 *perspective_p) graphene_vec4_t *perspective_p)
{ {
CoglMatrix matrix = *src; CoglMatrix matrix = *src;
CoglMatrix perspective; CoglMatrix perspective;
ClutterVertex4 vertex_tmp; graphene_vec4_t vertex_tmp;
graphene_point3d_t row[3], pdum; graphene_point3d_t row[3], pdum;
int i, j; int i, j;
@ -386,12 +396,13 @@ _clutter_util_matrix_decompose (const CoglMatrix *src,
MAT (&matrix, 3, 2) != 0.f) MAT (&matrix, 3, 2) != 0.f)
{ {
CoglMatrix perspective_inv; CoglMatrix perspective_inv;
ClutterVertex4 p; graphene_vec4_t p;
vertex_tmp.x = MAT (&matrix, 3, 0); graphene_vec4_init (&vertex_tmp,
vertex_tmp.y = MAT (&matrix, 3, 1); MAT (&matrix, 3, 0),
vertex_tmp.z = MAT (&matrix, 3, 2); MAT (&matrix, 3, 1),
vertex_tmp.w = MAT (&matrix, 3, 3); MAT (&matrix, 3, 2),
MAT (&matrix, 3, 3));
/* solve the equation by inverting perspective... */ /* solve the equation by inverting perspective... */
cogl_matrix_get_inverse (&perspective, &perspective_inv); cogl_matrix_get_inverse (&perspective, &perspective_inv);
@ -412,10 +423,7 @@ _clutter_util_matrix_decompose (const CoglMatrix *src,
else else
{ {
/* no perspective */ /* no perspective */
perspective_p->x = 0.0f; graphene_vec4_init_from_vec4 (perspective_p, graphene_vec4_zero ());
perspective_p->y = 0.0f;
perspective_p->z = 0.0f;
perspective_p->w = 1.0f;
} }
/* translation */ /* translation */