transform: Add optimization for common case

Transforming identity by an other transform does not mean we need to
painstakingly apply the individual steps of other to construct a new
transform, it means we can just return other.

Or in math terms:
  I * B = B
so just return B.
This commit is contained in:
Benjamin Otte
2020-02-20 00:02:19 +01:00
parent d7d7957b04
commit 41ef6e9fa5

View File

@@ -1622,6 +1622,12 @@ gsk_transform_transform (GskTransform *next,
if (other == NULL)
return next;
if (gsk_transform_is_identity (next))
{
gsk_transform_unref (next);
return gsk_transform_ref (other);
}
next = gsk_transform_transform (next, other->next);
return other->transform_class->apply (other, next);
}