removed perspective matrix caching from ClutterStage

This commit is contained in:
Tomas Frydrych 2007-06-01 16:20:57 +00:00
parent f6b675fc7d
commit 479fe01b5a
4 changed files with 46 additions and 55 deletions

View File

@ -1,3 +1,10 @@
2007-06-01 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-actor.c:
* clutter/clutter-stage.c:
* clutter/clutter-private.h:
Removed perspective matrix caching from ClutterStage.
2007-06-01 Neil J. Patel <njp@o-hand.com> 2007-06-01 Neil J. Patel <njp@o-hand.com>
* clutter/clutter-entry.c: (clutter_entry_set_property), * clutter/clutter-entry.c: (clutter_entry_set_property),
@ -23,7 +30,7 @@
Added a signla to track cursor movements. Added a signla to track cursor movements.
Moved the sursor painting function so it can be subclassed. Moved the sursor painting function so it can be subclassed.
007-06-01 Tomas Frydrych <tf@openedhand.com> 2007-06-01 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-actor.c: * clutter/clutter-actor.c:
(clutter_actor_get_transformed_point): (clutter_actor_get_transformed_point):

View File

@ -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: * clutter_actor_get_transformed_point:
* @self: A #ClutterActor * @self: A #ClutterActor
@ -702,16 +733,16 @@ clutter_actor_get_transformed_point (ClutterActor *actor,
ClutterUnit *z_return) ClutterUnit *z_return)
{ {
ClutterFixed mtx[16]; ClutterFixed mtx[16];
const ClutterFixed *mtx_p; ClutterFixed mtx_p[16];
ClutterActorPrivate *priv; ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (actor)); g_return_if_fail (CLUTTER_IS_ACTOR (actor));
priv = actor->priv; 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); *x_return = CLUTTER_UNITS_FROM_INT(x);
*y_return = CLUTTER_UNITS_FROM_INT(y); *y_return = CLUTTER_UNITS_FROM_INT(y);
@ -734,7 +765,7 @@ clutter_actor_get_transformed_vertices (ClutterActor * self,
ClutterVertices * verts) ClutterVertices * verts)
{ {
ClutterFixed mtx[16]; ClutterFixed mtx[16];
const ClutterFixed *mtx_p; ClutterFixed mtx_p[16];
ClutterFixed x, y, z; ClutterFixed x, y, z;
ClutterActorPrivate *priv; ClutterActorPrivate *priv;
@ -746,9 +777,9 @@ clutter_actor_get_transformed_vertices (ClutterActor * self,
priv = self->priv; priv = self->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]);
#if 0 #if 0
g_debug ("Matrix\n" g_debug ("Matrix\n"

View File

@ -119,8 +119,6 @@ void _clutter_event_button_generate (ClutterBackend *backend,
void _clutter_feature_init (void); void _clutter_feature_init (void);
const ClutterFixed * _clutter_stage_get_perspective_matrix (ClutterStage * stage);
/* Does this need to be private ? */ /* Does this need to be private ? */
void clutter_do_event (ClutterEvent *event); void clutter_do_event (ClutterEvent *event);

View File

@ -61,8 +61,6 @@ struct _ClutterStagePrivate
guint is_fullscreen : 1; guint is_fullscreen : 1;
guint is_offscreen : 1; guint is_offscreen : 1;
guint is_cursor_visible : 1; guint is_cursor_visible : 1;
ClutterFixed perspective_mtx[16];
}; };
enum enum
@ -384,43 +382,6 @@ clutter_stage_class_init (ClutterStageClass *klass)
g_type_class_add_private (gobject_class, sizeof (ClutterStagePrivate)); 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 static void
clutter_stage_init (ClutterStage *self) 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_near = CLUTTER_FLOAT_TO_FIXED (0.1);
priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED (100.0); 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); 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_near = perspective->z_near;
priv->perspective.z_far = perspective->z_far; priv->perspective.z_far = perspective->z_far;
_clutter_stage_refresh_perspective_matrix (priv);
CLUTTER_SET_PRIVATE_FLAGS(stage, CLUTTER_ACTOR_SYNC_MATRICES); 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_near = CLUTTER_FLOAT_TO_FIXED(z_near);
priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED(z_far); 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); CLUTTER_SET_PRIVATE_FLAGS(stage, CLUTTER_ACTOR_SYNC_MATRICES);
} }