Replace ClutterVertex by graphene_point3d_t

Pretty direct and straightforward port. This requires a
GNOME Shell counterpart. In addition to that, include a
progress function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
This commit is contained in:
Georges Basile Stavracas Neto 2019-02-20 10:18:48 -03:00
parent ba0f17f5b1
commit a5d0cfe8fb
30 changed files with 252 additions and 431 deletions

View File

@ -657,7 +657,7 @@ cally_actor_get_extents (AtkComponent *component,
ClutterActor *actor = NULL; ClutterActor *actor = NULL;
gint top_level_x, top_level_y; gint top_level_x, top_level_y;
gfloat f_width, f_height; gfloat f_width, f_height;
ClutterVertex verts[4]; graphene_point3d_t verts[4];
ClutterActor *stage = NULL; ClutterActor *stage = NULL;
g_return_if_fail (CALLY_IS_ACTOR (component)); g_return_if_fail (CALLY_IS_ACTOR (component));

View File

@ -1438,7 +1438,7 @@ static void cally_text_get_character_extents (AtkText *text,
PangoLayout *layout; PangoLayout *layout;
PangoRectangle extents; PangoRectangle extents;
const gchar *text_value; const gchar *text_value;
ClutterVertex verts[4]; graphene_point3d_t verts[4];
actor = CALLY_GET_CLUTTER_ACTOR (text); actor = CALLY_GET_CLUTTER_ACTOR (text);
if (actor == NULL) /* State is defunct */ if (actor == NULL) /* State is defunct */
@ -2294,7 +2294,7 @@ _cally_misc_get_index_at_point (ClutterText *clutter_text,
gint index, x_window, y_window, x_toplevel, y_toplevel; gint index, x_window, y_window, x_toplevel, y_toplevel;
gint x_temp, y_temp; gint x_temp, y_temp;
gboolean ret; gboolean ret;
ClutterVertex verts[4]; graphene_point3d_t verts[4];
PangoLayout *layout; PangoLayout *layout;
gint x_layout, y_layout; gint x_layout, y_layout;

View File

@ -340,7 +340,7 @@ clutter_actor_box_contains (const ClutterActorBox *box,
/** /**
* clutter_actor_box_from_vertices: * clutter_actor_box_from_vertices:
* @box: a #ClutterActorBox * @box: a #ClutterActorBox
* @verts: (array fixed-size=4): array of four #ClutterVertex * @verts: (array fixed-size=4): array of four #graphene_point3d_t
* *
* Calculates the bounding box represented by the four vertices; for details * Calculates the bounding box represented by the four vertices; for details
* of the vertex array see clutter_actor_get_abs_allocation_vertices(). * of the vertex array see clutter_actor_get_abs_allocation_vertices().
@ -349,7 +349,7 @@ clutter_actor_box_contains (const ClutterActorBox *box,
*/ */
void void
clutter_actor_box_from_vertices (ClutterActorBox *box, clutter_actor_box_from_vertices (ClutterActorBox *box,
const ClutterVertex verts[]) const graphene_point3d_t verts[])
{ {
gfloat x_1, x_2, y_1, y_2; gfloat x_1, x_2, y_1, y_2;

View File

@ -135,7 +135,7 @@ struct _AnchorCoord
} fraction; } fraction;
/* Use when is_fractional == FALSE */ /* Use when is_fractional == FALSE */
ClutterVertex units; graphene_point3d_t units;
} v; } v;
}; };
@ -203,7 +203,7 @@ struct _ClutterTransformInfo
AnchorCoord anchor; AnchorCoord anchor;
/* translation */ /* translation */
ClutterVertex translation; graphene_point3d_t translation;
/* z_position */ /* z_position */
gfloat z_position; gfloat z_position;

View File

@ -2890,8 +2890,8 @@ clutter_actor_real_queue_relayout (ClutterActor *self)
* @self: A #ClutterActor * @self: A #ClutterActor
* @ancestor: (allow-none): A #ClutterActor ancestor, or %NULL to use the * @ancestor: (allow-none): A #ClutterActor ancestor, or %NULL to use the
* default #ClutterStage * default #ClutterStage
* @point: A point as #ClutterVertex * @point: A point as #graphene_point3d_t
* @vertex: (out caller-allocates): The translated #ClutterVertex * @vertex: (out caller-allocates): The translated #graphene_point3d_t
* *
* Transforms @point in coordinates relative to the actor into * Transforms @point in coordinates relative to the actor into
* ancestor-relative coordinates using the relevant transform * ancestor-relative coordinates using the relevant transform
@ -2907,8 +2907,8 @@ clutter_actor_real_queue_relayout (ClutterActor *self)
void void
clutter_actor_apply_relative_transform_to_point (ClutterActor *self, clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
ClutterActor *ancestor, ClutterActor *ancestor,
const ClutterVertex *point, const graphene_point3d_t *point,
ClutterVertex *vertex) graphene_point3d_t *vertex)
{ {
gfloat w; gfloat w;
CoglMatrix matrix; CoglMatrix matrix;
@ -2936,8 +2936,8 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
static gboolean static gboolean
_clutter_actor_fully_transform_vertices (ClutterActor *self, _clutter_actor_fully_transform_vertices (ClutterActor *self,
const ClutterVertex *vertices_in, const graphene_point3d_t *vertices_in,
ClutterVertex *vertices_out, graphene_point3d_t *vertices_out,
int n_vertices) int n_vertices)
{ {
ClutterActor *stage; ClutterActor *stage;
@ -2980,8 +2980,8 @@ _clutter_actor_fully_transform_vertices (ClutterActor *self,
/** /**
* clutter_actor_apply_transform_to_point: * clutter_actor_apply_transform_to_point:
* @self: A #ClutterActor * @self: A #ClutterActor
* @point: A point as #ClutterVertex * @point: A point as #graphene_point3d_t
* @vertex: (out caller-allocates): The translated #ClutterVertex * @vertex: (out caller-allocates): The translated #graphene_point3d_t
* *
* Transforms @point in coordinates relative to the actor * Transforms @point in coordinates relative to the actor
* into screen-relative coordinates with the current actor * into screen-relative coordinates with the current actor
@ -2991,8 +2991,8 @@ _clutter_actor_fully_transform_vertices (ClutterActor *self,
**/ **/
void void
clutter_actor_apply_transform_to_point (ClutterActor *self, clutter_actor_apply_transform_to_point (ClutterActor *self,
const ClutterVertex *point, const graphene_point3d_t *point,
ClutterVertex *vertex) graphene_point3d_t *vertex)
{ {
g_return_if_fail (point != NULL); g_return_if_fail (point != NULL);
g_return_if_fail (vertex != NULL); g_return_if_fail (vertex != NULL);
@ -3043,9 +3043,9 @@ _clutter_actor_get_relative_transformation_matrix (ClutterActor *self,
static gboolean static gboolean
_clutter_actor_transform_and_project_box (ClutterActor *self, _clutter_actor_transform_and_project_box (ClutterActor *self,
const ClutterActorBox *box, const ClutterActorBox *box,
ClutterVertex verts[]) graphene_point3d_t *verts)
{ {
ClutterVertex box_vertices[4]; graphene_point3d_t box_vertices[4];
box_vertices[0].x = box->x1; box_vertices[0].x = box->x1;
box_vertices[0].y = box->y1; box_vertices[0].y = box->y1;
@ -3069,8 +3069,8 @@ _clutter_actor_transform_and_project_box (ClutterActor *self,
* @self: A #ClutterActor * @self: A #ClutterActor
* @ancestor: (allow-none): A #ClutterActor to calculate the vertices * @ancestor: (allow-none): A #ClutterActor to calculate the vertices
* against, or %NULL to use the #ClutterStage * against, or %NULL to use the #ClutterStage
* @verts: (out) (array fixed-size=4) (element-type Clutter.Vertex): return * @verts: (out) (array fixed-size=4): return
* location for an array of 4 #ClutterVertex in which to store the result * location for an array of 4 #graphene_point3d_t in which to store the result
* *
* Calculates the transformed coordinates of the four corners of the * Calculates the transformed coordinates of the four corners of the
* actor in the plane of @ancestor. The returned vertices relate to * actor in the plane of @ancestor. The returned vertices relate to
@ -3091,11 +3091,11 @@ _clutter_actor_transform_and_project_box (ClutterActor *self,
void void
clutter_actor_get_allocation_vertices (ClutterActor *self, clutter_actor_get_allocation_vertices (ClutterActor *self,
ClutterActor *ancestor, ClutterActor *ancestor,
ClutterVertex verts[]) graphene_point3d_t *verts)
{ {
ClutterActorPrivate *priv; ClutterActorPrivate *priv;
ClutterActorBox box; ClutterActorBox box;
ClutterVertex vertices[4]; graphene_point3d_t vertices[4];
CoglMatrix modelview; CoglMatrix modelview;
g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (CLUTTER_IS_ACTOR (self));
@ -3147,9 +3147,9 @@ clutter_actor_get_allocation_vertices (ClutterActor *self,
cogl_matrix_transform_points (&modelview, cogl_matrix_transform_points (&modelview,
3, 3,
sizeof (ClutterVertex), sizeof (graphene_point3d_t),
vertices, vertices,
sizeof (ClutterVertex), sizeof (graphene_point3d_t),
vertices, vertices,
4); 4);
} }
@ -3158,7 +3158,7 @@ clutter_actor_get_allocation_vertices (ClutterActor *self,
* clutter_actor_get_abs_allocation_vertices: * clutter_actor_get_abs_allocation_vertices:
* @self: A #ClutterActor * @self: A #ClutterActor
* @verts: (out) (array fixed-size=4): Pointer to a location of an array * @verts: (out) (array fixed-size=4): Pointer to a location of an array
* of 4 #ClutterVertex where to store the result. * of 4 #graphene_point3d_t where to store the result.
* *
* Calculates the transformed screen coordinates of the four corners of * Calculates the transformed screen coordinates of the four corners of
* the actor; the returned vertices relate to the #ClutterActorBox * the actor; the returned vertices relate to the #ClutterActorBox
@ -3173,7 +3173,7 @@ clutter_actor_get_allocation_vertices (ClutterActor *self,
*/ */
void void
clutter_actor_get_abs_allocation_vertices (ClutterActor *self, clutter_actor_get_abs_allocation_vertices (ClutterActor *self,
ClutterVertex verts[]) graphene_point3d_t *verts)
{ {
ClutterActorPrivate *priv; ClutterActorPrivate *priv;
ClutterActorBox actor_space_allocation; ClutterActorBox actor_space_allocation;
@ -3414,7 +3414,7 @@ _clutter_actor_draw_paint_volume_full (ClutterActor *self,
{ {
static CoglPipeline *outline = NULL; static CoglPipeline *outline = NULL;
CoglPrimitive *prim; CoglPrimitive *prim;
ClutterVertex line_ends[12 * 2]; graphene_point3d_t line_ends[12 * 2];
int n_vertices; int n_vertices;
CoglContext *ctx = CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ()); clutter_backend_get_cogl_context (clutter_get_default_backend ());
@ -4473,7 +4473,7 @@ static const ClutterTransformInfo default_transform_info = {
{ 0, }, /* anchor XXX:2.0 - remove*/ { 0, }, /* anchor XXX:2.0 - remove*/
CLUTTER_VERTEX_INIT_ZERO, /* translation */ GRAPHENE_POINT3D_INIT_ZERO, /* translation */
0.f, /* z-position */ 0.f, /* z-position */
@ -4864,9 +4864,9 @@ clutter_actor_get_rotation_angle (ClutterActor *self,
static inline void static inline void
clutter_actor_set_rotation_center_internal (ClutterActor *self, clutter_actor_set_rotation_center_internal (ClutterActor *self,
ClutterRotateAxis axis, ClutterRotateAxis axis,
const ClutterVertex *center) const graphene_point3d_t *center)
{ {
ClutterVertex v = CLUTTER_VERTEX_INIT_ZERO; graphene_point3d_t v = GRAPHENE_POINT3D_INIT_ZERO;
GObject *obj = G_OBJECT (self); GObject *obj = G_OBJECT (self);
ClutterTransformInfo *info; ClutterTransformInfo *info;
@ -5781,7 +5781,7 @@ clutter_actor_get_property (GObject *object,
case PROP_ROTATION_CENTER_X: /* XXX:2.0 - remove */ case PROP_ROTATION_CENTER_X: /* XXX:2.0 - remove */
{ {
ClutterVertex center; graphene_point3d_t center;
clutter_actor_get_rotation (actor, CLUTTER_X_AXIS, clutter_actor_get_rotation (actor, CLUTTER_X_AXIS,
&center.x, &center.x,
@ -5794,7 +5794,7 @@ clutter_actor_get_property (GObject *object,
case PROP_ROTATION_CENTER_Y: /* XXX:2.0 - remove */ case PROP_ROTATION_CENTER_Y: /* XXX:2.0 - remove */
{ {
ClutterVertex center; graphene_point3d_t center;
clutter_actor_get_rotation (actor, CLUTTER_Y_AXIS, clutter_actor_get_rotation (actor, CLUTTER_Y_AXIS,
&center.x, &center.x,
@ -5807,7 +5807,7 @@ clutter_actor_get_property (GObject *object,
case PROP_ROTATION_CENTER_Z: /* XXX:2.0 - remove */ case PROP_ROTATION_CENTER_Z: /* XXX:2.0 - remove */
{ {
ClutterVertex center; graphene_point3d_t center;
clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS, clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS,
&center.x, &center.x,
@ -6224,7 +6224,7 @@ clutter_actor_update_default_paint_volume (ClutterActor *self,
priv->clip.size.width >= 0 && priv->clip.size.width >= 0 &&
priv->clip.size.height >= 0) priv->clip.size.height >= 0)
{ {
ClutterVertex origin; graphene_point3d_t origin;
origin.x = priv->clip.origin.x; origin.x = priv->clip.origin.x;
origin.y = priv->clip.origin.y; origin.y = priv->clip.origin.y;
@ -7277,7 +7277,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
g_param_spec_boxed ("rotation-center-x", g_param_spec_boxed ("rotation-center-x",
P_("Rotation Center X"), P_("Rotation Center X"),
P_("The rotation center on the X axis"), P_("The rotation center on the X axis"),
CLUTTER_TYPE_VERTEX, GRAPHENE_TYPE_POINT3D,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS | G_PARAM_STATIC_STRINGS |
G_PARAM_DEPRECATED); G_PARAM_DEPRECATED);
@ -7295,7 +7295,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
g_param_spec_boxed ("rotation-center-y", g_param_spec_boxed ("rotation-center-y",
P_("Rotation Center Y"), P_("Rotation Center Y"),
P_("The rotation center on the Y axis"), P_("The rotation center on the Y axis"),
CLUTTER_TYPE_VERTEX, GRAPHENE_TYPE_POINT3D,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS | G_PARAM_STATIC_STRINGS |
G_PARAM_DEPRECATED); G_PARAM_DEPRECATED);
@ -7313,7 +7313,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
g_param_spec_boxed ("rotation-center-z", g_param_spec_boxed ("rotation-center-z",
P_("Rotation Center Z"), P_("Rotation Center Z"),
P_("The rotation center on the Z axis"), P_("The rotation center on the Z axis"),
CLUTTER_TYPE_VERTEX, GRAPHENE_TYPE_POINT3D,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS | G_PARAM_STATIC_STRINGS |
G_PARAM_DEPRECATED); G_PARAM_DEPRECATED);
@ -8968,7 +8968,7 @@ _clutter_actor_queue_redraw_full (ClutterActor *self,
if (flags & CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION) if (flags & CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION)
{ {
ClutterActorBox allocation_clip; ClutterActorBox allocation_clip;
ClutterVertex origin; graphene_point3d_t origin;
/* If the actor doesn't have a valid allocation then we will /* If the actor doesn't have a valid allocation then we will
* queue a full stage redraw. */ * queue a full stage redraw. */
@ -9172,7 +9172,7 @@ clutter_actor_queue_redraw_with_clip (ClutterActor *self,
const cairo_rectangle_int_t *clip) const cairo_rectangle_int_t *clip)
{ {
ClutterPaintVolume volume; ClutterPaintVolume volume;
ClutterVertex origin; graphene_point3d_t origin;
g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (CLUTTER_IS_ACTOR (self));
@ -10994,8 +10994,8 @@ clutter_actor_get_transformed_position (ClutterActor *self,
gfloat *x, gfloat *x,
gfloat *y) gfloat *y)
{ {
ClutterVertex v1; graphene_point3d_t v1;
ClutterVertex v2; graphene_point3d_t v2;
v1.x = v1.y = v1.z = 0; v1.x = v1.y = v1.z = 0;
clutter_actor_apply_transform_to_point (self, &v1, &v2); clutter_actor_apply_transform_to_point (self, &v1, &v2);
@ -11041,7 +11041,7 @@ clutter_actor_get_transformed_size (ClutterActor *self,
gfloat *height) gfloat *height)
{ {
ClutterActorPrivate *priv; ClutterActorPrivate *priv;
ClutterVertex v[4]; graphene_point3d_t v[4];
gfloat x_min, x_max, y_min, y_max; gfloat x_min, x_max, y_min, y_max;
gint i; gint i;
@ -12353,7 +12353,7 @@ clutter_actor_set_rotation (ClutterActor *self,
gfloat y, gfloat y,
gfloat z) gfloat z)
{ {
ClutterVertex v; graphene_point3d_t v;
g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (CLUTTER_IS_ACTOR (self));
@ -15332,7 +15332,7 @@ clutter_actor_transform_stage_point (ClutterActor *self,
gfloat *x_out, gfloat *x_out,
gfloat *y_out) gfloat *y_out)
{ {
ClutterVertex v[4]; graphene_point3d_t v[4];
double ST[3][3]; double ST[3][3];
double RQ[3][3]; double RQ[3][3];
int du, dv; int du, dv;

View File

@ -431,7 +431,7 @@ void clutter_actor_get_allocation_box
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_actor_get_allocation_vertices (ClutterActor *self, void clutter_actor_get_allocation_vertices (ClutterActor *self,
ClutterActor *ancestor, ClutterActor *ancestor,
ClutterVertex verts[]); graphene_point3d_t *verts);
CLUTTER_EXPORT CLUTTER_EXPORT
gboolean clutter_actor_has_allocation (ClutterActor *self); gboolean clutter_actor_has_allocation (ClutterActor *self);
CLUTTER_EXPORT CLUTTER_EXPORT
@ -817,16 +817,16 @@ gboolean clutter_actor_transform_stage_point
gfloat *y_out); gfloat *y_out);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_actor_get_abs_allocation_vertices (ClutterActor *self, void clutter_actor_get_abs_allocation_vertices (ClutterActor *self,
ClutterVertex verts[]); graphene_point3d_t *verts);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_actor_apply_transform_to_point (ClutterActor *self, void clutter_actor_apply_transform_to_point (ClutterActor *self,
const ClutterVertex *point, const graphene_point3d_t *point,
ClutterVertex *vertex); graphene_point3d_t *vertex);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_actor_apply_relative_transform_to_point (ClutterActor *self, void clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
ClutterActor *ancestor, ClutterActor *ancestor,
const ClutterVertex *point, const graphene_point3d_t *point,
ClutterVertex *vertex); graphene_point3d_t *vertex);
/* Implicit animations */ /* Implicit animations */
CLUTTER_EXPORT CLUTTER_EXPORT

View File

@ -96,7 +96,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPathNode, clutter_path_node_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPoint, clutter_point_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPoint, clutter_point_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRect, clutter_rect_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRect, clutter_rect_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSize, clutter_size_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSize, clutter_size_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterVertex, clutter_vertex_free)
#endif /* __GI_SCANNER__ */ #endif /* __GI_SCANNER__ */

View File

@ -149,178 +149,6 @@ G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterGeometry, clutter_geometry,
/*
* ClutterVertices
*/
/**
* clutter_vertex_new:
* @x: X coordinate
* @y: Y coordinate
* @z: Z coordinate
*
* Creates a new #ClutterVertex for the point in 3D space
* identified by the 3 coordinates @x, @y, @z.
*
* This function is the logical equivalent of:
*
* |[
* clutter_vertex_init (clutter_vertex_alloc (), x, y, z);
* ]|
*
* Return value: (transfer full): the newly allocated #ClutterVertex.
* Use clutter_vertex_free() to free the resources
*
* Since: 1.0
*/
ClutterVertex *
clutter_vertex_new (gfloat x,
gfloat y,
gfloat z)
{
return clutter_vertex_init (clutter_vertex_alloc (), x, y, z);
}
/**
* clutter_vertex_alloc: (constructor)
*
* Allocates a new, empty #ClutterVertex.
*
* Return value: (transfer full): the newly allocated #ClutterVertex.
* Use clutter_vertex_free() to free its resources
*
* Since: 1.12
*/
ClutterVertex *
clutter_vertex_alloc (void)
{
return g_slice_new0 (ClutterVertex);
}
/**
* clutter_vertex_init:
* @vertex: a #ClutterVertex
* @x: X coordinate
* @y: Y coordinate
* @z: Z coordinate
*
* Initializes @vertex with the given coordinates.
*
* Return value: (transfer none): the initialized #ClutterVertex
*
* Since: 1.10
*/
ClutterVertex *
clutter_vertex_init (ClutterVertex *vertex,
gfloat x,
gfloat y,
gfloat z)
{
g_return_val_if_fail (vertex != NULL, NULL);
vertex->x = x;
vertex->y = y;
vertex->z = z;
return vertex;
}
/**
* clutter_vertex_copy:
* @vertex: a #ClutterVertex
*
* Copies @vertex
*
* Return value: (transfer full): a newly allocated copy of #ClutterVertex.
* Use clutter_vertex_free() to free the allocated resources
*
* Since: 1.0
*/
ClutterVertex *
clutter_vertex_copy (const ClutterVertex *vertex)
{
if (G_LIKELY (vertex != NULL))
return g_slice_dup (ClutterVertex, vertex);
return NULL;
}
/**
* clutter_vertex_free:
* @vertex: a #ClutterVertex
*
* Frees a #ClutterVertex allocated using clutter_vertex_alloc() or
* clutter_vertex_copy().
*
* Since: 1.0
*/
void
clutter_vertex_free (ClutterVertex *vertex)
{
if (G_UNLIKELY (vertex != NULL))
g_slice_free (ClutterVertex, vertex);
}
/**
* clutter_vertex_equal:
* @vertex_a: a #ClutterVertex
* @vertex_b: a #ClutterVertex
*
* Compares @vertex_a and @vertex_b for equality
*
* Return value: %TRUE if the passed #ClutterVertex are equal
*
* Since: 1.0
*/
gboolean
clutter_vertex_equal (const ClutterVertex *vertex_a,
const ClutterVertex *vertex_b)
{
g_return_val_if_fail (vertex_a != NULL && vertex_b != NULL, FALSE);
if (vertex_a == vertex_b)
return TRUE;
return fabsf (vertex_a->x - vertex_b->x) < FLOAT_EPSILON &&
fabsf (vertex_a->y - vertex_b->y) < FLOAT_EPSILON &&
fabsf (vertex_a->z - vertex_b->z) < FLOAT_EPSILON;
}
static void
clutter_vertex_interpolate (const ClutterVertex *a,
const ClutterVertex *b,
double progress,
ClutterVertex *res)
{
res->x = a->x + (b->x - a->x) * progress;
res->y = a->y + (b->y - a->y) * progress;
res->z = a->z + (b->z - a->z) * progress;
}
static gboolean
clutter_vertex_progress (const GValue *a,
const GValue *b,
gdouble progress,
GValue *retval)
{
const ClutterVertex *av = g_value_get_boxed (a);
const ClutterVertex *bv = g_value_get_boxed (b);
ClutterVertex res;
clutter_vertex_interpolate (av, bv, progress, &res);
g_value_set_boxed (retval, &res);
return TRUE;
}
G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterVertex, clutter_vertex,
clutter_vertex_copy,
clutter_vertex_free,
CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_vertex_progress));
/* /*
* ClutterMargin * ClutterMargin
*/ */
@ -1393,20 +1221,20 @@ clutter_matrix_progress (const GValue *a,
{ {
const ClutterMatrix *matrix1 = g_value_get_boxed (a); const ClutterMatrix *matrix1 = g_value_get_boxed (a);
const ClutterMatrix *matrix2 = g_value_get_boxed (b); const ClutterMatrix *matrix2 = g_value_get_boxed (b);
ClutterVertex scale1 = CLUTTER_VERTEX_INIT (1.f, 1.f, 1.f); graphene_point3d_t scale1 = GRAPHENE_POINT3D_INIT (1.f, 1.f, 1.f);
float shear1[3] = { 0.f, 0.f, 0.f }; float shear1[3] = { 0.f, 0.f, 0.f };
ClutterVertex rotate1 = CLUTTER_VERTEX_INIT_ZERO; graphene_point3d_t rotate1 = GRAPHENE_POINT3D_INIT_ZERO;
ClutterVertex translate1 = CLUTTER_VERTEX_INIT_ZERO; graphene_point3d_t translate1 = GRAPHENE_POINT3D_INIT_ZERO;
ClutterVertex4 perspective1 = { 0.f, 0.f, 0.f, 0.f }; ClutterVertex4 perspective1 = { 0.f, 0.f, 0.f, 0.f };
ClutterVertex scale2 = CLUTTER_VERTEX_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 };
ClutterVertex rotate2 = CLUTTER_VERTEX_INIT_ZERO; graphene_point3d_t rotate2 = GRAPHENE_POINT3D_INIT_ZERO;
ClutterVertex translate2 = CLUTTER_VERTEX_INIT_ZERO; graphene_point3d_t translate2 = GRAPHENE_POINT3D_INIT_ZERO;
ClutterVertex4 perspective2 = { 0.f, 0.f, 0.f, 0.f }; ClutterVertex4 perspective2 = { 0.f, 0.f, 0.f, 0.f };
ClutterVertex scale_res = CLUTTER_VERTEX_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;
ClutterVertex rotate_res = CLUTTER_VERTEX_INIT_ZERO; graphene_point3d_t rotate_res = GRAPHENE_POINT3D_INIT_ZERO;
ClutterVertex translate_res = CLUTTER_VERTEX_INIT_ZERO; graphene_point3d_t translate_res = GRAPHENE_POINT3D_INIT_ZERO;
ClutterVertex4 perspective_res = { 0.f, 0.f, 0.f, 0.f }; ClutterVertex4 perspective_res = { 0.f, 0.f, 0.f, 0.f };
ClutterMatrix res; ClutterMatrix res;
@ -1427,11 +1255,11 @@ clutter_matrix_progress (const GValue *a,
res.ww = perspective_res.w; res.ww = perspective_res.w;
/* translation */ /* translation */
clutter_vertex_interpolate (&translate1, &translate2, progress, &translate_res); graphene_point3d_interpolate (&translate1, &translate2, progress, &translate_res);
cogl_matrix_translate (&res, translate_res.x, translate_res.y, translate_res.z); cogl_matrix_translate (&res, translate_res.x, translate_res.y, translate_res.z);
/* rotation */ /* rotation */
clutter_vertex_interpolate (&rotate1, &rotate2, progress, &rotate_res); graphene_point3d_interpolate (&rotate1, &rotate2, progress, &rotate_res);
cogl_matrix_rotate (&res, rotate_res.x, 1.0f, 0.0f, 0.0f); cogl_matrix_rotate (&res, rotate_res.x, 1.0f, 0.0f, 0.0f);
cogl_matrix_rotate (&res, rotate_res.y, 0.0f, 1.0f, 0.0f); cogl_matrix_rotate (&res, rotate_res.y, 0.0f, 1.0f, 0.0f);
cogl_matrix_rotate (&res, rotate_res.z, 0.0f, 0.0f, 1.0f); cogl_matrix_rotate (&res, rotate_res.z, 0.0f, 0.0f, 1.0f);
@ -1450,7 +1278,7 @@ clutter_matrix_progress (const GValue *a,
_clutter_util_matrix_skew_xy (&res, shear_res); _clutter_util_matrix_skew_xy (&res, shear_res);
/* scale */ /* scale */
clutter_vertex_interpolate (&scale1, &scale2, progress, &scale_res); graphene_point3d_interpolate (&scale1, &scale2, progress, &scale_res);
cogl_matrix_scale (&res, scale_res.x, scale_res.y, scale_res.z); cogl_matrix_scale (&res, scale_res.x, scale_res.y, scale_res.z);
g_value_set_boxed (retval, &res); g_value_set_boxed (retval, &res);

View File

@ -152,7 +152,9 @@ clutter_bind_constraint_update_allocation (ClutterConstraint *constraint,
ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (constraint); ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (constraint);
gfloat source_width, source_height; gfloat source_width, source_height;
gfloat actor_width, actor_height; gfloat actor_width, actor_height;
ClutterVertex source_position = { 0., }; graphene_point3d_t source_position;
source_position = GRAPHENE_POINT3D_INIT (0.f, 0.f, 0.f);
if (bind->source == NULL) if (bind->source == NULL)
return; return;

View File

@ -182,7 +182,7 @@ clutter_blur_effect_modify_paint_volume (ClutterEffect *effect,
ClutterPaintVolume *volume) ClutterPaintVolume *volume)
{ {
gfloat cur_width, cur_height; gfloat cur_width, cur_height;
ClutterVertex origin; graphene_point3d_t origin;
clutter_paint_volume_get_origin (volume, &origin); clutter_paint_volume_get_origin (volume, &origin);
cur_width = clutter_paint_volume_get_width (volume); cur_width = clutter_paint_volume_get_width (volume);

View File

@ -0,0 +1,54 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* Copyright (C) 2019 Endless, Inc
* Copyright (C) 2009, 2010 Intel Corp
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clutter-build-config.h"
#include "clutter-graphene.h"
#include "clutter-private.h"
#include "clutter-types.h"
static gboolean
graphene_point3d_progress (const GValue *a,
const GValue *b,
double progress,
GValue *retval)
{
const graphene_point3d_t *av = g_value_get_boxed (a);
const graphene_point3d_t *bv = g_value_get_boxed (b);
graphene_point3d_t res;
graphene_point3d_interpolate (av, bv, progress, &res);
g_value_set_boxed (retval, &res);
return TRUE;
}
void
clutter_graphene_init (void)
{
clutter_interval_register_progress_func (GRAPHENE_TYPE_POINT3D,
graphene_point3d_progress);
}

View File

@ -0,0 +1,30 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* Copyright (C) 2019 Endless, Inc
* Copyright (C) 2009, 2010 Intel Corp
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLUTTER_GRAPHENE_H
#define CLUTTER_GRAPHENE_H
void clutter_graphene_init (void);
#endif

View File

@ -59,6 +59,7 @@
#include "clutter-event-private.h" #include "clutter-event-private.h"
#include "clutter-feature.h" #include "clutter-feature.h"
#include "clutter-input-pointer-a11y-private.h" #include "clutter-input-pointer-a11y-private.h"
#include "clutter-graphene.h"
#include "clutter-main.h" #include "clutter-main.h"
#include "clutter-master-clock.h" #include "clutter-master-clock.h"
#include "clutter-mutter.h" #include "clutter-mutter.h"
@ -2194,6 +2195,8 @@ clutter_base_init (void)
/* initialise the Big Clutter Lock™ if necessary */ /* initialise the Big Clutter Lock™ if necessary */
clutter_threads_init_default (); clutter_threads_init_default ();
clutter_graphene_init ();
} }
} }

View File

@ -86,7 +86,7 @@ struct _ClutterOffscreenEffectPrivate
ClutterActor *actor; ClutterActor *actor;
ClutterActor *stage; ClutterActor *stage;
ClutterVertex position; graphene_point3d_t position;
int fbo_offset_x; int fbo_offset_x;
int fbo_offset_y; int fbo_offset_y;
@ -250,9 +250,11 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect)
gfloat target_width = -1, target_height = -1; gfloat target_width = -1, target_height = -1;
gfloat resource_scale; gfloat resource_scale;
gfloat ceiled_resource_scale; gfloat ceiled_resource_scale;
ClutterVertex local_offset = { 0.f, 0.f, 0.f }; graphene_point3d_t local_offset;
gfloat old_viewport[4]; gfloat old_viewport[4];
local_offset = GRAPHENE_POINT3D_INIT (0.0f, 0.0f, 0.0f);
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect))) if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
return FALSE; return FALSE;

View File

@ -58,7 +58,7 @@ struct _ClutterPaintVolume
* elements 4, 5, 6 and 7 most of the time for 2D actors when * elements 4, 5, 6 and 7 most of the time for 2D actors when
* calculating the projected paint box. * calculating the projected paint box.
*/ */
ClutterVertex vertices[8]; graphene_point3d_t vertices[8];
/* As an optimization for internally managed PaintVolumes we allow /* As an optimization for internally managed PaintVolumes we allow
* initializing ClutterPaintVolume variables allocated on the stack * initializing ClutterPaintVolume variables allocated on the stack

View File

@ -63,7 +63,7 @@ _clutter_paint_volume_new (ClutterActor *actor)
pv->actor = actor; pv->actor = actor;
memset (pv->vertices, 0, 8 * sizeof (ClutterVertex)); memset (pv->vertices, 0, 8 * sizeof (graphene_point3d_t));
pv->is_static = FALSE; pv->is_static = FALSE;
pv->is_empty = TRUE; pv->is_empty = TRUE;
@ -96,7 +96,7 @@ _clutter_paint_volume_init_static (ClutterPaintVolume *pv,
{ {
pv->actor = actor; pv->actor = actor;
memset (pv->vertices, 0, 8 * sizeof (ClutterVertex)); memset (pv->vertices, 0, 8 * sizeof (graphene_point3d_t));
pv->is_static = TRUE; pv->is_static = TRUE;
pv->is_empty = TRUE; pv->is_empty = TRUE;
@ -170,7 +170,7 @@ clutter_paint_volume_free (ClutterPaintVolume *pv)
/** /**
* clutter_paint_volume_set_origin: * clutter_paint_volume_set_origin:
* @pv: a #ClutterPaintVolume * @pv: a #ClutterPaintVolume
* @origin: a #ClutterVertex * @origin: a #graphene_point3d_t
* *
* Sets the origin of the paint volume. * Sets the origin of the paint volume.
* *
@ -183,7 +183,7 @@ clutter_paint_volume_free (ClutterPaintVolume *pv)
*/ */
void void
clutter_paint_volume_set_origin (ClutterPaintVolume *pv, clutter_paint_volume_set_origin (ClutterPaintVolume *pv,
const ClutterVertex *origin) const graphene_point3d_t *origin)
{ {
static const int key_vertices[4] = { 0, 1, 3, 4 }; static const int key_vertices[4] = { 0, 1, 3, 4 };
float dx, dy, dz; float dx, dy, dz;
@ -210,7 +210,7 @@ clutter_paint_volume_set_origin (ClutterPaintVolume *pv,
/** /**
* clutter_paint_volume_get_origin: * clutter_paint_volume_get_origin:
* @pv: a #ClutterPaintVolume * @pv: a #ClutterPaintVolume
* @vertex: (out): the return location for a #ClutterVertex * @vertex: (out): the return location for a #graphene_point3d_t
* *
* Retrieves the origin of the #ClutterPaintVolume. * Retrieves the origin of the #ClutterPaintVolume.
* *
@ -218,7 +218,7 @@ clutter_paint_volume_set_origin (ClutterPaintVolume *pv,
*/ */
void void
clutter_paint_volume_get_origin (const ClutterPaintVolume *pv, clutter_paint_volume_get_origin (const ClutterPaintVolume *pv,
ClutterVertex *vertex) graphene_point3d_t *vertex)
{ {
g_return_if_fail (pv != NULL); g_return_if_fail (pv != NULL);
g_return_if_fail (vertex != NULL); g_return_if_fail (vertex != NULL);
@ -659,7 +659,7 @@ clutter_paint_volume_union_box (ClutterPaintVolume *pv,
const ClutterActorBox *box) const ClutterActorBox *box)
{ {
ClutterPaintVolume volume; ClutterPaintVolume volume;
ClutterVertex origin; graphene_point3d_t origin;
g_return_if_fail (pv != NULL); g_return_if_fail (pv != NULL);
g_return_if_fail (box != NULL); g_return_if_fail (box != NULL);
@ -757,7 +757,7 @@ _clutter_paint_volume_get_bounding_box (ClutterPaintVolume *pv,
ClutterActorBox *box) ClutterActorBox *box)
{ {
gfloat x_min, y_min, x_max, y_max; gfloat x_min, y_min, x_max, y_max;
ClutterVertex *vertices; graphene_point3d_t *vertices;
int count; int count;
gint i; gint i;
@ -878,9 +878,9 @@ _clutter_paint_volume_transform (ClutterPaintVolume *pv,
cogl_matrix_transform_points (matrix, cogl_matrix_transform_points (matrix,
3, 3,
sizeof (ClutterVertex), sizeof (graphene_point3d_t),
pv->vertices, pv->vertices,
sizeof (ClutterVertex), sizeof (graphene_point3d_t),
pv->vertices, pv->vertices,
transform_count); transform_count);
@ -896,7 +896,7 @@ _clutter_paint_volume_axis_align (ClutterPaintVolume *pv)
{ {
int count; int count;
int i; int i;
ClutterVertex origin; graphene_point3d_t origin;
float max_x; float max_x;
float max_y; float max_y;
float max_z; float max_z;
@ -1075,7 +1075,7 @@ _clutter_paint_volume_cull (ClutterPaintVolume *pv,
const ClutterPlane *planes) const ClutterPlane *planes)
{ {
int vertex_count; int vertex_count;
ClutterVertex *vertices = pv->vertices; graphene_point3d_t *vertices = pv->vertices;
gboolean partial = FALSE; gboolean partial = FALSE;
int i; int i;
int j; int j;

View File

@ -223,8 +223,8 @@ GType _clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager
void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
const CoglMatrix *projection, const CoglMatrix *projection,
const float *viewport, const float *viewport,
const ClutterVertex *vertices_in, const graphene_point3d_t *vertices_in,
ClutterVertex *vertices_out, graphene_point3d_t *vertices_out,
int n_vertices); int n_vertices);
void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src, void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
@ -278,10 +278,10 @@ void _clutter_util_matrix_skew_yz (ClutterMatrix *matrix,
float factor); float factor);
gboolean _clutter_util_matrix_decompose (const ClutterMatrix *src, gboolean _clutter_util_matrix_decompose (const ClutterMatrix *src,
ClutterVertex *scale_p, graphene_point3d_t *scale_p,
float shear_p[3], float shear_p[3],
ClutterVertex *rotate_p, graphene_point3d_t *rotate_p,
ClutterVertex *translate_p, graphene_point3d_t *translate_p,
ClutterVertex4 *perspective_p); ClutterVertex4 *perspective_p);
CLUTTER_EXPORT CLUTTER_EXPORT

View File

@ -2799,7 +2799,7 @@ add_selection_to_paint_volume (ClutterText *text,
{ {
ClutterPaintVolume *total_volume = user_data; ClutterPaintVolume *total_volume = user_data;
ClutterPaintVolume rect_volume; ClutterPaintVolume rect_volume;
ClutterVertex vertex; graphene_point3d_t vertex;
_clutter_paint_volume_init_static (&rect_volume, CLUTTER_ACTOR (text)); _clutter_paint_volume_init_static (&rect_volume, CLUTTER_ACTOR (text));
@ -2821,7 +2821,7 @@ clutter_text_get_paint_volume_for_cursor (ClutterText *text,
ClutterPaintVolume *volume) ClutterPaintVolume *volume)
{ {
ClutterTextPrivate *priv = text->priv; ClutterTextPrivate *priv = text->priv;
ClutterVertex origin; graphene_point3d_t origin;
clutter_text_ensure_cursor_position (text, resource_scale); clutter_text_ensure_cursor_position (text, resource_scale);
@ -2864,7 +2864,7 @@ clutter_text_get_paint_volume (ClutterActor *self,
{ {
PangoLayout *layout; PangoLayout *layout;
PangoRectangle ink_rect; PangoRectangle ink_rect;
ClutterVertex origin; graphene_point3d_t origin;
float resource_scale; float resource_scale;
/* If the text is single line editable then it gets clipped to /* If the text is single line editable then it gets clipped to

View File

@ -33,6 +33,8 @@
#include <clutter/clutter-macros.h> #include <clutter/clutter-macros.h>
#include <clutter/clutter-enums.h> #include <clutter/clutter-enums.h>
#include <graphene-gobject.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define CLUTTER_TYPE_ACTOR_BOX (clutter_actor_box_get_type ()) #define CLUTTER_TYPE_ACTOR_BOX (clutter_actor_box_get_type ())
@ -42,7 +44,6 @@ G_BEGIN_DECLS
#define CLUTTER_TYPE_MATRIX (clutter_matrix_get_type ()) #define CLUTTER_TYPE_MATRIX (clutter_matrix_get_type ())
#define CLUTTER_TYPE_PAINT_VOLUME (clutter_paint_volume_get_type ()) #define CLUTTER_TYPE_PAINT_VOLUME (clutter_paint_volume_get_type ())
#define CLUTTER_TYPE_PERSPECTIVE (clutter_perspective_get_type ()) #define CLUTTER_TYPE_PERSPECTIVE (clutter_perspective_get_type ())
#define CLUTTER_TYPE_VERTEX (clutter_vertex_get_type ())
#define CLUTTER_TYPE_POINT (clutter_point_get_type ()) #define CLUTTER_TYPE_POINT (clutter_point_get_type ())
#define CLUTTER_TYPE_SIZE (clutter_size_get_type ()) #define CLUTTER_TYPE_SIZE (clutter_size_get_type ())
#define CLUTTER_TYPE_RECT (clutter_rect_get_type ()) #define CLUTTER_TYPE_RECT (clutter_rect_get_type ())
@ -85,7 +86,6 @@ typedef struct _ClutterPerspective ClutterPerspective;
typedef struct _ClutterPoint ClutterPoint; typedef struct _ClutterPoint ClutterPoint;
typedef struct _ClutterRect ClutterRect; typedef struct _ClutterRect ClutterRect;
typedef struct _ClutterSize ClutterSize; typedef struct _ClutterSize ClutterSize;
typedef struct _ClutterVertex ClutterVertex;
typedef struct _ClutterAlpha ClutterAlpha; typedef struct _ClutterAlpha ClutterAlpha;
typedef struct _ClutterAnimation ClutterAnimation; typedef struct _ClutterAnimation ClutterAnimation;
@ -376,69 +376,6 @@ float clutter_rect_get_width (ClutterRect *rect
CLUTTER_EXPORT CLUTTER_EXPORT
float clutter_rect_get_height (ClutterRect *rect); float clutter_rect_get_height (ClutterRect *rect);
/**
* ClutterVertex:
* @x: X coordinate of the vertex
* @y: Y coordinate of the vertex
* @z: Z coordinate of the vertex
*
* A point in 3D space, expressed in pixels
*
* Since: 0.4
*/
struct _ClutterVertex
{
gfloat x;
gfloat y;
gfloat z;
};
/**
* CLUTTER_VERTEX_INIT:
* @x: the X coordinate of the vertex
* @y: the Y coordinate of the vertex
* @z: the Z coordinate of the vertex
*
* A simple macro for initializing a #ClutterVertex when declaring it, e.g.:
*
* |[
* ClutterVertex v = CLUTTER_VERTEX_INIT (x, y, z);
* ]|
*
* Since: 1.10
*/
#define CLUTTER_VERTEX_INIT(x,y,z) { (x), (y), (z) }
/**
* CLUTTER_VERTEX_INIT_ZERO:
*
* A simple macro for initializing a #ClutterVertex to (0, 0, 0).
*
* Since: 1.12
*/
#define CLUTTER_VERTEX_INIT_ZERO CLUTTER_VERTEX_INIT (0.f, 0.f, 0.f)
CLUTTER_EXPORT
GType clutter_vertex_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
ClutterVertex *clutter_vertex_new (gfloat x,
gfloat y,
gfloat z);
CLUTTER_EXPORT
ClutterVertex *clutter_vertex_alloc (void);
CLUTTER_EXPORT
ClutterVertex *clutter_vertex_init (ClutterVertex *vertex,
gfloat x,
gfloat y,
gfloat z);
CLUTTER_EXPORT
ClutterVertex *clutter_vertex_copy (const ClutterVertex *vertex);
CLUTTER_EXPORT
void clutter_vertex_free (ClutterVertex *vertex);
CLUTTER_EXPORT
gboolean clutter_vertex_equal (const ClutterVertex *vertex_a,
const ClutterVertex *vertex_b);
/** /**
* ClutterActorBox: * ClutterActorBox:
* @x1: X coordinate of the top left corner * @x1: X coordinate of the top left corner
@ -543,7 +480,7 @@ gboolean clutter_actor_box_contains (const ClutterActorBox *box,
gfloat y); gfloat y);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_actor_box_from_vertices (ClutterActorBox *box, void clutter_actor_box_from_vertices (ClutterActorBox *box,
const ClutterVertex verts[]); const graphene_point3d_t verts[]);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_actor_box_interpolate (const ClutterActorBox *initial, void clutter_actor_box_interpolate (const ClutterActorBox *initial,
const ClutterActorBox *final, const ClutterActorBox *final,
@ -675,10 +612,10 @@ void clutter_paint_volume_free (ClutterPaintVolume
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_paint_volume_set_origin (ClutterPaintVolume *pv, void clutter_paint_volume_set_origin (ClutterPaintVolume *pv,
const ClutterVertex *origin); const graphene_point3d_t *origin);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_paint_volume_get_origin (const ClutterPaintVolume *pv, void clutter_paint_volume_get_origin (const ClutterPaintVolume *pv,
ClutterVertex *vertex); graphene_point3d_t *vertex);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_paint_volume_set_width (ClutterPaintVolume *pv, void clutter_paint_volume_set_width (ClutterPaintVolume *pv,
gfloat width); gfloat width);

View File

@ -51,8 +51,8 @@ void
_clutter_util_fully_transform_vertices (const CoglMatrix *modelview, _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
const CoglMatrix *projection, const CoglMatrix *projection,
const float *viewport, const float *viewport,
const ClutterVertex *vertices_in, const graphene_point3d_t *vertices_in,
ClutterVertex *vertices_out, graphene_point3d_t *vertices_out,
int n_vertices) int n_vertices)
{ {
CoglMatrix modelview_projection; CoglMatrix modelview_projection;
@ -69,7 +69,7 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
modelview); modelview);
cogl_matrix_project_points (&modelview_projection, cogl_matrix_project_points (&modelview_projection,
3, 3,
sizeof (ClutterVertex), sizeof (graphene_point3d_t),
vertices_in, vertices_in,
sizeof (ClutterVertex4), sizeof (ClutterVertex4),
vertices_tmp, vertices_tmp,
@ -79,7 +79,7 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
{ {
cogl_matrix_transform_points (modelview, cogl_matrix_transform_points (modelview,
3, 3,
sizeof (ClutterVertex), sizeof (graphene_point3d_t),
vertices_in, vertices_in,
sizeof (ClutterVertex4), sizeof (ClutterVertex4),
vertices_tmp, vertices_tmp,
@ -97,7 +97,7 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
for (i = 0; i < n_vertices; i++) for (i = 0; i < n_vertices; i++)
{ {
ClutterVertex4 vertex_tmp = vertices_tmp[i]; ClutterVertex4 vertex_tmp = vertices_tmp[i];
ClutterVertex *vertex_out = &vertices_out[i]; graphene_point3d_t *vertex_out = &vertices_out[i];
/* Finally translate from OpenGL coords to window coords */ /* Finally translate from OpenGL coords to window coords */
vertex_out->x = MTX_GL_SCALE_X (vertex_tmp.x, vertex_tmp.w, vertex_out->x = MTX_GL_SCALE_X (vertex_tmp.x, vertex_tmp.w,
viewport[2], viewport[0]); viewport[2], viewport[0]);
@ -299,48 +299,12 @@ _clutter_util_matrix_skew_yz (ClutterMatrix *matrix,
matrix->zw += matrix->yw * factor; matrix->zw += matrix->yw * factor;
} }
static float
_clutter_util_vertex_length (const ClutterVertex *vertex)
{
return sqrtf (vertex->x * vertex->x + vertex->y * vertex->y + vertex->z * vertex->z);
}
static void static void
_clutter_util_vertex_normalize (ClutterVertex *vertex) _clutter_util_vertex_combine (const graphene_point3d_t *a,
{ const graphene_point3d_t *b,
float factor = _clutter_util_vertex_length (vertex);
if (factor == 0.f)
return;
vertex->x /= factor;
vertex->y /= factor;
vertex->z /= factor;
}
static float
_clutter_util_vertex_dot (const ClutterVertex *v1,
const ClutterVertex *v2)
{
return v1->x * v2->x + v1->y * v2->y + v1->z * v2->z;
}
static void
_clutter_util_vertex_cross (const ClutterVertex *v1,
const ClutterVertex *v2,
ClutterVertex *res)
{
res->x = v1->y * v2->z - v2->y * v1->z;
res->y = v1->z * v2->x - v2->z * v1->x;
res->z = v1->x * v2->y - v2->x * v1->y;
}
static void
_clutter_util_vertex_combine (const ClutterVertex *a,
const ClutterVertex *b,
double ascl, double ascl,
double bscl, double bscl,
ClutterVertex *res) graphene_point3d_t *res)
{ {
res->x = (ascl * a->x) + (bscl * b->x); res->x = (ascl * a->x) + (bscl * b->x);
res->y = (ascl * a->y) + (bscl * b->y); res->y = (ascl * a->y) + (bscl * b->y);
@ -388,16 +352,16 @@ _clutter_util_vertex4_interpolate (const ClutterVertex4 *a,
*/ */
gboolean gboolean
_clutter_util_matrix_decompose (const ClutterMatrix *src, _clutter_util_matrix_decompose (const ClutterMatrix *src,
ClutterVertex *scale_p, graphene_point3d_t *scale_p,
float shear_p[3], float shear_p[3],
ClutterVertex *rotate_p, graphene_point3d_t *rotate_p,
ClutterVertex *translate_p, graphene_point3d_t *translate_p,
ClutterVertex4 *perspective_p) ClutterVertex4 *perspective_p)
{ {
CoglMatrix matrix = *src; CoglMatrix matrix = *src;
CoglMatrix perspective; CoglMatrix perspective;
ClutterVertex4 vertex_tmp; ClutterVertex4 vertex_tmp;
ClutterVertex row[3], pdum; graphene_point3d_t row[3], pdum;
int i, j; int i, j;
#define XY_SHEAR 0 #define XY_SHEAR 0
@ -485,34 +449,34 @@ _clutter_util_matrix_decompose (const ClutterMatrix *src,
} }
/* compute scale.x and normalize the first row */ /* compute scale.x and normalize the first row */
scale_p->x = _clutter_util_vertex_length (&row[0]); scale_p->x = graphene_point3d_length (&row[0]);
_clutter_util_vertex_normalize (&row[0]); graphene_point3d_normalize (&row[0], &row[0]);
/* compute XY shear and make the second row orthogonal to the first */ /* compute XY shear and make the second row orthogonal to the first */
shear_p[XY_SHEAR] = _clutter_util_vertex_dot (&row[0], &row[1]); shear_p[XY_SHEAR] = graphene_point3d_dot (&row[0], &row[1]);
_clutter_util_vertex_combine (&row[1], &row[0], _clutter_util_vertex_combine (&row[1], &row[0],
1.0, -shear_p[XY_SHEAR], 1.0, -shear_p[XY_SHEAR],
&row[1]); &row[1]);
/* compute the Y scale and normalize the second row */ /* compute the Y scale and normalize the second row */
scale_p->y = _clutter_util_vertex_length (&row[1]); scale_p->y = graphene_point3d_length (&row[1]);
_clutter_util_vertex_normalize (&row[1]); graphene_point3d_normalize (&row[1], &row[1]);
shear_p[XY_SHEAR] /= scale_p->y; shear_p[XY_SHEAR] /= scale_p->y;
/* compute XZ and YZ shears, orthogonalize the third row */ /* compute XZ and YZ shears, orthogonalize the third row */
shear_p[XZ_SHEAR] = _clutter_util_vertex_dot (&row[0], &row[2]); shear_p[XZ_SHEAR] = graphene_point3d_dot (&row[0], &row[2]);
_clutter_util_vertex_combine (&row[2], &row[0], _clutter_util_vertex_combine (&row[2], &row[0],
1.0, -shear_p[XZ_SHEAR], 1.0, -shear_p[XZ_SHEAR],
&row[2]); &row[2]);
shear_p[YZ_SHEAR] = _clutter_util_vertex_dot (&row[1], &row[2]); shear_p[YZ_SHEAR] = graphene_point3d_dot (&row[1], &row[2]);
_clutter_util_vertex_combine (&row[2], &row[1], _clutter_util_vertex_combine (&row[2], &row[1],
1.0, -shear_p[YZ_SHEAR], 1.0, -shear_p[YZ_SHEAR],
&row[2]); &row[2]);
/* get the Z scale and normalize the third row*/ /* get the Z scale and normalize the third row*/
scale_p->z = _clutter_util_vertex_length (&row[2]); scale_p->z = graphene_point3d_length (&row[2]);
_clutter_util_vertex_normalize (&row[2]); graphene_point3d_normalize (&row[2], &row[2]);
shear_p[XZ_SHEAR] /= scale_p->z; shear_p[XZ_SHEAR] /= scale_p->z;
shear_p[YZ_SHEAR] /= scale_p->z; shear_p[YZ_SHEAR] /= scale_p->z;
@ -520,8 +484,8 @@ _clutter_util_matrix_decompose (const ClutterMatrix *src,
* check for a coordinate system flip; if the determinant * check for a coordinate system flip; if the determinant
* is -1, then negate the matrix and scaling factors * is -1, then negate the matrix and scaling factors
*/ */
_clutter_util_vertex_cross (&row[1], &row[2], &pdum); graphene_point3d_cross (&row[1], &row[2], &pdum);
if (_clutter_util_vertex_dot (&row[0], &pdum) < 0.f) if (graphene_point3d_dot (&row[0], &pdum) < 0.f)
{ {
scale_p->x *= -1.f; scale_p->x *= -1.f;

View File

@ -244,7 +244,7 @@ clutter_zoom_action_real_zoom (ClutterZoomAction *action,
ClutterZoomActionPrivate *priv = action->priv; ClutterZoomActionPrivate *priv = action->priv;
gfloat x, y, z; gfloat x, y, z;
gdouble scale_x, scale_y; gdouble scale_x, scale_y;
ClutterVertex out, in; graphene_point3d_t out, in;
in.x = priv->transformed_focal_point.x; in.x = priv->transformed_focal_point.x;
in.y = priv->transformed_focal_point.y; in.y = priv->transformed_focal_point.y;

View File

@ -2220,7 +2220,7 @@ clutter_actor_animate_with_timeline (ClutterActor *actor,
* *
* Will animate the "rotation-angle-z" property between the current value * Will animate the "rotation-angle-z" property between the current value
* and 360 degrees, and set the "rotation-center-z" property to the fixed * and 360 degrees, and set the "rotation-center-z" property to the fixed
* value of the #ClutterVertex "center". * value of the #graphene_point3d_t "center".
* *
* This function will implicitly create a #ClutterAnimation object which * This function will implicitly create a #ClutterAnimation object which
* will be assigned to the @actor and will be returned to the developer * will be assigned to the @actor and will be returned to the developer

View File

@ -438,7 +438,7 @@ set_viewport_with_buffer_under_fbo_source (ClutterActor *fbo_source,
* falling back to a stage sized fbo with an offset of (0,0) * falling back to a stage sized fbo with an offset of (0,0)
*/ */
ClutterVertex verts[4]; graphene_point3d_t verts[4];
float x_min = G_MAXFLOAT, y_min = G_MAXFLOAT; float x_min = G_MAXFLOAT, y_min = G_MAXFLOAT;
int i; int i;

View File

@ -127,6 +127,7 @@ clutter_sources = [
'clutter-flatten-effect.c', 'clutter-flatten-effect.c',
'clutter-flow-layout.c', 'clutter-flow-layout.c',
'clutter-gesture-action.c', 'clutter-gesture-action.c',
'clutter-graphene.c',
'clutter-grid-layout.c', 'clutter-grid-layout.c',
'clutter-image.c', 'clutter-image.c',
'clutter-input-device.c', 'clutter-input-device.c',
@ -191,6 +192,7 @@ clutter_private_headers = [
'clutter-effect-private.h', 'clutter-effect-private.h',
'clutter-event-private.h', 'clutter-event-private.h',
'clutter-flatten-effect.h', 'clutter-flatten-effect.h',
'clutter-graphene.h',
'clutter-gesture-action-private.h', 'clutter-gesture-action-private.h',
'clutter-id-pool.h', 'clutter-id-pool.h',
'clutter-input-focus-private.h', 'clutter-input-focus-private.h',

View File

@ -66,7 +66,7 @@ round_to_fixed (float x)
* in @x_origin and @y_origin. * in @x_origin and @y_origin.
*/ */
gboolean gboolean
meta_actor_vertices_are_untransformed (ClutterVertex *verts, meta_actor_vertices_are_untransformed (graphene_point3d_t *verts,
float widthf, float widthf,
float heightf, float heightf,
int *x_origin, int *x_origin,
@ -119,7 +119,7 @@ meta_actor_is_untransformed (ClutterActor *actor,
int *y_origin) int *y_origin)
{ {
gfloat widthf, heightf; gfloat widthf, heightf;
ClutterVertex verts[4]; graphene_point3d_t verts[4];
clutter_actor_get_size (actor, &widthf, &heightf); clutter_actor_get_size (actor, &widthf, &heightf);
clutter_actor_get_abs_allocation_vertices (actor, verts); clutter_actor_get_abs_allocation_vertices (actor, verts);
@ -153,7 +153,7 @@ meta_actor_painting_untransformed (CoglFramebuffer *fb,
int *y_origin) int *y_origin)
{ {
CoglMatrix modelview, projection, modelview_projection; CoglMatrix modelview, projection, modelview_projection;
ClutterVertex vertices[4]; graphene_point3d_t vertices[4];
float viewport[4]; float viewport[4];
int i; int i;

View File

@ -23,7 +23,7 @@
#include "clutter/clutter.h" #include "clutter/clutter.h"
gboolean meta_actor_vertices_are_untransformed (ClutterVertex *verts, gboolean meta_actor_vertices_are_untransformed (graphene_point3d_t *verts,
float widthf, float widthf,
float heightf, float heightf,
int *x_origin, int *x_origin,

View File

@ -1152,7 +1152,7 @@ meta_window_actor_transform_relative_position (MetaScreenCastWindow *screen_cast
MetaWindowActorPrivate *priv = MetaWindowActorPrivate *priv =
meta_window_actor_get_instance_private (window_actor); meta_window_actor_get_instance_private (window_actor);
MetaRectangle bounds; MetaRectangle bounds;
ClutterVertex v1 = { 0.f, }, v2 = { 0.f, }; graphene_point3d_t v1 = { 0.f, }, v2 = { 0.f, };
meta_window_actor_get_frame_bounds (screen_cast_window, &bounds); meta_window_actor_get_frame_bounds (screen_cast_window, &bounds);

View File

@ -101,7 +101,7 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state)
macro so that the assertion failure will report the right line macro so that the assertion failure will report the right line
number */ number */
#define assert_coords(state, x_1, y_1, x_2, y_2) G_STMT_START { \ #define assert_coords(state, x_1, y_1, x_2, y_2) G_STMT_START { \
ClutterVertex verts[4]; \ graphene_point3d_t verts[4]; \
clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \ clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \
check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \ check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \
g_assert (approx_equal ((x_1), verts[0].x)); \ g_assert (approx_equal ((x_1), verts[0].x)); \
@ -116,7 +116,7 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state)
g_assert (approx_equal (v->x, xc) && \ g_assert (approx_equal (v->x, xc) && \
approx_equal (v->y, yc) && \ approx_equal (v->y, yc) && \
approx_equal (v->z, zc)); \ approx_equal (v->z, zc)); \
g_boxed_free (CLUTTER_TYPE_VERTEX, v); } G_STMT_END g_boxed_free (GRAPHENE_TYPE_POINT3D, v); } G_STMT_END
static inline gboolean static inline gboolean
approx_equal (int a, int b) approx_equal (int a, int b)
@ -130,7 +130,7 @@ check_coords (TestState *state,
gint y_1, gint y_1,
gint x_2, gint x_2,
gint y_2, gint y_2,
const ClutterVertex *verts) const graphene_point3d_t *verts)
{ {
if (g_test_verbose ()) if (g_test_verbose ())
g_print ("checking that (%i,%i,%i,%i) \xe2\x89\x88 (%i,%i,%i,%i): %s\n", g_print ("checking that (%i,%i,%i,%i) \xe2\x89\x88 (%i,%i,%i,%i): %s\n",
@ -426,7 +426,7 @@ test_rotate_center (TestState *state)
{ {
ClutterActor *rect = state->rect; ClutterActor *rect = state->rect;
gdouble angle_x, angle_y, angle_z; gdouble angle_x, angle_y, angle_z;
ClutterVertex *center_x, *center_y, *center_z; graphene_point3d_t *center_x, *center_y, *center_z;
ClutterGravity z_center_gravity; ClutterGravity z_center_gravity;
gfloat stage_width, stage_height; gfloat stage_width, stage_height;
gfloat rect_x, rect_y; gfloat rect_x, rect_y;

View File

@ -334,7 +334,7 @@ my_thing_allocate (ClutterActor *self,
if (clutter_actor_is_scaled (child) || if (clutter_actor_is_scaled (child) ||
clutter_actor_is_rotated (child)) clutter_actor_is_rotated (child))
{ {
ClutterVertex v1 = { 0, }, v2 = { 0, }; graphene_point3d_t v1 = { 0, }, v2 = { 0, };
ClutterActorBox transformed_box = { 0, }; ClutterActorBox transformed_box = { 0, };
/* origin */ /* origin */

View File

@ -1646,11 +1646,11 @@ meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,
{ {
ClutterActor *actor = ClutterActor *actor =
CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)); CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface));
ClutterVertex sv = { graphene_point3d_t sv = {
.x = sx * surface->scale, .x = sx * surface->scale,
.y = sy * surface->scale, .y = sy * surface->scale,
}; };
ClutterVertex v = { 0 }; graphene_point3d_t v = { 0 };
clutter_actor_apply_relative_transform_to_point (actor, NULL, &sv, &v); clutter_actor_apply_relative_transform_to_point (actor, NULL, &sv, &v);