diff --git a/ChangeLog b/ChangeLog index cf6e4824d..6223db22c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-06-01 Tomas Frydrych + + * clutter/clutter-actor.c: + * clutter/clutter-stage.c: + * clutter/clutter-private.h: + Removed perspective matrix caching from ClutterStage. + 2007-06-01 Neil J. Patel * clutter/clutter-entry.c: (clutter_entry_set_property), @@ -23,7 +30,7 @@ Added a signla to track cursor movements. Moved the sursor painting function so it can be subclassed. -007-06-01 Tomas Frydrych +2007-06-01 Tomas Frydrych * clutter/clutter-actor.c: (clutter_actor_get_transformed_point): diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index b98e6167b..93b5e55df 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -679,6 +679,37 @@ mtx_create (ClutterActorPrivate *priv, } } +static void +mtx_perspective (ClutterFixed * m, ClutterStage * stage) +{ + ClutterFixed xmax, ymax; + ClutterPerspective perspective; + ClutterFixed x, y, c, d; + + memset (m, 0, sizeof (ClutterFixed) * 16); + + clutter_stage_get_perspectivex (stage, &perspective); + + ymax = clutter_qmulx (perspective.z_near, + clutter_tani (perspective.fovy >> 1)); + + xmax = clutter_qmulx (ymax, perspective.aspect); + + x = CFX_DIV (perspective.z_near, xmax); + y = CFX_DIV (perspective.z_near, ymax); + c = CFX_DIV (-(perspective.z_far + perspective.z_near), + ( perspective.z_far - perspective.z_near)); + + d = CFX_DIV (-(clutter_qmulx (2 * perspective.z_far, perspective.z_near)), + (perspective.z_far - perspective.z_near)); + + M(m,0,0) = x; + M(m,1,1) = y; + M(m,2,2) = c; + M(m,2,3) = d; + M(m,3,2) = -CFX_ONE; +} + /** * clutter_actor_get_transformed_point: * @self: A #ClutterActor @@ -702,16 +733,16 @@ clutter_actor_get_transformed_point (ClutterActor *actor, ClutterUnit *z_return) { ClutterFixed mtx[16]; - const ClutterFixed *mtx_p; + ClutterFixed mtx_p[16]; ClutterActorPrivate *priv; g_return_if_fail (CLUTTER_IS_ACTOR (actor)); priv = actor->priv; - mtx_p = _clutter_stage_get_perspective_matrix (CLUTTER_STAGE (clutter_stage_get_default())); + mtx_perspective (&mtx_p[0], CLUTTER_STAGE (clutter_stage_get_default())); - mtx_create (priv, &mtx[0], mtx_p); + mtx_create (priv, &mtx[0], &mtx_p[0]); *x_return = CLUTTER_UNITS_FROM_INT(x); *y_return = CLUTTER_UNITS_FROM_INT(y); @@ -734,7 +765,7 @@ clutter_actor_get_transformed_vertices (ClutterActor * self, ClutterVertices * verts) { ClutterFixed mtx[16]; - const ClutterFixed *mtx_p; + ClutterFixed mtx_p[16]; ClutterFixed x, y, z; ClutterActorPrivate *priv; @@ -746,9 +777,9 @@ clutter_actor_get_transformed_vertices (ClutterActor * self, priv = self->priv; - mtx_p = _clutter_stage_get_perspective_matrix (CLUTTER_STAGE (clutter_stage_get_default())); - - mtx_create (priv, &mtx[0], mtx_p); + mtx_perspective (&mtx_p[0], CLUTTER_STAGE (clutter_stage_get_default())); + + mtx_create (priv, &mtx[0], &mtx_p[0]); #if 0 g_debug ("Matrix\n" diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 9bdd29e88..0844df7b2 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -119,8 +119,6 @@ void _clutter_event_button_generate (ClutterBackend *backend, void _clutter_feature_init (void); -const ClutterFixed * _clutter_stage_get_perspective_matrix (ClutterStage * stage); - /* Does this need to be private ? */ void clutter_do_event (ClutterEvent *event); diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index c35847b20..034c67631 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -61,8 +61,6 @@ struct _ClutterStagePrivate guint is_fullscreen : 1; guint is_offscreen : 1; guint is_cursor_visible : 1; - - ClutterFixed perspective_mtx[16]; }; enum @@ -384,43 +382,6 @@ clutter_stage_class_init (ClutterStageClass *klass) g_type_class_add_private (gobject_class, sizeof (ClutterStagePrivate)); } -static void -_clutter_stage_refresh_perspective_matrix (ClutterStagePrivate * priv) -{ - ClutterFixed xmax, ymax; - ClutterFixed x, y, c, d; - - memset (&priv->perspective_mtx[0], 0, sizeof (priv->perspective_mtx)); - - ymax = clutter_qmulx (priv->perspective.z_near, - clutter_tani (priv->perspective.fovy >> 1)); - - xmax = clutter_qmulx (ymax, priv->perspective.aspect); - - x = CFX_DIV (priv->perspective.z_near, xmax); - y = CFX_DIV (priv->perspective.z_near, ymax); - c = CFX_DIV (-(priv->perspective.z_far + priv->perspective.z_near), - ( priv->perspective.z_far - priv->perspective.z_near)); - - d = CFX_DIV (-(clutter_qmulx (2 * priv->perspective.z_far, - priv->perspective.z_near)), - (priv->perspective.z_far - priv->perspective.z_near)); - -#define M(row,col) priv->perspective_mtx[col*4+row] - M(0,0) = x; - M(1,1) = y; - M(2,2) = c; - M(2,3) = d; - M(3,2) = -CFX_ONE; -#undef M -} - -const ClutterFixed * -_clutter_stage_get_perspective_matrix (ClutterStage * stage) -{ - return &stage->priv->perspective_mtx[0]; -} - static void clutter_stage_init (ClutterStage *self) { @@ -445,8 +406,6 @@ clutter_stage_init (ClutterStage *self) priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED (0.1); priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED (100.0); - _clutter_stage_refresh_perspective_matrix (priv); - clutter_actor_set_size (CLUTTER_ACTOR (self), 640, 480); } @@ -546,8 +505,6 @@ clutter_stage_set_perspectivex (ClutterStage *stage, priv->perspective.z_near = perspective->z_near; priv->perspective.z_far = perspective->z_far; - _clutter_stage_refresh_perspective_matrix (priv); - CLUTTER_SET_PRIVATE_FLAGS(stage, CLUTTER_ACTOR_SYNC_MATRICES); } @@ -597,8 +554,6 @@ clutter_stage_set_perspective (ClutterStage *stage, priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED(z_near); priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED(z_far); - _clutter_stage_refresh_perspective_matrix (priv); - CLUTTER_SET_PRIVATE_FLAGS(stage, CLUTTER_ACTOR_SYNC_MATRICES); }