clutter/actor: Extend caching in apply_relative_transformation_matrix
Apart from a few edge cases we can avoid walking the tree and transform to the ancestor coordinate space by multiplying the actor stage-relative matrix with the inverse of the ancestor's stage-relative matrix. Since the stage-relative matrices are cached, this reduces the number of matrix multiplications we do in many situations considerably. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3259>
This commit is contained in:
parent
47d4613ce7
commit
dfd58ca8f1
@ -3045,6 +3045,10 @@ _clutter_actor_apply_relative_transformation_matrix (ClutterActor *self,
|
||||
ClutterActor *ancestor,
|
||||
graphene_matrix_t *matrix)
|
||||
{
|
||||
ClutterActorPrivate *priv = self->priv;
|
||||
graphene_matrix_t parent_modelview;
|
||||
graphene_matrix_t inverse_parent_modelview;
|
||||
|
||||
/* Note we terminate before ever calling stage->apply_transform()
|
||||
* since that would conceptually be relative to the underlying
|
||||
* window OpenGL coordinates so we'd need a special @ancestor
|
||||
@ -3052,10 +3056,6 @@ _clutter_actor_apply_relative_transformation_matrix (ClutterActor *self,
|
||||
if (self == ancestor)
|
||||
return;
|
||||
|
||||
if (ancestor == NULL)
|
||||
{
|
||||
ClutterActorPrivate *priv = self->priv;
|
||||
|
||||
if (!priv->absolute_modelview_valid)
|
||||
{
|
||||
graphene_matrix_init_identity (&priv->absolute_modelview);
|
||||
@ -3072,12 +3072,26 @@ _clutter_actor_apply_relative_transformation_matrix (ClutterActor *self,
|
||||
priv->absolute_modelview_valid = TRUE;
|
||||
}
|
||||
|
||||
if (ancestor == NULL)
|
||||
{
|
||||
graphene_matrix_multiply (&priv->absolute_modelview, matrix, matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->priv->parent != NULL)
|
||||
_clutter_actor_apply_relative_transformation_matrix (self->priv->parent,
|
||||
graphene_matrix_init_identity (&parent_modelview);
|
||||
_clutter_actor_apply_relative_transformation_matrix (ancestor,
|
||||
NULL,
|
||||
&parent_modelview);
|
||||
if (graphene_matrix_inverse (&parent_modelview,
|
||||
&inverse_parent_modelview))
|
||||
{
|
||||
graphene_matrix_multiply (&inverse_parent_modelview, matrix, matrix);
|
||||
graphene_matrix_multiply (&priv->absolute_modelview, matrix, matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->parent != NULL)
|
||||
_clutter_actor_apply_relative_transformation_matrix (priv->parent,
|
||||
ancestor,
|
||||
matrix);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user