transformnode: Avoid matrix multiplication if we can

If the given matrix is explicitly of category IDENTITY, we don't need to
do anything, and in the 2D_TRANSLATE case, just offset the child bounds.
Those are the two most common cases.
This commit is contained in:
Timm Bäder 2019-02-26 07:24:18 +01:00
parent 5577e30ad4
commit bbd4e2f60d

View File

@ -2547,9 +2547,30 @@ gsk_transform_node_new_with_category (GskRenderNode *child,
graphene_matrix_init_from_matrix (&self->transform, transform);
self->category = category;
graphene_matrix_transform_bounds (&self->transform,
&child->bounds,
&self->render_node.bounds);
switch (category)
{
case GSK_MATRIX_CATEGORY_IDENTITY:
graphene_rect_init_from_rect (&self->render_node.bounds, &child->bounds);
break;
case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
{
graphene_rect_init_from_rect (&self->render_node.bounds, &child->bounds);
self->render_node.bounds.origin.x += graphene_matrix_get_value (transform, 3, 0);
self->render_node.bounds.origin.y += graphene_matrix_get_value (transform, 3, 1);
}
break;
case GSK_MATRIX_CATEGORY_2D_AFFINE:
case GSK_MATRIX_CATEGORY_ANY:
case GSK_MATRIX_CATEGORY_UNKNOWN:
case GSK_MATRIX_CATEGORY_INVERTIBLE:
default:
graphene_matrix_transform_bounds (&self->transform,
&child->bounds,
&self->render_node.bounds);
}
return &self->render_node;
}