diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile index 58b6ad82d6756645605ddae87b89b57f2b02643a..2acacc1acc6f995337d51897a01fc25de8b8abe7 100644 --- a/.gitlab-ci/Dockerfile +++ b/.gitlab-ci/Dockerfile @@ -18,7 +18,7 @@ RUN dnf -y update && dnf -y upgrade && \ dnf builddep -y mutter && \ # Until Fedora catches up with meson build-deps - dnf install -y meson xorg-x11-server-Xorg gnome-settings-daemon-devel egl-wayland-devel xorg-x11-server-Xwayland && \ + dnf install -y meson xorg-x11-server-Xorg gnome-settings-daemon-devel egl-wayland-devel xorg-x11-server-Xwayland graphene-devel && \ # Until Fedora catches up with mesa bug fixes dnf upgrade -y mesa-dri-drivers mesa-libEGL && \ diff --git a/clutter/clutter/cally/cally-actor.c b/clutter/clutter/cally/cally-actor.c index d97357de4cfc0f0cd8e9ac3b4cf102239fd96d7e..07eaea67d3f8924c762ce083264c4fd475091573 100644 --- a/clutter/clutter/cally/cally-actor.c +++ b/clutter/clutter/cally/cally-actor.c @@ -657,7 +657,7 @@ cally_actor_get_extents (AtkComponent *component, ClutterActor *actor = NULL; gint top_level_x, top_level_y; gfloat f_width, f_height; - ClutterVertex verts[4]; + graphene_point3d_t verts[4]; ClutterActor *stage = NULL; g_return_if_fail (CALLY_IS_ACTOR (component)); diff --git a/clutter/clutter/cally/cally-text.c b/clutter/clutter/cally/cally-text.c index 6375a38559ddf81dd33026773997cbacb3bfd5d7..cbdec8496fcdf30c39fd107ca9356a8a489be991 100644 --- a/clutter/clutter/cally/cally-text.c +++ b/clutter/clutter/cally/cally-text.c @@ -1438,7 +1438,7 @@ static void cally_text_get_character_extents (AtkText *text, PangoLayout *layout; PangoRectangle extents; const gchar *text_value; - ClutterVertex verts[4]; + graphene_point3d_t verts[4]; actor = CALLY_GET_CLUTTER_ACTOR (text); 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 x_temp, y_temp; gboolean ret; - ClutterVertex verts[4]; + graphene_point3d_t verts[4]; PangoLayout *layout; gint x_layout, y_layout; diff --git a/clutter/clutter/clutter-actor-box.c b/clutter/clutter/clutter-actor-box.c index 6871274c5d19e02aabb52e595a6d3b8462b8eb62..a2308ac31462ed4ef362b08cfbcd0465f5499a53 100644 --- a/clutter/clutter/clutter-actor-box.c +++ b/clutter/clutter/clutter-actor-box.c @@ -340,7 +340,7 @@ clutter_actor_box_contains (const ClutterActorBox *box, /** * clutter_actor_box_from_vertices: * @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 * of the vertex array see clutter_actor_get_abs_allocation_vertices(). @@ -348,8 +348,8 @@ clutter_actor_box_contains (const ClutterActorBox *box, * Since: 1.0 */ void -clutter_actor_box_from_vertices (ClutterActorBox *box, - const ClutterVertex verts[]) +clutter_actor_box_from_vertices (ClutterActorBox *box, + const graphene_point3d_t verts[]) { gfloat x_1, x_2, y_1, y_2; diff --git a/clutter/clutter/clutter-actor-private.h b/clutter/clutter/clutter-actor-private.h index fa2d4c328fd8636e9c5d7b5a1dd96260461af09d..d8952b6b189c5589afdef69c3b5405283ec1c430 100644 --- a/clutter/clutter/clutter-actor-private.h +++ b/clutter/clutter/clutter-actor-private.h @@ -135,7 +135,7 @@ struct _AnchorCoord } fraction; /* Use when is_fractional == FALSE */ - ClutterVertex units; + graphene_point3d_t units; } v; }; @@ -163,7 +163,7 @@ struct _SizeRequest struct _ClutterLayoutInfo { /* fixed position coordinates */ - ClutterPoint fixed_pos; + graphene_point_t fixed_pos; ClutterMargin margin; @@ -173,8 +173,8 @@ struct _ClutterLayoutInfo guint x_expand : 1; guint y_expand : 1; - ClutterSize minimum; - ClutterSize natural; + graphene_size_t minimum; + graphene_size_t natural; }; const ClutterLayoutInfo * _clutter_actor_get_layout_info_or_defaults (ClutterActor *self); @@ -203,13 +203,13 @@ struct _ClutterTransformInfo AnchorCoord anchor; /* translation */ - ClutterVertex translation; + graphene_point3d_t translation; /* z_position */ gfloat z_position; /* transformation center */ - ClutterPoint pivot; + graphene_point_t pivot; gfloat pivot_z; CoglMatrix transform; diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 0379b32ea77633b4a49531ff9183b2cf9ec7e740..e6a406911b245b6408278f94b117c91233c665c2 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -701,7 +701,7 @@ struct _ClutterActorPrivate ClutterAllocationFlags allocation_flags; /* clip, in actor coordinates */ - ClutterRect clip; + graphene_rect_t clip; /* the cached transformation matrix; see apply_transform() */ CoglMatrix transform; @@ -902,7 +902,6 @@ enum PROP_DEPTH, /* XXX:2.0 remove */ PROP_Z_POSITION, - PROP_CLIP, /* XXX:2.0 remove */ PROP_CLIP_RECT, PROP_HAS_CLIP, PROP_CLIP_TO_ALLOCATION, @@ -1289,7 +1288,7 @@ static gboolean _clutter_actor_transform_local_box_to_stage (ClutterActor *self, ClutterStage *stage, const ClutterActorBox *box, - ClutterPoint vertices[4]) + graphene_point_t vertices[4]) { CoglFramebuffer *fb = cogl_get_draw_framebuffer (); CoglMatrix stage_transform, inv_stage_transform; @@ -1345,7 +1344,7 @@ clutter_actor_pick_box (ClutterActor *self, const ClutterActorBox *box) { ClutterStage *stage; - ClutterPoint vertices[4]; + graphene_point_t vertices[4]; g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (box != NULL); @@ -1364,7 +1363,7 @@ _clutter_actor_push_pick_clip (ClutterActor *self, const ClutterActorBox *clip) { ClutterStage *stage; - ClutterPoint vertices[4]; + graphene_point_t vertices[4]; stage = CLUTTER_STAGE (_clutter_actor_get_stage_internal (self)); @@ -2891,8 +2890,8 @@ clutter_actor_real_queue_relayout (ClutterActor *self) * @self: A #ClutterActor * @ancestor: (allow-none): A #ClutterActor ancestor, or %NULL to use the * default #ClutterStage - * @point: A point as #ClutterVertex - * @vertex: (out caller-allocates): The translated #ClutterVertex + * @point: A point as #graphene_point3d_t + * @vertex: (out caller-allocates): The translated #graphene_point3d_t * * Transforms @point in coordinates relative to the actor into * ancestor-relative coordinates using the relevant transform @@ -2906,10 +2905,10 @@ clutter_actor_real_queue_relayout (ClutterActor *self) * Since: 0.6 */ void -clutter_actor_apply_relative_transform_to_point (ClutterActor *self, - ClutterActor *ancestor, - const ClutterVertex *point, - ClutterVertex *vertex) +clutter_actor_apply_relative_transform_to_point (ClutterActor *self, + ClutterActor *ancestor, + const graphene_point3d_t *point, + graphene_point3d_t *vertex) { gfloat w; CoglMatrix matrix; @@ -2936,10 +2935,10 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self, } static gboolean -_clutter_actor_fully_transform_vertices (ClutterActor *self, - const ClutterVertex *vertices_in, - ClutterVertex *vertices_out, - int n_vertices) +_clutter_actor_fully_transform_vertices (ClutterActor *self, + const graphene_point3d_t *vertices_in, + graphene_point3d_t *vertices_out, + int n_vertices) { ClutterActor *stage; CoglMatrix modelview; @@ -2981,8 +2980,8 @@ _clutter_actor_fully_transform_vertices (ClutterActor *self, /** * clutter_actor_apply_transform_to_point: * @self: A #ClutterActor - * @point: A point as #ClutterVertex - * @vertex: (out caller-allocates): The translated #ClutterVertex + * @point: A point as #graphene_point3d_t + * @vertex: (out caller-allocates): The translated #graphene_point3d_t * * Transforms @point in coordinates relative to the actor * into screen-relative coordinates with the current actor @@ -2991,9 +2990,9 @@ _clutter_actor_fully_transform_vertices (ClutterActor *self, * Since: 0.4 **/ void -clutter_actor_apply_transform_to_point (ClutterActor *self, - const ClutterVertex *point, - ClutterVertex *vertex) +clutter_actor_apply_transform_to_point (ClutterActor *self, + const graphene_point3d_t *point, + graphene_point3d_t *vertex) { g_return_if_fail (point != NULL); g_return_if_fail (vertex != NULL); @@ -3043,10 +3042,10 @@ _clutter_actor_get_relative_transformation_matrix (ClutterActor *self, * transformed vertices to @verts[]. */ static gboolean _clutter_actor_transform_and_project_box (ClutterActor *self, - const ClutterActorBox *box, - ClutterVertex verts[]) + const ClutterActorBox *box, + graphene_point3d_t *verts) { - ClutterVertex box_vertices[4]; + graphene_point3d_t box_vertices[4]; box_vertices[0].x = box->x1; box_vertices[0].y = box->y1; @@ -3070,8 +3069,8 @@ _clutter_actor_transform_and_project_box (ClutterActor *self, * @self: A #ClutterActor * @ancestor: (allow-none): A #ClutterActor to calculate the vertices * against, or %NULL to use the #ClutterStage - * @verts: (out) (array fixed-size=4) (element-type Clutter.Vertex): return - * location for an array of 4 #ClutterVertex in which to store the result + * @verts: (out) (array fixed-size=4): return + * 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 * actor in the plane of @ancestor. The returned vertices relate to @@ -3090,13 +3089,13 @@ _clutter_actor_transform_and_project_box (ClutterActor *self, * Since: 0.6 */ void -clutter_actor_get_allocation_vertices (ClutterActor *self, - ClutterActor *ancestor, - ClutterVertex verts[]) +clutter_actor_get_allocation_vertices (ClutterActor *self, + ClutterActor *ancestor, + graphene_point3d_t *verts) { ClutterActorPrivate *priv; ClutterActorBox box; - ClutterVertex vertices[4]; + graphene_point3d_t vertices[4]; CoglMatrix modelview; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -3148,9 +3147,9 @@ clutter_actor_get_allocation_vertices (ClutterActor *self, cogl_matrix_transform_points (&modelview, 3, - sizeof (ClutterVertex), + sizeof (graphene_point3d_t), vertices, - sizeof (ClutterVertex), + sizeof (graphene_point3d_t), vertices, 4); } @@ -3159,7 +3158,7 @@ clutter_actor_get_allocation_vertices (ClutterActor *self, * clutter_actor_get_abs_allocation_vertices: * @self: A #ClutterActor * @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 * the actor; the returned vertices relate to the #ClutterActorBox @@ -3173,8 +3172,8 @@ clutter_actor_get_allocation_vertices (ClutterActor *self, * Since: 0.4 */ void -clutter_actor_get_abs_allocation_vertices (ClutterActor *self, - ClutterVertex verts[]) +clutter_actor_get_abs_allocation_vertices (ClutterActor *self, + graphene_point3d_t *verts) { ClutterActorPrivate *priv; ClutterActorBox actor_space_allocation; @@ -3415,7 +3414,7 @@ _clutter_actor_draw_paint_volume_full (ClutterActor *self, { static CoglPipeline *outline = NULL; CoglPrimitive *prim; - ClutterVertex line_ends[12 * 2]; + graphene_point3d_t line_ends[12 * 2]; int n_vertices; CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); @@ -4474,11 +4473,11 @@ static const ClutterTransformInfo default_transform_info = { { 0, }, /* anchor XXX:2.0 - remove*/ - CLUTTER_VERTEX_INIT_ZERO, /* translation */ + GRAPHENE_POINT3D_INIT_ZERO, /* translation */ 0.f, /* z-position */ - CLUTTER_POINT_INIT_ZERO, /* pivot */ + GRAPHENE_POINT_INIT_ZERO, /* pivot */ 0.f, /* pivot-z */ CLUTTER_MATRIX_INIT_IDENTITY, @@ -4557,8 +4556,8 @@ _clutter_actor_get_transform_info (ClutterActor *self) } static inline void -clutter_actor_set_pivot_point_internal (ClutterActor *self, - const ClutterPoint *pivot) +clutter_actor_set_pivot_point_internal (ClutterActor *self, + const graphene_point_t *pivot) { ClutterTransformInfo *info; @@ -4863,11 +4862,11 @@ clutter_actor_get_rotation_angle (ClutterActor *self, * rotation angle. */ static inline void -clutter_actor_set_rotation_center_internal (ClutterActor *self, - ClutterRotateAxis axis, - const ClutterVertex *center) +clutter_actor_set_rotation_center_internal (ClutterActor *self, + ClutterRotateAxis axis, + const graphene_point3d_t *center) { - ClutterVertex v = CLUTTER_VERTEX_INIT_ZERO; + graphene_point3d_t v = GRAPHENE_POINT3D_INIT_ZERO; GObject *obj = G_OBJECT (self); ClutterTransformInfo *info; @@ -5094,8 +5093,8 @@ clutter_actor_set_anchor_coord (ClutterActor *self, } static void -clutter_actor_set_clip_rect (ClutterActor *self, - const ClutterRect *clip) +clutter_actor_set_clip_rect (ClutterActor *self, + const graphene_rect_t *clip) { ClutterActorPrivate *priv = self->priv; GObject *obj = G_OBJECT (self); @@ -5110,7 +5109,6 @@ clutter_actor_set_clip_rect (ClutterActor *self, clutter_actor_queue_redraw (self); - g_object_notify_by_pspec (obj, obj_props[PROP_CLIP]); /* XXX:2.0 - remove */ g_object_notify_by_pspec (obj, obj_props[PROP_CLIP_RECT]); g_object_notify_by_pspec (obj, obj_props[PROP_HAS_CLIP]); } @@ -5136,7 +5134,7 @@ clutter_actor_set_property (GObject *object, case PROP_POSITION: { - const ClutterPoint *pos = g_value_get_boxed (value); + const graphene_point_t *pos = g_value_get_boxed (value); if (pos != NULL) clutter_actor_set_position (actor, pos->x, pos->y); @@ -5155,7 +5153,7 @@ clutter_actor_set_property (GObject *object, case PROP_SIZE: { - const ClutterSize *size = g_value_get_boxed (value); + const graphene_size_t *size = g_value_get_boxed (value); if (size != NULL) clutter_actor_set_size (actor, size->width, size->height); @@ -5241,10 +5239,10 @@ clutter_actor_set_property (GObject *object, case PROP_PIVOT_POINT: { - const ClutterPoint *pivot = g_value_get_boxed (value); + const graphene_point_t *pivot = g_value_get_boxed (value); if (pivot == NULL) - pivot = clutter_point_zero (); + pivot = graphene_point_zero (); clutter_actor_set_pivot_point (actor, pivot->x, pivot->y); } @@ -5298,16 +5296,6 @@ clutter_actor_set_property (GObject *object, clutter_actor_set_scale_gravity (actor, g_value_get_enum (value)); break; - case PROP_CLIP: /* XXX:2.0 - remove */ - { - const ClutterGeometry *geom = g_value_get_boxed (value); - - clutter_actor_set_clip (actor, - geom->x, geom->y, - geom->width, geom->height); - } - break; - case PROP_CLIP_RECT: clutter_actor_set_clip_rect (actor, g_value_get_boxed (value)); break; @@ -5500,11 +5488,11 @@ clutter_actor_get_property (GObject *object, case PROP_POSITION: { - ClutterPoint position; + graphene_point_t position; - clutter_point_init (&position, - clutter_actor_get_x (actor), - clutter_actor_get_y (actor)); + graphene_point_init (&position, + clutter_actor_get_x (actor), + clutter_actor_get_y (actor)); g_value_set_boxed (value, &position); } break; @@ -5519,11 +5507,11 @@ clutter_actor_get_property (GObject *object, case PROP_SIZE: { - ClutterSize size; + graphene_size_t size; - clutter_size_init (&size, - clutter_actor_get_width (actor), - clutter_actor_get_height (actor)); + graphene_size_init (&size, + clutter_actor_get_width (actor), + clutter_actor_get_height (actor)); g_value_set_boxed (value, &size); } break; @@ -5646,19 +5634,6 @@ clutter_actor_get_property (GObject *object, g_value_set_boolean (value, priv->has_clip); break; - case PROP_CLIP: /* XXX:2.0 - remove */ - { - ClutterGeometry clip; - - clip.x = CLUTTER_NEARBYINT (priv->clip.origin.x); - clip.y = CLUTTER_NEARBYINT (priv->clip.origin.y); - clip.width = CLUTTER_NEARBYINT (priv->clip.size.width); - clip.height = CLUTTER_NEARBYINT (priv->clip.size.height); - - g_value_set_boxed (value, &clip); - } - break; - case PROP_CLIP_RECT: g_value_set_boxed (value, &priv->clip); break; @@ -5806,7 +5781,7 @@ clutter_actor_get_property (GObject *object, case PROP_ROTATION_CENTER_X: /* XXX:2.0 - remove */ { - ClutterVertex center; + graphene_point3d_t center; clutter_actor_get_rotation (actor, CLUTTER_X_AXIS, ¢er.x, @@ -5819,7 +5794,7 @@ clutter_actor_get_property (GObject *object, case PROP_ROTATION_CENTER_Y: /* XXX:2.0 - remove */ { - ClutterVertex center; + graphene_point3d_t center; clutter_actor_get_rotation (actor, CLUTTER_Y_AXIS, ¢er.x, @@ -5832,7 +5807,7 @@ clutter_actor_get_property (GObject *object, case PROP_ROTATION_CENTER_Z: /* XXX:2.0 - remove */ { - ClutterVertex center; + graphene_point3d_t center; clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS, ¢er.x, @@ -6249,7 +6224,7 @@ clutter_actor_update_default_paint_volume (ClutterActor *self, priv->clip.size.width >= 0 && priv->clip.size.height >= 0) { - ClutterVertex origin; + graphene_point3d_t origin; origin.x = priv->clip.origin.x; origin.y = priv->clip.origin.y; @@ -6525,7 +6500,7 @@ clutter_actor_class_init (ClutterActorClass *klass) g_param_spec_boxed ("position", P_("Position"), P_("The position of the origin of the actor"), - CLUTTER_TYPE_POINT, + GRAPHENE_TYPE_POINT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | CLUTTER_PARAM_ANIMATABLE); @@ -6584,7 +6559,7 @@ clutter_actor_class_init (ClutterActorClass *klass) g_param_spec_boxed ("size", P_("Size"), P_("The size of the actor"), - CLUTTER_TYPE_SIZE, + GRAPHENE_TYPE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | CLUTTER_PARAM_ANIMATABLE); @@ -7026,25 +7001,11 @@ clutter_actor_class_init (ClutterActorClass *klass) FALSE, CLUTTER_PARAM_READABLE); - /** - * ClutterActor:clip: - * - * The visible region of the actor, in actor-relative coordinates - * - * Deprecated: 1.12: Use #ClutterActor:clip-rect instead. - */ - obj_props[PROP_CLIP] = /* XXX:2.0 - remove */ - g_param_spec_boxed ("clip", - P_("Clip"), - P_("The clip region for the actor"), - CLUTTER_TYPE_GEOMETRY, - CLUTTER_PARAM_READWRITE); - /** * ClutterActor:clip-rect: * * The visible region of the actor, in actor-relative coordinates, - * expressed as a #ClutterRect. + * expressed as a #graphene_rect_t. * * Setting this property to %NULL will unset the existing clip. * @@ -7057,7 +7018,7 @@ clutter_actor_class_init (ClutterActorClass *klass) g_param_spec_boxed ("clip-rect", P_("Clip Rectangle"), P_("The visible region of the actor"), - CLUTTER_TYPE_RECT, + GRAPHENE_TYPE_RECT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); @@ -7094,7 +7055,7 @@ clutter_actor_class_init (ClutterActorClass *klass) g_param_spec_boxed ("pivot-point", P_("Pivot Point"), P_("The point around which the scaling and rotation occur"), - CLUTTER_TYPE_POINT, + GRAPHENE_TYPE_POINT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | CLUTTER_PARAM_ANIMATABLE); @@ -7316,7 +7277,7 @@ clutter_actor_class_init (ClutterActorClass *klass) g_param_spec_boxed ("rotation-center-x", P_("Rotation Center X"), P_("The rotation center on the X axis"), - CLUTTER_TYPE_VERTEX, + GRAPHENE_TYPE_POINT3D, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED); @@ -7334,7 +7295,7 @@ clutter_actor_class_init (ClutterActorClass *klass) g_param_spec_boxed ("rotation-center-y", P_("Rotation Center Y"), P_("The rotation center on the Y axis"), - CLUTTER_TYPE_VERTEX, + GRAPHENE_TYPE_POINT3D, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED); @@ -7352,7 +7313,7 @@ clutter_actor_class_init (ClutterActorClass *klass) g_param_spec_boxed ("rotation-center-z", P_("Rotation Center Z"), P_("The rotation center on the Z axis"), - CLUTTER_TYPE_VERTEX, + GRAPHENE_TYPE_POINT3D, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED); @@ -9007,7 +8968,7 @@ _clutter_actor_queue_redraw_full (ClutterActor *self, if (flags & CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION) { ClutterActorBox allocation_clip; - ClutterVertex origin; + graphene_point3d_t origin; /* If the actor doesn't have a valid allocation then we will * queue a full stage redraw. */ @@ -9211,7 +9172,7 @@ clutter_actor_queue_redraw_with_clip (ClutterActor *self, const cairo_rectangle_int_t *clip) { ClutterPaintVolume volume; - ClutterVertex origin; + graphene_point3d_t origin; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -10438,17 +10399,17 @@ clutter_actor_set_position (ClutterActor *self, gfloat x, gfloat y) { - ClutterPoint new_position; - ClutterPoint cur_position; + graphene_point_t new_position; + graphene_point_t cur_position; g_return_if_fail (CLUTTER_IS_ACTOR (self)); - clutter_point_init (&new_position, x, y); + graphene_point_init (&new_position, x, y); cur_position.x = clutter_actor_get_x (self); cur_position.y = clutter_actor_get_y (self); - if (!clutter_point_equals (&cur_position, &new_position)) + if (!graphene_point_equal (&cur_position, &new_position)) _clutter_actor_create_transition (self, obj_props[PROP_POSITION], &cur_position, &new_position); @@ -10883,8 +10844,8 @@ clutter_actor_set_height_internal (ClutterActor *self, } static void -clutter_actor_set_size_internal (ClutterActor *self, - const ClutterSize *size) +clutter_actor_set_size_internal (ClutterActor *self, + const graphene_size_t *size) { if (size != NULL) { @@ -10920,11 +10881,11 @@ clutter_actor_set_size (ClutterActor *self, gfloat width, gfloat height) { - ClutterSize new_size; + graphene_size_t new_size; g_return_if_fail (CLUTTER_IS_ACTOR (self)); - clutter_size_init (&new_size, width, height); + graphene_size_init (&new_size, width, height); /* minor optimization: if we don't have a duration then we can * skip the get_size() below, to avoid the chance of going through @@ -10943,11 +10904,11 @@ clutter_actor_set_size (ClutterActor *self, } else { - ClutterSize cur_size; + graphene_size_t cur_size; - clutter_size_init (&cur_size, - clutter_actor_get_width (self), - clutter_actor_get_height (self)); + graphene_size_init (&cur_size, + clutter_actor_get_width (self), + clutter_actor_get_height (self)); _clutter_actor_create_transition (self, obj_props[PROP_SIZE], @@ -11033,8 +10994,8 @@ clutter_actor_get_transformed_position (ClutterActor *self, gfloat *x, gfloat *y) { - ClutterVertex v1; - ClutterVertex v2; + graphene_point3d_t v1; + graphene_point3d_t v2; v1.x = v1.y = v1.z = 0; clutter_actor_apply_transform_to_point (self, &v1, &v2); @@ -11080,7 +11041,7 @@ clutter_actor_get_transformed_size (ClutterActor *self, gfloat *height) { ClutterActorPrivate *priv; - ClutterVertex v[4]; + graphene_point3d_t v[4]; gfloat x_min, x_max, y_min, y_max; gint i; @@ -11402,8 +11363,8 @@ clutter_actor_set_y_internal (ClutterActor *self, } static void -clutter_actor_set_position_internal (ClutterActor *self, - const ClutterPoint *position) +clutter_actor_set_position_internal (ClutterActor *self, + const graphene_point_t *position) { ClutterActorPrivate *priv = self->priv; ClutterLayoutInfo *linfo; @@ -11412,7 +11373,7 @@ clutter_actor_set_position_internal (ClutterActor *self, linfo = _clutter_actor_get_layout_info (self); if (priv->position_set && - clutter_point_equals (position, &linfo->fixed_pos)) + graphene_point_equal (position, &linfo->fixed_pos)) return; clutter_actor_store_old_geometry (self, &old); @@ -11497,8 +11458,7 @@ clutter_actor_set_y (ClutterActor *self, * the X coordinate of the origin of the allocation box. * * If the actor has any fixed coordinate set using clutter_actor_set_x(), - * clutter_actor_set_position() or clutter_actor_set_geometry(), this - * function will return that coordinate. + * clutter_actor_set_position(), this function will return that coordinate. * * If both the allocation and a fixed position are missing, this function * will return 0. @@ -11545,8 +11505,7 @@ clutter_actor_get_x (ClutterActor *self) * the Y coordinate of the origin of the allocation box. * * If the actor has any fixed coordinate set using clutter_actor_set_y(), - * clutter_actor_set_position() or clutter_actor_set_geometry(), this - * function will return that coordinate. + * clutter_actor_set_position(), this function will return that coordinate. * * If both the allocation and a fixed position are missing, this function * will return 0. @@ -12231,7 +12190,7 @@ clutter_actor_set_pivot_point (ClutterActor *self, gfloat pivot_x, gfloat pivot_y) { - ClutterPoint pivot = CLUTTER_POINT_INIT (pivot_x, pivot_y); + graphene_point_t pivot = GRAPHENE_POINT_INIT (pivot_x, pivot_y); const ClutterTransformInfo *info; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -12392,7 +12351,7 @@ clutter_actor_set_rotation (ClutterActor *self, gfloat y, gfloat z) { - ClutterVertex v; + graphene_point3d_t v; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -12589,7 +12548,6 @@ clutter_actor_set_clip (ClutterActor *self, clutter_actor_queue_redraw (self); - g_object_notify_by_pspec (obj, obj_props[PROP_CLIP]); g_object_notify_by_pspec (obj, obj_props[PROP_CLIP_RECT]); g_object_notify_by_pspec (obj, obj_props[PROP_HAS_CLIP]); } @@ -15372,7 +15330,7 @@ clutter_actor_transform_stage_point (ClutterActor *self, gfloat *x_out, gfloat *y_out) { - ClutterVertex v[4]; + graphene_point3d_t v[4]; double ST[3][3]; double RQ[3][3]; int du, dv; @@ -17848,9 +17806,9 @@ clutter_actor_get_paint_box (ClutterActor *self, } static gboolean -_clutter_actor_get_resource_scale_for_rect (ClutterActor *self, - ClutterRect *bounding_rect, - float *resource_scale) +_clutter_actor_get_resource_scale_for_rect (ClutterActor *self, + graphene_rect_t *bounding_rect, + float *resource_scale) { ClutterActor *stage; float max_scale = 0; @@ -17873,7 +17831,7 @@ static gboolean _clutter_actor_compute_resource_scale (ClutterActor *self, float *resource_scale) { - ClutterRect bounding_rect; + graphene_rect_t bounding_rect; ClutterActorPrivate *priv = self->priv; if (CLUTTER_ACTOR_IN_DESTRUCTION (self) || @@ -18417,13 +18375,13 @@ clutter_actor_get_layout_manager (ClutterActor *self) } static const ClutterLayoutInfo default_layout_info = { - CLUTTER_POINT_INIT_ZERO, /* fixed-pos */ + GRAPHENE_POINT_INIT_ZERO, /* fixed-pos */ { 0, 0, 0, 0 }, /* margin */ CLUTTER_ACTOR_ALIGN_FILL, /* x-align */ CLUTTER_ACTOR_ALIGN_FILL, /* y-align */ FALSE, FALSE, /* expand */ - CLUTTER_SIZE_INIT_ZERO, /* minimum */ - CLUTTER_SIZE_INIT_ZERO, /* natural */ + GRAPHENE_SIZE_INIT_ZERO, /* minimum */ + GRAPHENE_SIZE_INIT_ZERO, /* natural */ }; static void diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h index b1abff86df4d0dbd6c959c9ca9f1427028a577ca..dd09546ecb83b8fd14c4e7019526b328385865a3 100644 --- a/clutter/clutter/clutter-actor.h +++ b/clutter/clutter/clutter-actor.h @@ -431,7 +431,7 @@ void clutter_actor_get_allocation_box CLUTTER_EXPORT void clutter_actor_get_allocation_vertices (ClutterActor *self, ClutterActor *ancestor, - ClutterVertex verts[]); + graphene_point3d_t *verts); CLUTTER_EXPORT gboolean clutter_actor_has_allocation (ClutterActor *self); CLUTTER_EXPORT @@ -817,16 +817,16 @@ gboolean clutter_actor_transform_stage_point gfloat *y_out); CLUTTER_EXPORT void clutter_actor_get_abs_allocation_vertices (ClutterActor *self, - ClutterVertex verts[]); + graphene_point3d_t *verts); CLUTTER_EXPORT void clutter_actor_apply_transform_to_point (ClutterActor *self, - const ClutterVertex *point, - ClutterVertex *vertex); + const graphene_point3d_t *point, + graphene_point3d_t *vertex); CLUTTER_EXPORT void clutter_actor_apply_relative_transform_to_point (ClutterActor *self, ClutterActor *ancestor, - const ClutterVertex *point, - ClutterVertex *vertex); + const graphene_point3d_t *point, + graphene_point3d_t *vertex); /* Implicit animations */ CLUTTER_EXPORT diff --git a/clutter/clutter/clutter-autocleanups.h b/clutter/clutter/clutter-autocleanups.h index 0a68c0505fec1bc3b9ca46ae88418c32cf34a4f7..4d6aa054169960ec0770f8436e14c140b8703a84 100644 --- a/clutter/clutter/clutter-autocleanups.h +++ b/clutter/clutter/clutter-autocleanups.h @@ -93,10 +93,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterMatrix, clutter_matrix_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintNode, clutter_paint_node_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintVolume, clutter_paint_volume_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPathNode, clutter_path_node_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPoint, clutter_point_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRect, clutter_rect_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSize, clutter_size_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterVertex, clutter_vertex_free) #endif /* __GI_SCANNER__ */ diff --git a/clutter/clutter/clutter-base-types.c b/clutter/clutter/clutter-base-types.c index 61e6fcd265146140bf8a0cfff97c111dfe8ae989..fcbcd2ec7d77fc9559b0a293da57a6f5d516e51b 100644 --- a/clutter/clutter/clutter-base-types.c +++ b/clutter/clutter/clutter-base-types.c @@ -41,286 +41,6 @@ -/* - * ClutterGeometry - */ - -static ClutterGeometry* -clutter_geometry_copy (const ClutterGeometry *geometry) -{ - return g_slice_dup (ClutterGeometry, geometry); -} - -static void -clutter_geometry_free (ClutterGeometry *geometry) -{ - if (G_LIKELY (geometry != NULL)) - g_slice_free (ClutterGeometry, geometry); -} - -/** - * clutter_geometry_union: - * @geometry_a: a #ClutterGeometry - * @geometry_b: another #ClutterGeometry - * @result: (out): location to store the result - * - * Find the union of two rectangles represented as #ClutterGeometry. - * - * Since: 1.4 - * - * Deprecated: 1.16: Use #ClutterRect and clutter_rect_union() - */ -void -clutter_geometry_union (const ClutterGeometry *geometry_a, - const ClutterGeometry *geometry_b, - ClutterGeometry *result) -{ - /* We don't try to handle rectangles that can't be represented - * as a signed integer box */ - gint x_1 = MIN (geometry_a->x, geometry_b->x); - gint y_1 = MIN (geometry_a->y, geometry_b->y); - gint x_2 = MAX (geometry_a->x + (gint)geometry_a->width, - geometry_b->x + (gint)geometry_b->width); - gint y_2 = MAX (geometry_a->y + (gint)geometry_a->height, - geometry_b->y + (gint)geometry_b->height); - result->x = x_1; - result->y = y_1; - result->width = x_2 - x_1; - result->height = y_2 - y_1; -} - -/** - * clutter_geometry_intersects: - * @geometry0: The first geometry to test - * @geometry1: The second geometry to test - * - * Determines if @geometry0 and geometry1 intersect returning %TRUE if - * they do else %FALSE. - * - * Return value: %TRUE of @geometry0 and geometry1 intersect else - * %FALSE. - * - * Since: 1.4 - * - * Deprecated: 1.16: Use #ClutterRect and clutter_rect_intersection() - */ -gboolean -clutter_geometry_intersects (const ClutterGeometry *geometry0, - const ClutterGeometry *geometry1) -{ - if (geometry1->x >= (geometry0->x + (gint)geometry0->width) || - geometry1->y >= (geometry0->y + (gint)geometry0->height) || - (geometry1->x + (gint)geometry1->width) <= geometry0->x || - (geometry1->y + (gint)geometry1->height) <= geometry0->y) - return FALSE; - else - return TRUE; -} - -static gboolean -clutter_geometry_progress (const GValue *a, - const GValue *b, - gdouble progress, - GValue *retval) -{ - const ClutterGeometry *a_geom = g_value_get_boxed (a); - const ClutterGeometry *b_geom = g_value_get_boxed (b); - ClutterGeometry res = { 0, }; - gint a_width = a_geom->width; - gint b_width = b_geom->width; - gint a_height = a_geom->height; - gint b_height = b_geom->height; - - res.x = a_geom->x + (b_geom->x - a_geom->x) * progress; - res.y = a_geom->y + (b_geom->y - a_geom->y) * progress; - - res.width = a_width + (b_width - a_width) * progress; - res.height = a_height + (b_height - a_height) * progress; - - g_value_set_boxed (retval, &res); - - return TRUE; -} - -G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterGeometry, clutter_geometry, - clutter_geometry_copy, - clutter_geometry_free, - CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_geometry_progress)); - - - -/* - * 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 */ @@ -382,993 +102,6 @@ G_DEFINE_BOXED_TYPE (ClutterMargin, clutter_margin, clutter_margin_copy, clutter_margin_free) - - -/* - * ClutterPoint - */ - -static const ClutterPoint _clutter_point_zero = CLUTTER_POINT_INIT_ZERO; - -/** - * clutter_point_zero: - * - * A point centered at (0, 0). - * - * The returned value can be used as a guard. - * - * Return value: a point centered in (0, 0); the returned #ClutterPoint - * is owned by Clutter and it should not be modified or freed. - * - * Since: 1.12 - */ -const ClutterPoint * -clutter_point_zero (void) -{ - return &_clutter_point_zero; -} - -/** - * clutter_point_alloc: (constructor) - * - * Allocates a new #ClutterPoint. - * - * Return value: (transfer full): the newly allocated #ClutterPoint. - * Use clutter_point_free() to free its resources. - * - * Since: 1.12 - */ -ClutterPoint * -clutter_point_alloc (void) -{ - return g_slice_new0 (ClutterPoint); -} - -/** - * clutter_point_init: - * @point: a #ClutterPoint - * @x: the X coordinate of the point - * @y: the Y coordinate of the point - * - * Initializes @point with the given coordinates. - * - * Return value: (transfer none): the initialized #ClutterPoint - * - * Since: 1.12 - */ -ClutterPoint * -clutter_point_init (ClutterPoint *point, - float x, - float y) -{ - g_return_val_if_fail (point != NULL, NULL); - - point->x = x; - point->y = y; - - return point; -} - -/** - * clutter_point_copy: - * @point: a #ClutterPoint - * - * Creates a new #ClutterPoint with the same coordinates of @point. - * - * Return value: (transfer full): a newly allocated #ClutterPoint. - * Use clutter_point_free() to free its resources. - * - * Since: 1.12 - */ -ClutterPoint * -clutter_point_copy (const ClutterPoint *point) -{ - return g_slice_dup (ClutterPoint, point); -} - -/** - * clutter_point_free: - * @point: a #ClutterPoint - * - * Frees the resources allocated for @point. - * - * Since: 1.12 - */ -void -clutter_point_free (ClutterPoint *point) -{ - if (point != NULL && point != &_clutter_point_zero) - g_slice_free (ClutterPoint, point); -} - -/** - * clutter_point_equals: - * @a: the first #ClutterPoint to compare - * @b: the second #ClutterPoint to compare - * - * Compares two #ClutterPoint for equality. - * - * Return value: %TRUE if the #ClutterPoints are equal - * - * Since: 1.12 - */ -gboolean -clutter_point_equals (const ClutterPoint *a, - const ClutterPoint *b) -{ - if (a == b) - return TRUE; - - if (a == NULL || b == NULL) - return FALSE; - - return fabsf (a->x - b->x) < FLOAT_EPSILON && - fabsf (a->y - b->y) < FLOAT_EPSILON; -} - -/** - * clutter_point_distance: - * @a: a #ClutterPoint - * @b: a #ClutterPoint - * @x_distance: (out) (allow-none): return location for the horizontal - * distance between the points - * @y_distance: (out) (allow-none): return location for the vertical - * distance between the points - * - * Computes the distance between two #ClutterPoint. - * - * Return value: the distance between the points. - * - * Since: 1.12 - */ -float -clutter_point_distance (const ClutterPoint *a, - const ClutterPoint *b, - float *x_distance, - float *y_distance) -{ - float x_d, y_d; - - g_return_val_if_fail (a != NULL, 0.f); - g_return_val_if_fail (b != NULL, 0.f); - - if (clutter_point_equals (a, b)) - return 0.f; - - x_d = (a->x - b->x); - y_d = (a->y - b->y); - - if (x_distance != NULL) - *x_distance = fabsf (x_d); - - if (y_distance != NULL) - *y_distance = fabsf (y_d); - - return sqrt ((x_d * x_d) + (y_d * y_d)); -} - -static gboolean -clutter_point_progress (const GValue *a, - const GValue *b, - gdouble progress, - GValue *retval) -{ - const ClutterPoint *ap = g_value_get_boxed (a); - const ClutterPoint *bp = g_value_get_boxed (b); - ClutterPoint res = CLUTTER_POINT_INIT (0, 0); - - res.x = ap->x + (bp->x - ap->x) * progress; - res.y = ap->y + (bp->y - ap->y) * progress; - - g_value_set_boxed (retval, &res); - - return TRUE; -} - -G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterPoint, clutter_point, - clutter_point_copy, - clutter_point_free, - CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_point_progress)) - -static int -clutter_point_compare_line (const ClutterPoint *p, - const ClutterPoint *a, - const ClutterPoint *b) -{ - float x1 = b->x - a->x; - float y1 = b->y - a->y; - float x2 = p->x - a->x; - float y2 = p->y - a->y; - float cross_z = x1 * y2 - y1 * x2; - - if (cross_z > 0.f) - return 1; - else if (cross_z < 0.f) - return -1; - else - return 0; -} - -/** - * clutter_point_inside_quadrilateral: - * @point: a #ClutterPoint to test - * @vertices: array of vertices of the quadrilateral, in either clockwise or - * anticlockwise order. - * - * Determines whether a point is inside the convex quadrilateral provided, - * or on any of its edges or vertices. - * - * Returns: %TRUE if @point is inside or touching the quadrilateral - */ -gboolean -clutter_point_inside_quadrilateral (const ClutterPoint *point, - const ClutterPoint *vertices) -{ - unsigned int i; - int first_side; - - first_side = 0; - - for (i = 0; i < 4; i++) - { - int side; - - side = clutter_point_compare_line (point, - &vertices[i], - &vertices[(i + 1) % 4]); - - if (side) - { - if (first_side == 0) - first_side = side; - else if (side != first_side) - return FALSE; - } - } - - if (first_side == 0) - return FALSE; - - return TRUE; -} - - - -/* - * ClutterSize - */ - -/** - * clutter_size_alloc: (constructor) - * - * Allocates a new #ClutterSize. - * - * Return value: (transfer full): the newly allocated #ClutterSize. - * Use clutter_size_free() to free its resources. - * - * Since: 1.12 - */ -ClutterSize * -clutter_size_alloc (void) -{ - return g_slice_new0 (ClutterSize); -} - -/** - * clutter_size_init: - * @size: a #ClutterSize - * @width: the width - * @height: the height - * - * Initializes a #ClutterSize with the given dimensions. - * - * Return value: (transfer none): the initialized #ClutterSize - * - * Since: 1.12 - */ -ClutterSize * -clutter_size_init (ClutterSize *size, - float width, - float height) -{ - g_return_val_if_fail (size != NULL, NULL); - - size->width = width; - size->height = height; - - return size; -} - -/** - * clutter_size_copy: - * @size: a #ClutterSize - * - * Creates a new #ClutterSize and duplicates @size. - * - * Return value: (transfer full): the newly allocated #ClutterSize. - * Use clutter_size_free() to free its resources. - * - * Since: 1.12 - */ -ClutterSize * -clutter_size_copy (const ClutterSize *size) -{ - return g_slice_dup (ClutterSize, size); -} - -/** - * clutter_size_free: - * @size: a #ClutterSize - * - * Frees the resources allocated for @size. - * - * Since: 1.12 - */ -void -clutter_size_free (ClutterSize *size) -{ - if (size != NULL) - g_slice_free (ClutterSize, size); -} - -/** - * clutter_size_equals: - * @a: a #ClutterSize to compare - * @b: a #ClutterSize to compare - * - * Compares two #ClutterSize for equality. - * - * Return value: %TRUE if the two #ClutterSize are equal - * - * Since: 1.12 - */ -gboolean -clutter_size_equals (const ClutterSize *a, - const ClutterSize *b) -{ - if (a == b) - return TRUE; - - if (a == NULL || b == NULL) - return FALSE; - - return fabsf (a->width - b->width) < FLOAT_EPSILON && - fabsf (a->height - b->height) < FLOAT_EPSILON; -} - -static gboolean -clutter_size_progress (const GValue *a, - const GValue *b, - gdouble progress, - GValue *retval) -{ - const ClutterSize *as = g_value_get_boxed (a); - const ClutterSize *bs = g_value_get_boxed (b); - ClutterSize res = CLUTTER_SIZE_INIT (0, 0); - - res.width = as->width + (bs->width - as->width) * progress; - res.height = as->height + (bs->height - as->height) * progress; - - g_value_set_boxed (retval, &res); - - return TRUE; -} - -G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterSize, clutter_size, - clutter_size_copy, - clutter_size_free, - CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_size_progress)) - - - -/* - * ClutterRect - */ - -static const ClutterRect _clutter_rect_zero = CLUTTER_RECT_INIT_ZERO; - -static gboolean clutter_rect_progress (const GValue *a, - const GValue *b, - gdouble progress, - GValue *res); - -G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterRect, clutter_rect, - clutter_rect_copy, - clutter_rect_free, - CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_rect_progress)) - -static inline void -clutter_rect_normalize_internal (ClutterRect *rect) -{ - if (rect->size.width >= 0.f && rect->size.height >= 0.f) - return; - - if (rect->size.width < 0.f) - { - float size = fabsf (rect->size.width); - - rect->origin.x -= size; - rect->size.width = size; - } - - if (rect->size.height < 0.f) - { - float size = fabsf (rect->size.height); - - rect->origin.y -= size; - rect->size.height = size; - } -} - -/** - * clutter_rect_zero: - * - * A #ClutterRect with #ClutterRect.origin set at (0, 0) and a size - * of 0. - * - * The returned value can be used as a guard. - * - * Return value: a rectangle with origin in (0, 0) and a size of 0. - * The returned #ClutterRect is owned by Clutter and it should not - * be modified or freed. - * - * Since: 1.12 - */ -const ClutterRect * -clutter_rect_zero (void) -{ - return &_clutter_rect_zero; -} - -/** - * clutter_rect_alloc: (constructor) - * - * Creates a new, empty #ClutterRect. - * - * You can use clutter_rect_init() to initialize the returned rectangle, - * for instance: - * - * |[ - * rect = clutter_rect_init (clutter_rect_alloc (), x, y, width, height); - * ]| - * - * Return value: (transfer full): the newly allocated #ClutterRect. - * Use clutter_rect_free() to free its resources - * - * Since: 1.12 - */ -ClutterRect * -clutter_rect_alloc (void) -{ - return g_slice_new0 (ClutterRect); -} - -/** - * clutter_rect_init: - * @rect: a #ClutterRect - * @x: X coordinate of the origin - * @y: Y coordinate of the origin - * @width: width of the rectangle - * @height: height of the rectangle - * - * Initializes a #ClutterRect with the given origin and size. - * - * Return value: (transfer none): the updated rectangle - * - * Since: 1.12 - */ -ClutterRect * -clutter_rect_init (ClutterRect *rect, - float x, - float y, - float width, - float height) -{ - g_return_val_if_fail (rect != NULL, NULL); - - rect->origin.x = x; - rect->origin.y = y; - - rect->size.width = width; - rect->size.height = height; - - return rect; -} - -/** - * clutter_rect_copy: - * @rect: a #ClutterRect - * - * Copies @rect into a new #ClutterRect instance. - * - * Return value: (transfer full): the newly allocate copy of @rect. - * Use clutter_rect_free() to free the associated resources - * - * Since: 1.12 - */ -ClutterRect * -clutter_rect_copy (const ClutterRect *rect) -{ - if (rect != NULL) - { - ClutterRect *res; - - res = g_slice_dup (ClutterRect, rect); - clutter_rect_normalize_internal (res); - - return res; - } - - return NULL; -} - -/** - * clutter_rect_free: - * @rect: a #ClutterRect - * - * Frees the resources allocated by @rect. - * - * Since: 1.12 - */ -void -clutter_rect_free (ClutterRect *rect) -{ - if (rect != NULL && rect != &_clutter_rect_zero) - g_slice_free (ClutterRect, rect); -} - -/** - * clutter_rect_equals: - * @a: a #ClutterRect - * @b: a #ClutterRect - * - * Checks whether @a and @b are equals. - * - * This function will normalize both @a and @b before comparing - * their origin and size. - * - * Return value: %TRUE if the rectangles match in origin and size. - * - * Since: 1.12 - */ -gboolean -clutter_rect_equals (ClutterRect *a, - ClutterRect *b) -{ - if (a == b) - return TRUE; - - if (a == NULL || b == NULL) - return FALSE; - - clutter_rect_normalize_internal (a); - clutter_rect_normalize_internal (b); - - return clutter_point_equals (&a->origin, &b->origin) && - clutter_size_equals (&a->size, &b->size); -} - -/** - * clutter_rect_normalize: - * @rect: a #ClutterRect - * - * Normalizes a #ClutterRect. - * - * A #ClutterRect is defined by the area covered by its size; this means - * that a #ClutterRect with #ClutterRect.origin in [ 0, 0 ] and a - * #ClutterRect.size of [ 10, 10 ] is equivalent to a #ClutterRect with - * #ClutterRect.origin in [ 10, 10 ] and a #ClutterRect.size of [ -10, -10 ]. - * - * This function is useful to ensure that a rectangle has positive width - * and height; it will modify the passed @rect and normalize its size. - * - * Since: 1.12 - */ -ClutterRect * -clutter_rect_normalize (ClutterRect *rect) -{ - g_return_val_if_fail (rect != NULL, NULL); - - clutter_rect_normalize_internal (rect); - - return rect; -} - -/** - * clutter_rect_get_center: - * @rect: a #ClutterRect - * @center: (out caller-allocates): a #ClutterPoint - * - * Retrieves the center of @rect, after normalizing the rectangle, - * and updates @center with the correct coordinates. - * - * Since: 1.12 - */ -void -clutter_rect_get_center (ClutterRect *rect, - ClutterPoint *center) -{ - g_return_if_fail (rect != NULL); - g_return_if_fail (center != NULL); - - clutter_rect_normalize_internal (rect); - - center->x = rect->origin.x + (rect->size.width / 2.0f); - center->y = rect->origin.y + (rect->size.height / 2.0f); -} - -/** - * clutter_rect_contains_point: - * @rect: a #ClutterRect - * @point: the point to check - * - * Checks whether @point is contained by @rect, after normalizing the - * rectangle. - * - * Return value: %TRUE if the @point is contained by @rect. - * - * Since: 1.12 - */ -gboolean -clutter_rect_contains_point (ClutterRect *rect, - ClutterPoint *point) -{ - g_return_val_if_fail (rect != NULL, FALSE); - g_return_val_if_fail (point != NULL, FALSE); - - clutter_rect_normalize_internal (rect); - - return (point->x >= rect->origin.x) && - (point->y >= rect->origin.y) && - (point->x <= (rect->origin.x + rect->size.width)) && - (point->y <= (rect->origin.y + rect->size.height)); -} - -/** - * clutter_rect_contains_rect: - * @a: a #ClutterRect - * @b: a #ClutterRect - * - * Checks whether @a contains @b. - * - * The first rectangle contains the second if the union of the - * two #ClutterRect is equal to the first rectangle. - * - * Return value: %TRUE if the first rectangle contains the second. - * - * Since: 1.12 - */ -gboolean -clutter_rect_contains_rect (ClutterRect *a, - ClutterRect *b) -{ - ClutterRect res; - - g_return_val_if_fail (a != NULL, FALSE); - g_return_val_if_fail (b != NULL, FALSE); - - clutter_rect_union (a, b, &res); - - return clutter_rect_equals (a, &res); -} - -/** - * clutter_rect_union: - * @a: a #ClutterRect - * @b: a #ClutterRect - * @res: (out caller-allocates): a #ClutterRect - * - * Computes the smallest possible rectangle capable of fully containing - * both @a and @b, and places it into @res. - * - * This function will normalize both @a and @b prior to computing their - * union. - * - * Since: 1.12 - */ -void -clutter_rect_union (ClutterRect *a, - ClutterRect *b, - ClutterRect *res) -{ - g_return_if_fail (a != NULL); - g_return_if_fail (b != NULL); - g_return_if_fail (res != NULL); - - clutter_rect_normalize_internal (a); - clutter_rect_normalize_internal (b); - - res->origin.x = MIN (a->origin.x, b->origin.x); - res->origin.y = MIN (a->origin.y, b->origin.y); - - res->size.width = MAX (a->size.width, b->size.width); - res->size.height = MAX (a->size.height, b->size.height); -} - -/** - * clutter_rect_intersection: - * @a: a #ClutterRect - * @b: a #ClutterRect - * @res: (out caller-allocates) (allow-none): a #ClutterRect, or %NULL - * - * Computes the intersection of @a and @b, and places it in @res, if @res - * is not %NULL. - * - * This function will normalize both @a and @b prior to computing their - * intersection. - * - * This function can be used to simply check if the intersection of @a and @b - * is not empty, by using %NULL for @res. - * - * Return value: %TRUE if the intersection of @a and @b is not empty - * - * Since: 1.12 - */ -gboolean -clutter_rect_intersection (ClutterRect *a, - ClutterRect *b, - ClutterRect *res) -{ - float x_1, y_1, x_2, y_2; - - g_return_val_if_fail (a != NULL, FALSE); - g_return_val_if_fail (b != NULL, FALSE); - - clutter_rect_normalize_internal (a); - clutter_rect_normalize_internal (b); - - x_1 = MAX (a->origin.x, b->origin.x); - y_1 = MAX (a->origin.y, b->origin.y); - x_2 = MIN (a->origin.x + a->size.width, b->origin.x + b->size.width); - y_2 = MIN (a->origin.y + a->size.height, b->origin.y + b->size.height); - - if (x_1 >= x_2 || y_1 >= y_2) - { - if (res != NULL) - clutter_rect_init (res, 0.f, 0.f, 0.f, 0.f); - - return FALSE; - } - - if (res != NULL) - clutter_rect_init (res, x_1, y_1, x_2 - x_1, y_2 - y_1); - - return TRUE; -} - -/** - * clutter_rect_offset: - * @rect: a #ClutterRect - * @d_x: the horizontal offset value - * @d_y: the vertical offset value - * - * Offsets the origin of @rect by the given values, after normalizing - * the rectangle. - * - * Since: 1.12 - */ -void -clutter_rect_offset (ClutterRect *rect, - float d_x, - float d_y) -{ - g_return_if_fail (rect != NULL); - - clutter_rect_normalize_internal (rect); - - rect->origin.x += d_x; - rect->origin.y += d_y; -} - -/** - * clutter_rect_inset: - * @rect: a #ClutterRect - * @d_x: an horizontal value; a positive @d_x will create an inset rectangle, - * and a negative value will create a larger rectangle - * @d_y: a vertical value; a positive @d_x will create an inset rectangle, - * and a negative value will create a larger rectangle - * - * Normalizes the @rect and offsets its origin by the @d_x and @d_y values; - * the size is adjusted by (2 * @d_x, 2 * @d_y). - * - * If @d_x and @d_y are positive the size of the rectangle is decreased; if - * the values are negative, the size of the rectangle is increased. - * - * If the resulting rectangle has a negative width or height, the size is - * set to 0. - * - * Since: 1.12 - */ -void -clutter_rect_inset (ClutterRect *rect, - float d_x, - float d_y) -{ - g_return_if_fail (rect != NULL); - - clutter_rect_normalize_internal (rect); - - rect->origin.x += d_x; - rect->origin.y += d_y; - - if (d_x >= 0.f) - rect->size.width -= (d_x * 2.f); - else - rect->size.width += (d_x * -2.f); - - if (d_y >= 0.f) - rect->size.height -= (d_y * 2.f); - else - rect->size.height += (d_y * -2.f); - - if (rect->size.width < 0.f) - rect->size.width = 0.f; - - if (rect->size.height < 0.f) - rect->size.height = 0.f; -} - -/** - * clutter_rect_scale: - * @rect: a #ClutterRect - * @s_x: an horizontal scale value - * @s_y: a vertical scale value - * - * Scale the rectangle coordinates and size by @s_x horizontally and - * @s_y vertically. - */ -void -clutter_rect_scale (ClutterRect *rect, - float s_x, - float s_y) -{ - g_return_if_fail (rect != NULL); - g_return_if_fail (s_x > 0.f); - g_return_if_fail (s_y > 0.f); - - clutter_rect_normalize_internal (rect); - - rect->origin.x *= s_x; - rect->origin.y *= s_y; - rect->size.width *= s_x; - rect->size.height *= s_y; -} - -/** - * clutter_rect_clamp_to_pixel: - * @rect: a #ClutterRect - * - * Rounds the origin of @rect downwards to the nearest integer, and recompute the - * the size using the @rect origin and size rounded upwards to the nearest integer, - * so that @rect is updated to the smallest rectangle capable of fully containing - * the original, fractional rectangle in the coordinates space. - * - * Since: 1.12 - */ -void -clutter_rect_clamp_to_pixel (ClutterRect *rect) -{ - float x2, y2; - - g_return_if_fail (rect != NULL); - - clutter_rect_normalize_internal (rect); - - x2 = rect->origin.x + rect->size.width; - y2 = rect->origin.y + rect->size.height; - - rect->origin.x = floorf (rect->origin.x); - rect->origin.y = floorf (rect->origin.y); - - rect->size.width = ceilf (x2) - rect->origin.x; - rect->size.height = ceilf (y2) - rect->origin.y; -} - -/** - * clutter_rect_get_x: - * @rect: a #ClutterRect - * - * Retrieves the X coordinate of the origin of @rect. - * - * Return value: the X coordinate of the origin of the rectangle - * - * Since: 1.12 - */ -float -clutter_rect_get_x (ClutterRect *rect) -{ - g_return_val_if_fail (rect != NULL, 0.f); - - clutter_rect_normalize_internal (rect); - - return rect->origin.x; -} - -/** - * clutter_rect_get_y: - * @rect: a #ClutterRect - * - * Retrieves the Y coordinate of the origin of @rect. - * - * Return value: the Y coordinate of the origin of the rectangle - * - * Since: 1.12 - */ -float -clutter_rect_get_y (ClutterRect *rect) -{ - g_return_val_if_fail (rect != NULL, 0.f); - - clutter_rect_normalize_internal (rect); - - return rect->origin.y; -} - -/** - * clutter_rect_get_width: - * @rect: a #ClutterRect - * - * Retrieves the width of @rect. - * - * Return value: the width of the rectangle - * - * Since: 1.12 - */ -float -clutter_rect_get_width (ClutterRect *rect) -{ - g_return_val_if_fail (rect != NULL, 0.f); - - clutter_rect_normalize_internal (rect); - - return rect->size.width; -} - -/** - * clutter_rect_get_height: - * @rect: a #ClutterRect - * - * Retrieves the height of @rect. - * - * Return value: the height of the rectangle - * - * Since: 1.12 - */ -float -clutter_rect_get_height (ClutterRect *rect) -{ - g_return_val_if_fail (rect != NULL, 0.f); - - clutter_rect_normalize_internal (rect); - - return rect->size.height; -} - -static gboolean -clutter_rect_progress (const GValue *a, - const GValue *b, - gdouble progress, - GValue *retval) -{ - const ClutterRect *rect_a = g_value_get_boxed (a); - const ClutterRect *rect_b = g_value_get_boxed (b); - ClutterRect res = CLUTTER_RECT_INIT_ZERO; - -#define INTERPOLATE(r_a,r_b,member,field,factor) ((r_a)->member.field + (((r_b)->member.field - ((r_a)->member.field)) * (factor))) - - res.origin.x = INTERPOLATE (rect_a, rect_b, origin, x, progress); - res.origin.y = INTERPOLATE (rect_a, rect_b, origin, y, progress); - - res.size.width = INTERPOLATE (rect_a, rect_b, size, width, progress); - res.size.height = INTERPOLATE (rect_a, rect_b, size, height, progress); - -#undef INTERPOLATE - - g_value_set_boxed (retval, &res); - - return TRUE; -} - /** * ClutterMatrix: * @@ -1393,20 +126,20 @@ clutter_matrix_progress (const GValue *a, { const ClutterMatrix *matrix1 = g_value_get_boxed (a); 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 }; - ClutterVertex rotate1 = CLUTTER_VERTEX_INIT_ZERO; - ClutterVertex translate1 = CLUTTER_VERTEX_INIT_ZERO; + 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 }; - 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 }; - ClutterVertex rotate2 = CLUTTER_VERTEX_INIT_ZERO; - ClutterVertex translate2 = CLUTTER_VERTEX_INIT_ZERO; + 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 }; - 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; - ClutterVertex rotate_res = CLUTTER_VERTEX_INIT_ZERO; - ClutterVertex translate_res = CLUTTER_VERTEX_INIT_ZERO; + 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 }; ClutterMatrix res; @@ -1427,11 +160,11 @@ clutter_matrix_progress (const GValue *a, res.ww = perspective_res.w; /* 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); /* 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.y, 0.0f, 1.0f, 0.0f); cogl_matrix_rotate (&res, rotate_res.z, 0.0f, 0.0f, 1.0f); @@ -1450,7 +183,7 @@ clutter_matrix_progress (const GValue *a, _clutter_util_matrix_skew_xy (&res, shear_res); /* 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); g_value_set_boxed (retval, &res); diff --git a/clutter/clutter/clutter-bind-constraint.c b/clutter/clutter/clutter-bind-constraint.c index 138866882b222bb75f8114cb4ccfafa4790f59f0..3443599e6360e0f720d3c6119449d32191d7fb1d 100644 --- a/clutter/clutter/clutter-bind-constraint.c +++ b/clutter/clutter/clutter-bind-constraint.c @@ -152,7 +152,9 @@ clutter_bind_constraint_update_allocation (ClutterConstraint *constraint, ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (constraint); gfloat source_width, source_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) return; diff --git a/clutter/clutter/clutter-blur-effect.c b/clutter/clutter/clutter-blur-effect.c index 1ffb99c0f584c3573bf5fae659cd2336f95cfb00..06a7b2d4bb122f16e28c78bcd4f1a2edca5ed42d 100644 --- a/clutter/clutter/clutter-blur-effect.c +++ b/clutter/clutter/clutter-blur-effect.c @@ -182,7 +182,7 @@ clutter_blur_effect_modify_paint_volume (ClutterEffect *effect, ClutterPaintVolume *volume) { gfloat cur_width, cur_height; - ClutterVertex origin; + graphene_point3d_t origin; clutter_paint_volume_get_origin (volume, &origin); cur_width = clutter_paint_volume_get_width (volume); diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index 05ee15f2bc366e9dc7ba679eac32fa319524212d..6ffaeab52992b9c8ea9fd8eb9d57103d8ea83fae 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -177,7 +177,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect) if (priv->is_dirty) { - ClutterRect rect; + graphene_rect_t rect; gboolean mapped_buffer; CoglVertexP3T2C4 *verts; ClutterActor *actor; @@ -193,8 +193,8 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect) */ if (clutter_offscreen_effect_get_target_rect (effect, &rect)) { - width = clutter_rect_get_width (&rect); - height = clutter_rect_get_height (&rect); + width = graphene_rect_get_width (&rect); + height = graphene_rect_get_height (&rect); } else clutter_actor_get_size (actor, &width, &height); diff --git a/clutter/clutter/clutter-drag-action.c b/clutter/clutter/clutter-drag-action.c index 54e991bf80a92f8e8bc2fd253ea83e4cbabd6b2c..8298894722f7f3a412867f856c48ee5bdef22a99 100644 --- a/clutter/clutter/clutter-drag-action.c +++ b/clutter/clutter/clutter-drag-action.c @@ -81,7 +81,7 @@ struct _ClutterDragActionPrivate gint y_drag_threshold; ClutterActor *drag_handle; ClutterDragAxis drag_axis; - ClutterRect drag_area; + graphene_rect_t drag_area; ClutterInputDevice *device; ClutterEventSequence *sequence; @@ -542,7 +542,7 @@ clutter_drag_action_real_drag_motion (ClutterDragAction *action, if (action->priv->drag_area_set) { - ClutterRect *drag_area = &action->priv->drag_area; + graphene_rect_t *drag_area = &action->priv->drag_area; x = CLAMP (x, drag_area->origin.x, drag_area->origin.x + drag_area->size.width); y = CLAMP (y, drag_area->origin.y, drag_area->origin.y + drag_area->size.height); @@ -811,7 +811,7 @@ clutter_drag_action_class_init (ClutterDragActionClass *klass) g_param_spec_boxed ("drag-area", P_("Drag Area"), P_("Constrains the dragging to a rectangle"), - CLUTTER_TYPE_RECT, + GRAPHENE_TYPE_RECT, CLUTTER_PARAM_READWRITE); /** @@ -1267,10 +1267,10 @@ clutter_drag_action_get_motion_coords (ClutterDragAction *action, /** * clutter_drag_action_get_drag_area: * @action: a #ClutterDragAction - * @drag_area: (out caller-allocates): a #ClutterRect to be filled + * @drag_area: (out caller-allocates): a #graphene_rect_t to be filled * * Retrieves the "drag area" associated with @action, that - * is a #ClutterRect that constrains the actor movements, + * is a #graphene_rect_t that constrains the actor movements, * in parents coordinates. * * Returns: %TRUE if the actor is actually constrained (and thus @@ -1278,7 +1278,7 @@ clutter_drag_action_get_motion_coords (ClutterDragAction *action, */ gboolean clutter_drag_action_get_drag_area (ClutterDragAction *action, - ClutterRect *drag_area) + graphene_rect_t *drag_area) { g_return_val_if_fail (CLUTTER_IS_DRAG_ACTION (action), FALSE); @@ -1298,8 +1298,8 @@ clutter_drag_action_get_drag_area (ClutterDragAction *action, * If @drag_area is %NULL, the actor is not constrained. */ void -clutter_drag_action_set_drag_area (ClutterDragAction *action, - const ClutterRect *drag_area) +clutter_drag_action_set_drag_area (ClutterDragAction *action, + const graphene_rect_t *drag_area) { ClutterDragActionPrivate *priv; diff --git a/clutter/clutter/clutter-drag-action.h b/clutter/clutter/clutter-drag-action.h index c0df6223867b3e654c7b44313e75d3c9959539ef..6904dc5edd99f26afbb6e1c1faabd30a30b72e8b 100644 --- a/clutter/clutter/clutter-drag-action.h +++ b/clutter/clutter/clutter-drag-action.h @@ -141,11 +141,11 @@ void clutter_drag_action_get_motion_coords (ClutterDragAction *actio CLUTTER_EXPORT gboolean clutter_drag_action_get_drag_area (ClutterDragAction *action, - ClutterRect *drag_area); + graphene_rect_t *drag_area); CLUTTER_EXPORT -void clutter_drag_action_set_drag_area (ClutterDragAction *action, - const ClutterRect *drag_area); +void clutter_drag_action_set_drag_area (ClutterDragAction *action, + const graphene_rect_t *drag_area); G_END_DECLS diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 8ccf0e8da4f37337d047d02c7dc392769b25c72b..975ba570767a446ac6ba5943733ec1797567837d 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -370,7 +370,7 @@ clutter_event_get_coords (const ClutterEvent *event, gfloat *x, gfloat *y) { - ClutterPoint coords; + graphene_point_t coords; g_return_if_fail (event != NULL); @@ -386,15 +386,15 @@ clutter_event_get_coords (const ClutterEvent *event, /** * clutter_event_get_position: * @event: a #ClutterEvent - * @position: a #ClutterPoint + * @position: a #graphene_point_t * - * Retrieves the event coordinates as a #ClutterPoint. + * Retrieves the event coordinates as a #graphene_point_t. * * Since: 1.12 */ void clutter_event_get_position (const ClutterEvent *event, - ClutterPoint *position) + graphene_point_t *position) { g_return_if_fail (event != NULL); g_return_if_fail (position != NULL); @@ -415,42 +415,42 @@ clutter_event_get_position (const ClutterEvent *event, case CLUTTER_PAD_BUTTON_RELEASE: case CLUTTER_PAD_STRIP: case CLUTTER_PAD_RING: - clutter_point_init (position, 0.f, 0.f); + graphene_point_init (position, 0.f, 0.f); break; case CLUTTER_ENTER: case CLUTTER_LEAVE: - clutter_point_init (position, event->crossing.x, event->crossing.y); + graphene_point_init (position, event->crossing.x, event->crossing.y); break; case CLUTTER_BUTTON_PRESS: case CLUTTER_BUTTON_RELEASE: - clutter_point_init (position, event->button.x, event->button.y); + graphene_point_init (position, event->button.x, event->button.y); break; case CLUTTER_MOTION: - clutter_point_init (position, event->motion.x, event->motion.y); + graphene_point_init (position, event->motion.x, event->motion.y); break; case CLUTTER_TOUCH_BEGIN: case CLUTTER_TOUCH_UPDATE: case CLUTTER_TOUCH_END: case CLUTTER_TOUCH_CANCEL: - clutter_point_init (position, event->touch.x, event->touch.y); + graphene_point_init (position, event->touch.x, event->touch.y); break; case CLUTTER_SCROLL: - clutter_point_init (position, event->scroll.x, event->scroll.y); + graphene_point_init (position, event->scroll.x, event->scroll.y); break; case CLUTTER_TOUCHPAD_PINCH: - clutter_point_init (position, event->touchpad_pinch.x, - event->touchpad_pinch.y); + graphene_point_init (position, event->touchpad_pinch.x, + event->touchpad_pinch.y); break; case CLUTTER_TOUCHPAD_SWIPE: - clutter_point_init (position, event->touchpad_swipe.x, - event->touchpad_swipe.y); + graphene_point_init (position, event->touchpad_swipe.x, + event->touchpad_swipe.y); break; } @@ -1796,12 +1796,12 @@ float clutter_event_get_distance (const ClutterEvent *source, const ClutterEvent *target) { - ClutterPoint p0, p1; + graphene_point_t p0, p1; clutter_event_get_position (source, &p0); clutter_event_get_position (source, &p1); - return clutter_point_distance (&p0, &p1, NULL, NULL); + return graphene_point_distance (&p0, &p1, NULL, NULL); } /** @@ -1822,17 +1822,17 @@ double clutter_event_get_angle (const ClutterEvent *source, const ClutterEvent *target) { - ClutterPoint p0, p1; + graphene_point_t p0, p1; float x_distance, y_distance; double angle; clutter_event_get_position (source, &p0); clutter_event_get_position (target, &p1); - if (clutter_point_equals (&p0, &p1)) + if (graphene_point_equal (&p0, &p1)) return 0; - clutter_point_distance (&p0, &p1, &x_distance, &y_distance); + graphene_point_distance (&p0, &p1, &x_distance, &y_distance); angle = atan2 (x_distance, y_distance); diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 54155cd3df38ef7f2e961ac3600c30494062e27e..f090ca8e11134f2cb1499d6a0785742ecd5e1849 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -686,7 +686,7 @@ void clutter_event_get_coords (const ClutterEv gfloat *y); CLUTTER_EXPORT void clutter_event_get_position (const ClutterEvent *event, - ClutterPoint *position); + graphene_point_t *position); CLUTTER_EXPORT float clutter_event_get_distance (const ClutterEvent *source, const ClutterEvent *target); diff --git a/clutter/clutter/clutter-graphene.c b/clutter/clutter/clutter-graphene.c new file mode 100644 index 0000000000000000000000000000000000000000..d1c447a5e58f77cf7369b2c21c9e5685fd3cc1ad --- /dev/null +++ b/clutter/clutter/clutter-graphene.c @@ -0,0 +1,111 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Authored By Georges Basile Stavracas Neto + * + * 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 . + */ + +#include "clutter-build-config.h" + +#include "clutter-graphene.h" + +#include "clutter-private.h" +#include "clutter-types.h" + +static gboolean +graphene_point_progress (const GValue *a, + const GValue *b, + double progress, + GValue *retval) +{ + const graphene_point_t *ap = g_value_get_boxed (a); + const graphene_point_t *bp = g_value_get_boxed (b); + graphene_point_t res; + + graphene_point_interpolate (ap, bp, progress, &res); + + g_value_set_boxed (retval, &res); + + return TRUE; +} + +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; +} + +static gboolean +graphene_rect_progress (const GValue *a, + const GValue *b, + double progress, + GValue *retval) +{ + const graphene_rect_t *rect_a = g_value_get_boxed (a); + const graphene_rect_t *rect_b = g_value_get_boxed (b); + graphene_rect_t res; + + graphene_rect_interpolate (rect_a, rect_b, progress, &res); + + g_value_set_boxed (retval, &res); + + return TRUE; +} + +static gboolean +graphene_size_progress (const GValue *a, + const GValue *b, + double progress, + GValue *retval) +{ + const graphene_size_t *as = g_value_get_boxed (a); + const graphene_size_t *bs = g_value_get_boxed (b); + graphene_size_t res; + + graphene_size_interpolate (as, bs, progress, &res); + + g_value_set_boxed (retval, &res); + + return TRUE; +} + +void +clutter_graphene_init (void) +{ + clutter_interval_register_progress_func (GRAPHENE_TYPE_POINT, + graphene_point_progress); + clutter_interval_register_progress_func (GRAPHENE_TYPE_POINT3D, + graphene_point3d_progress); + clutter_interval_register_progress_func (GRAPHENE_TYPE_RECT, + graphene_rect_progress); + clutter_interval_register_progress_func (GRAPHENE_TYPE_SIZE, + graphene_size_progress); +} diff --git a/clutter/clutter/clutter-graphene.h b/clutter/clutter/clutter-graphene.h new file mode 100644 index 0000000000000000000000000000000000000000..ddea3ca4abfd6a017c857dc818e9110a055ed06b --- /dev/null +++ b/clutter/clutter/clutter-graphene.h @@ -0,0 +1,30 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Authored By Georges Basile Stavracas Neto + * + * 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 . + */ + +#ifndef CLUTTER_GRAPHENE_H +#define CLUTTER_GRAPHENE_H + +void clutter_graphene_init (void); + +#endif diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c index c664e83f18fca10be3e4d1b8f733afa4f7b5b32c..3975e88b5245150b89f6601620545231a53fa590 100644 --- a/clutter/clutter/clutter-input-device.c +++ b/clutter/clutter/clutter-input-device.c @@ -991,7 +991,7 @@ clutter_input_device_get_enabled (ClutterInputDevice *device) gboolean clutter_input_device_get_coords (ClutterInputDevice *device, ClutterEventSequence *sequence, - ClutterPoint *point) + graphene_point_t *point) { g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE); g_return_val_if_fail (point != NULL, FALSE); @@ -1038,7 +1038,7 @@ _clutter_input_device_update (ClutterInputDevice *device, ClutterStage *stage; ClutterActor *new_cursor_actor; ClutterActor *old_cursor_actor; - ClutterPoint point = { -1, -1 }; + graphene_point_t point = GRAPHENE_POINT_INIT (-1.0f, -1.0f); ClutterInputDeviceType device_type = device->device_type; g_assert (device_type != CLUTTER_KEYBOARD_DEVICE && diff --git a/clutter/clutter/clutter-input-device.h b/clutter/clutter/clutter-input-device.h index c121fe12cd7cc9517cd61a5f70417a95633c9bf3..00dcc01d52026b9f810ec130d23d7c48f731198f 100644 --- a/clutter/clutter/clutter-input-device.h +++ b/clutter/clutter/clutter-input-device.h @@ -58,7 +58,7 @@ gint clutter_input_device_get_device_id (ClutterInputDev CLUTTER_EXPORT gboolean clutter_input_device_get_coords (ClutterInputDevice *device, ClutterEventSequence *sequence, - ClutterPoint *point); + graphene_point_t *point); CLUTTER_EXPORT ClutterModifierType clutter_input_device_get_modifier_state (ClutterInputDevice *device); CLUTTER_EXPORT diff --git a/clutter/clutter/clutter-input-focus.c b/clutter/clutter/clutter-input-focus.c index d54494b0f4ced5c71de262e2d30311bfcf924b20..7a004f2596b7e1be0a24f23334c459079599c280 100644 --- a/clutter/clutter/clutter-input-focus.c +++ b/clutter/clutter/clutter-input-focus.c @@ -89,8 +89,8 @@ clutter_input_focus_reset (ClutterInputFocus *focus) } void -clutter_input_focus_set_cursor_location (ClutterInputFocus *focus, - const ClutterRect *rect) +clutter_input_focus_set_cursor_location (ClutterInputFocus *focus, + const graphene_rect_t *rect) { ClutterInputFocusPrivate *priv; diff --git a/clutter/clutter/clutter-input-focus.h b/clutter/clutter/clutter-input-focus.h index 3f971fec4b8648637209d9f38f95a853e5019a22..65736a7998db392ee8d4fe3097f21b3a43bd8f77 100644 --- a/clutter/clutter/clutter-input-focus.h +++ b/clutter/clutter/clutter-input-focus.h @@ -57,8 +57,8 @@ gboolean clutter_input_focus_is_focused (ClutterInputFocus *focus); CLUTTER_EXPORT void clutter_input_focus_reset (ClutterInputFocus *focus); CLUTTER_EXPORT -void clutter_input_focus_set_cursor_location (ClutterInputFocus *focus, - const ClutterRect *rect); +void clutter_input_focus_set_cursor_location (ClutterInputFocus *focus, + const graphene_rect_t *rect); CLUTTER_EXPORT void clutter_input_focus_set_surrounding (ClutterInputFocus *focus, diff --git a/clutter/clutter/clutter-input-method-private.h b/clutter/clutter/clutter-input-method-private.h index e8ab2cabff6d76adb2361dffe2054651013e3090..61e575e7ee10ac84433caedf0c9f3ad1d51dddb7 100644 --- a/clutter/clutter/clutter-input-method-private.h +++ b/clutter/clutter/clutter-input-method-private.h @@ -26,8 +26,8 @@ ClutterInputFocus * clutter_input_method_get_focus (ClutterInputMethod *method); void clutter_input_method_reset (ClutterInputMethod *method); -void clutter_input_method_set_cursor_location (ClutterInputMethod *method, - const ClutterRect *rect); +void clutter_input_method_set_cursor_location (ClutterInputMethod *method, + const graphene_rect_t *rect); void clutter_input_method_set_surrounding (ClutterInputMethod *method, const gchar *text, guint cursor, diff --git a/clutter/clutter/clutter-input-method.c b/clutter/clutter/clutter-input-method.c index 344e192976353df42880f58e3f1821cc76e378e3..0fb0931227f9fe837444cb59d687255c197dfa81 100644 --- a/clutter/clutter/clutter-input-method.c +++ b/clutter/clutter/clutter-input-method.c @@ -187,7 +187,7 @@ clutter_input_method_class_init (ClutterInputMethodClass *klass) G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, - G_TYPE_NONE, 1, CLUTTER_TYPE_RECT); + G_TYPE_NONE, 1, GRAPHENE_TYPE_RECT); pspecs[PROP_CONTENT_HINTS] = g_param_spec_flags ("content-hints", @@ -377,8 +377,8 @@ clutter_input_method_reset (ClutterInputMethod *im) } void -clutter_input_method_set_cursor_location (ClutterInputMethod *im, - const ClutterRect *rect) +clutter_input_method_set_cursor_location (ClutterInputMethod *im, + const graphene_rect_t *rect) { g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im)); diff --git a/clutter/clutter/clutter-input-method.h b/clutter/clutter/clutter-input-method.h index ba1bc223a22ebbeec7d7e1e7d6ca281d38b228a2..92f960f0a5602fe939e8321eaef17d059fc607ac 100644 --- a/clutter/clutter/clutter-input-method.h +++ b/clutter/clutter/clutter-input-method.h @@ -42,8 +42,8 @@ struct _ClutterInputMethodClass void (* reset) (ClutterInputMethod *im); - void (* set_cursor_location) (ClutterInputMethod *im, - const ClutterRect *rect); + void (* set_cursor_location) (ClutterInputMethod *im, + const graphene_rect_t *rect); void (* set_surrounding) (ClutterInputMethod *im, const gchar *text, guint cursor, diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index 2bb5bd2c8b063b4ff42356e18f323f7dd54cff84..3b1eec459ad6c63ae6e3e61b0144d00b8b8d210e 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -59,6 +59,7 @@ #include "clutter-event-private.h" #include "clutter-feature.h" #include "clutter-input-pointer-a11y-private.h" +#include "clutter-graphene.h" #include "clutter-main.h" #include "clutter-master-clock.h" #include "clutter-mutter.h" @@ -2194,6 +2195,8 @@ clutter_base_init (void) /* initialise the Big Clutter Lock™ if necessary */ clutter_threads_init_default (); + + clutter_graphene_init (); } } diff --git a/clutter/clutter/clutter-offscreen-effect.c b/clutter/clutter/clutter-offscreen-effect.c index 9e3756765887ae71219e36951dfa18bdeca87b42..cc3150d44cf201a418fce90d898ac2d15b8a9827 100644 --- a/clutter/clutter/clutter-offscreen-effect.c +++ b/clutter/clutter/clutter-offscreen-effect.c @@ -86,7 +86,7 @@ struct _ClutterOffscreenEffectPrivate ClutterActor *actor; ClutterActor *stage; - ClutterVertex position; + graphene_point3d_t position; int fbo_offset_x; int fbo_offset_y; @@ -250,9 +250,11 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect) gfloat target_width = -1, target_height = -1; gfloat resource_scale; gfloat ceiled_resource_scale; - ClutterVertex local_offset = { 0.f, 0.f, 0.f }; + graphene_point3d_t local_offset; 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))) return FALSE; @@ -682,7 +684,7 @@ clutter_offscreen_effect_get_target_size (ClutterOffscreenEffect *effect, */ gboolean clutter_offscreen_effect_get_target_rect (ClutterOffscreenEffect *effect, - ClutterRect *rect) + graphene_rect_t *rect) { ClutterOffscreenEffectPrivate *priv; @@ -694,11 +696,11 @@ clutter_offscreen_effect_get_target_rect (ClutterOffscreenEffect *effect, if (priv->texture == NULL) return FALSE; - clutter_rect_init (rect, - priv->position.x, - priv->position.y, - cogl_texture_get_width (priv->texture), - cogl_texture_get_height (priv->texture)); + graphene_rect_init (rect, + priv->position.x, + priv->position.y, + cogl_texture_get_width (priv->texture), + cogl_texture_get_height (priv->texture)); return TRUE; } diff --git a/clutter/clutter/clutter-offscreen-effect.h b/clutter/clutter/clutter-offscreen-effect.h index 07619441e26796d60ee1d7c48dc030c21f67a180..6ab1637aed36393b19e426f66bbe4fba1d4f097f 100644 --- a/clutter/clutter/clutter-offscreen-effect.h +++ b/clutter/clutter/clutter-offscreen-effect.h @@ -114,7 +114,7 @@ gboolean clutter_offscreen_effect_get_target_size (ClutterOffscree CLUTTER_EXPORT gboolean clutter_offscreen_effect_get_target_rect (ClutterOffscreenEffect *effect, - ClutterRect *rect); + graphene_rect_t *rect); G_END_DECLS diff --git a/clutter/clutter/clutter-paint-volume-private.h b/clutter/clutter/clutter-paint-volume-private.h index 72bc7aee3a88154e551295b018d3a385f7a8cb5e..21e35c2020710466f9ebc5fa1cd8dc1140f256f7 100644 --- a/clutter/clutter/clutter-paint-volume-private.h +++ b/clutter/clutter/clutter-paint-volume-private.h @@ -58,7 +58,7 @@ struct _ClutterPaintVolume * elements 4, 5, 6 and 7 most of the time for 2D actors when * calculating the projected paint box. */ - ClutterVertex vertices[8]; + graphene_point3d_t vertices[8]; /* As an optimization for internally managed PaintVolumes we allow * initializing ClutterPaintVolume variables allocated on the stack diff --git a/clutter/clutter/clutter-paint-volume.c b/clutter/clutter/clutter-paint-volume.c index 6adf626a4c21d361026912e396f4557d953dc9f0..09edeb6f0cbfb48e14ccb1f9157c3f07a7c8dba5 100644 --- a/clutter/clutter/clutter-paint-volume.c +++ b/clutter/clutter/clutter-paint-volume.c @@ -63,7 +63,7 @@ _clutter_paint_volume_new (ClutterActor *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_empty = TRUE; @@ -96,7 +96,7 @@ _clutter_paint_volume_init_static (ClutterPaintVolume *pv, { 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_empty = TRUE; @@ -170,7 +170,7 @@ clutter_paint_volume_free (ClutterPaintVolume *pv) /** * clutter_paint_volume_set_origin: * @pv: a #ClutterPaintVolume - * @origin: a #ClutterVertex + * @origin: a #graphene_point3d_t * * Sets the origin of the paint volume. * @@ -182,8 +182,8 @@ clutter_paint_volume_free (ClutterPaintVolume *pv) * Since: 1.6 */ void -clutter_paint_volume_set_origin (ClutterPaintVolume *pv, - const ClutterVertex *origin) +clutter_paint_volume_set_origin (ClutterPaintVolume *pv, + const graphene_point3d_t *origin) { static const int key_vertices[4] = { 0, 1, 3, 4 }; float dx, dy, dz; @@ -210,7 +210,7 @@ clutter_paint_volume_set_origin (ClutterPaintVolume *pv, /** * clutter_paint_volume_get_origin: * @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. * @@ -218,7 +218,7 @@ clutter_paint_volume_set_origin (ClutterPaintVolume *pv, */ void clutter_paint_volume_get_origin (const ClutterPaintVolume *pv, - ClutterVertex *vertex) + graphene_point3d_t *vertex) { g_return_if_fail (pv != NULL); g_return_if_fail (vertex != NULL); @@ -659,7 +659,7 @@ clutter_paint_volume_union_box (ClutterPaintVolume *pv, const ClutterActorBox *box) { ClutterPaintVolume volume; - ClutterVertex origin; + graphene_point3d_t origin; g_return_if_fail (pv != NULL); g_return_if_fail (box != NULL); @@ -757,7 +757,7 @@ _clutter_paint_volume_get_bounding_box (ClutterPaintVolume *pv, ClutterActorBox *box) { gfloat x_min, y_min, x_max, y_max; - ClutterVertex *vertices; + graphene_point3d_t *vertices; int count; gint i; @@ -878,9 +878,9 @@ _clutter_paint_volume_transform (ClutterPaintVolume *pv, cogl_matrix_transform_points (matrix, 3, - sizeof (ClutterVertex), + sizeof (graphene_point3d_t), pv->vertices, - sizeof (ClutterVertex), + sizeof (graphene_point3d_t), pv->vertices, transform_count); @@ -896,7 +896,7 @@ _clutter_paint_volume_axis_align (ClutterPaintVolume *pv) { int count; int i; - ClutterVertex origin; + graphene_point3d_t origin; float max_x; float max_y; float max_z; @@ -1075,7 +1075,7 @@ _clutter_paint_volume_cull (ClutterPaintVolume *pv, const ClutterPlane *planes) { int vertex_count; - ClutterVertex *vertices = pv->vertices; + graphene_point3d_t *vertices = pv->vertices; gboolean partial = FALSE; int i; int j; @@ -1097,24 +1097,18 @@ _clutter_paint_volume_cull (ClutterPaintVolume *pv, for (i = 0; i < 4; i++) { + const ClutterPlane *plane = &planes[i]; int out = 0; for (j = 0; j < vertex_count; j++) { - ClutterVertex p; - float distance; + graphene_vec3_t v; - /* XXX: for perspective projections this can be optimized - * out because all the planes should pass through the origin - * so (0,0,0) is a valid v0. */ - p.x = vertices[j].x - planes[i].v0[0]; - p.y = vertices[j].y - planes[i].v0[1]; - p.z = vertices[j].z - planes[i].v0[2]; + graphene_vec3_init (&v, + vertices[j].x - graphene_vec3_get_x (&plane->v0), + vertices[j].y - graphene_vec3_get_y (&plane->v0), + vertices[j].z - graphene_vec3_get_z (&plane->v0)); - distance = (planes[i].n[0] * p.x + - planes[i].n[1] * p.y + - planes[i].n[2] * p.z); - - if (distance < 0) + if (graphene_vec3_dot (&plane->n, &v) < 0) out++; } diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h index fb94bfa0752c4bca26ae28e41cad16ed5c2a35a4..28c56c0d0e6e0cec1b8b3d49787b56dcf3ebaa98 100644 --- a/clutter/clutter/clutter-private.h +++ b/clutter/clutter/clutter-private.h @@ -220,17 +220,17 @@ void _clutter_run_repaint_functions (ClutterRepaintFlags flags); GType _clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager); -void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, - const CoglMatrix *projection, - const float *viewport, - const ClutterVertex *vertices_in, - ClutterVertex *vertices_out, - int n_vertices); +void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, + const CoglMatrix *projection, + const float *viewport, + const graphene_point3d_t *vertices_in, + graphene_point3d_t *vertices_out, + int n_vertices); void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src, - ClutterRect *dest); + graphene_rect_t *dest); -void _clutter_util_rectangle_int_extents (const ClutterRect *src, +void _clutter_util_rectangle_int_extents (const graphene_rect_t *src, cairo_rectangle_int_t *dest); void _clutter_util_rectangle_offset (const cairo_rectangle_int_t *src, @@ -278,10 +278,10 @@ void _clutter_util_matrix_skew_yz (ClutterMatrix *matrix, float factor); gboolean _clutter_util_matrix_decompose (const ClutterMatrix *src, - ClutterVertex *scale_p, + graphene_point3d_t *scale_p, float shear_p[3], - ClutterVertex *rotate_p, - ClutterVertex *translate_p, + graphene_point3d_t *rotate_p, + graphene_point3d_t *translate_p, ClutterVertex4 *perspective_p); CLUTTER_EXPORT @@ -292,8 +292,8 @@ PangoDirection _clutter_pango_find_base_dir (const gchar *text, typedef struct _ClutterPlane { - float v0[3]; - float n[3]; + graphene_vec3_t v0; + graphene_vec3_t n; } ClutterPlane; typedef enum _ClutterCullResult diff --git a/clutter/clutter/clutter-script-parser.c b/clutter/clutter/clutter-script-parser.c index b17a7d2335c25f4b50bd64e9bbcd73b32baa52fe..ea14b4166cfc1bdc535ddaea0358dd4c754808d3 100644 --- a/clutter/clutter/clutter-script-parser.c +++ b/clutter/clutter/clutter-script-parser.c @@ -352,63 +352,64 @@ _clutter_script_parse_knot (ClutterScript *script, } static gboolean -parse_geometry_from_array (JsonArray *array, - ClutterGeometry *geometry) +parse_rect_from_array (JsonArray *array, + graphene_rect_t *rect) { if (json_array_get_length (array) != 4) return FALSE; - geometry->x = json_array_get_int_element (array, 0); - geometry->y = json_array_get_int_element (array, 1); - geometry->width = json_array_get_int_element (array, 2); - geometry->height = json_array_get_int_element (array, 3); + graphene_rect_init (rect, + json_array_get_int_element (array, 0), + json_array_get_int_element (array, 1), + json_array_get_int_element (array, 2), + json_array_get_int_element (array, 3)); return TRUE; } static gboolean -parse_geometry_from_object (JsonObject *object, - ClutterGeometry *geometry) +parse_rect_from_object (JsonObject *object, + graphene_rect_t *rect) { if (json_object_has_member (object, "x")) - geometry->x = json_object_get_int_member (object, "x"); + rect->origin.x = json_object_get_int_member (object, "x"); else - geometry->x = 0; + rect->origin.x = 0; if (json_object_has_member (object, "y")) - geometry->y = json_object_get_int_member (object, "y"); + rect->origin.y = json_object_get_int_member (object, "y"); else - geometry->y = 0; + rect->origin.y = 0; if (json_object_has_member (object, "width")) - geometry->width = json_object_get_int_member (object, "width"); + rect->size.width = json_object_get_int_member (object, "width"); else - geometry->width = 0; + rect->size.width = 0; if (json_object_has_member (object, "height")) - geometry->height = json_object_get_int_member (object, "height"); + rect->size.height = json_object_get_int_member (object, "height"); else - geometry->height = 0; + rect->size.height = 0; return TRUE; } gboolean -_clutter_script_parse_geometry (ClutterScript *script, - JsonNode *node, - ClutterGeometry *geometry) +_clutter_script_parse_rect (ClutterScript *script, + JsonNode *node, + graphene_rect_t *rect) { g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE); g_return_val_if_fail (node != NULL, FALSE); - g_return_val_if_fail (geometry != NULL, FALSE); + g_return_val_if_fail (rect != NULL, FALSE); switch (JSON_NODE_TYPE (node)) { case JSON_NODE_ARRAY: - return parse_geometry_from_array (json_node_get_array (node), geometry); + return parse_rect_from_array (json_node_get_array (node), rect); case JSON_NODE_OBJECT: - return parse_geometry_from_object (json_node_get_object (node), geometry); + return parse_rect_from_object (json_node_get_object (node), rect); default: break; @@ -492,8 +493,8 @@ _clutter_script_parse_color (ClutterScript *script, } static gboolean -parse_point_from_array (JsonArray *array, - ClutterPoint *point) +parse_point_from_array (JsonArray *array, + graphene_point_t *point) { if (json_array_get_length (array) != 2) return FALSE; @@ -505,8 +506,8 @@ parse_point_from_array (JsonArray *array, } static gboolean -parse_point_from_object (JsonObject *object, - ClutterPoint *point) +parse_point_from_object (JsonObject *object, + graphene_point_t *point) { if (json_object_has_member (object, "x")) point->x = json_object_get_double_member (object, "x"); @@ -522,9 +523,9 @@ parse_point_from_object (JsonObject *object, } gboolean -_clutter_script_parse_point (ClutterScript *script, - JsonNode *node, - ClutterPoint *point) +_clutter_script_parse_point (ClutterScript *script, + JsonNode *node, + graphene_point_t *point) { g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE); g_return_val_if_fail (node != NULL, FALSE); @@ -546,8 +547,8 @@ _clutter_script_parse_point (ClutterScript *script, } static gboolean -parse_size_from_array (JsonArray *array, - ClutterSize *size) +parse_size_from_array (JsonArray *array, + graphene_size_t *size) { if (json_array_get_length (array) != 2) return FALSE; @@ -559,8 +560,8 @@ parse_size_from_array (JsonArray *array, } static gboolean -parse_size_from_object (JsonObject *object, - ClutterSize *size) +parse_size_from_object (JsonObject *object, + graphene_size_t *size) { if (json_object_has_member (object, "width")) size->width = json_object_get_double_member (object, "width"); @@ -576,9 +577,9 @@ parse_size_from_object (JsonObject *object, } gboolean -_clutter_script_parse_size (ClutterScript *script, - JsonNode *node, - ClutterSize *size) +_clutter_script_parse_size (ClutterScript *script, + JsonNode *node, + graphene_size_t *size) { g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE); g_return_val_if_fail (node != NULL, FALSE); @@ -1328,11 +1329,11 @@ _clutter_script_parse_node (ClutterScript *script, return TRUE; } } - else if (p_type == CLUTTER_TYPE_GEOMETRY) + else if (p_type == GRAPHENE_TYPE_RECT) { - ClutterGeometry geom = { 0, }; + graphene_rect_t rect = GRAPHENE_RECT_INIT_ZERO; - /* geometry := { + /* rect := { * "x" : (int), * "y" : (int), * "width" : (int), @@ -1340,9 +1341,9 @@ _clutter_script_parse_node (ClutterScript *script, * } */ - if (_clutter_script_parse_geometry (script, node, &geom)) + if (_clutter_script_parse_rect (script, node, &rect)) { - g_value_set_boxed (value, &geom); + g_value_set_boxed (value, &rect); return TRUE; } } @@ -1364,9 +1365,9 @@ _clutter_script_parse_node (ClutterScript *script, return TRUE; } } - else if (p_type == CLUTTER_TYPE_POINT) + else if (p_type == GRAPHENE_TYPE_POINT) { - ClutterPoint point = CLUTTER_POINT_INIT_ZERO; + graphene_point_t point = GRAPHENE_POINT_INIT_ZERO; if (_clutter_script_parse_point (script, node, &point)) { @@ -1374,9 +1375,9 @@ _clutter_script_parse_node (ClutterScript *script, return TRUE; } } - else if (p_type == CLUTTER_TYPE_SIZE) + else if (p_type == GRAPHENE_TYPE_SIZE) { - ClutterSize size = CLUTTER_SIZE_INIT_ZERO; + graphene_size_t size = GRAPHENE_SIZE_INIT_ZERO; if (_clutter_script_parse_size (script, node, &size)) { @@ -1417,15 +1418,15 @@ _clutter_script_parse_node (ClutterScript *script, return TRUE; } } - else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_GEOMETRY)) + else if (G_VALUE_HOLDS (value, GRAPHENE_TYPE_RECT)) { - ClutterGeometry geom = { 0, }; + graphene_rect_t rect = GRAPHENE_RECT_INIT_ZERO; - /* geometry := [ (int), (int), (int), (int) ] */ + /* rect := [ (int), (int), (int), (int) ] */ - if (_clutter_script_parse_geometry (script, node, &geom)) + if (_clutter_script_parse_rect (script, node, &rect)) { - g_value_set_boxed (value, &geom); + g_value_set_boxed (value, &rect); return TRUE; } } @@ -1441,9 +1442,9 @@ _clutter_script_parse_node (ClutterScript *script, return TRUE; } } - else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_POINT)) + else if (G_VALUE_HOLDS (value, GRAPHENE_TYPE_POINT)) { - ClutterPoint point = CLUTTER_POINT_INIT_ZERO; + graphene_point_t point = GRAPHENE_POINT_INIT_ZERO; if (_clutter_script_parse_point (script, node, &point)) { @@ -1451,9 +1452,9 @@ _clutter_script_parse_node (ClutterScript *script, return TRUE; } } - else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_SIZE)) + else if (G_VALUE_HOLDS (value, GRAPHENE_TYPE_SIZE)) { - ClutterSize size = CLUTTER_SIZE_INIT_ZERO; + graphene_size_t size = GRAPHENE_SIZE_INIT_ZERO; if (_clutter_script_parse_size (script, node, &size)) { diff --git a/clutter/clutter/clutter-script-private.h b/clutter/clutter/clutter-script-private.h index 52a67bcdc6b14ce571fd70af5d1043232d1c8916..9c08d82d68869b0f81070177cb8ad7014fa354ca 100644 --- a/clutter/clutter/clutter-script-private.h +++ b/clutter/clutter/clutter-script-private.h @@ -122,20 +122,20 @@ gboolean _clutter_script_flags_from_string (GType gtype, gboolean _clutter_script_parse_knot (ClutterScript *script, JsonNode *node, ClutterKnot *knot); -gboolean _clutter_script_parse_geometry (ClutterScript *script, +gboolean _clutter_script_parse_rect (ClutterScript *script, JsonNode *node, - ClutterGeometry *geometry); + graphene_rect_t *rect); gboolean _clutter_script_parse_color (ClutterScript *script, JsonNode *node, ClutterColor *color); GObject *_clutter_script_parse_alpha (ClutterScript *script, JsonNode *node); -gboolean _clutter_script_parse_point (ClutterScript *script, - JsonNode *node, - ClutterPoint *point); +gboolean _clutter_script_parse_point (ClutterScript *script, + JsonNode *node, + graphene_point_t *point); gboolean _clutter_script_parse_size (ClutterScript *script, JsonNode *node, - ClutterSize *size); + graphene_size_t *size); gboolean _clutter_script_parse_translatable_string (ClutterScript *script, JsonNode *node, diff --git a/clutter/clutter/clutter-scroll-actor.c b/clutter/clutter/clutter-scroll-actor.c index a6cf6d54e11fcabaf1744287b7346c15a6aeb97f..969ba5370863d3ae7b7bf0268e24466a74eab2df 100644 --- a/clutter/clutter/clutter-scroll-actor.c +++ b/clutter/clutter/clutter-scroll-actor.c @@ -56,7 +56,7 @@ struct _ClutterScrollActorPrivate { - ClutterPoint scroll_to; + graphene_point_t scroll_to; ClutterScrollMode scroll_mode; @@ -94,19 +94,19 @@ G_DEFINE_TYPE_WITH_CODE (ClutterScrollActor, clutter_scroll_actor, CLUTTER_TYPE_ clutter_animatable_iface_init)) static void -clutter_scroll_actor_set_scroll_to_internal (ClutterScrollActor *self, - const ClutterPoint *point) +clutter_scroll_actor_set_scroll_to_internal (ClutterScrollActor *self, + const graphene_point_t *point) { ClutterScrollActorPrivate *priv = self->priv; ClutterActor *actor = CLUTTER_ACTOR (self); ClutterMatrix m = CLUTTER_MATRIX_INIT_IDENTITY; float dx, dy; - if (clutter_point_equals (&priv->scroll_to, point)) + if (graphene_point_equal (&priv->scroll_to, point)) return; if (point == NULL) - clutter_point_init (&priv->scroll_to, 0.f, 0.f); + graphene_point_init (&priv->scroll_to, 0.f, 0.f); else priv->scroll_to = *point; @@ -216,7 +216,7 @@ clutter_scroll_actor_set_final_state (ClutterAnimatable *animatable, if (strcmp (property_name, "scroll-to") == 0) { ClutterScrollActor *self = CLUTTER_SCROLL_ACTOR (animatable); - const ClutterPoint *point = g_value_get_boxed (value); + const graphene_point_t *point = g_value_get_boxed (value); clutter_scroll_actor_set_scroll_to_internal (self, point); } @@ -248,7 +248,7 @@ clutter_animatable_iface_init (ClutterAnimatableInterface *iface) g_param_spec_boxed ("scroll-to", "Scroll To", "The point to scroll the actor to", - CLUTTER_TYPE_POINT, + GRAPHENE_TYPE_POINT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | CLUTTER_PARAM_ANIMATABLE); @@ -322,7 +322,7 @@ clutter_scroll_actor_get_scroll_mode (ClutterScrollActor *actor) /** * clutter_scroll_actor_scroll_to_point: * @actor: a #ClutterScrollActor - * @point: a #ClutterPoint + * @point: a #graphene_point_t * * Scrolls the contents of @actor so that @point is the new origin * of the visible area. @@ -335,8 +335,8 @@ clutter_scroll_actor_get_scroll_mode (ClutterScrollActor *actor) * Since: 1.12 */ void -clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor, - const ClutterPoint *point) +clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor, + const graphene_point_t *point) { ClutterScrollActorPrivate *priv; const ClutterAnimationInfo *info; @@ -390,10 +390,10 @@ clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor, /* if a transition already exist, update its bounds */ clutter_transition_set_from (priv->transition, - CLUTTER_TYPE_POINT, + GRAPHENE_TYPE_POINT, &priv->scroll_to); clutter_transition_set_to (priv->transition, - CLUTTER_TYPE_POINT, + GRAPHENE_TYPE_POINT, point); /* always use the current easing state */ @@ -417,10 +417,10 @@ clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor, * Since: 1.12 */ void -clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor, - const ClutterRect *rect) +clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor, + const graphene_rect_t *rect) { - ClutterRect n_rect; + graphene_rect_t n_rect; g_return_if_fail (CLUTTER_IS_SCROLL_ACTOR (actor)); g_return_if_fail (rect != NULL); @@ -428,7 +428,7 @@ clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor, n_rect = *rect; /* normalize, so that we have a valid origin */ - clutter_rect_normalize (&n_rect); + graphene_rect_normalize (&n_rect); clutter_scroll_actor_scroll_to_point (actor, &n_rect.origin); } diff --git a/clutter/clutter/clutter-scroll-actor.h b/clutter/clutter/clutter-scroll-actor.h index f2eada11c7b90a9de659c8aa84ad9cd8f870087d..e6a17652130a9efbf316f03d156a4899a3cf3db8 100644 --- a/clutter/clutter/clutter-scroll-actor.h +++ b/clutter/clutter/clutter-scroll-actor.h @@ -86,11 +86,11 @@ CLUTTER_EXPORT ClutterScrollMode clutter_scroll_actor_get_scroll_mode (ClutterScrollActor *actor); CLUTTER_EXPORT -void clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor, - const ClutterPoint *point); +void clutter_scroll_actor_scroll_to_point (ClutterScrollActor *actor, + const graphene_point_t *point); CLUTTER_EXPORT -void clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor, - const ClutterRect *rect); +void clutter_scroll_actor_scroll_to_rect (ClutterScrollActor *actor, + const graphene_rect_t *rect); G_END_DECLS diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h index 12b55ad76930097bf524b2c4f0c43c9655e96a1c..f32835141656435d9f24e0d2d904fc1bb22c64a1 100644 --- a/clutter/clutter/clutter-stage-private.h +++ b/clutter/clutter/clutter-stage-private.h @@ -79,12 +79,12 @@ gint64 _clutter_stage_get_update_time (ClutterStage *stage); void _clutter_stage_clear_update_time (ClutterStage *stage); gboolean _clutter_stage_has_full_redraw_queued (ClutterStage *stage); -void clutter_stage_log_pick (ClutterStage *stage, - const ClutterPoint *vertices, - ClutterActor *actor); +void clutter_stage_log_pick (ClutterStage *stage, + const graphene_point_t *vertices, + ClutterActor *actor); -void clutter_stage_push_pick_clip (ClutterStage *stage, - const ClutterPoint *vertices); +void clutter_stage_push_pick_clip (ClutterStage *stage, + const graphene_point_t *vertices); void clutter_stage_pop_pick_clip (ClutterStage *stage); @@ -133,9 +133,9 @@ gboolean _clutter_stage_update_state (ClutterStage *stag void _clutter_stage_set_scale_factor (ClutterStage *stage, int factor); -gboolean _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage, - ClutterRect *rect, - float *view_scale); +gboolean _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage, + graphene_rect_t *rect, + float *view_scale); void _clutter_stage_presented (ClutterStage *stage, CoglFrameEvent frame_event, diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index fd2d3008c449529574bbc458e6efe6517ebff6ea..774ef592737904fea7bd8224bbb8a253af8a9720 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -107,7 +107,7 @@ struct _ClutterStageQueueRedrawEntry typedef struct _PickRecord { - ClutterPoint vertex[4]; + graphene_point_t vertex[4]; ClutterActor *actor; int clip_stack_top; } PickRecord; @@ -115,7 +115,7 @@ typedef struct _PickRecord typedef struct _PickClipRecord { int prev; - ClutterPoint vertex[4]; + graphene_point_t vertex[4]; } PickClipRecord; struct _ClutterStagePrivate @@ -129,8 +129,6 @@ struct _ClutterStagePrivate CoglMatrix view; float viewport[4]; - ClutterFog fog; - gchar *title; ClutterActor *key_focused_actor; @@ -173,7 +171,6 @@ struct _ClutterStagePrivate guint relayout_pending : 1; guint redraw_pending : 1; guint is_cursor_visible : 1; - guint use_fog : 1; guint throttle_motion_events : 1; guint use_alpha : 1; guint min_size_changed : 1; @@ -191,8 +188,6 @@ enum PROP_CURSOR_VISIBLE, PROP_PERSPECTIVE, PROP_TITLE, - PROP_USE_FOG, - PROP_FOG, PROP_USE_ALPHA, PROP_KEY_FOCUS, PROP_NO_CLEAR_HINT, @@ -381,9 +376,9 @@ _clutter_stage_clear_pick_stack (ClutterStage *stage) } void -clutter_stage_log_pick (ClutterStage *stage, - const ClutterPoint *vertices, - ClutterActor *actor) +clutter_stage_log_pick (ClutterStage *stage, + const graphene_point_t *vertices, + ClutterActor *actor) { ClutterStagePrivate *priv; PickRecord rec; @@ -395,7 +390,7 @@ clutter_stage_log_pick (ClutterStage *stage, g_assert (!priv->pick_stack_frozen); - memcpy (rec.vertex, vertices, 4 * sizeof (ClutterPoint)); + memcpy (rec.vertex, vertices, 4 * sizeof (graphene_point_t)); rec.actor = actor; rec.clip_stack_top = priv->pick_clip_stack_top; @@ -403,8 +398,8 @@ clutter_stage_log_pick (ClutterStage *stage, } void -clutter_stage_push_pick_clip (ClutterStage *stage, - const ClutterPoint *vertices) +clutter_stage_push_pick_clip (ClutterStage *stage, + const graphene_point_t *vertices) { ClutterStagePrivate *priv; PickClipRecord clip; @@ -416,7 +411,7 @@ clutter_stage_push_pick_clip (ClutterStage *stage, g_assert (!priv->pick_stack_frozen); clip.prev = priv->pick_clip_stack_top; - memcpy (clip.vertex, vertices, 4 * sizeof (ClutterPoint)); + memcpy (clip.vertex, vertices, 4 * sizeof (graphene_point_t)); g_array_append_val (priv->pick_clip_stack, clip); priv->pick_clip_stack_top = priv->pick_clip_stack->len - 1; @@ -449,7 +444,7 @@ clutter_stage_pop_pick_clip (ClutterStage *stage) } static gboolean -is_quadrilateral_axis_aligned_rectangle (const ClutterPoint *vertices) +is_quadrilateral_axis_aligned_rectangle (const graphene_point_t *vertices) { int i; @@ -467,8 +462,8 @@ is_quadrilateral_axis_aligned_rectangle (const ClutterPoint *vertices) } static gboolean -is_inside_axis_aligned_rectangle (const ClutterPoint *point, - const ClutterPoint *vertices) +is_inside_axis_aligned_rectangle (const graphene_point_t *point, + const graphene_point_t *vertices) { float min_x = FLT_MAX; float max_x = FLT_MIN; @@ -490,15 +485,70 @@ is_inside_axis_aligned_rectangle (const ClutterPoint *point, point->y < max_y); } +static int +clutter_point_compare_line (const graphene_point_t *p, + const graphene_point_t *a, + const graphene_point_t *b) +{ + graphene_vec3_t vec_pa; + graphene_vec3_t vec_pb; + graphene_vec3_t cross; + float cross_z; + + graphene_vec3_init (&vec_pa, p->x - a->x, p->y - a->y, 0.f); + graphene_vec3_init (&vec_pb, p->x - b->x, p->y - b->y, 0.f); + graphene_vec3_cross (&vec_pa, &vec_pb, &cross); + cross_z = graphene_vec3_get_z (&cross); + + if (cross_z > 0.f) + return 1; + else if (cross_z < 0.f) + return -1; + else + return 0; +} + +static gboolean +is_inside_unaligned_rectangle (const graphene_point_t *point, + const graphene_point_t *vertices) +{ + unsigned int i; + int first_side; + + first_side = 0; + + for (i = 0; i < 4; i++) + { + int side; + + side = clutter_point_compare_line (point, + &vertices[i], + &vertices[(i + 1) % 4]); + + if (side) + { + if (first_side == 0) + first_side = side; + else if (side != first_side) + return FALSE; + } + } + + if (first_side == 0) + return FALSE; + + return TRUE; +} + static gboolean -is_inside_input_region (const ClutterPoint *point, - const ClutterPoint *vertices) +is_inside_input_region (const graphene_point_t *point, + const graphene_point_t *vertices) { if (is_quadrilateral_axis_aligned_rectangle (vertices)) return is_inside_axis_aligned_rectangle (point, vertices); else - return clutter_point_inside_quadrilateral (point, vertices); + return is_inside_unaligned_rectangle (point, vertices); } static gboolean @@ -507,7 +557,7 @@ pick_record_contains_pixel (ClutterStage *stage, int x, int y) { - const ClutterPoint point = CLUTTER_POINT_INIT (x, y); + const graphene_point_t point = GRAPHENE_POINT_INIT (x, y); ClutterStagePrivate *priv; int clip_index; @@ -720,8 +770,9 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon, Vector4 *tmp_poly; ClutterPlane *plane; int i; - float b[3]; - float c[3]; + Vector4 *poly; + graphene_vec3_t b; + graphene_vec3_t c; int count; tmp_poly = g_alloca (sizeof (Vector4) * n_vertices * 2); @@ -788,23 +839,37 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon, for (i = 0; i < count; i++) { plane = &planes[i]; - memcpy (plane->v0, tmp_poly + i, sizeof (float) * 3); - memcpy (b, tmp_poly + n_vertices + i, sizeof (float) * 3); - memcpy (c, tmp_poly + n_vertices + i + 1, sizeof (float) * 3); - cogl_vector3_subtract (b, b, plane->v0); - cogl_vector3_subtract (c, c, plane->v0); - cogl_vector3_cross_product (plane->n, b, c); - cogl_vector3_normalize (plane->n); + + poly = &tmp_poly[i]; + graphene_vec3_init (&plane->v0, poly->x, poly->y, poly->z); + + poly = &tmp_poly[n_vertices + i]; + graphene_vec3_init (&b, poly->x, poly->y, poly->z); + + poly = &tmp_poly[n_vertices + i + 1]; + graphene_vec3_init (&c, poly->x, poly->y, poly->z); + + graphene_vec3_subtract (&b, &plane->v0, &b); + graphene_vec3_subtract (&c, &plane->v0, &c); + graphene_vec3_cross (&b, &c, &plane->n); + graphene_vec3_normalize (&plane->n, &plane->n); } plane = &planes[n_vertices - 1]; - memcpy (plane->v0, tmp_poly + 0, sizeof (float) * 3); - memcpy (b, tmp_poly + (2 * n_vertices - 1), sizeof (float) * 3); - memcpy (c, tmp_poly + n_vertices, sizeof (float) * 3); - cogl_vector3_subtract (b, b, plane->v0); - cogl_vector3_subtract (c, c, plane->v0); - cogl_vector3_cross_product (plane->n, b, c); - cogl_vector3_normalize (plane->n); + + poly = &tmp_poly[0]; + graphene_vec3_init (&plane->v0, poly->x, poly->y, poly->z); + + poly = &tmp_poly[2 * n_vertices - 1]; + graphene_vec3_init (&b, poly->x, poly->y, poly->z); + + poly = &tmp_poly[n_vertices]; + graphene_vec3_init (&c, poly->x, poly->y, poly->z); + + graphene_vec3_subtract (&b, &plane->v0, &b); + graphene_vec3_subtract (&c, &plane->v0, &c); + graphene_vec3_cross (&b, &c, &plane->n); + graphene_vec3_normalize (&plane->n, &plane->n); } static void @@ -1357,7 +1422,7 @@ _clutter_stage_check_updated_pointers (ClutterStage *stage) GSList *updating = NULL; const GSList *devices; cairo_rectangle_int_t clip; - ClutterPoint point; + graphene_point_t point; gboolean has_clip; has_clip = _clutter_stage_window_get_redraw_clip_bounds (priv->impl, &clip); @@ -1801,14 +1866,6 @@ clutter_stage_set_property (GObject *object, clutter_stage_set_title (stage, g_value_get_string (value)); break; - case PROP_USE_FOG: - clutter_stage_set_use_fog (stage, g_value_get_boolean (value)); - break; - - case PROP_FOG: - clutter_stage_set_fog (stage, g_value_get_boxed (value)); - break; - case PROP_USE_ALPHA: clutter_stage_set_use_alpha (stage, g_value_get_boolean (value)); break; @@ -1863,14 +1920,6 @@ clutter_stage_get_property (GObject *gobject, g_value_set_string (value, priv->title); break; - case PROP_USE_FOG: - g_value_set_boolean (value, priv->use_fog); - break; - - case PROP_FOG: - g_value_set_boxed (value, &priv->fog); - break; - case PROP_USE_ALPHA: g_value_set_boolean (value, priv->use_alpha); break; @@ -2056,41 +2105,6 @@ clutter_stage_class_init (ClutterStageClass *klass) NULL, CLUTTER_PARAM_READWRITE); - /** - * ClutterStage:use-fog: - * - * Whether the stage should use a linear GL "fog" in creating the - * depth-cueing effect, to enhance the perception of depth by fading - * actors farther from the viewpoint. - * - * Since: 0.6 - * - * Deprecated: 1.10: This property does not do anything. - */ - obj_props[PROP_USE_FOG] = - g_param_spec_boolean ("use-fog", - P_("Use Fog"), - P_("Whether to enable depth cueing"), - FALSE, - CLUTTER_PARAM_READWRITE | G_PARAM_DEPRECATED); - - /** - * ClutterStage:fog: - * - * The settings for the GL "fog", used only if #ClutterStage:use-fog - * is set to %TRUE - * - * Since: 1.0 - * - * Deprecated: 1.10: This property does not do anything. - */ - obj_props[PROP_FOG] = - g_param_spec_boxed ("fog", - P_("Fog"), - P_("Settings for the depth cueing"), - CLUTTER_TYPE_FOG, - CLUTTER_PARAM_READWRITE | G_PARAM_DEPRECATED); - /** * ClutterStage:use-alpha: * @@ -2328,7 +2342,6 @@ clutter_stage_init (ClutterStage *self) priv->event_queue = g_queue_new (); priv->is_cursor_visible = TRUE; - priv->use_fog = FALSE; priv->throttle_motion_events = TRUE; priv->min_size_changed = FALSE; priv->sync_delay = -1; @@ -2337,10 +2350,6 @@ clutter_stage_init (ClutterStage *self) clutter_actor_set_background_color (CLUTTER_ACTOR (self), &default_stage_color); - /* FIXME - remove for 2.0 */ - priv->fog.z_near = 1.0; - priv->fog.z_far = 2.0; - priv->relayout_pending = TRUE; clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); @@ -3078,136 +3087,6 @@ clutter_stage_get_key_focus (ClutterStage *stage) return CLUTTER_ACTOR (stage); } -/** - * clutter_stage_get_use_fog: - * @stage: the #ClutterStage - * - * Gets whether the depth cueing effect is enabled on @stage. - * - * Return value: %TRUE if the depth cueing effect is enabled - * - * Since: 0.6 - * - * Deprecated: 1.10: This function will always return %FALSE - */ -gboolean -clutter_stage_get_use_fog (ClutterStage *stage) -{ - g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE); - - return stage->priv->use_fog; -} - -/** - * clutter_stage_set_use_fog: - * @stage: the #ClutterStage - * @fog: %TRUE for enabling the depth cueing effect - * - * Sets whether the depth cueing effect on the stage should be enabled - * or not. - * - * Depth cueing is a 3D effect that makes actors farther away from the - * viewing point less opaque, by fading them with the stage color. - - * The parameters of the GL fog used can be changed using the - * clutter_stage_set_fog() function. - * - * Since: 0.6 - * - * Deprecated: 1.10: Calling this function produces no visible effect - */ -void -clutter_stage_set_use_fog (ClutterStage *stage, - gboolean fog) -{ -} - -/** - * clutter_stage_set_fog: - * @stage: the #ClutterStage - * @fog: a #ClutterFog structure - * - * Sets the fog (also known as "depth cueing") settings for the @stage. - * - * A #ClutterStage will only use a linear fog progression, which - * depends solely on the distance from the viewer. The cogl_set_fog() - * function in COGL exposes more of the underlying implementation, - * and allows changing the for progression function. It can be directly - * used by disabling the #ClutterStage:use-fog property and connecting - * a signal handler to the #ClutterActor::paint signal on the @stage, - * like: - * - * |[ - * clutter_stage_set_use_fog (stage, FALSE); - * g_signal_connect (stage, "paint", G_CALLBACK (on_stage_paint), NULL); - * ]| - * - * The paint signal handler will call cogl_set_fog() with the - * desired settings: - * - * |[ - * static void - * on_stage_paint (ClutterActor *actor) - * { - * ClutterColor stage_color = { 0, }; - * CoglColor fog_color = { 0, }; - * - * // set the fog color to the stage background color - * clutter_stage_get_color (CLUTTER_STAGE (actor), &stage_color); - * cogl_color_init_from_4ub (&fog_color, - * stage_color.red, - * stage_color.green, - * stage_color.blue, - * stage_color.alpha); - * - * // enable fog // - * cogl_set_fog (&fog_color, - * COGL_FOG_MODE_EXPONENTIAL, // mode - * 0.5, // density - * 5.0, 30.0); // z_near and z_far - * } - * ]| - * - * The fogging functions only work correctly when the visible actors use - * unmultiplied alpha colors. By default Cogl will premultiply textures and - * cogl_set_source_color() will premultiply colors, so unless you explicitly - * load your textures requesting an unmultiplied internal format and use - * cogl_material_set_color() you can only use fogging with fully opaque actors. - * Support for premultiplied colors will improve in the future when we can - * depend on fragment shaders. - * - * Since: 0.6 - * - * Deprecated: 1.10: Fog settings are ignored. - */ -void -clutter_stage_set_fog (ClutterStage *stage, - ClutterFog *fog) -{ -} - -/** - * clutter_stage_get_fog: - * @stage: the #ClutterStage - * @fog: (out): return location for a #ClutterFog structure - * - * Retrieves the current depth cueing settings from the stage. - * - * Since: 0.6 - * - * Deprecated: 1.10: This function will always return the default - * values of #ClutterFog - */ -void -clutter_stage_get_fog (ClutterStage *stage, - ClutterFog *fog) -{ - g_return_if_fail (CLUTTER_IS_STAGE (stage)); - g_return_if_fail (fog != NULL); - - *fog = stage->priv->fog; -} - /*** Perspective boxed type ******/ static gpointer @@ -3230,24 +3109,6 @@ G_DEFINE_BOXED_TYPE (ClutterPerspective, clutter_perspective, clutter_perspective_copy, clutter_perspective_free); -static gpointer -clutter_fog_copy (gpointer data) -{ - if (G_LIKELY (data)) - return g_slice_dup (ClutterFog, data); - - return NULL; -} - -static void -clutter_fog_free (gpointer data) -{ - if (G_LIKELY (data)) - g_slice_free (ClutterFog, data); -} - -G_DEFINE_BOXED_TYPE (ClutterFog, clutter_fog, clutter_fog_copy, clutter_fog_free); - /** * clutter_stage_new: * @@ -4651,7 +4512,7 @@ clutter_stage_get_capture_final_size (ClutterStage *stage, if (rect) { - ClutterRect capture_rect; + graphene_rect_t capture_rect; _clutter_util_rect_from_rectangle (rect, &capture_rect); if (!_clutter_stage_get_max_view_scale_factor_for_rect (stage, @@ -4858,9 +4719,9 @@ clutter_stage_update_resource_scales (ClutterStage *stage) } gboolean -_clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage, - ClutterRect *rect, - float *view_scale) +_clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage, + graphene_rect_t *rect, + float *view_scale) { ClutterStagePrivate *priv = stage->priv; float scale = 0.0f; @@ -4870,12 +4731,12 @@ _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage, { ClutterStageView *view = l->data; cairo_rectangle_int_t view_layout; - ClutterRect view_rect; + graphene_rect_t view_rect; clutter_stage_view_get_layout (view, &view_layout); _clutter_util_rect_from_rectangle (&view_layout, &view_rect); - if (clutter_rect_intersection (&view_rect, rect, NULL)) + if (graphene_rect_intersection (&view_rect, rect, NULL)) scale = MAX (clutter_stage_view_get_scale (view), scale); } diff --git a/clutter/clutter/clutter-stage.h b/clutter/clutter/clutter-stage.h index c28904bd0749f5337e03896896d59fa6f90ce548..9579f167643c78a321fe6c4e35d2dd24d30fdce7 100644 --- a/clutter/clutter/clutter-stage.h +++ b/clutter/clutter/clutter-stage.h @@ -115,26 +115,6 @@ struct _ClutterPerspective gfloat z_far; }; -/** - * ClutterFog: - * @z_near: starting distance from the viewer to the near clipping - * plane (always positive) - * @z_far: final distance from the viewer to the far clipping - * plane (always positive) - * - * Fog settings used to create the depth cueing effect. - * - * Since: 0.6 - * - * Deprecated: 1.10: The fog-related API in #ClutterStage has been - * deprecated as well. - */ -struct _ClutterFog -{ - gfloat z_near; - gfloat z_far; -}; - /** * ClutterFrameInfo: (skip) */ @@ -153,8 +133,6 @@ typedef struct _ClutterCapture CLUTTER_EXPORT GType clutter_perspective_get_type (void) G_GNUC_CONST; -CLUTTER_DEPRECATED -GType clutter_fog_get_type (void) G_GNUC_CONST; CLUTTER_EXPORT GType clutter_stage_get_type (void) G_GNUC_CONST; diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c index f8e5efa38d68645c4ed788ad517e881b72928cfb..aa1477bd102a4480f978751dc4912943d61c08e4 100644 --- a/clutter/clutter/clutter-text.c +++ b/clutter/clutter/clutter-text.c @@ -157,7 +157,7 @@ struct _ClutterTextPrivate gint text_logical_y; /* Where to draw the cursor */ - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; ClutterColor cursor_color; guint cursor_size; @@ -1304,7 +1304,7 @@ static inline void update_cursor_location (ClutterText *self) { ClutterTextPrivate *priv = self->priv; - ClutterRect rect; + graphene_rect_t rect; float x, y; if (!priv->editable) @@ -1312,7 +1312,7 @@ update_cursor_location (ClutterText *self) rect = priv->cursor_rect; clutter_actor_get_transformed_position (CLUTTER_ACTOR (self), &x, &y); - clutter_rect_offset (&rect, x, y); + graphene_rect_offset (&rect, x, y); clutter_input_focus_set_cursor_location (priv->input_focus, &rect); } @@ -1322,7 +1322,7 @@ clutter_text_ensure_cursor_position (ClutterText *self, { ClutterTextPrivate *priv = self->priv; gfloat x, y, cursor_height; - ClutterRect cursor_rect = CLUTTER_RECT_INIT_ZERO; + graphene_rect_t cursor_rect = GRAPHENE_RECT_INIT_ZERO; gint position; position = priv->position; @@ -1345,25 +1345,17 @@ clutter_text_ensure_cursor_position (ClutterText *self, &x, &y, &cursor_height); - clutter_rect_init (&cursor_rect, - x, - y + CURSOR_Y_PADDING * scale, - priv->cursor_size * scale, - cursor_height - 2 * CURSOR_Y_PADDING * scale); + graphene_rect_init (&cursor_rect, + x, + y + CURSOR_Y_PADDING * scale, + priv->cursor_size * scale, + cursor_height - 2 * CURSOR_Y_PADDING * scale); - if (!clutter_rect_equals (&priv->cursor_rect, &cursor_rect)) + if (!graphene_rect_equal (&priv->cursor_rect, &cursor_rect)) { - ClutterGeometry cursor_pos; - priv->cursor_rect = cursor_rect; - /* XXX:2.0 - remove */ - cursor_pos.x = clutter_rect_get_x (&priv->cursor_rect); - cursor_pos.y = clutter_rect_get_y (&priv->cursor_rect); - cursor_pos.width = clutter_rect_get_width (&priv->cursor_rect); - cursor_pos.height = clutter_rect_get_height (&priv->cursor_rect); - g_signal_emit (self, text_signals[CURSOR_EVENT], 0, &cursor_pos); - + g_signal_emit (self, text_signals[CURSOR_EVENT], 0, &cursor_rect); g_signal_emit (self, text_signals[CURSOR_CHANGED], 0); update_cursor_location (self); @@ -2712,7 +2704,7 @@ clutter_text_paint (ClutterActor *self) if (actor_width < text_width) { - gint cursor_x = clutter_rect_get_x (&priv->cursor_rect); + gint cursor_x = graphene_rect_get_x (&priv->cursor_rect); if (priv->position == -1) { @@ -2799,7 +2791,7 @@ add_selection_to_paint_volume (ClutterText *text, { ClutterPaintVolume *total_volume = user_data; ClutterPaintVolume rect_volume; - ClutterVertex vertex; + graphene_point3d_t vertex; _clutter_paint_volume_init_static (&rect_volume, CLUTTER_ACTOR (text)); @@ -2821,7 +2813,7 @@ clutter_text_get_paint_volume_for_cursor (ClutterText *text, ClutterPaintVolume *volume) { ClutterTextPrivate *priv = text->priv; - ClutterVertex origin; + graphene_point3d_t origin; clutter_text_ensure_cursor_position (text, resource_scale); @@ -2864,7 +2856,7 @@ clutter_text_get_paint_volume (ClutterActor *self, { PangoLayout *layout; PangoRectangle ink_rect; - ClutterVertex origin; + graphene_point3d_t origin; float resource_scale; /* If the text is single line editable then it gets clipped to @@ -4399,10 +4391,10 @@ clutter_text_class_init (ClutterTextClass *klass) /** * ClutterText::cursor-event: * @self: the #ClutterText that emitted the signal - * @geometry: the coordinates of the cursor + * @rect: the coordinates of the cursor * * The ::cursor-event signal is emitted whenever the cursor position - * changes inside a #ClutterText actor. Inside @geometry it is stored + * changes inside a #ClutterText actor. Inside @rect it is stored * the current position and size of the cursor, relative to the actor * itself. * @@ -4417,7 +4409,7 @@ clutter_text_class_init (ClutterTextClass *klass) G_STRUCT_OFFSET (ClutterTextClass, cursor_event), NULL, NULL, NULL, G_TYPE_NONE, 1, - CLUTTER_TYPE_GEOMETRY | G_SIGNAL_TYPE_STATIC_SCOPE); + GRAPHENE_TYPE_RECT | G_SIGNAL_TYPE_STATIC_SCOPE); /** * ClutterText::cursor-changed: @@ -6780,8 +6772,8 @@ clutter_text_get_layout_offsets (ClutterText *self, * Since: 1.16 */ void -clutter_text_get_cursor_rect (ClutterText *self, - ClutterRect *rect) +clutter_text_get_cursor_rect (ClutterText *self, + graphene_rect_t *rect) { g_return_if_fail (CLUTTER_IS_TEXT (self)); g_return_if_fail (rect != NULL); diff --git a/clutter/clutter/clutter-text.h b/clutter/clutter/clutter-text.h index aa65ba2e6b1e4a417e4f876d8ab8d9f266e1a839..7fa8116da9ffa94c23de48bda0ce37df0a42df7e 100644 --- a/clutter/clutter/clutter-text.h +++ b/clutter/clutter/clutter-text.h @@ -82,7 +82,7 @@ struct _ClutterTextClass void (* text_changed) (ClutterText *self); void (* activate) (ClutterText *self); void (* cursor_event) (ClutterText *self, - const ClutterGeometry *geometry); + const graphene_rect_t *rect); void (* cursor_changed) (ClutterText *self); /*< private >*/ @@ -230,7 +230,7 @@ CLUTTER_EXPORT guint clutter_text_get_cursor_size (ClutterText *self); CLUTTER_EXPORT void clutter_text_get_cursor_rect (ClutterText *self, - ClutterRect *rect); + graphene_rect_t *rect); CLUTTER_EXPORT void clutter_text_set_selectable (ClutterText *self, gboolean selectable); diff --git a/clutter/clutter/clutter-timeline.c b/clutter/clutter/clutter-timeline.c index 88b76be4b546c8d7ad4d50b8d1ccd54a2d832169..cddbf39b5563a78f2189bc1d6a232bdf00454be0 100644 --- a/clutter/clutter/clutter-timeline.c +++ b/clutter/clutter/clutter-timeline.c @@ -145,8 +145,8 @@ struct _ClutterTimelinePrivate ClutterStepMode step_mode; /* cubic-bezier() parameters */ - ClutterPoint cb_1; - ClutterPoint cb_2; + graphene_point_t cb_1; + graphene_point_t cb_2; guint is_playing : 1; @@ -846,8 +846,8 @@ clutter_timeline_init (ClutterTimeline *self) self->priv->step_mode = CLUTTER_STEP_MODE_END; /* default cubic-bezier() paramereters are (0, 0, 1, 1) */ - clutter_point_init (&self->priv->cb_1, 0, 0); - clutter_point_init (&self->priv->cb_2, 1, 1); + graphene_point_init (&self->priv->cb_1, 0, 0); + graphene_point_init (&self->priv->cb_2, 1, 1); } struct CheckIfMarkerHitClosure @@ -2485,9 +2485,9 @@ clutter_timeline_get_step_progress (ClutterTimeline *timeline, * Since: 1.12 */ void -clutter_timeline_set_cubic_bezier_progress (ClutterTimeline *timeline, - const ClutterPoint *c_1, - const ClutterPoint *c_2) +clutter_timeline_set_cubic_bezier_progress (ClutterTimeline *timeline, + const graphene_point_t *c_1, + const graphene_point_t *c_2) { ClutterTimelinePrivate *priv; @@ -2522,9 +2522,9 @@ clutter_timeline_set_cubic_bezier_progress (ClutterTimeline *timeline, * Since: 1.12 */ gboolean -clutter_timeline_get_cubic_bezier_progress (ClutterTimeline *timeline, - ClutterPoint *c_1, - ClutterPoint *c_2) +clutter_timeline_get_cubic_bezier_progress (ClutterTimeline *timeline, + graphene_point_t *c_1, + graphene_point_t *c_2) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); diff --git a/clutter/clutter/clutter-timeline.h b/clutter/clutter/clutter-timeline.h index 036f555f091b00a2381be0f70ff9968c86450a3f..656a4c5033f556cd4e8c4382c2f6b1bbb3473cce 100644 --- a/clutter/clutter/clutter-timeline.h +++ b/clutter/clutter/clutter-timeline.h @@ -208,13 +208,13 @@ gboolean clutter_timeline_get_step_progress gint *n_steps, ClutterStepMode *step_mode); CLUTTER_EXPORT -void clutter_timeline_set_cubic_bezier_progress (ClutterTimeline *timeline, - const ClutterPoint *c_1, - const ClutterPoint *c_2); +void clutter_timeline_set_cubic_bezier_progress (ClutterTimeline *timeline, + const graphene_point_t *c_1, + const graphene_point_t *c_2); CLUTTER_EXPORT -gboolean clutter_timeline_get_cubic_bezier_progress (ClutterTimeline *timeline, - ClutterPoint *c_1, - ClutterPoint *c_2); +gboolean clutter_timeline_get_cubic_bezier_progress (ClutterTimeline *timeline, + graphene_point_t *c_1, + graphene_point_t *c_2); CLUTTER_EXPORT gint64 clutter_timeline_get_duration_hint (ClutterTimeline *timeline); diff --git a/clutter/clutter/clutter-types.h b/clutter/clutter/clutter-types.h index 0508028273588119b9aee78859c8cf39867cf996..d047b05d1f5dfb0d95dc2634fa5c9c91741eae88 100644 --- a/clutter/clutter/clutter-types.h +++ b/clutter/clutter/clutter-types.h @@ -33,20 +33,16 @@ #include #include +#include + G_BEGIN_DECLS #define CLUTTER_TYPE_ACTOR_BOX (clutter_actor_box_get_type ()) -#define CLUTTER_TYPE_FOG (clutter_fog_get_type ()) -#define CLUTTER_TYPE_GEOMETRY (clutter_geometry_get_type ()) #define CLUTTER_TYPE_KNOT (clutter_knot_get_type ()) #define CLUTTER_TYPE_MARGIN (clutter_margin_get_type ()) #define CLUTTER_TYPE_MATRIX (clutter_matrix_get_type ()) #define CLUTTER_TYPE_PAINT_VOLUME (clutter_paint_volume_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_SIZE (clutter_size_get_type ()) -#define CLUTTER_TYPE_RECT (clutter_rect_get_type ()) typedef struct _ClutterActor ClutterActor; @@ -79,14 +75,9 @@ typedef struct _ClutterPathNode ClutterPathNode; typedef struct _ClutterActorBox ClutterActorBox; typedef struct _ClutterColor ClutterColor; -typedef struct _ClutterGeometry ClutterGeometry; /* XXX:2.0 - remove */ typedef struct _ClutterKnot ClutterKnot; typedef struct _ClutterMargin ClutterMargin; typedef struct _ClutterPerspective ClutterPerspective; -typedef struct _ClutterPoint ClutterPoint; -typedef struct _ClutterRect ClutterRect; -typedef struct _ClutterSize ClutterSize; -typedef struct _ClutterVertex ClutterVertex; typedef struct _ClutterAlpha ClutterAlpha; typedef struct _ClutterAnimation ClutterAnimation; @@ -113,7 +104,6 @@ typedef union _ClutterEvent ClutterEvent; */ typedef struct _ClutterEventSequence ClutterEventSequence; -typedef struct _ClutterFog ClutterFog; /* deprecated */ typedef struct _ClutterBehaviour ClutterBehaviour; /* deprecated */ typedef struct _ClutterShader ClutterShader; /* deprecated */ @@ -137,310 +127,6 @@ typedef struct _ClutterShader ClutterShader; /* deprecated */ */ typedef struct _ClutterPaintVolume ClutterPaintVolume; -/** - * ClutterPoint: - * @x: X coordinate, in pixels - * @y: Y coordinate, in pixels - * - * A point in 2D space. - * - * Since: 1.12 - */ -struct _ClutterPoint -{ - float x; - float y; -}; - -/** - * CLUTTER_POINT_INIT: - * @x: X coordinate - * @y: Y coordinate - * - * A simple macro for initializing a #ClutterPoint when declaring it, e.g.: - * - * |[ - * ClutterPoint p = CLUTTER_POINT_INIT (100, 100); - * ]| - * - * Since: 1.12 - */ -#define CLUTTER_POINT_INIT(x,y) { (x), (y) } - -/** - * CLUTTER_POINT_INIT_ZERO: - * - * A simple macro for initializing a #ClutterPoint to (0, 0) when - * declaring it. - * - * Since: 1.12 - */ -#define CLUTTER_POINT_INIT_ZERO CLUTTER_POINT_INIT (0.f, 0.f) - -CLUTTER_EXPORT -GType clutter_point_get_type (void) G_GNUC_CONST; - -CLUTTER_EXPORT -const ClutterPoint * clutter_point_zero (void); -CLUTTER_EXPORT -ClutterPoint * clutter_point_alloc (void); -CLUTTER_EXPORT -ClutterPoint * clutter_point_init (ClutterPoint *point, - float x, - float y); -CLUTTER_EXPORT -ClutterPoint * clutter_point_copy (const ClutterPoint *point); -CLUTTER_EXPORT -void clutter_point_free (ClutterPoint *point); -CLUTTER_EXPORT -gboolean clutter_point_equals (const ClutterPoint *a, - const ClutterPoint *b); -CLUTTER_EXPORT -float clutter_point_distance (const ClutterPoint *a, - const ClutterPoint *b, - float *x_distance, - float *y_distance); -CLUTTER_EXPORT -gboolean clutter_point_inside_quadrilateral (const ClutterPoint *point, - const ClutterPoint *vertices); - -/** - * ClutterSize: - * @width: the width, in pixels - * @height: the height, in pixels - * - * A size, in 2D space. - * - * Since: 1.12 - */ -struct _ClutterSize -{ - float width; - float height; -}; - -/** - * CLUTTER_SIZE_INIT: - * @width: the width - * @height: the height - * - * A simple macro for initializing a #ClutterSize when declaring it, e.g.: - * - * |[ - * ClutterSize s = CLUTTER_SIZE_INIT (200, 200); - * ]| - * - * Since: 1.12 - */ -#define CLUTTER_SIZE_INIT(width,height) { (width), (height) } - -/** - * CLUTTER_SIZE_INIT_ZERO: - * - * A simple macro for initializing a #ClutterSize to (0, 0) when - * declaring it. - * - * Since: 1.12 - */ -#define CLUTTER_SIZE_INIT_ZERO CLUTTER_SIZE_INIT (0.f, 0.f) - -CLUTTER_EXPORT -GType clutter_size_get_type (void) G_GNUC_CONST; - -CLUTTER_EXPORT -ClutterSize * clutter_size_alloc (void); -CLUTTER_EXPORT -ClutterSize * clutter_size_init (ClutterSize *size, - float width, - float height); -CLUTTER_EXPORT -ClutterSize * clutter_size_copy (const ClutterSize *size); -CLUTTER_EXPORT -void clutter_size_free (ClutterSize *size); -CLUTTER_EXPORT -gboolean clutter_size_equals (const ClutterSize *a, - const ClutterSize *b); - -/** - * ClutterRect: - * @origin: the origin of the rectangle - * @size: the size of the rectangle - * - * The location and size of a rectangle. - * - * The width and height of a #ClutterRect can be negative; Clutter considers - * a rectangle with an origin of [ 0.0, 0.0 ] and a size of [ 10.0, 10.0 ] to - * be equivalent to a rectangle with origin of [ 10.0, 10.0 ] and size of - * [ -10.0, -10.0 ]. - * - * Application code can normalize rectangles using clutter_rect_normalize(): - * this function will ensure that the width and height of a #ClutterRect are - * positive values. All functions taking a #ClutterRect as an argument will - * implicitly normalize it before computing eventual results. For this reason - * it is safer to access the contents of a #ClutterRect by using the provided - * API at all times, instead of directly accessing the structure members. - * - * Since: 1.12 - */ -struct _ClutterRect -{ - ClutterPoint origin; - ClutterSize size; -}; - -/** - * CLUTTER_RECT_INIT: - * @x: the X coordinate - * @y: the Y coordinate - * @width: the width - * @height: the height - * - * A simple macro for initializing a #ClutterRect when declaring it, e.g.: - * - * |[ - * ClutterRect r = CLUTTER_RECT_INIT (100, 100, 200, 200); - * ]| - * - * Since: 1.12 - */ -#define CLUTTER_RECT_INIT(x,y,width,height) { { (x), (y) }, { (width), (height) } } - -/** - * CLUTTER_RECT_INIT_ZERO: - * - * A simple macro for initializing a #ClutterRect to (0, 0, 0, 0) when - * declaring it. - * - * Since: 1.12 - */ -#define CLUTTER_RECT_INIT_ZERO CLUTTER_RECT_INIT (0.f, 0.f, 0.f, 0.f) - -CLUTTER_EXPORT -GType clutter_rect_get_type (void) G_GNUC_CONST; - -CLUTTER_EXPORT -const ClutterRect * clutter_rect_zero (void); -CLUTTER_EXPORT -ClutterRect * clutter_rect_alloc (void); -CLUTTER_EXPORT -ClutterRect * clutter_rect_init (ClutterRect *rect, - float x, - float y, - float width, - float height); -CLUTTER_EXPORT -ClutterRect * clutter_rect_copy (const ClutterRect *rect); -CLUTTER_EXPORT -void clutter_rect_free (ClutterRect *rect); -CLUTTER_EXPORT -gboolean clutter_rect_equals (ClutterRect *a, - ClutterRect *b); - -CLUTTER_EXPORT -ClutterRect * clutter_rect_normalize (ClutterRect *rect); -CLUTTER_EXPORT -void clutter_rect_get_center (ClutterRect *rect, - ClutterPoint *center); -CLUTTER_EXPORT -gboolean clutter_rect_contains_point (ClutterRect *rect, - ClutterPoint *point); -CLUTTER_EXPORT -gboolean clutter_rect_contains_rect (ClutterRect *a, - ClutterRect *b); -CLUTTER_EXPORT -void clutter_rect_union (ClutterRect *a, - ClutterRect *b, - ClutterRect *res); -CLUTTER_EXPORT -gboolean clutter_rect_intersection (ClutterRect *a, - ClutterRect *b, - ClutterRect *res); -CLUTTER_EXPORT -void clutter_rect_offset (ClutterRect *rect, - float d_x, - float d_y); -CLUTTER_EXPORT -void clutter_rect_inset (ClutterRect *rect, - float d_x, - float d_y); -CLUTTER_EXPORT -void clutter_rect_scale (ClutterRect *rect, - float s_x, - float s_y); -CLUTTER_EXPORT -void clutter_rect_clamp_to_pixel (ClutterRect *rect); -CLUTTER_EXPORT -float clutter_rect_get_x (ClutterRect *rect); -CLUTTER_EXPORT -float clutter_rect_get_y (ClutterRect *rect); -CLUTTER_EXPORT -float clutter_rect_get_width (ClutterRect *rect); -CLUTTER_EXPORT -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: * @x1: X coordinate of the top left corner @@ -544,8 +230,8 @@ gboolean clutter_actor_box_contains (const ClutterActorBox *box, gfloat x, gfloat y); CLUTTER_EXPORT -void clutter_actor_box_from_vertices (ClutterActorBox *box, - const ClutterVertex verts[]); +void clutter_actor_box_from_vertices (ClutterActorBox *box, + const graphene_point3d_t verts[]); CLUTTER_EXPORT void clutter_actor_box_interpolate (const ClutterActorBox *initial, const ClutterActorBox *final, @@ -571,41 +257,6 @@ CLUTTER_EXPORT void clutter_actor_box_scale (ClutterActorBox *box, gfloat scale); -/** - * ClutterGeometry: - * @x: X coordinate of the top left corner of an actor - * @y: Y coordinate of the top left corner of an actor - * @width: width of an actor - * @height: height of an actor - * - * The rectangle containing an actor's bounding box, measured in pixels. - * - * You should not use #ClutterGeometry, or operate on its fields - * directly; you should use #cairo_rectangle_int_t or #ClutterRect if you - * need a rectangle type, depending on the precision required. - * - * Deprecated: 1.16 - */ -struct _ClutterGeometry -{ - /*< public >*/ - gint x; - gint y; - guint width; - guint height; -}; - -CLUTTER_EXPORT -GType clutter_geometry_get_type (void) G_GNUC_CONST; - -CLUTTER_DEPRECATED -void clutter_geometry_union (const ClutterGeometry *geometry_a, - const ClutterGeometry *geometry_b, - ClutterGeometry *result); -CLUTTER_DEPRECATED -gboolean clutter_geometry_intersects (const ClutterGeometry *geometry0, - const ClutterGeometry *geometry1); - /** * ClutterKnot: * @x: X coordinate of the knot @@ -677,10 +328,10 @@ void clutter_paint_volume_free (ClutterPaintVolume CLUTTER_EXPORT void clutter_paint_volume_set_origin (ClutterPaintVolume *pv, - const ClutterVertex *origin); + const graphene_point3d_t *origin); CLUTTER_EXPORT void clutter_paint_volume_get_origin (const ClutterPaintVolume *pv, - ClutterVertex *vertex); + graphene_point3d_t *vertex); CLUTTER_EXPORT void clutter_paint_volume_set_width (ClutterPaintVolume *pv, gfloat width); diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c index 917da76be468028e38fc336dc9ea83c9f2dba2fb..88585124047e646c04ef3e508bfa52a384ea3071 100644 --- a/clutter/clutter/clutter-util.c +++ b/clutter/clutter/clutter-util.c @@ -51,8 +51,8 @@ void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, const CoglMatrix *projection, const float *viewport, - const ClutterVertex *vertices_in, - ClutterVertex *vertices_out, + const graphene_point3d_t *vertices_in, + graphene_point3d_t *vertices_out, int n_vertices) { CoglMatrix modelview_projection; @@ -69,7 +69,7 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, modelview); cogl_matrix_project_points (&modelview_projection, 3, - sizeof (ClutterVertex), + sizeof (graphene_point3d_t), vertices_in, sizeof (ClutterVertex4), vertices_tmp, @@ -79,7 +79,7 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, { cogl_matrix_transform_points (modelview, 3, - sizeof (ClutterVertex), + sizeof (graphene_point3d_t), vertices_in, sizeof (ClutterVertex4), vertices_tmp, @@ -97,7 +97,7 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, for (i = 0; i < n_vertices; 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 */ vertex_out->x = MTX_GL_SCALE_X (vertex_tmp.x, vertex_tmp.w, viewport[2], viewport[0]); @@ -108,9 +108,9 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src, - ClutterRect *dest) + graphene_rect_t *dest) { - *dest = (ClutterRect) { + *dest = (graphene_rect_t) { .origin = { .x = src->x, .y = src->y @@ -123,12 +123,12 @@ _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src, } void -_clutter_util_rectangle_int_extents (const ClutterRect *src, +_clutter_util_rectangle_int_extents (const graphene_rect_t *src, cairo_rectangle_int_t *dest) { - ClutterRect tmp = *src; + graphene_rect_t tmp = *src; - clutter_rect_clamp_to_pixel (&tmp); + graphene_rect_round_extents (&tmp, &tmp); *dest = (cairo_rectangle_int_t) { .x = tmp.origin.x, @@ -299,48 +299,12 @@ _clutter_util_matrix_skew_yz (ClutterMatrix *matrix, 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 -_clutter_util_vertex_normalize (ClutterVertex *vertex) -{ - 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 bscl, - ClutterVertex *res) +_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); @@ -388,16 +352,16 @@ _clutter_util_vertex4_interpolate (const ClutterVertex4 *a, */ gboolean _clutter_util_matrix_decompose (const ClutterMatrix *src, - ClutterVertex *scale_p, + graphene_point3d_t *scale_p, float shear_p[3], - ClutterVertex *rotate_p, - ClutterVertex *translate_p, + graphene_point3d_t *rotate_p, + graphene_point3d_t *translate_p, ClutterVertex4 *perspective_p) { CoglMatrix matrix = *src; CoglMatrix perspective; ClutterVertex4 vertex_tmp; - ClutterVertex row[3], pdum; + graphene_point3d_t row[3], pdum; int i, j; #define XY_SHEAR 0 @@ -485,34 +449,34 @@ _clutter_util_matrix_decompose (const ClutterMatrix *src, } /* compute scale.x and normalize the first row */ - scale_p->x = _clutter_util_vertex_length (&row[0]); - _clutter_util_vertex_normalize (&row[0]); + 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] = _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], 1.0, -shear_p[XY_SHEAR], &row[1]); /* compute the Y scale and normalize the second row */ - scale_p->y = _clutter_util_vertex_length (&row[1]); - _clutter_util_vertex_normalize (&row[1]); + 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] = _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], 1.0, -shear_p[XZ_SHEAR], &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], 1.0, -shear_p[YZ_SHEAR], &row[2]); /* get the Z scale and normalize the third row*/ - scale_p->z = _clutter_util_vertex_length (&row[2]); - _clutter_util_vertex_normalize (&row[2]); + 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; @@ -520,8 +484,8 @@ _clutter_util_matrix_decompose (const ClutterMatrix *src, * check for a coordinate system flip; if the determinant * is -1, then negate the matrix and scaling factors */ - _clutter_util_vertex_cross (&row[1], &row[2], &pdum); - if (_clutter_util_vertex_dot (&row[0], &pdum) < 0.f) + graphene_point3d_cross (&row[1], &row[2], &pdum); + if (graphene_point3d_dot (&row[0], &pdum) < 0.f) { scale_p->x *= -1.f; diff --git a/clutter/clutter/clutter-zoom-action.c b/clutter/clutter/clutter-zoom-action.c index 6cd35fbc1fe7c2ec61b24be3404e126b7cf4c401..c25b7968892a130e717609d7a0af715af2f4643c 100644 --- a/clutter/clutter/clutter-zoom-action.c +++ b/clutter/clutter/clutter-zoom-action.c @@ -80,9 +80,9 @@ struct _ClutterZoomActionPrivate ZoomPoint points[2]; - ClutterPoint initial_focal_point; - ClutterPoint focal_point; - ClutterPoint transformed_focal_point; + graphene_point_t initial_focal_point; + graphene_point_t focal_point; + graphene_point_t transformed_focal_point; gfloat initial_x; gfloat initial_y; @@ -238,13 +238,13 @@ clutter_zoom_action_gesture_cancel (ClutterGestureAction *action, static gboolean clutter_zoom_action_real_zoom (ClutterZoomAction *action, ClutterActor *actor, - ClutterPoint *focal_point, + graphene_point_t *focal_point, gdouble factor) { ClutterZoomActionPrivate *priv = action->priv; gfloat x, y, z; gdouble scale_x, scale_y; - ClutterVertex out, in; + graphene_point3d_t out, in; in.x = priv->transformed_focal_point.x; in.y = priv->transformed_focal_point.y; @@ -400,7 +400,7 @@ clutter_zoom_action_class_init (ClutterZoomActionClass *klass) _clutter_marshal_BOOLEAN__OBJECT_BOXED_DOUBLE, G_TYPE_BOOLEAN, 3, CLUTTER_TYPE_ACTOR, - CLUTTER_TYPE_POINT, + GRAPHENE_TYPE_POINT, G_TYPE_DOUBLE); } @@ -478,7 +478,7 @@ clutter_zoom_action_get_zoom_axis (ClutterZoomAction *action) /** * clutter_zoom_action_get_focal_point: * @action: a #ClutterZoomAction - * @point: (out): a #ClutterPoint + * @point: (out): a #graphene_point_t * * Retrieves the focal point of the current zoom * @@ -486,7 +486,7 @@ clutter_zoom_action_get_zoom_axis (ClutterZoomAction *action) */ void clutter_zoom_action_get_focal_point (ClutterZoomAction *action, - ClutterPoint *point) + graphene_point_t *point) { g_return_if_fail (CLUTTER_IS_ZOOM_ACTION (action)); g_return_if_fail (point != NULL); @@ -497,7 +497,7 @@ clutter_zoom_action_get_focal_point (ClutterZoomAction *action, /** * clutter_zoom_action_get_transformed_focal_point: * @action: a #ClutterZoomAction - * @point: (out): a #ClutterPoint + * @point: (out): a #graphene_point_t * * Retrieves the focal point relative to the actor's coordinates of * the current zoom @@ -506,7 +506,7 @@ clutter_zoom_action_get_focal_point (ClutterZoomAction *action, */ void clutter_zoom_action_get_transformed_focal_point (ClutterZoomAction *action, - ClutterPoint *point) + graphene_point_t *point) { g_return_if_fail (CLUTTER_IS_ZOOM_ACTION (action)); g_return_if_fail (point != NULL); diff --git a/clutter/clutter/clutter-zoom-action.h b/clutter/clutter/clutter-zoom-action.h index 2a4601684b72e1ce7d6fcd6e9667a7661fe78063..f1f7e572d921e0fca799db8fe41e0cb91334379a 100644 --- a/clutter/clutter/clutter-zoom-action.h +++ b/clutter/clutter/clutter-zoom-action.h @@ -79,7 +79,7 @@ struct _ClutterZoomActionClass /*< public >*/ gboolean (* zoom) (ClutterZoomAction *action, ClutterActor *actor, - ClutterPoint *focal_point, + graphene_point_t *focal_point, gdouble factor); /*< private >*/ @@ -104,10 +104,10 @@ ClutterZoomAxis clutter_zoom_action_get_zoom_axis (ClutterZoomActi CLUTTER_EXPORT void clutter_zoom_action_get_focal_point (ClutterZoomAction *action, - ClutterPoint *point); + graphene_point_t *point); CLUTTER_EXPORT void clutter_zoom_action_get_transformed_focal_point (ClutterZoomAction *action, - ClutterPoint *point); + graphene_point_t *point); G_END_DECLS diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 4810e42a4b8bb5896970ddc804b299bec5f1d709..34890452797418a668da64a07f53b75e9776a893 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -625,14 +625,14 @@ is_buffer_age_enabled (void) } static void -scale_and_clamp_rect (const ClutterRect *rect, +scale_and_clamp_rect (const graphene_rect_t *rect, float scale, cairo_rectangle_int_t *dest) { - ClutterRect tmp = *rect; + graphene_rect_t tmp = *rect; - clutter_rect_scale (&tmp, scale, scale); + graphene_rect_scale (&tmp, scale, scale, &tmp); _clutter_util_rectangle_int_extents (&tmp, dest); } @@ -699,12 +699,12 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, * frames when starting up... */ cogl_onscreen_get_frame_counter (COGL_ONSCREEN (fb)) > 3) { - ClutterRect rect; + graphene_rect_t rect; may_use_clipped_redraw = TRUE; _clutter_util_rect_from_rectangle (&redraw_clip, &rect); - clutter_rect_offset (&rect, -view_rect.x, -view_rect.y); + graphene_rect_offset (&rect, -view_rect.x, -view_rect.y); scale_and_clamp_rect (&rect, fb_scale, &fb_clip_region); if (fb_scale != floorf (fb_scale)) @@ -742,7 +742,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, if (valid_buffer_age (view_cogl, age)) { - ClutterRect rect; + graphene_rect_t rect; cairo_rectangle_int_t damage_region; *current_fb_damage = fb_clip_region; @@ -802,7 +802,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, } else if (use_clipped_redraw) { - ClutterRect rect; + graphene_rect_t rect; cairo_rectangle_int_t scissor_rect; cairo_rectangle_int_t paint_rect; @@ -848,7 +848,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, may_use_clipped_redraw && !clip_region_empty) { - ClutterRect rect; + graphene_rect_t rect; cairo_rectangle_int_t scissor_rect; cairo_rectangle_int_t paint_rect; diff --git a/clutter/clutter/deprecated/clutter-actor-deprecated.c b/clutter/clutter/deprecated/clutter-actor-deprecated.c deleted file mode 100644 index b13584812a389a383aac97d0658a0371f2d2522d..0000000000000000000000000000000000000000 --- a/clutter/clutter/deprecated/clutter-actor-deprecated.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "clutter-build-config.h" - -#include - -#define CLUTTER_DISABLE_DEPRECATION_WARNINGS -#include "deprecated/clutter-actor.h" - -#include "clutter-actor-private.h" -#include "clutter-private.h" - -/** - * clutter_actor_get_allocation_geometry: - * @self: A #ClutterActor - * @geom: (out): allocation geometry in pixels - * - * Gets the layout box an actor has been assigned. The allocation can - * only be assumed valid inside a paint() method; anywhere else, it - * may be out-of-date. - * - * An allocation does not incorporate the actor's scale or anchor point; - * those transformations do not affect layout, only rendering. - * - * The returned rectangle is in pixels. - * - * Since: 0.8 - * - * Deprecated: 1.12: Use clutter_actor_get_allocation_box() instead. - */ -void -clutter_actor_get_allocation_geometry (ClutterActor *self, - ClutterGeometry *geom) -{ - ClutterActorBox box; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - g_return_if_fail (geom != NULL); - - clutter_actor_get_allocation_box (self, &box); - - geom->x = CLUTTER_NEARBYINT (clutter_actor_box_get_x (&box)); - geom->y = CLUTTER_NEARBYINT (clutter_actor_box_get_y (&box)); - geom->width = CLUTTER_NEARBYINT (clutter_actor_box_get_width (&box)); - geom->height = CLUTTER_NEARBYINT (clutter_actor_box_get_height (&box)); -} diff --git a/clutter/clutter/deprecated/clutter-actor.h b/clutter/clutter/deprecated/clutter-actor.h index f568f5a4077d6ea0e84cfa7654dfa5ef8b5c2f35..40ebcec258fffb022b0034360b9fc1b2991ac267 100644 --- a/clutter/clutter/deprecated/clutter-actor.h +++ b/clutter/clutter/deprecated/clutter-actor.h @@ -145,10 +145,6 @@ CLUTTER_DEPRECATED void clutter_actor_get_transformation_matrix (ClutterActor *self, ClutterMatrix *matrix); -CLUTTER_DEPRECATED_FOR (clutter_actor_get_allocation_box) -void clutter_actor_get_allocation_geometry (ClutterActor *self, - ClutterGeometry *geom); - G_END_DECLS #endif /* __CLUTTER_ACTOR_DEPRECATED_H__ */ diff --git a/clutter/clutter/deprecated/clutter-animation.c b/clutter/clutter/deprecated/clutter-animation.c index 035f8549ab520fc726e4a516b9aef3df117c9f2d..bb8c8a7a36d2c991e4fecdf61007fafec501bed8 100644 --- a/clutter/clutter/deprecated/clutter-animation.c +++ b/clutter/clutter/deprecated/clutter-animation.c @@ -2220,7 +2220,7 @@ clutter_actor_animate_with_timeline (ClutterActor *actor, * * Will animate the "rotation-angle-z" property between the current value * 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 * will be assigned to the @actor and will be returned to the developer diff --git a/clutter/clutter/deprecated/clutter-rectangle.c b/clutter/clutter/deprecated/clutter-rectangle.c index 6fb066b2f46f8f31ad6a421e8f75873b6028a4d1..da9f5014f820c4e45db5e6096ec90c4be3957132 100644 --- a/clutter/clutter/deprecated/clutter-rectangle.c +++ b/clutter/clutter/deprecated/clutter-rectangle.c @@ -84,7 +84,7 @@ clutter_rectangle_paint (ClutterActor *self) CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer (); static CoglPipeline *default_color_pipeline = NULL; CoglPipeline *content_pipeline; - ClutterGeometry geom; + ClutterActorBox alloc; CoglColor color; guint8 tmp_alpha; @@ -92,7 +92,7 @@ clutter_rectangle_paint (ClutterActor *self) "painting rect '%s'", clutter_actor_get_name (self) ? clutter_actor_get_name (self) : "unknown"); - clutter_actor_get_allocation_geometry (self, &geom); + clutter_actor_get_allocation_box (self, &alloc); if (G_UNLIKELY (default_color_pipeline == NULL)) { @@ -140,40 +140,41 @@ clutter_rectangle_paint (ClutterActor *self) /* We paint the border and the content only if the rectangle * is big enough to show them */ - if ((priv->border_width * 2) < geom.width && - (priv->border_width * 2) < geom.height) + if ((priv->border_width * 2) < clutter_actor_box_get_width (&alloc) && + (priv->border_width * 2) < clutter_actor_box_get_height (&alloc)) { /* paint the border. this sucks, but it's the only way to make a border */ cogl_framebuffer_draw_rectangle (framebuffer, border_pipeline, priv->border_width, 0, - geom.width, + clutter_actor_box_get_width (&alloc), priv->border_width); cogl_framebuffer_draw_rectangle (framebuffer, border_pipeline, - geom.width - priv->border_width, + clutter_actor_box_get_width (&alloc) - priv->border_width, priv->border_width, - geom.width, geom.height); + clutter_actor_box_get_width (&alloc), + clutter_actor_box_get_height (&alloc)); cogl_framebuffer_draw_rectangle (framebuffer, border_pipeline, - 0, geom.height - priv->border_width, - geom.width - priv->border_width, - geom.height); + 0, clutter_actor_box_get_height (&alloc) - priv->border_width, + clutter_actor_box_get_width (&alloc) - priv->border_width, + clutter_actor_box_get_height (&alloc)); cogl_framebuffer_draw_rectangle (framebuffer, border_pipeline, 0, 0, priv->border_width, - geom.height - priv->border_width); + clutter_actor_box_get_height (&alloc) - priv->border_width); /* now paint the rectangle */ cogl_framebuffer_draw_rectangle (framebuffer, content_pipeline, priv->border_width, priv->border_width, - geom.width - priv->border_width, - geom.height - priv->border_width); + clutter_actor_box_get_width (&alloc) - priv->border_width, + clutter_actor_box_get_height (&alloc) - priv->border_width); } else { @@ -183,7 +184,9 @@ clutter_rectangle_paint (ClutterActor *self) */ cogl_framebuffer_draw_rectangle (framebuffer, border_pipeline, - 0, 0, geom.width, geom.height); + 0, 0, + clutter_actor_box_get_width (&alloc), + clutter_actor_box_get_height (&alloc)); } cogl_object_unref (border_pipeline); @@ -192,7 +195,9 @@ clutter_rectangle_paint (ClutterActor *self) { cogl_framebuffer_draw_rectangle (framebuffer, content_pipeline, - 0, 0, geom.width, geom.height); + 0, 0, + clutter_actor_box_get_width (&alloc), + clutter_actor_box_get_height (&alloc)); } cogl_object_unref (content_pipeline); diff --git a/clutter/clutter/deprecated/clutter-stage.h b/clutter/clutter/deprecated/clutter-stage.h index 4395f9439389f27b7872a3f28b440bc0497f06ce..20b103cf0f08f2aa25b3bf7e27522ab81c84ed66 100644 --- a/clutter/clutter/deprecated/clutter-stage.h +++ b/clutter/clutter/deprecated/clutter-stage.h @@ -74,20 +74,6 @@ gboolean clutter_stage_is_default (ClutterStage *stage); CLUTTER_DEPRECATED_FOR(clutter_actor_queue_redraw) void clutter_stage_queue_redraw (ClutterStage *stage); -CLUTTER_DEPRECATED -void clutter_stage_set_use_fog (ClutterStage *stage, - gboolean fog); - -CLUTTER_DEPRECATED -gboolean clutter_stage_get_use_fog (ClutterStage *stage); - -CLUTTER_DEPRECATED -void clutter_stage_set_fog (ClutterStage *stage, - ClutterFog *fog); - -CLUTTER_DEPRECATED -void clutter_stage_get_fog (ClutterStage *stage, - ClutterFog *fog); CLUTTER_DEPRECATED_FOR(clutter_actor_set_background_color) void clutter_stage_set_color (ClutterStage *stage, diff --git a/clutter/clutter/deprecated/clutter-texture.c b/clutter/clutter/deprecated/clutter-texture.c index 203e84f435370f6a870e8a060cd65cce1f058211..b53a2dee12ee88271063b7aa179a00204b4c72c7 100644 --- a/clutter/clutter/deprecated/clutter-texture.c +++ b/clutter/clutter/deprecated/clutter-texture.c @@ -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) */ - ClutterVertex verts[4]; + graphene_point3d_t verts[4]; float x_min = G_MAXFLOAT, y_min = G_MAXFLOAT; int i; diff --git a/clutter/clutter/meson.build b/clutter/clutter/meson.build index 44ee1a315e35f06fa075a2a0c689ca6e6b385dd6..6928de1335721295bbccf3a95b5d7622a4878d3f 100644 --- a/clutter/clutter/meson.build +++ b/clutter/clutter/meson.build @@ -127,6 +127,7 @@ clutter_sources = [ 'clutter-flatten-effect.c', 'clutter-flow-layout.c', 'clutter-gesture-action.c', + 'clutter-graphene.c', 'clutter-grid-layout.c', 'clutter-image.c', 'clutter-input-device.c', @@ -191,6 +192,7 @@ clutter_private_headers = [ 'clutter-effect-private.h', 'clutter-event-private.h', 'clutter-flatten-effect.h', + 'clutter-graphene.h', 'clutter-gesture-action-private.h', 'clutter-id-pool.h', 'clutter-input-focus-private.h', @@ -240,7 +242,6 @@ clutter_deprecated_headers = [ ] clutter_deprecated_sources = [ - 'deprecated/clutter-actor-deprecated.c', 'deprecated/clutter-alpha.c', 'deprecated/clutter-animation.c', 'deprecated/clutter-behaviour.c', @@ -454,6 +455,7 @@ libmutter_clutter = shared_library(libmutter_clutter_name, libmutter_clutter_dep = declare_dependency( sources: [clutter_enum_types[1]], link_with: libmutter_clutter, + dependencies: clutter_deps, ) if have_introspection diff --git a/cogl/cogl/cogl-context-private.h b/cogl/cogl/cogl-context-private.h index 13087e88129ca69bc464b7b4062a4a3e9278a061..1ce19b23a627e197915275662b7ae154c27523cc 100644 --- a/cogl/cogl/cogl-context-private.h +++ b/cogl/cogl/cogl-context-private.h @@ -147,8 +147,6 @@ struct _CoglContext GArray *texture_units; int active_texture_unit; - CoglPipelineFogState legacy_fog_state; - /* Pipelines */ CoglPipeline *opaque_color_pipeline; /* used for set_source_color */ CoglPipeline *blended_color_pipeline; /* used for set_source_color */ diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index b57800e97cc0699290fcb344c1c3fe5d1df6832a..ff27e4b23afd634d5c966dbaba67008566998d66 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -262,8 +262,6 @@ cogl_context_new (CoglDisplay *display, GE (context, glActiveTexture (GL_TEXTURE1)); } - context->legacy_fog_state.enabled = FALSE; - context->opaque_color_pipeline = cogl_pipeline_new (context); context->blended_color_pipeline = cogl_pipeline_new (context); context->texture_pipeline = cogl_pipeline_new (context); diff --git a/cogl/cogl/cogl-euler.c b/cogl/cogl/cogl-euler.c deleted file mode 100644 index 016aaa6c5df927936ffb672f9148ad7c62b61f6f..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl-euler.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#include "cogl-config.h" - -#include -#include -#include -#include "cogl-gtype-private.h" - -#include -#include - -COGL_GTYPE_DEFINE_BOXED (Euler, euler, - cogl_euler_copy, - cogl_euler_free); - -void -cogl_euler_init (CoglEuler *euler, - float heading, - float pitch, - float roll) -{ - euler->heading = heading; - euler->pitch = pitch; - euler->roll = roll; -} - -void -cogl_euler_init_from_matrix (CoglEuler *euler, - const CoglMatrix *matrix) -{ - /* - * Extracting a canonical Euler angle from a matrix: - * (where it is assumed the matrix contains no scaling, mirroring or - * skewing) - * - * A Euler angle is a combination of three rotations around mutually - * perpendicular axis. For this algorithm they are: - * - * Heading: A rotation about the Y axis by an angle H: - * | cosH 0 sinH| - * | 0 1 0| - * |-sinH 0 cosH| - * - * Pitch: A rotation around the X axis by an angle P: - * |1 0 0| - * |0 cosP -sinP| - * |0 sinP cosP| - * - * Roll: A rotation about the Z axis by an angle R: - * |cosR -sinR 0| - * |sinR cosR 0| - * | 0 0 1| - * - * When multiplied as matrices this gives: - * | cosHcosR+sinHsinPsinR sinRcosP -sinHcosR+cosHsinPsinR| - * M = |-cosHsinR+sinHsinPcosR cosRcosP sinRsinH+cosHsinPcosB| - * | sinHcosP -sinP cosHcosP | - * - * Given that there are an infinite number of ways to represent - * a given orientation, the "canonical" Euler angle is any such that: - * -180 < H < 180, - * -180 < R < 180 and - * -90 < P < 90 - * - * M[3][2] = -sinP lets us immediately solve for P = asin(-M[3][2]) - * (Note: asin has a range of +-90) - * This gives cosP - * This means we can use M[3][1] to calculate sinH: - * sinH = M[3][1]/cosP - * And use M[3][3] to calculate cosH: - * cosH = M[3][3]/cosP - * This lets us calculate H = atan2(sinH,cosH), but we optimise this: - * 1st note: atan2(x, y) does: atan(x/y) and uses the sign of x and y to - * determine the quadrant of the final angle. - * 2nd note: we know cosP is > 0 (ignoring cosP == 0) - * Therefore H = atan2((M[3][1]/cosP) / (M[3][3]/cosP)) can be simplified - * by skipping the division by cosP since it won't change the x/y ratio - * nor will it change their sign. This gives: - * H = atan2(M[3][1], M[3][3]) - * R is computed in the same way as H from M[1][2] and M[2][2] so: - * R = atan2(M[1][2], M[2][2]) - * Note: If cosP were == 0 then H and R could not be calculated as above - * because all the necessary matrix values would == 0. In other words we are - * pitched vertically and so H and R would now effectively rotate around the - * same axis - known as "Gimbal lock". In this situation we will set all the - * rotation on H and set R = 0. - * So with P = R = 0 we have cosP = 0, sinR = 0 and cosR = 1 - * We can substitute those into the above equation for M giving: - * | cosH 0 -sinH| - * |sinHsinP 0 cosHsinP| - * | 0 -sinP 0| - * And calculate H as atan2 (-M[3][2], M[1][1]) - */ - - float sinP; - float H; /* heading */ - float P; /* pitch */ - float R; /* roll */ - - /* NB: CoglMatrix provides struct members named according to the - * [row][column] indexed. So matrix->zx is row 3 column 1. */ - sinP = -matrix->zy; - - /* Determine the Pitch, avoiding domain errors with asin () which - * might occur due to previous imprecision in manipulating the - * matrix. */ - if (sinP <= -1.0f) - P = -G_PI_2; - else if (sinP >= 1.0f) - P = G_PI_2; - else - P = asinf (sinP); - - /* If P is too close to 0 then we have hit Gimbal lock */ - if (sinP > 0.999f) - { - H = atan2f (-matrix->zy, matrix->xx); - R = 0; - } - else - { - H = atan2f (matrix->zx, matrix->zz); - R = atan2f (matrix->xy, matrix->yy); - } - - euler->heading = H; - euler->pitch = P; - euler->roll = R; -} - -gboolean -cogl_euler_equal (const void *v1, const void *v2) -{ - const CoglEuler *a = v1; - const CoglEuler *b = v2; - - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); - - if (v1 == v2) - return TRUE; - - return (a->heading == b->heading && - a->pitch == b->pitch && - a->roll == b->roll); -} - -CoglEuler * -cogl_euler_copy (const CoglEuler *src) -{ - if (G_LIKELY (src)) - { - CoglEuler *new = g_slice_new (CoglEuler); - memcpy (new, src, sizeof (float) * 3); - return new; - } - else - return NULL; -} - -void -cogl_euler_free (CoglEuler *euler) -{ - g_slice_free (CoglEuler, euler); -} - diff --git a/cogl/cogl/cogl-euler.h b/cogl/cogl/cogl-euler.h deleted file mode 100644 index 9b5f53aeb6b76a6285abed9389db29962defb2c9..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl-euler.h +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __COGL_EULER_H -#define __COGL_EULER_H - -#include - -#include - -G_BEGIN_DECLS - -/** - * SECTION:cogl-euler - * @short_description: Functions for initializing and manipulating - * euler angles. - * - * Euler angles are a simple representation of a 3 dimensional - * rotation; comprised of 3 ordered heading, pitch and roll rotations. - * An important thing to understand is that the axis of rotation - * belong to the object being rotated and so they also rotate as each - * of the heading, pitch and roll rotations are applied. - * - * One way to consider euler angles is to imagine controlling an - * aeroplane, where you first choose a heading (Such as flying south - * east), then you set the pitch (such as 30 degrees to take off) and - * then you might set a roll, by dipping the left, wing as you prepare - * to turn. - * - * They have some advantages and limitations that it helps to be - * aware of: - * - * Advantages: - * - * - * Easy to understand and use, compared to quaternions and matrices, - * so may be a good choice for a user interface. - * - * - * Efficient storage, needing only 3 components any rotation can be - * represented. - * Actually the #CoglEuler type isn't optimized for size because - * we may cache the equivalent #CoglQuaternion along with a euler - * rotation, but it would be trivial for an application to track the - * components of euler rotations in a packed float array if optimizing - * for size was important. The values could be passed to Cogl only when - * manipulation is necessary. - * - * - * - * Disadvantages: - * - * - * Aliasing: it's possible to represent some rotations with multiple - * different heading, pitch and roll rotations. - * - * - * They can suffer from a problem called Gimbal Lock. A good - * explanation of this can be seen on wikipedia here: - * http://en.wikipedia.org/wiki/Gimbal_lock but basically two - * of the axis of rotation may become aligned and so you loose a - * degree of freedom. For example a pitch of +-90° would mean that - * heading and bank rotate around the same axis. - * - * - * If you use euler angles to orient something in 3D space and try to - * transition between orientations by interpolating the component - * angles you probably wont get the transitions you expect as they may - * not follow the shortest path between the two orientations. - * - * - * There's no standard to what order the component axis rotations are - * applied. The most common convention seems to be what we do in Cogl - * with heading (y-axis), pitch (x-axis) and then roll (z-axis), but - * other software might apply x-axis, y-axis then z-axis or any other - * order so you need to consider this if you are accepting euler - * rotations from some other software. Other software may also use - * slightly different aeronautical terms, such as "yaw" instead of - * "heading" or "bank" instead of "roll". - * - * - * - * To minimize the aliasing issue we may refer to "Canonical Euler" - * angles where heading and roll are restricted to +- 180° and pitch is - * restricted to +- 90°. If pitch is +- 90° bank is set to 0°. - * - * Quaternions don't suffer from Gimbal Lock and they can be nicely - * interpolated between, their disadvantage is that they don't have an - * intuitive representation. - * - * A common practice is to accept angles in the intuitive Euler form - * and convert them to quaternions internally to avoid Gimbal Lock and - * handle interpolations. See cogl_quaternion_init_from_euler(). - */ - -/** - * CoglEuler: - * @heading: Angle to rotate around an object's y axis - * @pitch: Angle to rotate around an object's x axis - * @roll: Angle to rotate around an object's z axis - * - * Represents an ordered rotation first of @heading degrees around an - * object's y axis, then @pitch degrees around an object's x axis and - * finally @roll degrees around an object's z axis. - * - * It's important to understand the that axis are associated - * with the object being rotated, so the axis also rotate in sequence - * with the rotations being applied. - * - * The members of a #CoglEuler can be initialized, for example, with - * cogl_euler_init() and cogl_euler_init_from_quaternion (). - * - * You may also want to look at cogl_quaternion_init_from_euler() if - * you want to do interpolation between 3d rotations. - * - * Since: 2.0 - */ -struct _CoglEuler -{ - /*< public > */ - float heading; - float pitch; - float roll; - - /*< private > */ - /* May cached a quaternion here in the future */ - float padding0; - float padding1; - float padding2; - float padding3; - float padding4; -}; -COGL_STRUCT_SIZE_ASSERT (CoglEuler, 32); - -/** - * cogl_euler_get_gtype: - * - * Returns: a #GType that can be used with the GLib type system. - */ -GType cogl_euler_get_gtype (void); - -/** - * cogl_euler_init: - * @euler: The #CoglEuler angle to initialize - * @heading: Angle to rotate around an object's y axis - * @pitch: Angle to rotate around an object's x axis - * @roll: Angle to rotate around an object's z axis - * - * Initializes @euler to represent a rotation of @x_angle degrees - * around the x axis, then @y_angle degrees around the y_axis and - * @z_angle degrees around the z axis. - * - * Since: 2.0 - */ -void -cogl_euler_init (CoglEuler *euler, - float heading, - float pitch, - float roll); - -/** - * cogl_euler_init_from_matrix: - * @euler: The #CoglEuler angle to initialize - * @matrix: A #CoglMatrix containing a rotation, but no scaling, - * mirroring or skewing. - * - * Extracts a euler rotation from the given @matrix and - * initializses @euler with the component x, y and z rotation angles. - */ -void -cogl_euler_init_from_matrix (CoglEuler *euler, - const CoglMatrix *matrix); - -/** - * cogl_euler_init_from_quaternion: - * @euler: The #CoglEuler angle to initialize - * @quaternion: A #CoglEuler with the rotation to initialize with - * - * Initializes a @euler rotation with the equivalent rotation - * represented by the given @quaternion. - */ -void -cogl_euler_init_from_quaternion (CoglEuler *euler, - const CoglQuaternion *quaternion); - -/** - * cogl_euler_equal: - * @v1: The first euler angle to compare - * @v2: The second euler angle to compare - * - * Compares the two given euler angles @v1 and @v1 and it they are - * equal returns %TRUE else %FALSE. - * - * This function only checks that all three components rotations - * are numerically equal, it does not consider that some rotations - * can be represented with different component rotations - * - * Returns: %TRUE if @v1 and @v2 are equal else %FALSE. - * Since: 2.0 - */ -gboolean -cogl_euler_equal (const void *v1, const void *v2); - -/** - * cogl_euler_copy: - * @src: A #CoglEuler to copy - * - * Allocates a new #CoglEuler and initilizes it with the component - * angles of @src. The newly allocated euler should be freed using - * cogl_euler_free(). - * - * Returns: A newly allocated #CoglEuler - * Since: 2.0 - */ -CoglEuler * -cogl_euler_copy (const CoglEuler *src); - -/** - * cogl_euler_free: - * @euler: A #CoglEuler allocated via cogl_euler_copy() - * - * Frees a #CoglEuler that was previously allocated using - * cogl_euler_copy(). - * - * Since: 2.0 - */ -void -cogl_euler_free (CoglEuler *euler); - -G_END_DECLS - -#endif /* __COGL_EULER_H */ - diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index 1114ce197910dc2d883a4882c8cd5d79406f1780..1120b25381f9d851991d7f3e8aff5032bf663a84 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -1545,22 +1545,9 @@ cogl_framebuffer_rotate (CoglFramebuffer *framebuffer, COGL_FRAMEBUFFER_STATE_MODELVIEW; } -void -cogl_framebuffer_rotate_quaternion (CoglFramebuffer *framebuffer, - const CoglQuaternion *quaternion) -{ - CoglMatrixStack *modelview_stack = - _cogl_framebuffer_get_modelview_stack (framebuffer); - cogl_matrix_stack_rotate_quaternion (modelview_stack, quaternion); - - if (framebuffer->context->current_draw_buffer == framebuffer) - framebuffer->context->current_draw_buffer_changes |= - COGL_FRAMEBUFFER_STATE_MODELVIEW; -} - void cogl_framebuffer_rotate_euler (CoglFramebuffer *framebuffer, - const CoglEuler *euler) + const graphene_euler_t *euler) { CoglMatrixStack *modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer); diff --git a/cogl/cogl/cogl-framebuffer.h b/cogl/cogl/cogl-framebuffer.h index 08ed3354b4cc13ed268b7b426e935f897d790bf5..99ed6bde9efce25bd5b99631b22ec346dc79d901 100644 --- a/cogl/cogl/cogl-framebuffer.h +++ b/cogl/cogl/cogl-framebuffer.h @@ -52,11 +52,11 @@ typedef struct _CoglFramebuffer CoglFramebuffer; #include #include #include -#include -#include #include #include +#include + G_BEGIN_DECLS /** @@ -362,25 +362,10 @@ cogl_framebuffer_rotate (CoglFramebuffer *framebuffer, float y, float z); -/** - * cogl_framebuffer_rotate_quaternion: - * @framebuffer: A #CoglFramebuffer pointer - * @quaternion: A #CoglQuaternion - * - * Multiplies the current model-view matrix by one that rotates - * according to the rotation described by @quaternion. - * - * Since: 2.0 - * Stability: unstable - */ -void -cogl_framebuffer_rotate_quaternion (CoglFramebuffer *framebuffer, - const CoglQuaternion *quaternion); - /** * cogl_framebuffer_rotate_euler: * @framebuffer: A #CoglFramebuffer pointer - * @euler: A #CoglEuler + * @euler: A #graphene_euler_t * * Multiplies the current model-view matrix by one that rotates * according to the rotation described by @euler. @@ -390,7 +375,7 @@ cogl_framebuffer_rotate_quaternion (CoglFramebuffer *framebuffer, */ void cogl_framebuffer_rotate_euler (CoglFramebuffer *framebuffer, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_framebuffer_transform: diff --git a/cogl/cogl/cogl-matrix-stack-private.h b/cogl/cogl/cogl-matrix-stack-private.h index dec789b8ad31318b4e4ca8bf58d9ce47aeb2f8e5..c442782cffff78e483650f58d3fb6da458006677 100644 --- a/cogl/cogl/cogl-matrix-stack-private.h +++ b/cogl/cogl/cogl-matrix-stack-private.h @@ -45,7 +45,6 @@ typedef enum _CoglMatrixOp COGL_MATRIX_OP_LOAD_IDENTITY, COGL_MATRIX_OP_TRANSLATE, COGL_MATRIX_OP_ROTATE, - COGL_MATRIX_OP_ROTATE_QUATERNION, COGL_MATRIX_OP_ROTATE_EULER, COGL_MATRIX_OP_SCALE, COGL_MATRIX_OP_MULTIPLY, @@ -69,9 +68,7 @@ typedef struct _CoglMatrixEntryTranslate { CoglMatrixEntry _parent_data; - float x; - float y; - float z; + graphene_point3d_t translate; } CoglMatrixEntryTranslate; @@ -80,9 +77,7 @@ typedef struct _CoglMatrixEntryRotate CoglMatrixEntry _parent_data; float angle; - float x; - float y; - float z; + graphene_vec3_t axis; } CoglMatrixEntryRotate; @@ -90,22 +85,9 @@ typedef struct _CoglMatrixEntryRotateEuler { CoglMatrixEntry _parent_data; - /* This doesn't store an actual CoglEuler in order to avoid the - * padding */ - float heading; - float pitch; - float roll; + graphene_euler_t euler; } CoglMatrixEntryRotateEuler; -typedef struct _CoglMatrixEntryRotateQuaternion -{ - CoglMatrixEntry _parent_data; - - /* This doesn't store an actual CoglQuaternion in order to avoid the - * padding */ - float values[4]; -} CoglMatrixEntryRotateQuaternion; - typedef struct _CoglMatrixEntryScale { CoglMatrixEntry _parent_data; @@ -147,7 +129,6 @@ typedef union _CoglMatrixEntryFull CoglMatrixEntryTranslate translate; CoglMatrixEntryRotate rotate; CoglMatrixEntryRotateEuler rotate_euler; - CoglMatrixEntryRotateQuaternion rotate_quaternion; CoglMatrixEntryScale scale; CoglMatrixEntryMultiply multiply; CoglMatrixEntryLoad load; diff --git a/cogl/cogl/cogl-matrix-stack.c b/cogl/cogl/cogl-matrix-stack.c index 2d2aeba2a01b6fcab3cd751aefa18d228700dca2..fb033008959a4cb25156ce3d3e3b320495b2c23e 100644 --- a/cogl/cogl/cogl-matrix-stack.c +++ b/cogl/cogl/cogl-matrix-stack.c @@ -158,9 +158,7 @@ cogl_matrix_stack_translate (CoglMatrixStack *stack, entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_TRANSLATE); - entry->x = x; - entry->y = y; - entry->z = z; + graphene_point3d_init (&entry->translate, x, y, z); } void @@ -175,38 +173,18 @@ cogl_matrix_stack_rotate (CoglMatrixStack *stack, entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_ROTATE); entry->angle = angle; - entry->x = x; - entry->y = y; - entry->z = z; + graphene_vec3_init (&entry->axis, x, y, z); } void -cogl_matrix_stack_rotate_quaternion (CoglMatrixStack *stack, - const CoglQuaternion *quaternion) -{ - CoglMatrixEntryRotateQuaternion *entry; - - entry = _cogl_matrix_stack_push_operation (stack, - COGL_MATRIX_OP_ROTATE_QUATERNION); - - entry->values[0] = quaternion->w; - entry->values[1] = quaternion->x; - entry->values[2] = quaternion->y; - entry->values[3] = quaternion->z; -} - -void -cogl_matrix_stack_rotate_euler (CoglMatrixStack *stack, - const CoglEuler *euler) +cogl_matrix_stack_rotate_euler (CoglMatrixStack *stack, + const graphene_euler_t *euler) { CoglMatrixEntryRotateEuler *entry; entry = _cogl_matrix_stack_push_operation (stack, COGL_MATRIX_OP_ROTATE_EULER); - - entry->heading = euler->heading; - entry->pitch = euler->pitch; - entry->roll = euler->roll; + graphene_euler_init_from_euler (&entry->euler, euler); } void @@ -357,7 +335,6 @@ cogl_matrix_entry_unref (CoglMatrixEntry *entry) case COGL_MATRIX_OP_LOAD_IDENTITY: case COGL_MATRIX_OP_TRANSLATE: case COGL_MATRIX_OP_ROTATE: - case COGL_MATRIX_OP_ROTATE_QUATERNION: case COGL_MATRIX_OP_ROTATE_EULER: case COGL_MATRIX_OP_SCALE: break; @@ -498,7 +475,6 @@ initialized: case COGL_MATRIX_OP_LOAD_IDENTITY: case COGL_MATRIX_OP_TRANSLATE: case COGL_MATRIX_OP_ROTATE: - case COGL_MATRIX_OP_ROTATE_QUATERNION: case COGL_MATRIX_OP_ROTATE_EULER: case COGL_MATRIX_OP_SCALE: case COGL_MATRIX_OP_MULTIPLY: @@ -560,9 +536,9 @@ initialized: CoglMatrixEntryTranslate *translate = (CoglMatrixEntryTranslate *)children[i]; cogl_matrix_translate (matrix, - translate->x, - translate->y, - translate->z); + translate->translate.x, + translate->translate.y, + translate->translate.z); continue; } case COGL_MATRIX_OP_ROTATE: @@ -571,31 +547,17 @@ initialized: (CoglMatrixEntryRotate *)children[i]; cogl_matrix_rotate (matrix, rotate->angle, - rotate->x, - rotate->y, - rotate->z); + graphene_vec3_get_x (&rotate->axis), + graphene_vec3_get_y (&rotate->axis), + graphene_vec3_get_z (&rotate->axis)); continue; } case COGL_MATRIX_OP_ROTATE_EULER: { CoglMatrixEntryRotateEuler *rotate = (CoglMatrixEntryRotateEuler *)children[i]; - CoglEuler euler; - cogl_euler_init (&euler, - rotate->heading, - rotate->pitch, - rotate->roll); cogl_matrix_rotate_euler (matrix, - &euler); - continue; - } - case COGL_MATRIX_OP_ROTATE_QUATERNION: - { - CoglMatrixEntryRotateQuaternion *rotate = - (CoglMatrixEntryRotateQuaternion *)children[i]; - CoglQuaternion quaternion; - cogl_quaternion_init_from_array (&quaternion, rotate->values); - cogl_matrix_rotate_quaternion (matrix, &quaternion); + &rotate->euler); continue; } case COGL_MATRIX_OP_SCALE: @@ -790,9 +752,9 @@ cogl_matrix_entry_calculate_translation (CoglMatrixEntry *entry0, translate = (CoglMatrixEntryTranslate *)node0; - *x = *x - translate->x; - *y = *y - translate->y; - *z = *z - translate->z; + *x = *x - translate->translate.x; + *y = *y - translate->translate.y; + *z = *z - translate->translate.z; } for (head1 = common_ancestor1->next; head1; head1 = head1->next) { @@ -805,9 +767,9 @@ cogl_matrix_entry_calculate_translation (CoglMatrixEntry *entry0, translate = (CoglMatrixEntryTranslate *)node1; - *x = *x + translate->x; - *y = *y + translate->y; - *z = *z + translate->z; + *x = *x + translate->translate.x; + *y = *y + translate->translate.y; + *z = *z + translate->translate.z; } return TRUE; @@ -970,9 +932,8 @@ cogl_matrix_entry_equal (CoglMatrixEntry *entry0, /* We could perhaps use an epsilon to compare here? * I expect the false negatives are probaly never going to * be a problem and this is a bit cheaper. */ - if (translate0->x != translate1->x || - translate0->y != translate1->y || - translate0->z != translate1->z) + if (!graphene_point3d_equal (&translate0->translate, + &translate1->translate)) return FALSE; } break; @@ -983,24 +944,10 @@ cogl_matrix_entry_equal (CoglMatrixEntry *entry0, CoglMatrixEntryRotate *rotate1 = (CoglMatrixEntryRotate *)entry1; if (rotate0->angle != rotate1->angle || - rotate0->x != rotate1->x || - rotate0->y != rotate1->y || - rotate0->z != rotate1->z) + !graphene_vec3_equal (&rotate0->axis, &rotate1->axis)) return FALSE; } break; - case COGL_MATRIX_OP_ROTATE_QUATERNION: - { - CoglMatrixEntryRotateQuaternion *rotate0 = - (CoglMatrixEntryRotateQuaternion *)entry0; - CoglMatrixEntryRotateQuaternion *rotate1 = - (CoglMatrixEntryRotateQuaternion *)entry1; - int i; - for (i = 0; i < 4; i++) - if (rotate0->values[i] != rotate1->values[i]) - return FALSE; - } - break; case COGL_MATRIX_OP_ROTATE_EULER: { CoglMatrixEntryRotateEuler *rotate0 = @@ -1008,9 +955,7 @@ cogl_matrix_entry_equal (CoglMatrixEntry *entry0, CoglMatrixEntryRotateEuler *rotate1 = (CoglMatrixEntryRotateEuler *)entry1; - if (rotate0->heading != rotate1->heading || - rotate0->pitch != rotate1->pitch || - rotate0->roll != rotate1->roll) + if (!graphene_euler_equal (&rotate0->euler, &rotate1->euler)) return FALSE; } break; @@ -1086,9 +1031,9 @@ cogl_debug_matrix_entry_print (CoglMatrixEntry *entry) CoglMatrixEntryTranslate *translate = (CoglMatrixEntryTranslate *)entry; g_print (" TRANSLATE X=%f Y=%f Z=%f\n", - translate->x, - translate->y, - translate->z); + translate->translate.x, + translate->translate.y, + translate->translate.z); continue; } case COGL_MATRIX_OP_ROTATE: @@ -1097,20 +1042,9 @@ cogl_debug_matrix_entry_print (CoglMatrixEntry *entry) (CoglMatrixEntryRotate *)entry; g_print (" ROTATE ANGLE=%f X=%f Y=%f Z=%f\n", rotate->angle, - rotate->x, - rotate->y, - rotate->z); - continue; - } - case COGL_MATRIX_OP_ROTATE_QUATERNION: - { - CoglMatrixEntryRotateQuaternion *rotate = - (CoglMatrixEntryRotateQuaternion *)entry; - g_print (" ROTATE QUATERNION w=%f x=%f y=%f z=%f\n", - rotate->values[0], - rotate->values[1], - rotate->values[2], - rotate->values[3]); + graphene_vec3_get_x (&rotate->axis), + graphene_vec3_get_y (&rotate->axis), + graphene_vec3_get_z (&rotate->axis)); continue; } case COGL_MATRIX_OP_ROTATE_EULER: @@ -1118,9 +1052,9 @@ cogl_debug_matrix_entry_print (CoglMatrixEntry *entry) CoglMatrixEntryRotateEuler *rotate = (CoglMatrixEntryRotateEuler *)entry; g_print (" ROTATE EULER heading=%f pitch=%f roll=%f\n", - rotate->heading, - rotate->pitch, - rotate->roll); + graphene_euler_get_y (&rotate->euler), + graphene_euler_get_x (&rotate->euler), + graphene_euler_get_z (&rotate->euler)); continue; } case COGL_MATRIX_OP_SCALE: diff --git a/cogl/cogl/cogl-matrix-stack.h b/cogl/cogl/cogl-matrix-stack.h index 4be9f59c206b84c55ab1e247eea867b988b335c1..5a2c7d1389a87b437ce708be4aea94508c74a220 100644 --- a/cogl/cogl/cogl-matrix-stack.h +++ b/cogl/cogl/cogl-matrix-stack.h @@ -42,6 +42,7 @@ #include "cogl-matrix.h" #include "cogl-context.h" +#include /** * SECTION:cogl-matrix-stack @@ -306,29 +307,17 @@ cogl_matrix_stack_rotate (CoglMatrixStack *stack, float y, float z); -/** - * cogl_matrix_stack_rotate_quaternion: - * @stack: A #CoglMatrixStack - * @quaternion: A #CoglQuaternion - * - * Multiplies the current matrix by one that rotates according to the - * rotation described by @quaternion. - */ -void -cogl_matrix_stack_rotate_quaternion (CoglMatrixStack *stack, - const CoglQuaternion *quaternion); - /** * cogl_matrix_stack_rotate_euler: * @stack: A #CoglMatrixStack - * @euler: A #CoglEuler + * @euler: A #graphene_euler_t * * Multiplies the current matrix by one that rotates according to the * rotation described by @euler. */ void cogl_matrix_stack_rotate_euler (CoglMatrixStack *stack, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_matrix_stack_multiply: diff --git a/cogl/cogl/cogl-matrix.c b/cogl/cogl/cogl-matrix.c index af5591357d2d43b50109af7a8d2613c74987cc63..02c38344e6fbe1fddfed24e8c56826ee59ab8c6a 100644 --- a/cogl/cogl/cogl-matrix.c +++ b/cogl/cogl/cogl-matrix.c @@ -73,11 +73,8 @@ #include #include -#include -#include #include #include -#include #include #include @@ -1358,19 +1355,9 @@ cogl_matrix_rotate (CoglMatrix *matrix, _COGL_MATRIX_DEBUG_PRINT (matrix); } -void -cogl_matrix_rotate_quaternion (CoglMatrix *matrix, - const CoglQuaternion *quaternion) -{ - CoglMatrix rotation_transform; - - cogl_matrix_init_from_quaternion (&rotation_transform, quaternion); - cogl_matrix_multiply (matrix, matrix, &rotation_transform); -} - void cogl_matrix_rotate_euler (CoglMatrix *matrix, - const CoglEuler *euler) + const graphene_euler_t *euler) { CoglMatrix rotation_transform; @@ -1735,56 +1722,14 @@ _cogl_matrix_init_from_matrix_without_inverse (CoglMatrix *matrix, matrix->flags = src->flags | MAT_DIRTY_INVERSE; } -static void -_cogl_matrix_init_from_quaternion (CoglMatrix *matrix, - const CoglQuaternion *quaternion) -{ - float qnorm = _COGL_QUATERNION_NORM (quaternion); - float s = (qnorm > 0.0f) ? (2.0f / qnorm) : 0.0f; - float xs = quaternion->x * s; - float ys = quaternion->y * s; - float zs = quaternion->z * s; - float wx = quaternion->w * xs; - float wy = quaternion->w * ys; - float wz = quaternion->w * zs; - float xx = quaternion->x * xs; - float xy = quaternion->x * ys; - float xz = quaternion->x * zs; - float yy = quaternion->y * ys; - float yz = quaternion->y * zs; - float zz = quaternion->z * zs; - - matrix->xx = 1.0f - (yy + zz); - matrix->yx = xy + wz; - matrix->zx = xz - wy; - matrix->xy = xy - wz; - matrix->yy = 1.0f - (xx + zz); - matrix->zy = yz + wx; - matrix->xz = xz + wy; - matrix->yz = yz - wx; - matrix->zz = 1.0f - (xx + yy); - matrix->xw = matrix->yw = matrix->zw = 0.0f; - matrix->wx = matrix->wy = matrix->wz = 0.0f; - matrix->ww = 1.0f; - - matrix->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL); -} - -void -cogl_matrix_init_from_quaternion (CoglMatrix *matrix, - const CoglQuaternion *quaternion) -{ - _cogl_matrix_init_from_quaternion (matrix, quaternion); -} - void cogl_matrix_init_from_euler (CoglMatrix *matrix, - const CoglEuler *euler) + const graphene_euler_t *euler) { /* Convert angles to radians */ - float heading_rad = euler->heading / 180.0f * G_PI; - float pitch_rad = euler->pitch / 180.0f * G_PI; - float roll_rad = euler->roll / 180.0f * G_PI; + float heading_rad = graphene_euler_get_y (euler) / 180.0f * G_PI; + float pitch_rad = graphene_euler_get_x (euler) / 180.0f * G_PI; + float roll_rad = graphene_euler_get_z (euler) / 180.0f * G_PI; /* Pre-calculate the sin and cos */ float sin_heading = sinf (heading_rad); float cos_heading = cosf (heading_rad); @@ -2238,41 +2183,41 @@ cogl_matrix_look_at (CoglMatrix *matrix, float world_up_z) { CoglMatrix tmp; - float forward[3]; - float side[3]; - float up[3]; + graphene_vec3_t forward; + graphene_vec3_t side; + graphene_vec3_t up; /* Get a unit viewing direction vector */ - cogl_vector3_init (forward, - object_x - eye_position_x, - object_y - eye_position_y, - object_z - eye_position_z); - cogl_vector3_normalize (forward); + graphene_vec3_init (&forward, + object_x - eye_position_x, + object_y - eye_position_y, + object_z - eye_position_z); + graphene_vec3_normalize (&forward, &forward); - cogl_vector3_init (up, world_up_x, world_up_y, world_up_z); + graphene_vec3_init (&up, world_up_x, world_up_y, world_up_z); /* Take the sideways direction as being perpendicular to the viewing * direction and the word up vector. */ - cogl_vector3_cross_product (side, forward, up); - cogl_vector3_normalize (side); + graphene_vec3_cross (&forward, &up, &side); + graphene_vec3_normalize (&side, &side); /* Now we have unit sideways and forward-direction vectors calculate * a new mutually perpendicular up vector. */ - cogl_vector3_cross_product (up, side, forward); + graphene_vec3_cross (&side, &forward, &up); - tmp.xx = side[0]; - tmp.yx = side[1]; - tmp.zx = side[2]; + tmp.xx = graphene_vec3_get_x (&side); + tmp.yx = graphene_vec3_get_y (&side); + tmp.zx = graphene_vec3_get_z (&side); tmp.wx = 0; - tmp.xy = up[0]; - tmp.yy = up[1]; - tmp.zy = up[2]; + tmp.xy = graphene_vec3_get_x (&up); + tmp.yy = graphene_vec3_get_y (&up); + tmp.zy = graphene_vec3_get_z (&up); tmp.wy = 0; - tmp.xz = -forward[0]; - tmp.yz = -forward[1]; - tmp.zz = -forward[2]; + tmp.xz = -graphene_vec3_get_x (&forward); + tmp.yz = -graphene_vec3_get_y (&forward); + tmp.zz = -graphene_vec3_get_z (&forward); tmp.wz = 0; tmp.xw = 0; diff --git a/cogl/cogl/cogl-matrix.h b/cogl/cogl/cogl-matrix.h index 6d8ddb43324d2ce32c09b04622dafed79063c137..7779b4ae74ed458bb6475d1fa22e516a89796e74 100644 --- a/cogl/cogl/cogl-matrix.h +++ b/cogl/cogl/cogl-matrix.h @@ -41,9 +41,10 @@ #include #include -#include #include +#include + G_BEGIN_DECLS /** @@ -196,33 +197,19 @@ cogl_matrix_rotate (CoglMatrix *matrix, float y, float z); -/** - * cogl_matrix_rotate_quaternion: - * @matrix: A 4x4 transformation matrix - * @quaternion: A quaternion describing a rotation - * - * Multiplies @matrix with a rotation transformation described by the - * given #CoglQuaternion. - * - * Since: 2.0 - */ -void -cogl_matrix_rotate_quaternion (CoglMatrix *matrix, - const CoglQuaternion *quaternion); - /** * cogl_matrix_rotate_euler: * @matrix: A 4x4 transformation matrix * @euler: A euler describing a rotation * * Multiplies @matrix with a rotation transformation described by the - * given #CoglEuler. + * given #graphene_euler_t. * * Since: 2.0 */ void cogl_matrix_rotate_euler (CoglMatrix *matrix, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_matrix_translate: @@ -515,27 +502,16 @@ cogl_matrix_init_from_array (CoglMatrix *matrix, const float * cogl_matrix_get_array (const CoglMatrix *matrix); -/** - * cogl_matrix_init_from_quaternion: - * @matrix: A 4x4 transformation matrix - * @quaternion: A #CoglQuaternion - * - * Initializes @matrix from a #CoglQuaternion rotation. - */ -void -cogl_matrix_init_from_quaternion (CoglMatrix *matrix, - const CoglQuaternion *quaternion); - /** * cogl_matrix_init_from_euler: * @matrix: A 4x4 transformation matrix - * @euler: A #CoglEuler + * @euler: A #graphene_euler_t * - * Initializes @matrix from a #CoglEuler rotation. + * Initializes @matrix from a #graphene_euler_t rotation. */ void cogl_matrix_init_from_euler (CoglMatrix *matrix, - const CoglEuler *euler); + const graphene_euler_t *euler); /** * cogl_matrix_equal: diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 3db0b37dce3d4819b7ec7c54f51a6629e045c867..533e003f4989a136cc678b46feef8c87f2c76308 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -83,7 +83,6 @@ typedef enum COGL_PIPELINE_STATE_BLEND_INDEX, COGL_PIPELINE_STATE_USER_SHADER_INDEX, COGL_PIPELINE_STATE_DEPTH_INDEX, - COGL_PIPELINE_STATE_FOG_INDEX, COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE_INDEX, COGL_PIPELINE_STATE_POINT_SIZE_INDEX, COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE_INDEX, @@ -131,8 +130,6 @@ typedef enum _CoglPipelineState 1L<big_state->fog_state; - CoglPipelineFogState *fog_state1 = &authority1->big_state->fog_state; - - if (fog_state0->enabled == fog_state1->enabled && - cogl_color_equal (&fog_state0->color, &fog_state1->color) && - fog_state0->mode == fog_state1->mode && - fog_state0->density == fog_state1->density && - fog_state0->z_near == fog_state1->z_near && - fog_state0->z_far == fog_state1->z_far) - return TRUE; - else - return FALSE; -} - gboolean _cogl_pipeline_non_zero_point_size_equal (CoglPipeline *authority0, CoglPipeline *authority1) @@ -1192,41 +1174,6 @@ cogl_pipeline_get_depth_state (CoglPipeline *pipeline, *state = authority->big_state->depth_state; } -void -_cogl_pipeline_set_fog_state (CoglPipeline *pipeline, - const CoglPipelineFogState *fog_state) -{ - CoglPipelineState state = COGL_PIPELINE_STATE_FOG; - CoglPipeline *authority; - CoglPipelineFogState *current_fog_state; - - g_return_if_fail (cogl_is_pipeline (pipeline)); - - authority = _cogl_pipeline_get_authority (pipeline, state); - - current_fog_state = &authority->big_state->fog_state; - - if (current_fog_state->enabled == fog_state->enabled && - cogl_color_equal (¤t_fog_state->color, &fog_state->color) && - current_fog_state->mode == fog_state->mode && - current_fog_state->density == fog_state->density && - current_fog_state->z_near == fog_state->z_near && - current_fog_state->z_far == fog_state->z_far) - return; - - /* - Flush journal primitives referencing the current state. - * - Make sure the pipeline has no dependants so it may be modified. - * - If the pipeline isn't currently an authority for the state being - * changed, then initialize that state from the current authority. - */ - _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - - pipeline->big_state->fog_state = *fog_state; - - _cogl_pipeline_update_authority (pipeline, authority, state, - _cogl_pipeline_fog_state_equal); -} - void cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline, CoglPipelineCullFaceMode cull_face_mode) @@ -1850,23 +1797,6 @@ _cogl_pipeline_hash_depth_state (CoglPipeline *authority, state->hash = hash; } -void -_cogl_pipeline_hash_fog_state (CoglPipeline *authority, - CoglPipelineHashState *state) -{ - CoglPipelineFogState *fog_state = &authority->big_state->fog_state; - unsigned long hash = state->hash; - - if (!fog_state->enabled) - hash = _cogl_util_one_at_a_time_hash (hash, &fog_state->enabled, - sizeof (fog_state->enabled)); - else - hash = _cogl_util_one_at_a_time_hash (hash, &fog_state, - sizeof (CoglPipelineFogState)); - - state->hash = hash; -} - void _cogl_pipeline_hash_non_zero_point_size_state (CoglPipeline *authority, CoglPipelineHashState *state) diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index 0f98641eddcda19a76539f811005c4635dc9362c..5dcc86bdee790b5171093f76ab53b0bea18dc851 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -1002,13 +1002,6 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest, sizeof (CoglDepthState)); } - if (differences & COGL_PIPELINE_STATE_FOG) - { - memcpy (&big_state->fog_state, - &src->big_state->fog_state, - sizeof (CoglPipelineFogState)); - } - if (differences & COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE) big_state->non_zero_point_size = src->big_state->non_zero_point_size; @@ -1124,13 +1117,6 @@ _cogl_pipeline_init_multi_property_sparse_state (CoglPipeline *pipeline, sizeof (CoglDepthState)); break; } - case COGL_PIPELINE_STATE_FOG: - { - memcpy (&pipeline->big_state->fog_state, - &authority->big_state->fog_state, - sizeof (CoglPipelineFogState)); - break; - } case COGL_PIPELINE_STATE_CULL_FACE: { memcpy (&pipeline->big_state->cull_face_state, @@ -2258,11 +2244,6 @@ _cogl_pipeline_equal (CoglPipeline *pipeline0, authorities1[bit])) goto done; break; - case COGL_PIPELINE_STATE_FOG_INDEX: - if (!_cogl_pipeline_fog_state_equal (authorities0[bit], - authorities1[bit])) - goto done; - break; case COGL_PIPELINE_STATE_CULL_FACE_INDEX: if (!_cogl_pipeline_cull_face_state_equal (authorities0[bit], authorities1[bit])) @@ -2396,18 +2377,6 @@ _cogl_pipeline_update_authority (CoglPipeline *pipeline, } } -gboolean -_cogl_pipeline_get_fog_enabled (CoglPipeline *pipeline) -{ - CoglPipeline *authority; - - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); - - authority = - _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FOG); - return authority->big_state->fog_state.enabled; -} - unsigned long _cogl_pipeline_get_age (CoglPipeline *pipeline) { @@ -2569,9 +2538,6 @@ _cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline) cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL); } - if (ctx->legacy_fog_state.enabled) - _cogl_pipeline_set_fog_state (pipeline, &ctx->legacy_fog_state); - if (ctx->legacy_backface_culling_enabled) cogl_pipeline_set_cull_face_mode (pipeline, COGL_PIPELINE_CULL_FACE_MODE_BACK); @@ -2719,8 +2685,6 @@ _cogl_pipeline_init_state_hash_functions (void) _cogl_pipeline_hash_user_shader_state; state_hash_functions[COGL_PIPELINE_STATE_DEPTH_INDEX] = _cogl_pipeline_hash_depth_state; - state_hash_functions[COGL_PIPELINE_STATE_FOG_INDEX] = - _cogl_pipeline_hash_fog_state; state_hash_functions[COGL_PIPELINE_STATE_CULL_FACE_INDEX] = _cogl_pipeline_hash_cull_face_state; state_hash_functions[COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE_INDEX] = @@ -2738,7 +2702,7 @@ _cogl_pipeline_init_state_hash_functions (void) { /* So we get a big error if we forget to update this code! */ - _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 17, + _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 16, "Make sure to install a hash function for " "newly added pipeline state and update assert " "in _cogl_pipeline_init_state_hash_functions"); diff --git a/cogl/cogl/cogl-quaternion-private.h b/cogl/cogl/cogl-quaternion-private.h deleted file mode 100644 index eda672ea8eb0ab2c7177926de011c68631e7afdc..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl-quaternion-private.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2008,2009 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#ifndef __COGL_QUATERNION_PRIVATE_H__ -#define __COGL_QUATERNION_PRIVATE_H__ - -#include - -/* squared length */ -#define _COGL_QUATERNION_NORM(Q) \ - ((Q)->x*(Q)->x + (Q)->y*(Q)->y + (Q)->z*(Q)->z + (Q)->w*(Q)->w) - -#define _COGL_QUATERNION_DEGREES_TO_RADIANS (G_PI / 180.0f) -#define _COGL_QUATERNION_RADIANS_TO_DEGREES (180.0f / G_PI) - -#endif /* __COGL_QUATERNION_PRIVATE_H__ */ diff --git a/cogl/cogl/cogl-quaternion.c b/cogl/cogl/cogl-quaternion.c deleted file mode 100644 index 20bd2ad6c85ea51be6dfd259d3a350077d627819..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl-quaternion.c +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - * - * Various references relating to quaternions: - * - * http://www.cs.caltech.edu/courses/cs171/quatut.pdf - * http://mathworld.wolfram.com/Quaternion.html - * http://www.gamedev.net/reference/articles/article1095.asp - * http://www.cprogramming.com/tutorial/3d/quaternions.html - * http://www.isner.com/tutorials/quatSpells/quaternion_spells_12.htm - * http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56 - * 3D Maths Primer for Graphics and Game Development ISBN-10: 1556229119 - */ - -#include "cogl-config.h" - -#include -#include -#include -#include -#include -#include -#include "cogl-gtype-private.h" - -#include -#include - -#define FLOAT_EPSILON 1e-03 - -COGL_GTYPE_DEFINE_BOXED (Quaternion, quaternion, - cogl_quaternion_copy, - cogl_quaternion_free); - -static CoglQuaternion zero_quaternion = -{ - 0.0, 0.0, 0.0, 0.0, -}; - -static CoglQuaternion identity_quaternion = -{ - 1.0, 0.0, 0.0, 0.0, -}; - -/* This function is just here to be called from GDB so we don't really - want to put a declaration in a header and we just add it here to - avoid a warning */ -void -_cogl_quaternion_print (CoglQuaternion *quarternion); - -void -_cogl_quaternion_print (CoglQuaternion *quaternion) -{ - g_print ("[ %6.4f (%6.4f, %6.4f, %6.4f)]\n", - quaternion->w, - quaternion->x, - quaternion->y, - quaternion->z); -} - -void -cogl_quaternion_init (CoglQuaternion *quaternion, - float angle, - float x, - float y, - float z) -{ - float axis[3] = { x, y, z}; - cogl_quaternion_init_from_angle_vector (quaternion, angle, axis); -} - -void -cogl_quaternion_init_from_angle_vector (CoglQuaternion *quaternion, - float angle, - const float *axis3f_in) -{ - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - float axis[3]; - float half_angle; - float sin_half_angle; - - /* XXX: Should we make cogl_vector3_normalize have separate in and - * out args? */ - axis[0] = axis3f_in[0]; - axis[1] = axis3f_in[1]; - axis[2] = axis3f_in[2]; - cogl_vector3_normalize (axis); - - half_angle = angle * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f; - sin_half_angle = sinf (half_angle); - - quaternion->w = cosf (half_angle); - - quaternion->x = axis[0] * sin_half_angle; - quaternion->y = axis[1] * sin_half_angle; - quaternion->z = axis[2] * sin_half_angle; - - cogl_quaternion_normalize (quaternion); -} - -void -cogl_quaternion_init_identity (CoglQuaternion *quaternion) -{ - quaternion->w = 1.0; - - quaternion->x = 0.0; - quaternion->y = 0.0; - quaternion->z = 0.0; -} - -void -cogl_quaternion_init_from_array (CoglQuaternion *quaternion, - const float *array) -{ - quaternion->w = array[0]; - quaternion->x = array[1]; - quaternion->y = array[2]; - quaternion->z = array[3]; -} - -void -cogl_quaternion_init_from_x_rotation (CoglQuaternion *quaternion, - float angle) -{ - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - float half_angle = angle * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f; - - quaternion->w = cosf (half_angle); - - quaternion->x = sinf (half_angle); - quaternion->y = 0.0f; - quaternion->z = 0.0f; -} - -void -cogl_quaternion_init_from_y_rotation (CoglQuaternion *quaternion, - float angle) -{ - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - float half_angle = angle * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f; - - quaternion->w = cosf (half_angle); - - quaternion->x = 0.0f; - quaternion->y = sinf (half_angle); - quaternion->z = 0.0f; -} - -void -cogl_quaternion_init_from_z_rotation (CoglQuaternion *quaternion, - float angle) -{ - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - float half_angle = angle * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f; - - quaternion->w = cosf (half_angle); - - quaternion->x = 0.0f; - quaternion->y = 0.0f; - quaternion->z = sinf (half_angle); -} - -void -cogl_quaternion_init_from_euler (CoglQuaternion *quaternion, - const CoglEuler *euler) -{ - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - float sin_heading = - sinf (euler->heading * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); - float sin_pitch = - sinf (euler->pitch * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); - float sin_roll = - sinf (euler->roll * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); - float cos_heading = - cosf (euler->heading * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); - float cos_pitch = - cosf (euler->pitch * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); - float cos_roll = - cosf (euler->roll * _COGL_QUATERNION_DEGREES_TO_RADIANS * 0.5f); - - quaternion->w = - cos_heading * cos_pitch * cos_roll + - sin_heading * sin_pitch * sin_roll; - - quaternion->x = - cos_heading * sin_pitch * cos_roll + - sin_heading * cos_pitch * sin_roll; - quaternion->y = - sin_heading * cos_pitch * cos_roll - - cos_heading * sin_pitch * sin_roll; - quaternion->z = - cos_heading * cos_pitch * sin_roll - - sin_heading * sin_pitch * cos_roll; -} - -void -cogl_quaternion_init_from_quaternion (CoglQuaternion *quaternion, - CoglQuaternion *src) -{ - memcpy (quaternion, src, sizeof (float) * 4); -} - -/* XXX: it could be nice to make something like this public... */ -/* - * COGL_MATRIX_READ: - * @MATRIX: A 4x4 transformation matrix - * @ROW: The row of the value you want to read - * @COLUMN: The column of the value you want to read - * - * Reads a value from the given matrix using integers to index - * into the matrix. - */ -#define COGL_MATRIX_READ(MATRIX, ROW, COLUMN) \ - (((const float *)matrix)[COLUMN * 4 + ROW]) - -void -cogl_quaternion_init_from_matrix (CoglQuaternion *quaternion, - const CoglMatrix *matrix) -{ - /* Algorithm devised by Ken Shoemake, Ref: - * http://campar.in.tum.de/twiki/pub/Chair/DwarfTutorial/quatut.pdf - */ - - /* 3D maths literature refers to the diagonal of a matrix as the - * "trace" of a matrix... */ - float trace = matrix->xx + matrix->yy + matrix->zz; - float root; - - if (trace > 0.0f) - { - root = sqrtf (trace + 1); - quaternion->w = root * 0.5f; - root = 0.5f / root; - quaternion->x = (matrix->zy - matrix->yz) * root; - quaternion->y = (matrix->xz - matrix->zx) * root; - quaternion->z = (matrix->yx - matrix->xy) * root; - } - else - { -#define X 0 -#define Y 1 -#define Z 2 -#define W 3 - int h = X; - if (matrix->yy > matrix->xx) - h = Y; - if (matrix->zz > COGL_MATRIX_READ (matrix, h, h)) - h = Z; - switch (h) - { -#define CASE_MACRO(i, j, k, I, J, K) \ - case I: \ - root = sqrtf ((COGL_MATRIX_READ (matrix, I, I) - \ - (COGL_MATRIX_READ (matrix, J, J) + \ - COGL_MATRIX_READ (matrix, K, K))) + \ - COGL_MATRIX_READ (matrix, W, W)); \ - quaternion->i = root * 0.5f;\ - root = 0.5f / root;\ - quaternion->j = (COGL_MATRIX_READ (matrix, I, J) + \ - COGL_MATRIX_READ (matrix, J, I)) * root; \ - quaternion->k = (COGL_MATRIX_READ (matrix, K, I) + \ - COGL_MATRIX_READ (matrix, I, K)) * root; \ - quaternion->w = (COGL_MATRIX_READ (matrix, K, J) - \ - COGL_MATRIX_READ (matrix, J, K)) * root;\ - break - CASE_MACRO (x, y, z, X, Y, Z); - CASE_MACRO (y, z, x, Y, Z, X); - CASE_MACRO (z, x, y, Z, X, Y); -#undef CASE_MACRO -#undef X -#undef Y -#undef Z - } - } - - if (matrix->ww != 1.0f) - { - float s = 1.0 / sqrtf (matrix->ww); - quaternion->w *= s; - quaternion->x *= s; - quaternion->y *= s; - quaternion->z *= s; - } -} - -gboolean -cogl_quaternion_equal (const void *v1, const void *v2) -{ - const CoglQuaternion *a = v1; - const CoglQuaternion *b = v2; - - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); - - if (v1 == v2) - return TRUE; - - return (a->w == b->w && - a->x == b->x && - a->y == b->y && - a->z == b->z); -} - -CoglQuaternion * -cogl_quaternion_copy (const CoglQuaternion *src) -{ - if (G_LIKELY (src)) - { - CoglQuaternion *new = g_slice_new (CoglQuaternion); - memcpy (new, src, sizeof (float) * 4); - return new; - } - else - return NULL; -} - -void -cogl_quaternion_free (CoglQuaternion *quaternion) -{ - g_slice_free (CoglQuaternion, quaternion); -} - -float -cogl_quaternion_get_rotation_angle (const CoglQuaternion *quaternion) -{ - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - - /* FIXME: clamp [-1, 1] */ - return 2.0f * acosf (quaternion->w) * _COGL_QUATERNION_RADIANS_TO_DEGREES; -} - -void -cogl_quaternion_get_rotation_axis (const CoglQuaternion *quaternion, - float *vector3) -{ - float sin_half_angle_sqr; - float one_over_sin_angle_over_2; - - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - - /* NB: sin²(𝜃) + cos²(𝜃) = 1 */ - - sin_half_angle_sqr = 1.0f - quaternion->w * quaternion->w; - - if (sin_half_angle_sqr <= 0.0f) - { - /* Either an identity quaternion or numerical imprecision. - * Either way we return an arbitrary vector. */ - vector3[0] = 1; - vector3[1] = 0; - vector3[2] = 0; - return; - } - - /* Calculate 1 / sin(𝜃/2) */ - one_over_sin_angle_over_2 = 1.0f / sqrtf (sin_half_angle_sqr); - - vector3[0] = quaternion->x * one_over_sin_angle_over_2; - vector3[1] = quaternion->y * one_over_sin_angle_over_2; - vector3[2] = quaternion->z * one_over_sin_angle_over_2; -} - -void -cogl_quaternion_normalize (CoglQuaternion *quaternion) -{ - float slen = _COGL_QUATERNION_NORM (quaternion); - float factor = 1.0f / sqrtf (slen); - - quaternion->x *= factor; - quaternion->y *= factor; - quaternion->z *= factor; - - quaternion->w *= factor; - - return; -} - -float -cogl_quaternion_dot_product (const CoglQuaternion *a, - const CoglQuaternion *b) -{ - return a->w * b->w + a->x * b->x + a->y * b->y + a->z * b->z; -} - -void -cogl_quaternion_invert (CoglQuaternion *quaternion) -{ - quaternion->x = -quaternion->x; - quaternion->y = -quaternion->y; - quaternion->z = -quaternion->z; -} - -void -cogl_quaternion_multiply (CoglQuaternion *result, - const CoglQuaternion *a, - const CoglQuaternion *b) -{ - float w = a->w; - float x = a->x; - float y = a->y; - float z = a->z; - - g_return_if_fail (b != result); - - result->w = w * b->w - x * b->x - y * b->y - z * b->z; - - result->x = w * b->x + x * b->w + y * b->z - z * b->y; - result->y = w * b->y + y * b->w + z * b->x - x * b->z; - result->z = w * b->z + z * b->w + x * b->y - y * b->x; -} - -void -cogl_quaternion_pow (CoglQuaternion *quaternion, float exponent) -{ - float half_angle; - float new_half_angle; - float factor; - - /* Try and identify and nop identity quaternions to avoid - * dividing by zero */ - if (fabs (quaternion->w) > 0.9999f) - return; - - /* NB: We are using quaternions to represent an axis (a), angle (𝜃) pair - * in this form: - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - */ - - /* FIXME: clamp [-1, 1] */ - /* Extract 𝜃/2 from w */ - half_angle = acosf (quaternion->w); - - /* Compute the new 𝜃/2 */ - new_half_angle = half_angle * exponent; - - /* Compute the new w value */ - quaternion->w = cosf (new_half_angle); - - /* And new xyz values */ - factor = sinf (new_half_angle) / sinf (half_angle); - quaternion->x *= factor; - quaternion->y *= factor; - quaternion->z *= factor; -} - -void -cogl_quaternion_slerp (CoglQuaternion *result, - const CoglQuaternion *a, - const CoglQuaternion *b, - float t) -{ - float cos_difference; - float qb_w; - float qb_x; - float qb_y; - float qb_z; - float fa; - float fb; - - g_return_if_fail (t >=0 && t <= 1.0f); - - if (t == 0) - { - *result = *a; - return; - } - else if (t == 1) - { - *result = *b; - return; - } - - /* compute the cosine of the angle between the two given quaternions */ - cos_difference = cogl_quaternion_dot_product (a, b); - - /* If negative, use -b. Two quaternions q and -q represent the same angle but - * may produce a different slerp. We choose b or -b to rotate using the acute - * angle. - */ - if (cos_difference < 0.0f) - { - qb_w = -b->w; - qb_x = -b->x; - qb_y = -b->y; - qb_z = -b->z; - cos_difference = -cos_difference; - } - else - { - qb_w = b->w; - qb_x = b->x; - qb_y = b->y; - qb_z = b->z; - } - - /* If we have two unit quaternions the dot should be <= 1.0 */ - g_assert (cos_difference < 1.1f); - - - /* Determine the interpolation factors for each quaternion, simply using - * linear interpolation for quaternions that are nearly exactly the same. - * (this will avoid divisions by zero) - */ - - if (cos_difference > 0.9999f) - { - fa = 1.0f - t; - fb = t; - - /* XXX: should we also normalize() at the end in this case? */ - } - else - { - /* Calculate the sin of the angle between the two quaternions using the - * trig identity: sin²(𝜃) + cos²(𝜃) = 1 - */ - float sin_difference = sqrtf (1.0f - cos_difference * cos_difference); - - float difference = atan2f (sin_difference, cos_difference); - float one_over_sin_difference = 1.0f / sin_difference; - fa = sinf ((1.0f - t) * difference) * one_over_sin_difference; - fb = sinf (t * difference) * one_over_sin_difference; - } - - /* Finally interpolate the two quaternions */ - - result->x = fa * a->x + fb * qb_x; - result->y = fa * a->y + fb * qb_y; - result->z = fa * a->z + fb * qb_z; - result->w = fa * a->w + fb * qb_w; -} - -void -cogl_quaternion_nlerp (CoglQuaternion *result, - const CoglQuaternion *a, - const CoglQuaternion *b, - float t) -{ - float cos_difference; - float qb_w; - float qb_x; - float qb_y; - float qb_z; - float fa; - float fb; - - g_return_if_fail (t >=0 && t <= 1.0f); - - if (t == 0) - { - *result = *a; - return; - } - else if (t == 1) - { - *result = *b; - return; - } - - /* compute the cosine of the angle between the two given quaternions */ - cos_difference = cogl_quaternion_dot_product (a, b); - - /* If negative, use -b. Two quaternions q and -q represent the same angle but - * may produce a different slerp. We choose b or -b to rotate using the acute - * angle. - */ - if (cos_difference < 0.0f) - { - qb_w = -b->w; - qb_x = -b->x; - qb_y = -b->y; - qb_z = -b->z; - cos_difference = -cos_difference; - } - else - { - qb_w = b->w; - qb_x = b->x; - qb_y = b->y; - qb_z = b->z; - } - - /* If we have two unit quaternions the dot should be <= 1.0 */ - g_assert (cos_difference < 1.1f); - - fa = 1.0f - t; - fb = t; - - result->x = fa * a->x + fb * qb_x; - result->y = fa * a->y + fb * qb_y; - result->z = fa * a->z + fb * qb_z; - result->w = fa * a->w + fb * qb_w; - - cogl_quaternion_normalize (result); -} - -void -cogl_quaternion_squad (CoglQuaternion *result, - const CoglQuaternion *prev, - const CoglQuaternion *a, - const CoglQuaternion *b, - const CoglQuaternion *next, - float t) -{ - CoglQuaternion slerp0; - CoglQuaternion slerp1; - - cogl_quaternion_slerp (&slerp0, a, b, t); - cogl_quaternion_slerp (&slerp1, prev, next, t); - cogl_quaternion_slerp (result, &slerp0, &slerp1, 2.0f * t * (1.0f - t)); -} - -const CoglQuaternion * -cogl_get_static_identity_quaternion (void) -{ - return &identity_quaternion; -} - -const CoglQuaternion * -cogl_get_static_zero_quaternion (void) -{ - return &zero_quaternion; -} - diff --git a/cogl/cogl/cogl-quaternion.h b/cogl/cogl/cogl-quaternion.h deleted file mode 100644 index 6e8db6bf846b7e4fe9c149fa18f49aa14cc336bb..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl-quaternion.h +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __COGL_QUATERNION_H__ -#define __COGL_QUATERNION_H__ - -#include -#include - -G_BEGIN_DECLS - -/** - * SECTION:cogl-quaternion - * @short_description: Functions for initializing and manipulating - * quaternions. - * - * Quaternions have become a standard form for representing 3D - * rotations and have some nice properties when compared with other - * representation such as (roll,pitch,yaw) Euler angles. They can be - * used to interpolate between different rotations and they don't - * suffer from a problem called - * "Gimbal lock" - * where two of the axis of rotation may become aligned and you loose a - * degree of freedom. - * . - */ -#include -#include - -#include - -/** - * CoglQuaternion: - * @w: based on the angle of rotation it is cos(𝜃/2) - * @x: based on the angle of rotation and x component of the axis of - * rotation it is sin(𝜃/2)*axis.x - * @y: based on the angle of rotation and y component of the axis of - * rotation it is sin(𝜃/2)*axis.y - * @z: based on the angle of rotation and z component of the axis of - * rotation it is sin(𝜃/2)*axis.z - * - * A quaternion is comprised of a scalar component and a 3D vector - * component. The scalar component is normally referred to as w and the - * vector might either be referred to as v or a (for axis) or expanded - * with the individual components: (x, y, z) A full quaternion would - * then be written as [w (x, y, z)]. - * - * Quaternions can be considered to represent an axis and angle - * pair although sadly these numbers are buried somewhat under some - * maths... - * - * For the curious you can see here that a given axis (a) and angle (𝜃) - * pair are represented in a quaternion as follows: - * |[ - * [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] - * ]| - * - * Unit Quaternions: - * When using Quaternions to represent spatial orientations for 3D - * graphics it's always assumed you have a unit quaternion. The - * magnitude of a quaternion is defined as: - * |[ - * sqrt (w² + x² + y² + z²) - * ]| - * and a unit quaternion satisfies this equation: - * |[ - * w² + x² + y² + z² = 1 - * ]| - * - * Thankfully most of the time we don't actually have to worry about - * the maths that goes on behind the scenes but if you are curious to - * learn more here are some external references: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * 3D Maths Primer for Graphics and Game Development ISBN-10: 1556229119 - * - * - * - * - * - * - * - * - * - */ -struct _CoglQuaternion -{ - /*< public >*/ - float w; - - float x; - float y; - float z; - - /*< private >*/ - float padding0; - float padding1; - float padding2; - float padding3; -}; -COGL_STRUCT_SIZE_ASSERT (CoglQuaternion, 32); - -/** - * cogl_quaternion_get_gtype: - * - * Returns: a #GType that can be used with the GLib type system. - */ -GType cogl_quaternion_get_gtype (void); - -/** - * cogl_quaternion_init: - * @quaternion: An uninitialized #CoglQuaternion - * @angle: The angle you want to rotate around the given axis - * @x: The x component of your axis vector about which you want to - * rotate. - * @y: The y component of your axis vector about which you want to - * rotate. - * @z: The z component of your axis vector about which you want to - * rotate. - * - * Initializes a quaternion that rotates @angle degrees around the - * axis vector (@x, @y, @z). The axis vector does not need to be - * normalized. - * - * Returns: A normalized, unit quaternion representing an orientation - * rotated @angle degrees around the axis vector (@x, @y, @z) - * - * Since: 2.0 - */ -void -cogl_quaternion_init (CoglQuaternion *quaternion, - float angle, - float x, - float y, - float z); - -/** - * cogl_quaternion_init_from_angle_vector: - * @quaternion: An uninitialized #CoglQuaternion - * @angle: The angle to rotate around @axis3f - * @axis3f: your 3 component axis vector about which you want to rotate. - * - * Initializes a quaternion that rotates @angle degrees around the - * given @axis vector. The axis vector does not need to be - * normalized. - * - * Returns: A normalized, unit quaternion representing an orientation - * rotated @angle degrees around the given @axis vector. - * - * Since: 2.0 - */ -void -cogl_quaternion_init_from_angle_vector (CoglQuaternion *quaternion, - float angle, - const float *axis3f); - -/** - * cogl_quaternion_init_identity: - * @quaternion: An uninitialized #CoglQuaternion - * - * Initializes the quaternion with the canonical quaternion identity - * [1 (0, 0, 0)] which represents no rotation. Multiplying a - * quaternion with this identity leaves the quaternion unchanged. - * - * You might also want to consider using - * cogl_get_static_identity_quaternion(). - * - * Since: 2.0 - */ -void -cogl_quaternion_init_identity (CoglQuaternion *quaternion); - -/** - * cogl_quaternion_init_from_array: - * @quaternion: A #CoglQuaternion - * @array: An array of 4 floats w,(x,y,z) - * - * Initializes a [w (x, y,z)] quaternion directly from an array of 4 - * floats: [w,x,y,z]. - * - * Since: 2.0 - */ -void -cogl_quaternion_init_from_array (CoglQuaternion *quaternion, - const float *array); - -/** - * cogl_quaternion_init_from_x_rotation: - * @quaternion: An uninitialized #CoglQuaternion - * @angle: The angle to rotate around the x axis - * - * XXX: check which direction this rotates - * - * Since: 2.0 - */ -void -cogl_quaternion_init_from_x_rotation (CoglQuaternion *quaternion, - float angle); - -/** - * cogl_quaternion_init_from_y_rotation: - * @quaternion: An uninitialized #CoglQuaternion - * @angle: The angle to rotate around the y axis - * - * - * Since: 2.0 - */ -void -cogl_quaternion_init_from_y_rotation (CoglQuaternion *quaternion, - float angle); - -/** - * cogl_quaternion_init_from_z_rotation: - * @quaternion: An uninitialized #CoglQuaternion - * @angle: The angle to rotate around the z axis - * - * - * Since: 2.0 - */ -void -cogl_quaternion_init_from_z_rotation (CoglQuaternion *quaternion, - float angle); - -/** - * cogl_quaternion_init_from_euler: - * @quaternion: A #CoglQuaternion - * @euler: A #CoglEuler with which to initialize the quaternion - * - * Since: 2.0 - */ -void -cogl_quaternion_init_from_euler (CoglQuaternion *quaternion, - const CoglEuler *euler); - -/** - * cogl_quaternion_init_from_quaternion: - * @quaternion: A #CoglQuaternion - * @src: A #CoglQuaternion with which to initialize @quaternion - * - * Since: 2.0 - */ -void -cogl_quaternion_init_from_quaternion (CoglQuaternion *quaternion, - CoglQuaternion *src); - -/** - * cogl_quaternion_init_from_matrix: - * @quaternion: A Cogl Quaternion - * @matrix: A rotation matrix with which to initialize the quaternion - * - * Initializes a quaternion from a rotation matrix. - * - * Since: 1.10 - * Stability: unstable - */ -void -cogl_quaternion_init_from_matrix (CoglQuaternion *quaternion, - const CoglMatrix *matrix); - -/** - * cogl_quaternion_equal: - * @v1: A #CoglQuaternion - * @v2: A #CoglQuaternion - * - * Compares that all the components of quaternions @a and @b are - * equal. - * - * An epsilon value is not used to compare the float components, but - * the == operator is at least used so that 0 and -0 are considered - * equal. - * - * Returns: %TRUE if the quaternions are equal else %FALSE. - * - * Since: 2.0 - */ -gboolean -cogl_quaternion_equal (const void *v1, const void *v2); - -/** - * cogl_quaternion_copy: - * @src: A #CoglQuaternion - * - * Allocates a new #CoglQuaternion on the stack and initializes it with - * the same values as @src. - * - * Returns: A newly allocated #CoglQuaternion which should be freed - * using cogl_quaternion_free() - * - * Since: 2.0 - */ -CoglQuaternion * -cogl_quaternion_copy (const CoglQuaternion *src); - -/** - * cogl_quaternion_free: - * @quaternion: A #CoglQuaternion - * - * Frees a #CoglQuaternion that was previously allocated via - * cogl_quaternion_copy(). - * - * Since: 2.0 - */ -void -cogl_quaternion_free (CoglQuaternion *quaternion); - -/** - * cogl_quaternion_get_rotation_angle: - * @quaternion: A #CoglQuaternion - * - * - * Since: 2.0 - */ -float -cogl_quaternion_get_rotation_angle (const CoglQuaternion *quaternion); - -/** - * cogl_quaternion_get_rotation_axis: - * @quaternion: A #CoglQuaternion - * @vector3: (out): an allocated 3-float array - * - * Since: 2.0 - */ -void -cogl_quaternion_get_rotation_axis (const CoglQuaternion *quaternion, - float *vector3); - -/** - * cogl_quaternion_normalize: - * @quaternion: A #CoglQuaternion - * - * - * Since: 2.0 - */ -void -cogl_quaternion_normalize (CoglQuaternion *quaternion); - -/** - * cogl_quaternion_dot_product: - * @a: A #CoglQuaternion - * @b: A #CoglQuaternion - * - * Since: 2.0 - */ -float -cogl_quaternion_dot_product (const CoglQuaternion *a, - const CoglQuaternion *b); - -/** - * cogl_quaternion_invert: - * @quaternion: A #CoglQuaternion - * - * - * Since: 2.0 - */ -void -cogl_quaternion_invert (CoglQuaternion *quaternion); - -/** - * cogl_quaternion_multiply: - * @result: The destination #CoglQuaternion - * @left: The second #CoglQuaternion rotation to apply - * @right: The first #CoglQuaternion rotation to apply - * - * This combines the rotations of two quaternions into @result. The - * operation is not commutative so the order is important because AxB - * != BxA. Cogl follows the standard convention for quaternions here - * so the rotations are applied @right to @left. This is similar to the - * combining of matrices. - * - * It is possible to multiply the @a quaternion in-place, so - * @result can be equal to @a but can't be equal to @b. - * - * Since: 2.0 - */ -void -cogl_quaternion_multiply (CoglQuaternion *result, - const CoglQuaternion *left, - const CoglQuaternion *right); - -/** - * cogl_quaternion_pow: - * @quaternion: A #CoglQuaternion - * @exponent: the exponent - * - * - * Since: 2.0 - */ -void -cogl_quaternion_pow (CoglQuaternion *quaternion, float exponent); - -/** - * cogl_quaternion_slerp: - * @result: The destination #CoglQuaternion - * @a: The first #CoglQuaternion - * @b: The second #CoglQuaternion - * @t: The factor in the range [0,1] used to interpolate between - * quaternion @a and @b. - * - * Performs a spherical linear interpolation between two quaternions. - * - * Noteable properties: - * - * - * commutative: No - * - * - * constant velocity: Yes - * - * - * torque minimal (travels along the surface of the 4-sphere): Yes - * - * - * more expensive than cogl_quaternion_nlerp() - * - * - */ -void -cogl_quaternion_slerp (CoglQuaternion *result, - const CoglQuaternion *a, - const CoglQuaternion *b, - float t); - -/** - * cogl_quaternion_nlerp: - * @result: The destination #CoglQuaternion - * @a: The first #CoglQuaternion - * @b: The second #CoglQuaternion - * @t: The factor in the range [0,1] used to interpolate between - * quaterion @a and @b. - * - * Performs a normalized linear interpolation between two quaternions. - * That is it does a linear interpolation of the quaternion components - * and then normalizes the result. This will follow the shortest arc - * between the two orientations (just like the slerp() function) but - * will not progress at a constant speed. Unlike slerp() nlerp is - * commutative which is useful if you are blending animations - * together. (I.e. nlerp (tmp, a, b) followed by nlerp (result, tmp, - * d) is the same as nlerp (tmp, a, d) followed by nlerp (result, tmp, - * b)). Finally nlerp is cheaper than slerp so it can be a good choice - * if you don't need the constant speed property of the slerp() function. - * - * Notable properties: - * - * - * commutative: Yes - * - * - * constant velocity: No - * - * - * torque minimal (travels along the surface of the 4-sphere): Yes - * - * - * faster than cogl_quaternion_slerp() - * - * - */ -void -cogl_quaternion_nlerp (CoglQuaternion *result, - const CoglQuaternion *a, - const CoglQuaternion *b, - float t); -/** - * cogl_quaternion_squad: - * @result: The destination #CoglQuaternion - * @prev: A #CoglQuaternion used before @a - * @a: The first #CoglQuaternion - * @b: The second #CoglQuaternion - * @next: A #CoglQuaternion that will be used after @b - * @t: The factor in the range [0,1] used to interpolate between - * quaternion @a and @b. - * - * - * Since: 2.0 - */ -void -cogl_quaternion_squad (CoglQuaternion *result, - const CoglQuaternion *prev, - const CoglQuaternion *a, - const CoglQuaternion *b, - const CoglQuaternion *next, - float t); - -/** - * cogl_get_static_identity_quaternion: - * - * Returns a pointer to a singleton quaternion constant describing the - * canonical identity [1 (0, 0, 0)] which represents no rotation. - * - * If you multiply a quaternion with the identity quaternion you will - * get back the same value as the original quaternion. - * - * Returns: A pointer to an identity quaternion - * - * Since: 2.0 - */ -const CoglQuaternion * -cogl_get_static_identity_quaternion (void); - -/** - * cogl_get_static_zero_quaternion: - * - * Returns: a pointer to a singleton quaternion constant describing a - * rotation of 180 degrees around a degenerate axis: - * [0 (0, 0, 0)] - * - * Since: 2.0 - */ -const CoglQuaternion * -cogl_get_static_zero_quaternion (void); - -G_END_DECLS - -#endif /* __COGL_QUATERNION_H__ */ - diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h index da30242cc7bf8ba04d9159607be462b3b1c819fe..7906287e4373d8d2421c83b681089db72e22b035 100644 --- a/cogl/cogl/cogl-types.h +++ b/cogl/cogl/cogl-types.h @@ -85,17 +85,9 @@ GType cogl_handle_get_type (void) G_GNUC_CONST; /* We forward declare this in cogl-types to avoid circular dependencies - * between cogl-matrix.h, cogl-euler.h and cogl-quaterion.h */ + * between cogl-matrix.h and cogl-quaterion.h */ typedef struct _CoglMatrix CoglMatrix; -/* Same as above we forward declared CoglQuaternion to avoid - * circular dependencies. */ -typedef struct _CoglQuaternion CoglQuaternion; - -/* Same as above we forward declared CoglEuler to avoid - * circular dependencies. */ -typedef struct _CoglEuler CoglEuler; - /** * CoglAngle: * @@ -254,41 +246,6 @@ typedef enum COGL_TEXTURE_NO_ATLAS = 1 << 2 } CoglTextureFlags; -/** - * CoglFogMode: - * @COGL_FOG_MODE_LINEAR: Calculates the fog blend factor as: - * |[ - * f = end - eye_distance / end - start - * ]| - * @COGL_FOG_MODE_EXPONENTIAL: Calculates the fog blend factor as: - * |[ - * f = e ^ -(density * eye_distance) - * ]| - * @COGL_FOG_MODE_EXPONENTIAL_SQUARED: Calculates the fog blend factor as: - * |[ - * f = e ^ -(density * eye_distance)^2 - * ]| - * - * The fog mode determines the equation used to calculate the fogging blend - * factor while fogging is enabled. The simplest %COGL_FOG_MODE_LINEAR mode - * determines f as: - * - * |[ - * f = end - eye_distance / end - start - * ]| - * - * Where eye_distance is the distance of the current fragment in eye - * coordinates from the origin. - * - * Since: 1.0 - */ -typedef enum -{ - COGL_FOG_MODE_LINEAR, - COGL_FOG_MODE_EXPONENTIAL, - COGL_FOG_MODE_EXPONENTIAL_SQUARED -} CoglFogMode; - /** * COGL_BLEND_STRING_ERROR: * diff --git a/cogl/cogl/cogl-vector.c b/cogl/cogl/cogl-vector.c deleted file mode 100644 index 4a9da42c47bc3f02e497041048bf814c233201e4..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl-vector.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#include "cogl-config.h" - -#include -#include - -#include -#include -#include - -#define X 0 -#define Y 1 -#define Z 2 -#define W 3 - -void -cogl_vector3_init (float *vector, float x, float y, float z) -{ - vector[X] = x; - vector[Y] = y; - vector[Z] = z; -} - -void -cogl_vector3_init_zero (float *vector) -{ - memset (vector, 0, sizeof (float) * 3); -} - -gboolean -cogl_vector3_equal (const void *v1, const void *v2) -{ - float *vector0 = (float *)v1; - float *vector1 = (float *)v2; - - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); - - /* There's no point picking an arbitrary epsilon that's appropriate - * for comparing the components so we just use == that will at least - * consider -0 and 0 to be equal. */ - return - vector0[X] == vector1[X] && - vector0[Y] == vector1[Y] && - vector0[Z] == vector1[Z]; -} - -gboolean -cogl_vector3_equal_with_epsilon (const float *vector0, - const float *vector1, - float epsilon) -{ - g_return_val_if_fail (vector0 != NULL, FALSE); - g_return_val_if_fail (vector1 != NULL, FALSE); - - if (fabsf (vector0[X] - vector1[X]) < epsilon && - fabsf (vector0[Y] - vector1[Y]) < epsilon && - fabsf (vector0[Z] - vector1[Z]) < epsilon) - return TRUE; - else - return FALSE; -} - -float * -cogl_vector3_copy (const float *vector) -{ - if (vector) - return g_slice_copy (sizeof (float) * 3, vector); - return NULL; -} - -void -cogl_vector3_free (float *vector) -{ - g_slice_free1 (sizeof (float) * 3, vector); -} - -void -cogl_vector3_invert (float *vector) -{ - vector[X] = -vector[X]; - vector[Y] = -vector[Y]; - vector[Z] = -vector[Z]; -} - -void -cogl_vector3_add (float *result, - const float *a, - const float *b) -{ - result[X] = a[X] + b[X]; - result[Y] = a[Y] + b[Y]; - result[Z] = a[Z] + b[Z]; -} - -void -cogl_vector3_subtract (float *result, - const float *a, - const float *b) -{ - result[X] = a[X] - b[X]; - result[Y] = a[Y] - b[Y]; - result[Z] = a[Z] - b[Z]; -} - -void -cogl_vector3_multiply_scalar (float *vector, - float scalar) -{ - vector[X] *= scalar; - vector[Y] *= scalar; - vector[Z] *= scalar; -} - -void -cogl_vector3_divide_scalar (float *vector, - float scalar) -{ - float one_over_scalar = 1.0f / scalar; - vector[X] *= one_over_scalar; - vector[Y] *= one_over_scalar; - vector[Z] *= one_over_scalar; -} - -void -cogl_vector3_normalize (float *vector) -{ - float mag_squared = - vector[X] * vector[X] + - vector[Y] * vector[Y] + - vector[Z] * vector[Z]; - - if (mag_squared > 0.0f) - { - float one_over_mag = 1.0f / sqrtf (mag_squared); - vector[X] *= one_over_mag; - vector[Y] *= one_over_mag; - vector[Z] *= one_over_mag; - } -} - -float -cogl_vector3_magnitude (const float *vector) -{ - return sqrtf (vector[X] * vector[X] + - vector[Y] * vector[Y] + - vector[Z] * vector[Z]); -} - -void -cogl_vector3_cross_product (float *result, - const float *a, - const float *b) -{ - float tmp[3]; - - tmp[X] = a[Y] * b[Z] - a[Z] * b[Y]; - tmp[Y] = a[Z] * b[X] - a[X] * b[Z]; - tmp[Z] = a[X] * b[Y] - a[Y] * b[X]; - result[X] = tmp[X]; - result[Y] = tmp[Y]; - result[Z] = tmp[Z]; -} - -float -cogl_vector3_dot_product (const float *a, const float *b) -{ - return a[X] * b[X] + a[Y] * b[Y] + a[Z] * b[Z]; -} - -float -cogl_vector3_distance (const float *a, const float *b) -{ - float dx = b[X] - a[X]; - float dy = b[Y] - a[Y]; - float dz = b[Z] - a[Z]; - - return sqrtf (dx * dx + dy * dy + dz * dz); -} - -#if 0 -void -cogl_vector4_init (float *vector, float x, float y, float z) -{ - vector[X] = x; - vector[Y] = y; - vector[Z] = z; - vector[W] = w; -} - -void -cogl_vector4_init_zero (float *vector) -{ - memset (vector, 0, sizeof (CoglVector4)); -} - -void -cogl_vector4_init_from_vector4 (float *vector, float *src) -{ - *vector4 = *src; -} - -gboolean -cogl_vector4_equal (const void *v0, const void *v1) -{ - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); - - return memcmp (v1, v2, sizeof (float) * 4) == 0 ? TRUE : FALSE; -} - -float * -cogl_vector4_copy (float *vector) -{ - if (vector) - return g_slice_dup (CoglVector4, vector); - return NULL; -} - -void -cogl_vector4_free (float *vector) -{ - g_slice_free (CoglVector4, vector); -} - -void -cogl_vector4_invert (float *vector) -{ - vector.x = -vector.x; - vector.y = -vector.y; - vector.z = -vector.z; - vector.w = -vector.w; -} - -void -cogl_vector4_add (float *result, - float *a, - float *b) -{ - result.x = a.x + b.x; - result.y = a.y + b.y; - result.z = a.z + b.z; - result.w = a.w + b.w; -} - -void -cogl_vector4_subtract (float *result, - float *a, - float *b) -{ - result.x = a.x - b.x; - result.y = a.y - b.y; - result.z = a.z - b.z; - result.w = a.w - b.w; -} - -void -cogl_vector4_divide (float *vector, - float scalar) -{ - float one_over_scalar = 1.0f / scalar; - result.x *= one_over_scalar; - result.y *= one_over_scalar; - result.z *= one_over_scalar; - result.w *= one_over_scalar; -} - -#endif diff --git a/cogl/cogl/cogl-vector.h b/cogl/cogl/cogl-vector.h deleted file mode 100644 index 8518d42680593bc4b9dfb6a9cc02be74cf8f9dd8..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl-vector.h +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2008,2009,2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __COGL_VECTOR_H -#define __COGL_VECTOR_H - -G_BEGIN_DECLS - -/** - * SECTION:cogl-vector - * @short_description: Functions for handling single precision float - * vectors. - * - * This exposes a utility API that can be used for basic manipulation of 3 - * component float vectors. - */ - -/** - * cogl_vector3_init: - * @vector: The 3 component vector you want to initialize - * @x: The x component - * @y: The y component - * @z: The z component - * - * Initializes a 3 component, single precision float vector which can - * then be manipulated with the cogl_vector convenience APIs. Vectors - * can also be used in places where a "point" is often desired. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_init (float *vector, float x, float y, float z); - -/** - * cogl_vector3_init_zero: - * @vector: The 3 component vector you want to initialize - * - * Initializes a 3 component, single precision float vector with zero - * for each component. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_init_zero (float *vector); - -/** - * cogl_vector3_equal: - * @v1: The first 3 component vector you want to compare - * @v2: The second 3 component vector you want to compare - * - * Compares the components of two vectors and returns TRUE if they are - * the same. - * - * The comparison of the components is done with the '==' operator - * such that -0 is considered equal to 0, but otherwise there is no - * fuzziness such as an epsilon to consider vectors that are - * essentially identical except for some minor precision error - * differences due to the way they have been manipulated. - * - * Returns: TRUE if the vectors are equal else FALSE. - * - * Since: 1.4 - * Stability: Unstable - */ -gboolean -cogl_vector3_equal (const void *v1, const void *v2); - -/** - * cogl_vector3_equal_with_epsilon: - * @vector0: The first 3 component vector you want to compare - * @vector1: The second 3 component vector you want to compare - * @epsilon: The allowable difference between components to still be - * considered equal - * - * Compares the components of two vectors using the given epsilon and - * returns TRUE if they are the same, using an internal epsilon for - * comparing the floats. - * - * Each component is compared against the epsilon value in this way: - * |[ - * if (fabsf (vector0->x - vector1->x) < epsilon) - * ]| - * - * Returns: TRUE if the vectors are equal else FALSE. - * - * Since: 1.4 - * Stability: Unstable - */ -gboolean -cogl_vector3_equal_with_epsilon (const float *vector0, - const float *vector1, - float epsilon); - -/** - * cogl_vector3_copy: - * @vector: The 3 component vector you want to copy - * - * Allocates a new 3 component float vector on the heap initializing - * the components from the given @vector and returns a pointer to the - * newly allocated vector. You should free the memory using - * cogl_vector3_free() - * - * Returns: A newly allocated 3 component float vector - * - * Since: 1.4 - * Stability: Unstable - */ -float * -cogl_vector3_copy (const float *vector); - -/** - * cogl_vector3_free: - * @vector: The 3 component you want to free - * - * Frees a 3 component vector that was previously allocated with - * cogl_vector3_copy() - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_free (float *vector); - -/** - * cogl_vector3_invert: - * @vector: The 3 component vector you want to manipulate - * - * Inverts/negates all the components of the given @vector. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_invert (float *vector); - -/** - * cogl_vector3_add: - * @result: Where you want the result written - * @a: The first vector operand - * @b: The second vector operand - * - * Adds each of the corresponding components in vectors @a and @b - * storing the results in @result. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_add (float *result, - const float *a, - const float *b); - -/** - * cogl_vector3_subtract: - * @result: Where you want the result written - * @a: The first vector operand - * @b: The second vector operand - * - * Subtracts each of the corresponding components in vector @b from - * @a storing the results in @result. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_subtract (float *result, - const float *a, - const float *b); - -/** - * cogl_vector3_multiply_scalar: - * @vector: The 3 component vector you want to manipulate - * @scalar: The scalar you want to multiply the vector components by - * - * Multiplies each of the @vector components by the given scalar. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_multiply_scalar (float *vector, - float scalar); - -/** - * cogl_vector3_divide_scalar: - * @vector: The 3 component vector you want to manipulate - * @scalar: The scalar you want to divide the vector components by - * - * Divides each of the @vector components by the given scalar. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_divide_scalar (float *vector, - float scalar); - -/** - * cogl_vector3_normalize: - * @vector: The 3 component vector you want to manipulate - * - * Updates the vector so it is a "unit vector" such that the - * @vectors magnitude or length is equal to 1. - * - * It's safe to use this function with the [0, 0, 0] vector, it will not - * try to divide components by 0 (its norm) and will leave the vector - * untouched. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_normalize (float *vector); - -/** - * cogl_vector3_magnitude: - * @vector: The 3 component vector you want the magnitude for - * - * Calculates the scalar magnitude or length of @vector. - * - * Returns: The magnitude of @vector. - * - * Since: 1.4 - * Stability: Unstable - */ -float -cogl_vector3_magnitude (const float *vector); - -/** - * cogl_vector3_cross_product: - * @result: Where you want the result written - * @u: Your first 3 component vector - * @v: Your second 3 component vector - * - * Calculates the cross product between the two vectors @u and @v. - * - * The cross product is a vector perpendicular to both @u and @v. This - * can be useful for calculating the normal of a polygon by creating - * two vectors in its plane using the polygons vertices and taking - * their cross product. - * - * If the two vectors are parallel then the cross product is 0. - * - * You can use a right hand rule to determine which direction the - * perpendicular vector will point: If you place the two vectors tail, - * to tail and imagine grabbing the perpendicular line that extends - * through the common tail with your right hand such that you fingers - * rotate in the direction from @u to @v then the resulting vector - * points along your extended thumb. - * - * Returns: The cross product between two vectors @u and @v. - * - * Since: 1.4 - * Stability: Unstable - */ -void -cogl_vector3_cross_product (float *result, - const float *u, - const float *v); - -/** - * cogl_vector3_dot_product: - * @a: Your first 3 component vector - * @b: Your second 3 component vector - * - * Calculates the dot product of the two 3 component vectors. This - * can be used to determine the magnitude of one vector projected onto - * another. (for example a surface normal) - * - * For example if you have a polygon with a given normal vector and - * some other point for which you want to calculate its distance from - * the polygon, you can create a vector between one of the polygon - * vertices and that point and use the dot product to calculate the - * magnitude for that vector but projected onto the normal of the - * polygon. This way you don't just get the distance from the point to - * the edge of the polygon you get the distance from the point to the - * nearest part of the polygon. - * - * If you don't use a unit length normal in the above example - * then you would then also have to divide the result by the magnitude - * of the normal - * - * The dot product is calculated as: - * |[ - * (a->x * b->x + a->y * b->y + a->z * b->z) - * ]| - * - * For reference, the dot product can also be calculated from the - * angle between two vectors as: - * |[ - * |a||b|cos𝜃 - * ]| - * - * Returns: The dot product of two vectors. - * - * Since: 1.4 - * Stability: Unstable - */ -float -cogl_vector3_dot_product (const float *a, const float *b); - -/** - * cogl_vector3_distance: - * @a: The first point - * @b: The second point - * - * If you consider the two given vectors as (x,y,z) points instead - * then this will compute the distance between those two points. - * - * Returns: The distance between two points given as 3 component - * vectors. - * - * Since: 1.4 - * Stability: Unstable - */ -float -cogl_vector3_distance (const float *a, const float *b); - -G_END_DECLS - -#endif /* __COGL_VECTOR_H */ - diff --git a/cogl/cogl/cogl.c b/cogl/cogl/cogl.c index c90a9bde1b5f92faa74ad07460ddac2f035667c8..19217f692a194bb4fd925c73fa9d7ef2d4fccc2e 100644 --- a/cogl/cogl/cogl.c +++ b/cogl/cogl/cogl.c @@ -279,37 +279,6 @@ cogl_get_bitmasks (int *red, *alpha = cogl_framebuffer_get_alpha_bits (framebuffer); } -void -cogl_set_fog (const CoglColor *fog_color, - CoglFogMode mode, - float density, - float z_near, - float z_far) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (ctx->legacy_fog_state.enabled == FALSE) - ctx->legacy_state_set++; - - ctx->legacy_fog_state.enabled = TRUE; - ctx->legacy_fog_state.color = *fog_color; - ctx->legacy_fog_state.mode = mode; - ctx->legacy_fog_state.density = density; - ctx->legacy_fog_state.z_near = z_near; - ctx->legacy_fog_state.z_far = z_far; -} - -void -cogl_disable_fog (void) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (ctx->legacy_fog_state.enabled == TRUE) - ctx->legacy_state_set--; - - ctx->legacy_fog_state.enabled = FALSE; -} - void cogl_flush (void) { diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index 1c251cc88a9f3b4f3a3922f172c9870bbe23cc22..d93cb1b0919c7c3de80bfc26dde4a7f21023a5a1 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -42,6 +42,8 @@ #define __COGL_MUST_UNDEF_COGL_H_INSIDE__ #endif +#include + /* We currently keep gtype integration delimited in case we eventually * want to split it out into a separate utility library when Cogl * becomes a standalone project. (like cairo-gobject.so) @@ -99,9 +101,6 @@ #include #include #include -#include -#include -#include #include #include #include diff --git a/cogl/cogl/cogl.symbols b/cogl/cogl/cogl.symbols index df268d81d89b2bcb710cfc9b3b81fef6ce717334..d3d9140952bbe428b108b08222f064f2e37a9b41 100644 --- a/cogl/cogl/cogl.symbols +++ b/cogl/cogl/cogl.symbols @@ -184,8 +184,6 @@ cogl_depth_state_set_range cogl_depth_state_set_write_enabled cogl_depth_test_function_get_type -cogl_disable_fog - #ifdef COGL_HAS_GTYPE_SUPPORT cogl_display_get_gtype #endif @@ -196,19 +194,6 @@ cogl_display_set_onscreen_template cogl_double_to_fixed -cogl_euler_copy -cogl_euler_equal -cogl_euler_free -#ifdef COGL_HAS_GTYPE_SUPPORT -cogl_euler_get_gtype -#endif -cogl_euler_init -cogl_euler_init_from_matrix -#if 0 -/* not yet implemented */ -cogl_euler_init_from_quaternion -#endif - cogl_features_available cogl_feature_flags_get_type cogl_fence_closure_get_user_data @@ -223,8 +208,6 @@ cogl_fixed_sin cogl_fixed_sqrt cogl_fixed_tan -cogl_fog_mode_get_type - cogl_foreach_feature cogl_flush @@ -283,7 +266,6 @@ cogl_framebuffer_rotate #ifdef COGL_ENABLE_EXPERIMENTAL_API cogl_framebuffer_rotate_euler -cogl_framebuffer_rotate_quaternion #endif cogl_framebuffer_scale @@ -326,8 +308,6 @@ cogl_get_proc_address cogl_get_projection_matrix cogl_get_rectangle_indices cogl_get_source -cogl_get_static_identity_quaternion -cogl_get_static_zero_quaternion cogl_get_viewport #ifdef COGL_HAS_GLIB_SUPPORT @@ -475,7 +455,6 @@ cogl_matrix_init_from_array cogl_matrix_init_translation cogl_matrix_is_identity cogl_matrix_init_from_euler -cogl_matrix_init_from_quaternion cogl_matrix_init_identity cogl_matrix_look_at cogl_matrix_multiply @@ -489,7 +468,6 @@ cogl_matrix_rotate #ifdef COGL_ENABLE_EXPERIMENTAL_API cogl_matrix_rotate_euler -cogl_matrix_rotate_quaternion #endif cogl_matrix_scale @@ -509,7 +487,6 @@ cogl_matrix_stack_pop cogl_matrix_stack_push cogl_matrix_stack_rotate cogl_matrix_stack_rotate_euler -cogl_matrix_stack_rotate_quaternion cogl_matrix_stack_scale cogl_matrix_stack_set cogl_matrix_stack_translate @@ -738,31 +715,6 @@ cogl_push_framebuffer cogl_push_matrix cogl_push_source -cogl_quaternion_copy -cogl_quaternion_dot_product -cogl_quaternion_equal -cogl_quaternion_free -#ifdef COGL_HAS_GTYPE_SUPPORT -cogl_quaternion_get_gtype -#endif -cogl_quaternion_get_rotation_angle -cogl_quaternion_get_rotation_axis -cogl_quaternion_init -cogl_quaternion_init_from_angle_vector -cogl_quaternion_init_from_array -cogl_quaternion_init_from_euler -cogl_quaternion_init_from_x_rotation -cogl_quaternion_init_from_y_rotation -cogl_quaternion_init_from_z_rotation -cogl_quaternion_init_identity -cogl_quaternion_invert -cogl_quaternion_multiply -cogl_quaternion_nlerp -cogl_quaternion_normalize -cogl_quaternion_pow -cogl_quaternion_slerp -cogl_quaternion_squad - cogl_read_pixels cogl_read_pixels_flags_get_type @@ -797,7 +749,6 @@ cogl_set_depth_test_enabled #ifndef COGL_DISABLE_DEPRECATED cogl_set_draw_buffer #endif -cogl_set_fog #ifdef COGL_HAS_SDL_SUPPORT cogl_sdl_context_new cogl_sdl_handle_event @@ -934,23 +885,6 @@ cogl_texture_2d_sliced_new_with_size cogl_transform cogl_translate -cogl_vector3_add -cogl_vector3_copy -cogl_vector3_cross_product -cogl_vector3_distance -cogl_vector3_divide_scalar -cogl_vector3_dot_product -cogl_vector3_equal -cogl_vector3_equal_with_epsilon -cogl_vector3_free -cogl_vector3_init -cogl_vector3_init_zero -cogl_vector3_invert -cogl_vector3_magnitude -cogl_vector3_multiply_scalar -cogl_vector3_normalize -cogl_vector3_subtract - cogl_vertex_buffer_add cogl_vertex_buffer_delete cogl_vertex_buffer_disable diff --git a/cogl/cogl/cogl1-context.h b/cogl/cogl/cogl1-context.h index d9837f9504e3d79943788f8a329f843168dc7c27..7c3908bbdbd2e4b59b0baed0dc519e6eca246563 100644 --- a/cogl/cogl/cogl1-context.h +++ b/cogl/cogl/cogl1-context.h @@ -496,53 +496,6 @@ COGL_DEPRECATED_FOR (cogl_pipeline_get_cull_face_mode) gboolean cogl_get_backface_culling_enabled (void); -/** - * cogl_set_fog: - * @fog_color: The color of the fog - * @mode: A #CoglFogMode that determines the equation used to calculate the - * fogging blend factor. - * @density: Used by %COGL_FOG_MODE_EXPONENTIAL and by - * %COGL_FOG_MODE_EXPONENTIAL_SQUARED equations. - * @z_near: Position along Z axis where no fogging should be applied - * @z_far: Position along Z axis where full fogging should be applied - * - * Enables fogging. Fogging causes vertices that are further away from the eye - * to be rendered with a different color. The color is determined according to - * the chosen fog mode; at it's simplest the color is linearly interpolated so - * that vertices at @z_near are drawn fully with their original color and - * vertices at @z_far are drawn fully with @fog_color. Fogging will remain - * enabled until you call cogl_disable_fog(). - * - * The fogging functions only work correctly when primitives use - * unmultiplied alpha colors. By default Cogl will premultiply textures - * and cogl_set_source_color() will premultiply colors, so unless you - * explicitly load your textures requesting an unmultiplied internal format - * and use cogl_material_set_color() you can only use fogging with fully - * opaque primitives. This might improve in the future when we can depend - * on fragment shaders. - * - * Deprecated: 1.16: Use #CoglSnippet shader api for fog - */ -COGL_DEPRECATED_FOR (cogl_snippet_API) -void -cogl_set_fog (const CoglColor *fog_color, - CoglFogMode mode, - float density, - float z_near, - float z_far); - -/** - * cogl_disable_fog: - * - * This function disables fogging, so primitives drawn afterwards will not be - * blended with any previously set fog color. - * - * Deprecated: 1.16: Use #CoglSnippet shader api for fog - */ -COGL_DEPRECATED_FOR (cogl_snippet_API) -void -cogl_disable_fog (void); - /** * cogl_clear: * @color: Background color to clear to diff --git a/cogl/cogl/gl-prototypes/cogl-fixed-functions.h b/cogl/cogl/gl-prototypes/cogl-fixed-functions.h index 5c11fedf4c33838b1bf4e9bada291e002e29defe..b153d2c9bbf6719b59c12084bb15c066630fd905 100644 --- a/cogl/cogl/gl-prototypes/cogl-fixed-functions.h +++ b/cogl/cogl/gl-prototypes/cogl-fixed-functions.h @@ -65,10 +65,6 @@ COGL_EXT_BEGIN (fixed_function_core, "\0") COGL_EXT_FUNCTION (void, glAlphaFunc, (GLenum func, GLclampf ref)) -COGL_EXT_FUNCTION (void, glFogf, - (GLenum pname, GLfloat param)) -COGL_EXT_FUNCTION (void, glFogfv, - (GLenum pname, const GLfloat *params)) COGL_EXT_FUNCTION (void, glLoadMatrixf, (const GLfloat *m)) COGL_EXT_FUNCTION (void, glMaterialfv, diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 1057ef955aa69b8526417ec4410882d208817cec..261955796671444f5ba3fde0f8511c8b63e1feae 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -112,10 +112,7 @@ cogl_nonintrospected_headers = [ 'cogl-attribute.h', 'cogl-primitive.h', 'cogl-frame-info.h', - 'cogl-vector.h', - 'cogl-euler.h', 'cogl-output.h', - 'cogl-quaternion.h', 'cogl-matrix-stack.h', 'cogl-poll.h', 'cogl-texture-2d-gl.h', @@ -266,10 +263,6 @@ cogl_sources = [ 'cogl-primitive-private.h', 'cogl-primitive.c', 'cogl-matrix.c', - 'cogl-vector.c', - 'cogl-euler.c', - 'cogl-quaternion-private.h', - 'cogl-quaternion.c', 'cogl-matrix-private.h', 'cogl-matrix-stack.c', 'cogl-matrix-stack-private.h', @@ -494,7 +487,7 @@ if have_introspection sources: cogl_introspected_headers, nsversion: libmutter_api_version, namespace: 'Cogl', - includes: ['GL-1.0', 'GObject-2.0'], + includes: ['GL-1.0', 'GObject-2.0', 'Graphene-1.0'], dependencies: [cogl_deps], extra_args: introspection_args + [ '-UCOGL_COMPILATION', diff --git a/cogl/meson.build b/cogl/meson.build index 64a54a522eb8237692cf9435daa73bc50943eb08..2dfe5bcc6bbf6ac16f3a68a7747f281345c2f91b 100644 --- a/cogl/meson.build +++ b/cogl/meson.build @@ -18,6 +18,7 @@ cogl_config_h = configure_file( cogl_pkg_deps = [ glib_dep, gobject_dep, + graphene_dep, ] cogl_pkg_private_deps = [ diff --git a/cogl/tests/conform/meson.build b/cogl/tests/conform/meson.build index d5dcdc0aad61c8b20bf2121f77bade4617533d1a..b8c3c074938f53976a7e62054b8de1490c2321f4 100644 --- a/cogl/tests/conform/meson.build +++ b/cogl/tests/conform/meson.build @@ -25,7 +25,7 @@ cogl_test_conformance_sources = [ 'test-point-sprite.c', 'test-no-gl-header.c', 'test-version.c', - 'test-euler-quaternion.c', + 'test-euler.c', 'test-layer-remove.c', 'test-alpha-test.c', 'test-map-buffer-range.c', diff --git a/cogl/tests/conform/test-conform-main.c b/cogl/tests/conform/test-conform-main.c index 2b70d354334502bc5a49eacacabfad04f826dbdd..a01026d43cf2edfb8d4e2e4f752eedc80b0caa25 100644 --- a/cogl/tests/conform/test-conform-main.c +++ b/cogl/tests/conform/test-conform-main.c @@ -127,7 +127,7 @@ main (int argc, char **argv) UNPORTED_TEST (test_viewport); - ADD_TEST (test_euler_quaternion, 0, 0); + ADD_TEST (test_euler, 0, 0); ADD_TEST (test_color_hsl, 0, 0); ADD_TEST (test_fence, TEST_REQUIREMENT_FENCE, 0); diff --git a/cogl/tests/conform/test-declarations.h b/cogl/tests/conform/test-declarations.h index 5311119627dc2f960c537b152bd655fe51ed3a1d..850d59f0f8df161e1bec6ecbeb739cbc7a94bf4d 100644 --- a/cogl/tests/conform/test-declarations.h +++ b/cogl/tests/conform/test-declarations.h @@ -44,7 +44,7 @@ void test_pipeline_shader_state (void); void test_gles2_context (void); void test_gles2_context_fbo (void); void test_gles2_context_copy_tex_image (void); -void test_euler_quaternion (void); +void test_euler (void); void test_color_hsl (void); void test_fence (void); void test_texture_no_allocate (void); diff --git a/cogl/tests/conform/test-euler-quaternion.c b/cogl/tests/conform/test-euler.c similarity index 77% rename from cogl/tests/conform/test-euler-quaternion.c rename to cogl/tests/conform/test-euler.c index 3126671629722aaecf03191ba842af69e0326bec..c911a1a1374cef238f6bd66158b597cf389cb351 100644 --- a/cogl/tests/conform/test-euler-quaternion.c +++ b/cogl/tests/conform/test-euler.c @@ -36,10 +36,9 @@ } while (0) void -test_euler_quaternion (void) +test_euler (void) { - CoglEuler euler; - CoglQuaternion quaternion; + graphene_euler_t euler; CoglMatrix matrix_a, matrix_b; /* Try doing the rotation with three separate rotations */ @@ -49,18 +48,12 @@ test_euler_quaternion (void) cogl_matrix_rotate (&matrix_a, 50.0f, 0.0f, 0.0f, 1.0f); /* And try the same rotation with a euler */ - cogl_euler_init (&euler, -30, 40, 50); + graphene_euler_init_with_order (&euler, 40, -30, 50, GRAPHENE_EULER_ORDER_RYXZ); cogl_matrix_init_from_euler (&matrix_b, &euler); /* Verify that the matrices are approximately the same */ COMPARE_MATRICES (&matrix_a, &matrix_b); - /* Try converting the euler to a matrix via a quaternion */ - cogl_quaternion_init_from_euler (&quaternion, &euler); - memset (&matrix_b, 0, sizeof (matrix_b)); - cogl_matrix_init_from_quaternion (&matrix_b, &quaternion); - COMPARE_MATRICES (&matrix_a, &matrix_b); - /* Try applying the rotation from a euler to a framebuffer */ cogl_framebuffer_identity_matrix (test_fb); cogl_framebuffer_rotate_euler (test_fb, &euler); @@ -68,13 +61,6 @@ test_euler_quaternion (void) cogl_framebuffer_get_modelview_matrix (test_fb, &matrix_b); COMPARE_MATRICES (&matrix_a, &matrix_b); - /* And again with a quaternion */ - cogl_framebuffer_identity_matrix (test_fb); - cogl_framebuffer_rotate_quaternion (test_fb, &quaternion); - memset (&matrix_b, 0, sizeof (matrix_b)); - cogl_framebuffer_get_modelview_matrix (test_fb, &matrix_b); - COMPARE_MATRICES (&matrix_a, &matrix_b); - /* FIXME: This needs a lot more tests! */ if (cogl_test_verbose ()) diff --git a/meson.build b/meson.build index 4b456dbac4e7e77afb59df48a2f6306dd7cda653..f6395054fe6100abbeac943a67e3f76b8ba49941 100644 --- a/meson.build +++ b/meson.build @@ -17,6 +17,7 @@ libmutter_api_version = '@0@'.format(api_version) fribidi_req = '>= 1.0.0' glib_req = '>= 2.61.1' gi_req = '>= 0.9.5' +graphene_req = '>= 1.9.3' gtk3_req = '>= 3.19.8' gdk_pixbuf_req = '>= 2.0' uprof_req = '>= 0.3' @@ -86,6 +87,7 @@ mutter_installed_tests_libexecdir = join_paths( m_dep = cc.find_library('m', required: true) x11_dep = dependency('x11') +graphene_dep = dependency('graphene-gobject-1.0', version: graphene_req) gtk3_dep = dependency('gtk+-3.0', version: gtk3_req) gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0') pango_dep = dependency('pango', version: pango_req) diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 7b05d72ebc6a1b09926cef80367a7546455fb480..b019b4d7dd95e56141ac36bc8bde6806dcfeacda 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -258,7 +258,7 @@ meta_backend_monitors_changed (MetaBackend *backend) meta_backend_get_monitor_manager (backend); ClutterDeviceManager *manager = clutter_device_manager_get_default (); ClutterInputDevice *device = clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE); - ClutterPoint point; + graphene_point_t point; meta_backend_sync_screen_size (backend); diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index dae40b3d39abf72729c19c57ec1cd791f3e068a2..b342a98f39fc775cf34527d7a7016d0f1de5cfb9 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -85,7 +85,7 @@ meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer, static void align_cursor_position (MetaCursorRenderer *renderer, - ClutterRect *rect) + graphene_rect_t *rect) { MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer); @@ -104,10 +104,10 @@ align_cursor_position (MetaCursorRenderer *renderer, clutter_stage_view_get_layout (view, &view_layout); view_scale = clutter_stage_view_get_scale (view); - clutter_rect_offset (rect, -view_layout.x, -view_layout.y); + graphene_rect_offset (rect, -view_layout.x, -view_layout.y); rect->origin.x = floorf (rect->origin.x * view_scale) / view_scale; rect->origin.y = floorf (rect->origin.y * view_scale) / view_scale; - clutter_rect_offset (rect, view_layout.x, view_layout.y); + graphene_rect_offset (rect, view_layout.x, view_layout.y); } static void @@ -118,7 +118,7 @@ queue_redraw (MetaCursorRenderer *renderer, MetaBackend *backend = meta_get_backend (); ClutterActor *stage = meta_backend_get_stage (backend); CoglTexture *texture; - ClutterRect rect = CLUTTER_RECT_INIT_ZERO; + graphene_rect_t rect = GRAPHENE_RECT_INIT_ZERO; /* During early initialization, we can have no stage */ if (!stage) @@ -211,7 +211,7 @@ meta_cursor_renderer_init (MetaCursorRenderer *renderer) NULL); } -ClutterRect +graphene_rect_t meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite) { @@ -224,14 +224,14 @@ meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer, texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite); if (!texture) - return (ClutterRect) CLUTTER_RECT_INIT_ZERO; + return (graphene_rect_t) GRAPHENE_RECT_INIT_ZERO; meta_cursor_sprite_get_hotspot (cursor_sprite, &hot_x, &hot_y); texture_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite); width = cogl_texture_get_width (texture); height = cogl_texture_get_height (texture); - return (ClutterRect) { + return (graphene_rect_t) { .origin = { .x = priv->current_x - (hot_x * texture_scale), .y = priv->current_y - (hot_y * texture_scale) @@ -315,13 +315,13 @@ meta_cursor_renderer_set_position (MetaCursorRenderer *renderer, meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor); } -ClutterPoint +graphene_point_t meta_cursor_renderer_get_position (MetaCursorRenderer *renderer) { MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer); - return (ClutterPoint) { + return (graphene_point_t) { .x = priv->current_x, .y = priv->current_y }; diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h index 60f1dbe1585272005e459cc97aa2423437625bea..852551355051e65ee614e68becad59959b85cd44 100644 --- a/src/backends/meta-cursor-renderer.h +++ b/src/backends/meta-cursor-renderer.h @@ -62,7 +62,7 @@ void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer, void meta_cursor_renderer_set_position (MetaCursorRenderer *renderer, float x, float y); -ClutterPoint meta_cursor_renderer_get_position (MetaCursorRenderer *renderer); +graphene_point_t meta_cursor_renderer_get_position (MetaCursorRenderer *renderer); void meta_cursor_renderer_force_update (MetaCursorRenderer *renderer); MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer); @@ -76,8 +76,8 @@ void meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *ren gboolean meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite); -ClutterRect meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer, - MetaCursorSprite *cursor_sprite); +graphene_rect_t meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer, + MetaCursorSprite *cursor_sprite); void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite); diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c index 45291e2864b06be17c3fa860d31b566a5d8cb674..ec95e62af68c72f2e70912123b3117220ccc6f92 100644 --- a/src/backends/meta-cursor-tracker.c +++ b/src/backends/meta-cursor-tracker.c @@ -407,7 +407,7 @@ get_pointer_position_clutter (int *x, { ClutterDeviceManager *cmanager; ClutterInputDevice *cdevice; - ClutterPoint point; + graphene_point_t point; cmanager = clutter_device_manager_get_default (); cdevice = clutter_device_manager_get_core_device (cmanager, CLUTTER_POINTER_DEVICE); diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index f582217e59708f39c78a9677f6d9c6016b68e291..729d0f50df0f7f89c19d6974ae43414cce3c8860 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -145,33 +145,33 @@ is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src) MetaMonitor *monitor; MetaLogicalMonitor *logical_monitor; MetaRectangle logical_monitor_layout; - ClutterRect logical_monitor_rect; + graphene_rect_t logical_monitor_rect; MetaCursorSprite *cursor_sprite; monitor = get_monitor (monitor_src); logical_monitor = meta_monitor_get_logical_monitor (monitor); logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor); logical_monitor_rect = - meta_rectangle_to_clutter_rect (&logical_monitor_layout); + meta_rectangle_to_graphene_rect (&logical_monitor_layout); cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer); if (cursor_sprite) { - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; cursor_rect = meta_cursor_renderer_calculate_rect (cursor_renderer, cursor_sprite); - return clutter_rect_intersection (&cursor_rect, - &logical_monitor_rect, - NULL); + return graphene_rect_intersection (&cursor_rect, + &logical_monitor_rect, + NULL); } else { - ClutterPoint cursor_position; + graphene_point_t cursor_position; cursor_position = meta_cursor_renderer_get_position (cursor_renderer); - return clutter_rect_contains_point (&logical_monitor_rect, - &cursor_position); + return graphene_rect_contains_point (&logical_monitor_rect, + &cursor_position); } } @@ -381,10 +381,10 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc MetaMonitor *monitor; MetaLogicalMonitor *logical_monitor; MetaRectangle logical_monitor_layout; - ClutterRect logical_monitor_rect; + graphene_rect_t logical_monitor_rect; MetaRendererView *view; float view_scale; - ClutterPoint cursor_position; + graphene_point_t cursor_position; int x, y; cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer); @@ -400,7 +400,7 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc logical_monitor = meta_monitor_get_logical_monitor (monitor); logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor); logical_monitor_rect = - meta_rectangle_to_clutter_rect (&logical_monitor_layout); + meta_rectangle_to_graphene_rect (&logical_monitor_layout); view = meta_renderer_get_view_from_logical_monitor (renderer, logical_monitor); diff --git a/src/backends/meta-screen-cast-window-stream-src.c b/src/backends/meta-screen-cast-window-stream-src.c index c31830b032c6bcb8dae35c2fdd7c4f49e6d2174b..35ee2e7c989c61e1d1fbba7d5ee985c210d4b543 100644 --- a/src/backends/meta-screen-cast-window-stream-src.c +++ b/src/backends/meta-screen-cast-window-stream-src.c @@ -112,8 +112,8 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src, MetaCursorSprite *cursor_sprite; CoglTexture *cursor_texture; MetaScreenCastWindow *screen_cast_window; - ClutterPoint cursor_position; - ClutterPoint relative_cursor_position; + graphene_point_t cursor_position; + graphene_point_t relative_cursor_position; cairo_surface_t *cursor_surface; uint8_t *cursor_surface_data; GError *error = NULL; @@ -298,7 +298,7 @@ is_cursor_in_stream (MetaScreenCastWindowStreamSrc *window_src) MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); MetaCursorSprite *cursor_sprite; - ClutterPoint cursor_position; + graphene_point_t cursor_position; MetaScreenCastWindow *screen_cast_window; cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer); @@ -423,9 +423,9 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc meta_backend_get_cursor_renderer (backend); MetaScreenCastWindow *screen_cast_window = window_src->screen_cast_window; MetaCursorSprite *cursor_sprite; - ClutterPoint cursor_position; + graphene_point_t cursor_position; float scale; - ClutterPoint relative_cursor_position; + graphene_point_t relative_cursor_position; int x, y; cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer); diff --git a/src/backends/meta-screen-cast-window.c b/src/backends/meta-screen-cast-window.c index ce2bf82c9664a3b40cf435e9ad49b9dd9ec05f73..809aca9be2bdbd57a750872cd2375fedac0a3a0e 100644 --- a/src/backends/meta-screen-cast-window.c +++ b/src/backends/meta-screen-cast-window.c @@ -54,9 +54,9 @@ meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow *scree gboolean meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_cast_window, MetaCursorSprite *cursor_sprite, - ClutterPoint *cursor_position, + graphene_point_t *cursor_position, float *out_cursor_scale, - ClutterPoint *out_relative_cursor_position) + graphene_point_t *out_relative_cursor_position) { MetaScreenCastWindowInterface *iface = META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window); diff --git a/src/backends/meta-screen-cast-window.h b/src/backends/meta-screen-cast-window.h index badd8822484956b45e2061b7178d7ca6dba4fded..b836fec5c0bc33983605712f18888cfef0e1ec15 100644 --- a/src/backends/meta-screen-cast-window.h +++ b/src/backends/meta-screen-cast-window.h @@ -48,9 +48,9 @@ struct _MetaScreenCastWindowInterface gboolean (*transform_cursor_position) (MetaScreenCastWindow *screen_cast_window, MetaCursorSprite *cursor_sprite, - ClutterPoint *cursor_position, + graphene_point_t *cursor_position, float *out_cursor_scale, - ClutterPoint *out_relative_cursor_position); + graphene_point_t *out_relative_cursor_position); void (*capture_into) (MetaScreenCastWindow *screen_cast_window, MetaRectangle *bounds, @@ -70,9 +70,9 @@ void meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow * gboolean meta_screen_cast_window_transform_cursor_position (MetaScreenCastWindow *screen_cast_window, MetaCursorSprite *cursor_sprite, - ClutterPoint *cursor_position, + graphene_point_t *cursor_position, float *out_cursor_scale, - ClutterPoint *out_relative_cursor_position); + graphene_point_t *out_relative_cursor_position); void meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window, MetaRectangle *bounds, diff --git a/src/backends/meta-stage-private.h b/src/backends/meta-stage-private.h index 96301768860c2f3e0476d67e56d51a25ab4a0a46..428aec67f49bcf1737ed4bf67e5af447a75208e5 100644 --- a/src/backends/meta-stage-private.h +++ b/src/backends/meta-stage-private.h @@ -48,10 +48,10 @@ MetaOverlay *meta_stage_create_cursor_overlay (MetaStage *stage); void meta_stage_remove_cursor_overlay (MetaStage *stage, MetaOverlay *overlay); -void meta_stage_update_cursor_overlay (MetaStage *stage, - MetaOverlay *overlay, - CoglTexture *texture, - ClutterRect *rect); +void meta_stage_update_cursor_overlay (MetaStage *stage, + MetaOverlay *overlay, + CoglTexture *texture, + graphene_rect_t *rect); void meta_stage_set_active (MetaStage *stage, gboolean is_active); diff --git a/src/backends/meta-stage.c b/src/backends/meta-stage.c index 47922f1f3418dff86cbf74252b95354f25904304..b80431bffc402e93d52cbc562153c185f5c283db 100644 --- a/src/backends/meta-stage.c +++ b/src/backends/meta-stage.c @@ -55,8 +55,8 @@ struct _MetaOverlay CoglPipeline *pipeline; CoglTexture *texture; - ClutterRect current_rect; - ClutterRect previous_rect; + graphene_rect_t current_rect; + graphene_rect_t previous_rect; gboolean previous_is_valid; }; @@ -95,9 +95,9 @@ meta_overlay_free (MetaOverlay *overlay) } static void -meta_overlay_set (MetaOverlay *overlay, - CoglTexture *texture, - ClutterRect *rect) +meta_overlay_set (MetaOverlay *overlay, + CoglTexture *texture, + graphene_rect_t *rect) { if (overlay->texture != texture) { @@ -135,7 +135,7 @@ meta_overlay_paint (MetaOverlay *overlay) (overlay->current_rect.origin.y + overlay->current_rect.size.height)); - if (!clutter_rect_equals (&overlay->previous_rect, &overlay->current_rect)) + if (!graphene_rect_equal (&overlay->previous_rect, &overlay->current_rect)) { overlay->previous_rect = overlay->current_rect; overlay->previous_is_valid = TRUE; @@ -297,9 +297,9 @@ meta_stage_new (MetaBackend *backend) } static void -queue_redraw_clutter_rect (MetaStage *stage, - MetaOverlay *overlay, - ClutterRect *rect) +queue_redraw_clutter_rect (MetaStage *stage, + MetaOverlay *overlay, + graphene_rect_t *rect) { cairo_rectangle_int_t clip = { .x = floorf (rect->origin.x), @@ -358,10 +358,10 @@ meta_stage_remove_cursor_overlay (MetaStage *stage, } void -meta_stage_update_cursor_overlay (MetaStage *stage, - MetaOverlay *overlay, - CoglTexture *texture, - ClutterRect *rect) +meta_stage_update_cursor_overlay (MetaStage *stage, + MetaOverlay *overlay, + CoglTexture *texture, + graphene_rect_t *rect) { g_assert (meta_is_wayland_compositor () || texture == NULL); diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index 2ae5165ec5edb174e840b200675b4e97bf08832e..0bfae6d30d0810b8037fbb1dd7207dec75ee2e02 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -150,7 +150,7 @@ constrain_all_screen_monitors (ClutterInputDevice *device, float *x, float *y) { - ClutterPoint current; + graphene_point_t current; float cx, cy; GList *logical_monitors, *l; diff --git a/src/backends/native/meta-barrier-native.c b/src/backends/native/meta-barrier-native.c index e336d31bf686623c40bab87d345ddee970b84f81..34a2c90c48ed66cbe654391f6ae84053d02608d1 100644 --- a/src/backends/native/meta-barrier-native.c +++ b/src/backends/native/meta-barrier-native.c @@ -468,7 +468,7 @@ meta_barrier_manager_native_process (MetaBarrierManagerNative *manager, float *x, float *y) { - ClutterPoint prev_pos; + graphene_point_t prev_pos; float prev_x; float prev_y; float orig_x = *x; diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c index 34e6f09c91264dd8d38f150dbd37b7bf22521843..be10954ee60af19e79f0aee81ab819bc75fba8b9 100644 --- a/src/backends/native/meta-cursor-renderer-native.c +++ b/src/backends/native/meta-cursor-renderer-native.c @@ -286,7 +286,7 @@ typedef struct { MetaCursorRendererNative *in_cursor_renderer_native; MetaLogicalMonitor *in_logical_monitor; - ClutterRect in_local_cursor_rect; + graphene_rect_t in_local_cursor_rect; MetaCursorSprite *in_cursor_sprite; gboolean out_painted; @@ -306,7 +306,7 @@ update_monitor_crtc_cursor (MetaMonitor *monitor, meta_cursor_renderer_native_get_instance_private (cursor_renderer_native); MetaCrtc *crtc; MetaMonitorTransform transform; - ClutterRect scaled_crtc_rect; + graphene_rect_t scaled_crtc_rect; float scale; int crtc_x, crtc_y; int crtc_width, crtc_height; @@ -333,7 +333,7 @@ update_monitor_crtc_cursor (MetaMonitor *monitor, crtc_height = monitor_crtc_mode->crtc_mode->height; } - scaled_crtc_rect = (ClutterRect) { + scaled_crtc_rect = (graphene_rect_t) { .origin = { .x = crtc_x / scale, .y = crtc_y / scale @@ -347,9 +347,9 @@ update_monitor_crtc_cursor (MetaMonitor *monitor, crtc = meta_output_get_assigned_crtc (monitor_crtc_mode->output); if (priv->has_hw_cursor && - clutter_rect_intersection (&scaled_crtc_rect, - &data->in_local_cursor_rect, - NULL)) + graphene_rect_intersection (&scaled_crtc_rect, + &data->in_local_cursor_rect, + NULL)) { MetaGpuKms *gpu_kms; int kms_fd; @@ -392,13 +392,13 @@ update_hw_cursor (MetaCursorRendererNative *native, meta_backend_get_monitor_manager (backend); GList *logical_monitors; GList *l; - ClutterRect rect; + graphene_rect_t rect; gboolean painted = FALSE; if (cursor_sprite) rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite); else - rect = (ClutterRect) CLUTTER_RECT_INIT_ZERO; + rect = GRAPHENE_RECT_INIT_ZERO; logical_monitors = meta_monitor_manager_get_logical_monitors (monitor_manager); @@ -412,7 +412,7 @@ update_hw_cursor (MetaCursorRendererNative *native, data = (UpdateCrtcCursorData) { .in_cursor_renderer_native = native, .in_logical_monitor = logical_monitor, - .in_local_cursor_rect = (ClutterRect) { + .in_local_cursor_rect = (graphene_rect_t) { .origin = { .x = rect.origin.x - logical_monitor->rect.x, .y = rect.origin.y - logical_monitor->rect.y @@ -487,7 +487,7 @@ cursor_over_transformed_logical_monitor (MetaCursorRenderer *renderer, meta_backend_get_monitor_manager (backend); GList *logical_monitors; GList *l; - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; cursor_rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite); @@ -497,17 +497,17 @@ cursor_over_transformed_logical_monitor (MetaCursorRenderer *renderer, { MetaLogicalMonitor *logical_monitor = l->data; MetaRectangle logical_monitor_layout; - ClutterRect logical_monitor_rect; + graphene_rect_t logical_monitor_rect; MetaMonitorTransform transform; GList *monitors, *l_mon; logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor); logical_monitor_rect = - meta_rectangle_to_clutter_rect (&logical_monitor_layout); + meta_rectangle_to_graphene_rect (&logical_monitor_layout); - if (!clutter_rect_intersection (&cursor_rect, &logical_monitor_rect, - NULL)) + if (!graphene_rect_intersection (&cursor_rect, &logical_monitor_rect, + NULL)) continue; monitors = meta_logical_monitor_get_monitors (logical_monitor); @@ -545,7 +545,7 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer, MetaBackend *backend = priv->backend; MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; GList *logical_monitors; GList *l; gboolean has_visible_crtc_sprite = FALSE; @@ -564,12 +564,12 @@ can_draw_cursor_unscaled (MetaCursorRenderer *renderer, for (l = logical_monitors; l; l = l->next) { MetaLogicalMonitor *logical_monitor = l->data; - ClutterRect logical_monitor_rect = - meta_rectangle_to_clutter_rect (&logical_monitor->rect); + graphene_rect_t logical_monitor_rect = + meta_rectangle_to_graphene_rect (&logical_monitor->rect); - if (!clutter_rect_intersection (&cursor_rect, - &logical_monitor_rect, - NULL)) + if (!graphene_rect_intersection (&cursor_rect, + &logical_monitor_rect, + NULL)) continue; if (calculate_cursor_crtc_sprite_scale (cursor_sprite, @@ -692,7 +692,7 @@ calculate_cursor_sprite_gpus (MetaCursorRenderer *renderer, GList *gpus = NULL; GList *logical_monitors; GList *l; - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; cursor_rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite); @@ -702,16 +702,16 @@ calculate_cursor_sprite_gpus (MetaCursorRenderer *renderer, { MetaLogicalMonitor *logical_monitor = l->data; MetaRectangle logical_monitor_layout; - ClutterRect logical_monitor_rect; + graphene_rect_t logical_monitor_rect; GList *monitors, *l_mon; logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor); logical_monitor_rect = - meta_rectangle_to_clutter_rect (&logical_monitor_layout); + meta_rectangle_to_graphene_rect (&logical_monitor_layout); - if (!clutter_rect_intersection (&cursor_rect, &logical_monitor_rect, - NULL)) + if (!graphene_rect_intersection (&cursor_rect, &logical_monitor_rect, + NULL)) continue; monitors = meta_logical_monitor_get_monitors (logical_monitor); diff --git a/src/backends/native/meta-device-manager-native.c b/src/backends/native/meta-device-manager-native.c index d64458e6b8b22bad136e93e1bdc429df006d2695..f94abddb21421cf2a24545e61558eb7d161805ea 100644 --- a/src/backends/native/meta-device-manager-native.c +++ b/src/backends/native/meta-device-manager-native.c @@ -380,7 +380,7 @@ notify_pinch_gesture_event (ClutterInputDevice *input_device, MetaSeatNative *seat; ClutterStage *stage; ClutterEvent *event = NULL; - ClutterPoint pos; + graphene_point_t pos; /* We can drop the event on the floor if no stage has been * associated with the device yet. */ @@ -427,7 +427,7 @@ notify_swipe_gesture_event (ClutterInputDevice *input_device, MetaSeatNative *seat; ClutterStage *stage; ClutterEvent *event = NULL; - ClutterPoint pos; + graphene_point_t pos; /* We can drop the event on the floor if no stage has been * associated with the device yet. */ diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c index 714624cea79e1889cc67847553919c5bde4f4526..a14509bd3f6990770b46fc20a9176e22481ba9ca 100644 --- a/src/backends/native/meta-seat-native.c +++ b/src/backends/native/meta-seat-native.c @@ -571,7 +571,7 @@ meta_seat_native_notify_button (MetaSeatNative *seat, if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE) { - ClutterPoint point; + graphene_point_t point; clutter_input_device_get_coords (input_device, NULL, &point); event->button.x = point.x; diff --git a/src/backends/native/meta-seat-native.h b/src/backends/native/meta-seat-native.h index 0b8f3a002029ba0a2ea062e6b8df91c9bf33cc50..9dd2fbdad731c1edef088db42b722b98e75edcd3 100644 --- a/src/backends/native/meta-seat-native.h +++ b/src/backends/native/meta-seat-native.h @@ -39,7 +39,7 @@ struct _MetaTouchState int device_slot; int seat_slot; - ClutterPoint coords; + graphene_point_t coords; }; struct _MetaSeatNative diff --git a/src/compositor/clutter-utils.c b/src/compositor/clutter-utils.c index cfa35aaf930184c928865f4ee1c026a67e78817e..a399cd477ed025cf98d455756419738045d19eb5 100644 --- a/src/compositor/clutter-utils.c +++ b/src/compositor/clutter-utils.c @@ -66,11 +66,11 @@ round_to_fixed (float x) * in @x_origin and @y_origin. */ gboolean -meta_actor_vertices_are_untransformed (ClutterVertex *verts, - float widthf, - float heightf, - int *x_origin, - int *y_origin) +meta_actor_vertices_are_untransformed (graphene_point3d_t *verts, + float widthf, + float heightf, + int *x_origin, + int *y_origin) { int width, height; int v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y; @@ -119,7 +119,7 @@ meta_actor_is_untransformed (ClutterActor *actor, int *y_origin) { gfloat widthf, heightf; - ClutterVertex verts[4]; + graphene_point3d_t verts[4]; clutter_actor_get_size (actor, &widthf, &heightf); clutter_actor_get_abs_allocation_vertices (actor, verts); @@ -153,7 +153,7 @@ meta_actor_painting_untransformed (CoglFramebuffer *fb, int *y_origin) { CoglMatrix modelview, projection, modelview_projection; - ClutterVertex vertices[4]; + graphene_point3d_t vertices[4]; float viewport[4]; int i; diff --git a/src/compositor/clutter-utils.h b/src/compositor/clutter-utils.h index b340ba464a999abf7fb99f42082ae033f1d98a86..d0513393e999e81080ba55348b6587a24a8a80fc 100644 --- a/src/compositor/clutter-utils.h +++ b/src/compositor/clutter-utils.h @@ -23,11 +23,11 @@ #include "clutter/clutter.h" -gboolean meta_actor_vertices_are_untransformed (ClutterVertex *verts, - float widthf, - float heightf, - int *x_origin, - int *y_origin); +gboolean meta_actor_vertices_are_untransformed (graphene_point3d_t *verts, + float widthf, + float heightf, + int *x_origin, + int *y_origin); gboolean meta_actor_is_untransformed (ClutterActor *actor, int *x_origin, int *y_origin); diff --git a/src/compositor/meta-dnd-actor.c b/src/compositor/meta-dnd-actor.c index af49ee27d49acdb4e4c72a4e8ea3ca9581647879..31a01db90bd4fcb401526671a6fec3f9f71306f4 100644 --- a/src/compositor/meta-dnd-actor.c +++ b/src/compositor/meta-dnd-actor.c @@ -207,7 +207,7 @@ meta_dnd_actor_drag_finish (MetaDnDActor *self, if (CLUTTER_ACTOR_IS_VISIBLE (self->drag_origin)) { float anchor_x, anchor_y; - ClutterPoint dest; + graphene_point_t dest; clutter_actor_get_transformed_position (self->drag_origin, &dest.x, &dest.y); diff --git a/src/compositor/meta-feedback-actor.c b/src/compositor/meta-feedback-actor.c index 74ab8054c7ded5cc98a04d2a1a5ef7540e4a955c..c8eb0fcac0db2a8a271f7d2b2919b114f2ab0e5f 100644 --- a/src/compositor/meta-feedback-actor.c +++ b/src/compositor/meta-feedback-actor.c @@ -241,7 +241,7 @@ void meta_feedback_actor_update (MetaFeedbackActor *self, const ClutterEvent *event) { - ClutterPoint point; + graphene_point_t point; g_return_if_fail (META_IS_FEEDBACK_ACTOR (self)); g_return_if_fail (event != NULL); diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h index 9b340777d3bf7302dc91d6381c5bfa9f958f8308..e96c6f8a82d27954c164e3bc7a80b01329c2fa27 100644 --- a/src/compositor/meta-shaped-texture-private.h +++ b/src/compositor/meta-shaped-texture-private.h @@ -46,7 +46,7 @@ gboolean meta_shaped_texture_has_alpha (MetaShapedTexture *stex); void meta_shaped_texture_set_transform (MetaShapedTexture *stex, MetaMonitorTransform transform); void meta_shaped_texture_set_viewport_src_rect (MetaShapedTexture *stex, - ClutterRect *src_rect); + graphene_rect_t *src_rect); void meta_shaped_texture_reset_viewport_src_rect (MetaShapedTexture *stex); void meta_shaped_texture_set_viewport_dst_size (MetaShapedTexture *stex, int dst_width, diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 4b9e7864f67d5ff550134673b1684f33ddf15ab4..401aaadf7c6b8b2c01f25992253178e6650bac83 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -91,7 +91,7 @@ struct _MetaShapedTexture gboolean size_invalid; MetaMonitorTransform transform; gboolean has_viewport_src_rect; - ClutterRect viewport_src_rect; + graphene_rect_t viewport_src_rect; gboolean has_viewport_dst_size; int viewport_dst_width; int viewport_dst_height; @@ -279,31 +279,38 @@ get_base_pipeline (MetaShapedTexture *stex, if (stex->transform != META_MONITOR_TRANSFORM_NORMAL) { - CoglEuler euler; + graphene_euler_t euler; cogl_matrix_translate (&matrix, 0.5, 0.5, 0.0); switch (stex->transform) { case META_MONITOR_TRANSFORM_90: - cogl_euler_init (&euler, 0.0, 0.0, 90.0); + graphene_euler_init_with_order (&euler, 0.0, 0.0, 90.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_180: - cogl_euler_init (&euler, 0.0, 0.0, 180.0); + graphene_euler_init_with_order (&euler, 0.0, 0.0, 180.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_270: - cogl_euler_init (&euler, 0.0, 0.0, 270.0); + graphene_euler_init_with_order (&euler, 0.0, 0.0, 270.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED: - cogl_euler_init (&euler, 180.0, 0.0, 0.0); + graphene_euler_init_with_order (&euler, 0.0, 180.0, 0.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED_90: - cogl_euler_init (&euler, 0.0, 180.0, 90.0); + graphene_euler_init_with_order (&euler, 180.0, 0.0, 90.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED_180: - cogl_euler_init (&euler, 180.0, 0.0, 180.0); + graphene_euler_init_with_order (&euler, 0.0, 180.0, 180.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_FLIPPED_270: - cogl_euler_init (&euler, 0.0, 180.0, 270.0); + graphene_euler_init_with_order (&euler, 180.0, 0.0, 270.0, + GRAPHENE_EULER_ORDER_SYXZ); break; case META_MONITOR_TRANSFORM_NORMAL: g_assert_not_reached (); @@ -857,8 +864,8 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex, if (stex->has_viewport_src_rect || stex->has_viewport_dst_size) { - ClutterRect viewport; - ClutterRect inverted_viewport; + graphene_rect_t viewport; + graphene_rect_t inverted_viewport; float dst_width; float dst_height; int inverted_dst_width; @@ -870,7 +877,7 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex, } else { - viewport = (ClutterRect) { + viewport = (graphene_rect_t) { .origin.x = 0, .origin.y = 0, .size.width = stex->tex_width, @@ -889,7 +896,7 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex, dst_height = (float) stex->tex_height; } - inverted_viewport = (ClutterRect) { + inverted_viewport = (graphene_rect_t) { .origin.x = -(viewport.origin.x * (dst_width / viewport.size.width)), .origin.y = -(viewport.origin.y * (dst_height / viewport.size.height)), .size.width = dst_width, @@ -1088,7 +1095,7 @@ meta_shaped_texture_set_transform (MetaShapedTexture *stex, void meta_shaped_texture_set_viewport_src_rect (MetaShapedTexture *stex, - ClutterRect *src_rect) + graphene_rect_t *src_rect) { if (!stex->has_viewport_src_rect || stex->viewport_src_rect.origin.x != src_rect->origin.x || diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c index 6fb3cf99d2689061255f0e5e125b1eed3382bcf0..5227bfd9af62ec69e5744eae12f1c856e9d0ca23 100644 --- a/src/compositor/meta-surface-actor.c +++ b/src/compositor/meta-surface-actor.c @@ -537,8 +537,8 @@ meta_surface_actor_set_transform (MetaSurfaceActor *self, } void -meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor *self, - ClutterRect *src_rect) +meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor *self, + graphene_rect_t *src_rect) { MetaSurfaceActorPrivate *priv = meta_surface_actor_get_instance_private (self); diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h index ddf394155de9ba234afcf4e317a18ba05e1df982..6a5fc4e3f3def534568cd9cd0131b5520d6e3033 100644 --- a/src/compositor/meta-surface-actor.h +++ b/src/compositor/meta-surface-actor.h @@ -56,8 +56,8 @@ void meta_surface_actor_set_frozen (MetaSurfaceActor *actor, void meta_surface_actor_set_transform (MetaSurfaceActor *self, MetaMonitorTransform transform); -void meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor *self, - ClutterRect *src_rect); +void meta_surface_actor_set_viewport_src_rect (MetaSurfaceActor *self, + graphene_rect_t *src_rect); void meta_surface_actor_reset_viewport_src_rect (MetaSurfaceActor *self); void meta_surface_actor_set_viewport_dst_size (MetaSurfaceActor *self, int dst_width, diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index d52ec240a40b56b062bbe1a33995c28ab80b6edc..6e86424dc997b42925051dc5c8e097f8ba50f905 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -1152,7 +1152,7 @@ meta_window_actor_transform_relative_position (MetaScreenCastWindow *screen_cast MetaWindowActorPrivate *priv = meta_window_actor_get_instance_private (window_actor); 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); @@ -1174,9 +1174,9 @@ meta_window_actor_transform_relative_position (MetaScreenCastWindow *screen_cast static gboolean meta_window_actor_transform_cursor_position (MetaScreenCastWindow *screen_cast_window, MetaCursorSprite *cursor_sprite, - ClutterPoint *cursor_position, + graphene_point_t *cursor_position, float *out_cursor_scale, - ClutterPoint *out_relative_cursor_position) + graphene_point_t *out_relative_cursor_position) { MetaWindowActor *window_actor = META_WINDOW_ACTOR (screen_cast_window); MetaWindowActorPrivate *priv = diff --git a/src/compositor/region-utils.c b/src/compositor/region-utils.c index 752af85c5c3ed7135c30c35e288b7ac13fea040b..081f8a90630f8f6b662889d51751629854992f1b 100644 --- a/src/compositor/region-utils.c +++ b/src/compositor/region-utils.c @@ -410,10 +410,10 @@ meta_region_transform (cairo_region_t *region, } cairo_region_t * -meta_region_crop_and_scale (cairo_region_t *region, - ClutterRect *src_rect, - int dst_width, - int dst_height) +meta_region_crop_and_scale (cairo_region_t *region, + graphene_rect_t *src_rect, + int dst_width, + int dst_height) { int n_rects, i; cairo_rectangle_int_t *rects; diff --git a/src/compositor/region-utils.h b/src/compositor/region-utils.h index 84e4d83bc249db75c42d1cca5b3b4c1fe4bc9ee0..745021b5be3febf92d558f6baea209c31541996e 100644 --- a/src/compositor/region-utils.h +++ b/src/compositor/region-utils.h @@ -111,9 +111,9 @@ cairo_region_t * meta_region_transform (cairo_region_t *region, int width, int height); -cairo_region_t * meta_region_crop_and_scale (cairo_region_t *region, - ClutterRect *src_rect, - int dst_width, - int dst_height); +cairo_region_t * meta_region_crop_and_scale (cairo_region_t *region, + graphene_rect_t *src_rect, + int dst_width, + int dst_height); #endif /* __META_REGION_UTILS_H__ */ diff --git a/src/core/boxes-private.h b/src/core/boxes-private.h index 74f5c54b41a9eab652ab0ce5d90316518ef89714..e1a72d335ac72ef5c7b9b9ddf2c715c5c6b01fcb 100644 --- a/src/core/boxes-private.h +++ b/src/core/boxes-private.h @@ -252,10 +252,10 @@ void meta_rectangle_scale_double (const MetaRectangle *rect, MetaRoundingStrategy rounding_strategy, MetaRectangle *dest); -static inline ClutterRect -meta_rectangle_to_clutter_rect (MetaRectangle *rect) +static inline graphene_rect_t +meta_rectangle_to_graphene_rect (MetaRectangle *rect) { - return (ClutterRect) { + return (graphene_rect_t) { .origin = { .x = rect->x, .y = rect->y @@ -274,12 +274,12 @@ void meta_rectangle_transform (const MetaRectangle *rect, int height, MetaRectangle *dest); -void meta_rectangle_from_clutter_rect (ClutterRect *rect, - MetaRoundingStrategy rounding_strategy, - MetaRectangle *dest); +void meta_rectangle_from_graphene_rect (const graphene_rect_t *rect, + MetaRoundingStrategy rounding_strategy, + MetaRectangle *dest); void meta_rectangle_crop_and_scale (const MetaRectangle *rect, - ClutterRect *src_rect, + graphene_rect_t *src_rect, int dst_width, int dst_height, MetaRectangle *dest); diff --git a/src/core/boxes.c b/src/core/boxes.c index 25b709b5f1ddcef0cbd229d7c144464c02775092..6b7b0bbaf0cf89269f54727cc943a8a07fd79146 100644 --- a/src/core/boxes.c +++ b/src/core/boxes.c @@ -2042,11 +2042,11 @@ meta_rectangle_scale_double (const MetaRectangle *rect, MetaRoundingStrategy rounding_strategy, MetaRectangle *dest) { - ClutterRect tmp = CLUTTER_RECT_INIT (rect->x, rect->y, - rect->width, rect->height); + graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y, + rect->width, rect->height); - clutter_rect_scale (&tmp, scale, scale); - meta_rectangle_from_clutter_rect (&tmp, rounding_strategy, dest); + graphene_rect_scale (&tmp, scale, scale, &tmp); + meta_rectangle_from_graphene_rect (&tmp, rounding_strategy, dest); } void @@ -2121,9 +2121,9 @@ meta_rectangle_transform (const MetaRectangle *rect, } void -meta_rectangle_from_clutter_rect (ClutterRect *rect, - MetaRoundingStrategy rounding_strategy, - MetaRectangle *dest) +meta_rectangle_from_graphene_rect (const graphene_rect_t *rect, + MetaRoundingStrategy rounding_strategy, + MetaRectangle *dest) { switch (rounding_strategy) { @@ -2139,8 +2139,9 @@ meta_rectangle_from_clutter_rect (ClutterRect *rect, break; case META_ROUNDING_STRATEGY_GROW: { - ClutterRect clamped = *rect; - clutter_rect_clamp_to_pixel (&clamped); + graphene_rect_t clamped = *rect; + + graphene_rect_round_extents (&clamped, &clamped); *dest = (MetaRectangle) { .x = clamped.origin.x, @@ -2155,18 +2156,19 @@ meta_rectangle_from_clutter_rect (ClutterRect *rect, void meta_rectangle_crop_and_scale (const MetaRectangle *rect, - ClutterRect *src_rect, + graphene_rect_t *src_rect, int dst_width, int dst_height, MetaRectangle *dest) { - ClutterRect tmp = CLUTTER_RECT_INIT (rect->x, rect->y, - rect->width, rect->height); + graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y, + rect->width, rect->height); - clutter_rect_scale (&tmp, - src_rect->size.width / dst_width, - src_rect->size.height / dst_height); - clutter_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y); + graphene_rect_scale (&tmp, + src_rect->size.width / dst_width, + src_rect->size.height / dst_height, + &tmp); + graphene_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y); - meta_rectangle_from_clutter_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest); + meta_rectangle_from_graphene_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest); } diff --git a/src/core/display.c b/src/core/display.c index 24009b1530fe29afe2012b9f8018069162a21cdd..b4b4668aab37bcaff0938567075cd02e74bb5d65 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1540,7 +1540,7 @@ find_highest_logical_monitor_scale (MetaBackend *backend, meta_backend_get_monitor_manager (backend); MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; GList *logical_monitors; GList *l; float highest_scale = 0.0; @@ -1553,12 +1553,12 @@ find_highest_logical_monitor_scale (MetaBackend *backend, for (l = logical_monitors; l; l = l->next) { MetaLogicalMonitor *logical_monitor = l->data; - ClutterRect logical_monitor_rect = - meta_rectangle_to_clutter_rect (&logical_monitor->rect); + graphene_rect_t logical_monitor_rect = + meta_rectangle_to_graphene_rect (&logical_monitor->rect); - if (!clutter_rect_intersection (&cursor_rect, - &logical_monitor_rect, - NULL)) + if (!graphene_rect_intersection (&cursor_rect, + &logical_monitor_rect, + NULL)) continue; highest_scale = MAX (highest_scale, logical_monitor->scale); diff --git a/src/tests/clutter-test-utils.c b/src/tests/clutter-test-utils.c index 3bd99989ef0a269a1144094f74dae1073edbca78..c75bc4974972e6e599ed532bef9e2d6b19c7fb0b 100644 --- a/src/tests/clutter-test-utils.c +++ b/src/tests/clutter-test-utils.c @@ -264,7 +264,7 @@ clutter_test_run (void) typedef struct { ClutterActor *stage; - ClutterPoint point; + graphene_point_t point; gpointer result; @@ -339,10 +339,10 @@ on_key_press_event (ClutterActor *stage, * Since: 1.18 */ gboolean -clutter_test_check_actor_at_point (ClutterActor *stage, - const ClutterPoint *point, - ClutterActor *actor, - ClutterActor **result) +clutter_test_check_actor_at_point (ClutterActor *stage, + const graphene_point_t *point, + ClutterActor *actor, + ClutterActor **result) { ValidateData *data; guint press_id = 0; @@ -401,10 +401,10 @@ clutter_test_check_actor_at_point (ClutterActor *stage, * Since: 1.18 */ gboolean -clutter_test_check_color_at_point (ClutterActor *stage, - const ClutterPoint *point, - const ClutterColor *color, - ClutterColor *result) +clutter_test_check_color_at_point (ClutterActor *stage, + const graphene_point_t *point, + const ClutterColor *color, + ClutterColor *result) { ValidateData *data; gboolean retval; diff --git a/src/tests/clutter-test-utils.h b/src/tests/clutter-test-utils.h index f666d8773eeeb68d53ba5e6416c7a67a84cc4a47..62e8e9fdc6fdca329b81b15e968ed0ae03acc44f 100644 --- a/src/tests/clutter-test-utils.h +++ b/src/tests/clutter-test-utils.h @@ -121,7 +121,7 @@ ClutterActor * clutter_test_get_stage (void); #define clutter_test_assert_actor_at_point(stage,point,actor) \ G_STMT_START { \ - const ClutterPoint *__p = (point); \ + const graphene_point_t *__p = (point); \ ClutterActor *__actor = (actor); \ ClutterActor *__stage = (stage); \ ClutterActor *__res; \ @@ -141,7 +141,7 @@ G_STMT_START { \ #define clutter_test_assert_color_at_point(stage,point,color) \ G_STMT_START { \ - const ClutterPoint *__p = (point); \ + const graphene_point_t *__p = (point); \ const ClutterColor *__c = (color); \ ClutterActor *__stage = (stage); \ ClutterColor __res; \ @@ -158,15 +158,15 @@ G_STMT_START { \ } G_STMT_END CLUTTER_EXPORT -gboolean clutter_test_check_actor_at_point (ClutterActor *stage, - const ClutterPoint *point, - ClutterActor *actor, - ClutterActor **result); +gboolean clutter_test_check_actor_at_point (ClutterActor *stage, + const graphene_point_t *point, + ClutterActor *actor, + ClutterActor **result); CLUTTER_EXPORT -gboolean clutter_test_check_color_at_point (ClutterActor *stage, - const ClutterPoint *point, - const ClutterColor *color, - ClutterColor *result); +gboolean clutter_test_check_color_at_point (ClutterActor *stage, + const graphene_point_t *point, + const ClutterColor *color, + ClutterColor *result); G_END_DECLS diff --git a/src/tests/clutter/accessibility/cally-atktext-example.c b/src/tests/clutter/accessibility/cally-atktext-example.c index 634a9a74fcf56ba21c02f34c7ecc1c1e32745854..fce36f1a426eca9e7dc6b57148b2b513724b809c 100644 --- a/src/tests/clutter/accessibility/cally-atktext-example.c +++ b/src/tests/clutter/accessibility/cally-atktext-example.c @@ -40,7 +40,7 @@ test_atk_text (ClutterActor *actor) gchar *text = NULL; AtkObject *object = NULL; AtkText *cally_text = NULL; - gboolean bool = FALSE; + gboolean boolean = FALSE; gunichar unichar; gint count = -1; gint start = -1; @@ -89,17 +89,17 @@ test_atk_text (ClutterActor *actor) g_print ("atk_text_get_selection: %s, %i, %i\n", text, start, end); g_free(text); text = NULL; - bool = atk_text_remove_selection (cally_text, 0); - g_print ("atk_text_remove_selection (0): %i\n", bool); + boolean = atk_text_remove_selection (cally_text, 0); + g_print ("atk_text_remove_selection (0): %i\n", boolean); - bool = atk_text_remove_selection (cally_text, 1); - g_print ("atk_text_remove_selection (1): %i\n", bool); + boolean = atk_text_remove_selection (cally_text, 1); + g_print ("atk_text_remove_selection (1): %i\n", boolean); - bool = atk_text_add_selection (cally_text, 5, 10); - g_print ("atk_text_add_selection: %i\n", bool); + boolean = atk_text_add_selection (cally_text, 5, 10); + g_print ("atk_text_add_selection: %i\n", boolean); - bool = atk_text_set_selection (cally_text, 0, 6, 10); - g_print ("atk_text_set_selection: %i\n", bool); + boolean = atk_text_set_selection (cally_text, 0, 6, 10); + g_print ("atk_text_set_selection: %i\n", boolean); at_set = atk_text_get_run_attributes (cally_text, 0, &start, &end); diff --git a/src/tests/clutter/conform/actor-anchors.c b/src/tests/clutter/conform/actor-anchors.c index 842379818d72569fcf1b40658f1a155909abdabb..3cf3191f30705a61fd2e46627ab4bc333900c07c 100644 --- a/src/tests/clutter/conform/actor-anchors.c +++ b/src/tests/clutter/conform/actor-anchors.c @@ -101,7 +101,7 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state) macro so that the assertion failure will report the right line number */ #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); \ check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \ 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) && \ approx_equal (v->y, yc) && \ 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 approx_equal (int a, int b) @@ -130,7 +130,7 @@ check_coords (TestState *state, gint y_1, gint x_2, gint y_2, - const ClutterVertex *verts) + const graphene_point3d_t *verts) { if (g_test_verbose ()) 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; 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; gfloat stage_width, stage_height; gfloat rect_x, rect_y; diff --git a/src/tests/clutter/conform/actor-layout.c b/src/tests/clutter/conform/actor-layout.c index 099a279e1512ba684ec0d8d40f9a72b6f384242f..9a9814b08f2ab4a07bd32a32c430e28c1e1e7a07 100644 --- a/src/tests/clutter/conform/actor-layout.c +++ b/src/tests/clutter/conform/actor-layout.c @@ -8,7 +8,7 @@ actor_basic_layout (void) ClutterActor *stage = clutter_test_get_stage (); ClutterActor *vase; ClutterActor *flower[3]; - ClutterPoint p; + graphene_point_t p; vase = clutter_actor_new (); clutter_actor_set_name (vase, "Vase"); @@ -33,13 +33,13 @@ actor_basic_layout (void) clutter_actor_set_name (flower[2], "Green Flower"); clutter_actor_add_child (vase, flower[2]); - clutter_point_init (&p, 50, 50); + graphene_point_init (&p, 50, 50); clutter_test_assert_actor_at_point (stage, &p, flower[0]); - clutter_point_init (&p, 150, 50); + graphene_point_init (&p, 150, 50); clutter_test_assert_actor_at_point (stage, &p, flower[1]); - clutter_point_init (&p, 250, 50); + graphene_point_init (&p, 250, 50); clutter_test_assert_actor_at_point (stage, &p, flower[2]); } @@ -49,7 +49,7 @@ actor_margin_layout (void) ClutterActor *stage = clutter_test_get_stage (); ClutterActor *vase; ClutterActor *flower[3]; - ClutterPoint p; + graphene_point_t p; vase = clutter_actor_new (); clutter_actor_set_name (vase, "Vase"); @@ -78,13 +78,13 @@ actor_margin_layout (void) clutter_actor_set_margin_bottom (flower[2], 6); clutter_actor_add_child (vase, flower[2]); - clutter_point_init (&p, 0, 7); + graphene_point_init (&p, 0, 7); clutter_test_assert_actor_at_point (stage, &p, flower[0]); - clutter_point_init (&p, 106, 50); + graphene_point_init (&p, 106, 50); clutter_test_assert_actor_at_point (stage, &p, flower[1]); - clutter_point_init (&p, 212, 7); + graphene_point_init (&p, 212, 7); clutter_test_assert_actor_at_point (stage, &p, flower[2]); } diff --git a/src/tests/clutter/conform/meson.build b/src/tests/clutter/conform/meson.build index 24c80e82ab0f08a0f32a7c50b222a964e84dfd98..eced790b1abdd5d95a8ca7a048e24ebbc06ef7f6 100644 --- a/src/tests/clutter/conform/meson.build +++ b/src/tests/clutter/conform/meson.build @@ -33,7 +33,6 @@ clutter_conform_tests_general_tests = [ 'interval', 'script-parser', 'units', - 'point', ] clutter_conform_tests_deprecated_tests = [ diff --git a/src/tests/clutter/conform/point.c b/src/tests/clutter/conform/point.c deleted file mode 100644 index c8ecac7093dd447ab00be1c14b741ff6116435f8..0000000000000000000000000000000000000000 --- a/src/tests/clutter/conform/point.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "tests/clutter-test-utils.h" - -#include - -static void -point_on_nonempty_quadrilateral (void) -{ - int p; - static const ClutterPoint vertices[4] = - { - { 1.f, 2.f }, - { 6.f, 3.f }, - { 7.f, 6.f }, - { 0.f, 5.f } - }; - static const ClutterPoint points_inside[] = - { - { 2.f, 3.f }, - { 1.f, 4.f }, - { 5.f, 5.f }, - { 4.f, 3.f }, - }; - static const ClutterPoint points_outside[] = - { - { 3.f, 1.f }, - { 7.f, 4.f }, - { 4.f, 6.f }, - { 99.f, -77.f }, - { -1.f, 3.f }, - { -8.f, -8.f }, - { 11.f, 4.f }, - { -7.f, 4.f }, - }; - - for (p = 0; p < G_N_ELEMENTS (points_inside); p++) - { - const ClutterPoint *point = &points_inside[p]; - - g_assert_true (clutter_point_inside_quadrilateral (point, vertices)); - } - - for (p = 0; p < G_N_ELEMENTS (points_outside); p++) - { - const ClutterPoint *point = &points_outside[p]; - - g_assert_false (clutter_point_inside_quadrilateral (point, vertices)); - } -} - -static void -point_on_empty_quadrilateral (void) -{ - int p; - static const ClutterPoint vertices[4] = - { - { 5.f, 6.f }, - { 5.f, 6.f }, - { 5.f, 6.f }, - { 5.f, 6.f }, - }; - static const ClutterPoint points_outside[] = - { - { 3.f, 1.f }, - { 7.f, 4.f }, - { 4.f, 6.f }, - { 99.f, -77.f }, - { -1.f, 3.f }, - { -8.f, -8.f }, - }; - - for (p = 0; p < G_N_ELEMENTS (points_outside); p++) - { - const ClutterPoint *point = &points_outside[p]; - - g_assert_false (clutter_point_inside_quadrilateral (point, vertices)); - } - - g_assert_false (clutter_point_inside_quadrilateral (&vertices[0], vertices)); -} - -CLUTTER_TEST_SUITE ( - CLUTTER_TEST_UNIT ("/point/on_nonempty_quadrilateral", point_on_nonempty_quadrilateral) - CLUTTER_TEST_UNIT ("/point/on_empty_quadrilateral", point_on_empty_quadrilateral) -) diff --git a/src/tests/clutter/interactive/test-events.c b/src/tests/clutter/interactive/test-events.c index 013231ef89e9cc25dfa0dcc59c8d03c872bc7e3a..f31c7d228d6ce5677b17cc113eb4b6622420a53f 100644 --- a/src/tests/clutter/interactive/test-events.c +++ b/src/tests/clutter/interactive/test-events.c @@ -218,7 +218,7 @@ input_cb (ClutterActor *actor, { ClutterActor *stage = clutter_actor_get_stage (actor); ClutterActor *source_actor = clutter_event_get_source (event); - ClutterPoint position; + graphene_point_t position; gchar *state; gchar keybuf[128]; gint device_id; diff --git a/src/tests/clutter/interactive/test-layout.c b/src/tests/clutter/interactive/test-layout.c index 7a5b3cf2e41861311088e3ed7e52dca975bc2aba..4c73c0de2a8e50a464c4b9be18f16fc91f9e8003 100644 --- a/src/tests/clutter/interactive/test-layout.c +++ b/src/tests/clutter/interactive/test-layout.c @@ -334,7 +334,7 @@ my_thing_allocate (ClutterActor *self, if (clutter_actor_is_scaled (child) || clutter_actor_is_rotated (child)) { - ClutterVertex v1 = { 0, }, v2 = { 0, }; + graphene_point3d_t v1 = { 0, }, v2 = { 0, }; ClutterActorBox transformed_box = { 0, }; /* origin */ diff --git a/src/tests/clutter/interactive/test-texture-quality.c b/src/tests/clutter/interactive/test-texture-quality.c index 91c0f0dc67c721d5b20ebd2860ab497ab4f9a4a7..749112c65ddec676ce177743aff6fb61162f8263 100644 --- a/src/tests/clutter/interactive/test-texture-quality.c +++ b/src/tests/clutter/interactive/test-texture-quality.c @@ -54,7 +54,6 @@ test_texture_quality_main (int argc, char *argv[]) ClutterActor *stage; ClutterActor *image; ClutterColor stage_color = { 0x12, 0x34, 0x56, 0xff }; - ClutterFog stage_fog = { 10.0, -50.0 }; GError *error; gchar *file; @@ -63,8 +62,6 @@ test_texture_quality_main (int argc, char *argv[]) stage = clutter_stage_new (); clutter_actor_set_background_color (stage, &stage_color); - clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE); - clutter_stage_set_fog (CLUTTER_STAGE (stage), &stage_fog); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/src/wayland/meta-pointer-confinement-wayland.c b/src/wayland/meta-pointer-confinement-wayland.c index 29e5cc3fb3e1663b54ee5610555bc5c1ed81d623..d5491e9f4f02cc85aaa3a4798a15293830df0122 100644 --- a/src/wayland/meta-pointer-confinement-wayland.c +++ b/src/wayland/meta-pointer-confinement-wayland.c @@ -622,7 +622,7 @@ meta_pointer_confinement_wayland_maybe_warp (MetaPointerConfinementWayland *self { MetaWaylandSeat *seat; MetaWaylandSurface *surface; - ClutterPoint point; + graphene_point_t point; float sx; float sy; cairo_region_t *region; diff --git a/src/wayland/meta-wayland-cursor-surface.c b/src/wayland/meta-wayland-cursor-surface.c index 76268d5f238d723c260e8129fe15112495226a02..d90cb36a70e13b0882871c01c3d49424d61b7580 100644 --- a/src/wayland/meta-wayland-cursor-surface.c +++ b/src/wayland/meta-wayland-cursor-surface.c @@ -186,18 +186,18 @@ meta_wayland_cursor_surface_is_on_logical_monitor (MetaWaylandSurfaceRole *role, META_WAYLAND_CURSOR_SURFACE (surface->role); MetaWaylandCursorSurfacePrivate *priv = meta_wayland_cursor_surface_get_instance_private (cursor_surface); - ClutterPoint point; - ClutterRect logical_monitor_rect; + graphene_point_t point; + graphene_rect_t logical_monitor_rect; if (!priv->cursor_renderer) return FALSE; logical_monitor_rect = - meta_rectangle_to_clutter_rect (&logical_monitor->rect); + meta_rectangle_to_graphene_rect (&logical_monitor->rect); point = meta_cursor_renderer_get_position (priv->cursor_renderer); - return clutter_rect_contains_point (&logical_monitor_rect, &point); + return graphene_rect_contains_point (&logical_monitor_rect, &point); } static void diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c index 38aa0f31728c948b459e02141dbacedc9d0d6b52..b9d3a6c75d96d50479f1979b4070aa3255d14956 100644 --- a/src/wayland/meta-wayland-data-device.c +++ b/src/wayland/meta-wayland-data-device.c @@ -1161,7 +1161,7 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data { MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device); MetaWaylandDragGrab *drag_grab; - ClutterPoint pos, surface_pos; + graphene_point_t pos, surface_pos; ClutterModifierType modifiers; MetaSurfaceActor *surface_actor; diff --git a/src/wayland/meta-wayland-dnd-surface.c b/src/wayland/meta-wayland-dnd-surface.c index 2020309a83e63c90a2a5280d0fab6363d46d202b..bcb5317a291bb9bc36620764643d457f0c19bc6e 100644 --- a/src/wayland/meta-wayland-dnd-surface.c +++ b/src/wayland/meta-wayland-dnd-surface.c @@ -72,7 +72,7 @@ dnd_surface_find_logical_monitor (MetaWaylandActorSurface *actor_surface) meta_backend_get_cursor_renderer (backend); MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); - ClutterPoint pointer_pos; + graphene_point_t pointer_pos; pointer_pos = meta_cursor_renderer_get_position (cursor_renderer); return meta_monitor_manager_get_logical_monitor_at (monitor_manager, diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index 751f6b9b964e75965d4694aed0503b0723cae02b..4619af78dabb8c5592d547ca9e8235768eff3b86 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -926,7 +926,7 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer, if (surface != NULL) { struct wl_client *client = wl_resource_get_client (surface->resource); - ClutterPoint pos; + graphene_point_t pos; pointer->focus_surface = surface; @@ -1039,7 +1039,7 @@ meta_wayland_pointer_get_relative_coordinates (MetaWaylandPointer *pointer, wl_fixed_t *sy) { float xf = 0.0f, yf = 0.0f; - ClutterPoint pos; + graphene_point_t pos; clutter_input_device_get_coords (pointer->device, NULL, &pos); meta_wayland_surface_get_relative_coordinates (surface, pos.x, pos.y, &xf, &yf); diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 647f05338e899e9f37ea1bfcf7765d5a2f79a135..e10467502c757e37a5566667af497f72f6f132b2 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -274,7 +274,7 @@ surface_process_damage (MetaWaylandSurface *surface, cairo_region_t *scaled_region; cairo_region_t *transformed_region; cairo_region_t *viewport_region; - ClutterRect src_rect; + graphene_rect_t src_rect; MetaSurfaceActor *actor; /* If the client destroyed the buffer it attached before committing, but @@ -303,7 +303,7 @@ surface_process_damage (MetaWaylandSurface *surface, scaled_region = meta_region_scale (surface_region, surface->scale); if (surface->viewport.has_src_rect) { - src_rect = (ClutterRect) { + src_rect = (graphene_rect_t) { .origin.x = surface->viewport.src_rect.origin.x * surface->scale, .origin.y = surface->viewport.src_rect.origin.y * surface->scale, .size.width = surface->viewport.src_rect.size.width * surface->scale, @@ -312,7 +312,7 @@ surface_process_damage (MetaWaylandSurface *surface, } else { - src_rect = (ClutterRect) { + src_rect = (graphene_rect_t) { .size.width = surface_rect.width * surface->scale, .size.height = surface_rect.height * surface->scale, }; @@ -1646,11 +1646,11 @@ meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface, { ClutterActor *actor = CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)); - ClutterVertex sv = { + graphene_point3d_t sv = { .x = sx * 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); diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 5f867be9d2f0a6b037a563ca0d596bde0fe6317a..818e7b0475ec5416dff78f23717fdbddfc36e407 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -110,7 +110,7 @@ struct _MetaWaylandPendingState gboolean has_new_buffer_transform; MetaMonitorTransform buffer_transform; gboolean has_new_viewport_src_rect; - ClutterRect viewport_src_rect; + graphene_rect_t viewport_src_rect; gboolean has_new_viewport_dst_size; int viewport_dst_width; int viewport_dst_height; @@ -212,7 +212,7 @@ struct _MetaWaylandSurface gulong destroy_handler_id; gboolean has_src_rect; - ClutterRect src_rect; + graphene_rect_t src_rect; gboolean has_dst_size; int dst_width; diff --git a/src/wayland/meta-wayland-text-input-legacy.c b/src/wayland/meta-wayland-text-input-legacy.c index d4caa9aadee6ae87fff6081fe295fcb2901e0761..3ad48988a0ec5b26d2606c27ff536792d01d1d54 100644 --- a/src/wayland/meta-wayland-text-input-legacy.c +++ b/src/wayland/meta-wayland-text-input-legacy.c @@ -475,7 +475,7 @@ text_input_commit_state (struct wl_client *client, if (text_input->pending_state & META_WAYLAND_PENDING_STATE_INPUT_RECT) { - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; float x1, y1, x2, y2; cairo_rectangle_int_t rect; @@ -487,7 +487,7 @@ text_input_commit_state (struct wl_client *client, rect.y + rect.height, &x2, &y2); - clutter_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1); + graphene_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1); clutter_input_focus_set_cursor_location (text_input->input_focus, &cursor_rect); } diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c index d63f489bd56654f48107d44df599403a4c90d68d..ee9b895cb588358cb85c750aba8775391e21b444 100644 --- a/src/wayland/meta-wayland-text-input.c +++ b/src/wayland/meta-wayland-text-input.c @@ -573,7 +573,7 @@ text_input_commit_state (struct wl_client *client, if (text_input->pending_state & META_WAYLAND_PENDING_STATE_INPUT_RECT) { - ClutterRect cursor_rect; + graphene_rect_t cursor_rect; float x1, y1, x2, y2; cairo_rectangle_int_t rect; @@ -585,7 +585,7 @@ text_input_commit_state (struct wl_client *client, rect.y + rect.height, &x2, &y2); - clutter_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1); + graphene_rect_init (&cursor_rect, x1, y1, x2 - x1, y2 - y1); clutter_input_focus_set_cursor_location (text_input->input_focus, &cursor_rect); } diff --git a/src/wayland/meta-xwayland-dnd.c b/src/wayland/meta-xwayland-dnd.c index 3ad58e4d28f2a5525f91cd3886903f5dd106c5ef..c014023172981e7afca6a70418c82b79752b696c 100644 --- a/src/wayland/meta-xwayland-dnd.c +++ b/src/wayland/meta-xwayland-dnd.c @@ -519,7 +519,7 @@ meta_x11_drag_dest_update (MetaWaylandDataDevice *data_device, MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); MetaXWaylandDnd *dnd = compositor->xwayland_manager.dnd; MetaWaylandSeat *seat = compositor->seat; - ClutterPoint pos; + graphene_point_t pos; clutter_input_device_get_coords (seat->pointer->device, NULL, &pos); xdnd_send_position (dnd, dnd->dnd_dest, @@ -602,7 +602,7 @@ pick_drop_surface (MetaWaylandCompositor *compositor, { MetaDisplay *display = meta_get_display (); MetaWindow *focus_window = NULL; - ClutterPoint pos; + graphene_point_t pos; clutter_event_get_coords (event, &pos.x, &pos.y); focus_window = meta_stack_get_default_focus_window_at_point (display->stack, @@ -793,7 +793,7 @@ meta_xwayland_dnd_handle_client_message (MetaWaylandCompositor *compositor, else if (event->message_type == xdnd_atoms[ATOM_DND_POSITION]) { ClutterEvent *motion; - ClutterPoint pos; + graphene_point_t pos; uint32_t action = 0; dnd->client_message_timestamp = event->data.l[3];