mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
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
This commit is contained in:
parent
566b081cd7
commit
fe0a325e9f
@ -83,15 +83,15 @@ cogl_matrix_progress (const GValue *a,
|
|||||||
/* skew */
|
/* skew */
|
||||||
shear_res = shear1[2] + (shear2[2] - shear1[2]) * progress; /* YZ */
|
shear_res = shear1[2] + (shear2[2] - shear1[2]) * progress; /* YZ */
|
||||||
if (shear_res != 0.f)
|
if (shear_res != 0.f)
|
||||||
_clutter_util_matrix_skew_yz (&res, shear_res);
|
cogl_matrix_skew_yz (&res, shear_res);
|
||||||
|
|
||||||
shear_res = shear1[1] + (shear2[1] - shear1[1]) * progress; /* XZ */
|
shear_res = shear1[1] + (shear2[1] - shear1[1]) * progress; /* XZ */
|
||||||
if (shear_res != 0.f)
|
if (shear_res != 0.f)
|
||||||
_clutter_util_matrix_skew_xz (&res, shear_res);
|
cogl_matrix_skew_xz (&res, shear_res);
|
||||||
|
|
||||||
shear_res = shear1[0] + (shear2[0] - shear1[0]) * progress; /* XY */
|
shear_res = shear1[0] + (shear2[0] - shear1[0]) * progress; /* XY */
|
||||||
if (shear_res != 0.f)
|
if (shear_res != 0.f)
|
||||||
_clutter_util_matrix_skew_xy (&res, shear_res);
|
cogl_matrix_skew_xy (&res, shear_res);
|
||||||
|
|
||||||
/* scale */
|
/* scale */
|
||||||
graphene_point3d_interpolate (&scale1, &scale2, progress, &scale_res);
|
graphene_point3d_interpolate (&scale1, &scale2, progress, &scale_res);
|
||||||
|
@ -257,13 +257,6 @@ _clutter_util_vertex4_interpolate (const ClutterVertex4 *a,
|
|||||||
|
|
||||||
float _clutter_util_matrix_determinant (const CoglMatrix *matrix);
|
float _clutter_util_matrix_determinant (const CoglMatrix *matrix);
|
||||||
|
|
||||||
void _clutter_util_matrix_skew_xy (CoglMatrix *matrix,
|
|
||||||
float factor);
|
|
||||||
void _clutter_util_matrix_skew_xz (CoglMatrix *matrix,
|
|
||||||
float factor);
|
|
||||||
void _clutter_util_matrix_skew_yz (CoglMatrix *matrix,
|
|
||||||
float factor);
|
|
||||||
|
|
||||||
gboolean _clutter_util_matrix_decompose (const CoglMatrix *src,
|
gboolean _clutter_util_matrix_decompose (const CoglMatrix *src,
|
||||||
graphene_point3d_t *scale_p,
|
graphene_point3d_t *scale_p,
|
||||||
float shear_p[3],
|
float shear_p[3],
|
||||||
|
@ -285,36 +285,6 @@ _clutter_util_matrix_transpose_vector4_transform (const CoglMatrix *matrix,
|
|||||||
+ matrix->ww * point->w;
|
+ matrix->ww * point->w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
_clutter_util_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_clutter_util_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_clutter_util_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_clutter_util_vertex_combine (const graphene_point3d_t *a,
|
_clutter_util_vertex_combine (const graphene_point3d_t *a,
|
||||||
const graphene_point3d_t *b,
|
const graphene_point3d_t *b,
|
||||||
|
@ -2246,3 +2246,42 @@ cogl_gtype_matrix_get_type (void)
|
|||||||
{
|
{
|
||||||
return cogl_matrix_get_gtype ();
|
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);
|
||||||
|
}
|
||||||
|
@ -760,6 +760,51 @@ GType cogl_matrix_get_gtype (void);
|
|||||||
COGL_EXPORT GType
|
COGL_EXPORT GType
|
||||||
cogl_gtype_matrix_get_type (void);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_MATRIX_H */
|
#endif /* __COGL_MATRIX_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user