From 305bb124b71b8fd531009f050cc83d89af1dfb93 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 12 Nov 2010 16:08:25 +0000 Subject: [PATCH] use cogl_matrix_transform_points in clutter When transforming a paint-volume or transforming allocation vertices we are transforming more than one point at a time so we can batch those together with cogl_matrix_transform_points instead of cogl_matrix_transform_point. Also in both of these cases we don't need to do a projective transform so using cogl_matrix_transform_points also lets us reduce the per-vertex computation. --- clutter/clutter-actor.c | 23 ++++++++--------------- clutter/clutter-paint-volume.c | 18 +++++++----------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 34b40dead..553b112c5 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -2115,7 +2115,6 @@ clutter_actor_get_allocation_vertices (ClutterActor *self, ClutterActorBox box; ClutterVertex vertices[4]; CoglMatrix modelview; - float w; g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (ancestor == NULL || CLUTTER_IS_ACTOR (ancestor)); @@ -2163,19 +2162,13 @@ clutter_actor_get_allocation_vertices (ClutterActor *self, _clutter_actor_get_relative_modelview (self, ancestor, &modelview); - w = 1; - cogl_matrix_transform_point (&modelview, - &vertices[0].x, &vertices[0].y, &vertices[0].z, - &w); - cogl_matrix_transform_point (&modelview, - &vertices[1].x, &vertices[1].y, &vertices[1].z, - &w); - cogl_matrix_transform_point (&modelview, - &vertices[2].x, &vertices[2].y, &vertices[2].z, - &w); - cogl_matrix_transform_point (&modelview, - &vertices[3].x, &vertices[3].y, &vertices[3].z, - &w); + cogl_matrix_transform_points (&modelview, + 3, + sizeof (ClutterVertex), + vertices, + sizeof (ClutterVertex), + vertices, + 4); } /** @@ -8862,7 +8855,7 @@ clutter_actor_find_property (ClutterAnimatable *animatable, if (meta != NULL) { klass = G_OBJECT_GET_CLASS (meta); - + pspec = g_object_class_find_property (klass, p_name); g_free (p_name); diff --git a/clutter/clutter-paint-volume.c b/clutter/clutter-paint-volume.c index 2eb1327b1..cd7a4e7b2 100644 --- a/clutter/clutter-paint-volume.c +++ b/clutter/clutter-paint-volume.c @@ -693,7 +693,6 @@ _clutter_paint_volume_transform (ClutterPaintVolume *pv, const CoglMatrix *matrix) { int transform_count; - int i; if (pv->is_empty) { @@ -718,16 +717,13 @@ _clutter_paint_volume_transform (ClutterPaintVolume *pv, else transform_count = 8; - - for (i = 0; i < transform_count; i++) - { - gfloat w = 1; - cogl_matrix_transform_point (matrix, - &pv->vertices[i].x, - &pv->vertices[i].y, - &pv->vertices[i].z, - &w); - } + cogl_matrix_transform_points (matrix, + 3, + sizeof (ClutterVertex), + pv->vertices, + sizeof (ClutterVertex), + pv->vertices, + transform_count); pv->is_axis_aligned = FALSE; }