summaryrefslogtreecommitdiff
path: root/gsk/gsktransform.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2019-06-03 16:20:12 +0200
committerTimm Bäder <mail@baedert.org>2019-06-03 17:03:02 +0200
commit05ca772631e4454918c5b0befd5ee6b808546774 (patch)
tree980254beab4daacfab93c9af6c5c2c3cf3d267fa /gsk/gsktransform.c
parentefe9bba343f0ca839bb134fcc46bacd54b247a6a (diff)
downloadgtk+-05ca772631e4454918c5b0befd5ee6b808546774.tar.gz
GskTransform: Ignore identity transforms
We often end up with e.g. a scale of 1 or a translation by 0/0. Ignore those transforms since they don't do anything.
Diffstat (limited to 'gsk/gsktransform.c')
-rw-r--r--gsk/gsktransform.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c
index a32d62131d..d70fdadf4c 100644
--- a/gsk/gsktransform.c
+++ b/gsk/gsktransform.c
@@ -644,7 +644,10 @@ gsk_transform_translate_3d (GskTransform *next,
const graphene_point3d_t *point)
{
GskTranslateTransform *result;
-
+
+ if (graphene_point3d_equal (point, graphene_point3d_zero ()))
+ return gsk_transform_ref (next);
+
if (gsk_transform_has_class (next, &GSK_TRANSLATE_TRANSFORM_CLASS))
{
GskTranslateTransform *t = (GskTranslateTransform *) next;
@@ -797,6 +800,9 @@ gsk_transform_rotate (GskTransform *next,
{
GskRotateTransform *result;
+ if (angle == 0.0f)
+ return gsk_transform_ref (next);
+
if (gsk_transform_has_class (next, &GSK_ROTATE_TRANSFORM_CLASS))
{
GskTransform *r = gsk_transform_rotate (gsk_transform_ref (next->next),
@@ -921,10 +927,13 @@ gsk_transform_rotate_3d (GskTransform *next,
const graphene_vec3_t *axis)
{
GskRotate3dTransform *result;
-
+
if (graphene_vec3_get_x (axis) == 0.0 && graphene_vec3_get_y (axis) == 0.0)
return gsk_transform_rotate (next, angle);
+ if (angle == 0.0f)
+ return gsk_transform_ref (next);
+
result = gsk_transform_alloc (&GSK_ROTATE3D_TRANSFORM_CLASS,
GSK_TRANSFORM_CATEGORY_3D,
next);
@@ -1110,7 +1119,10 @@ gsk_transform_scale_3d (GskTransform *next,
float factor_z)
{
GskScaleTransform *result;
-
+
+ if (factor_x == 1 && factor_y == 1 && factor_z == 1)
+ return gsk_transform_ref (next);
+
if (gsk_transform_has_class (next, &GSK_SCALE_TRANSFORM_CLASS))
{
GskScaleTransform *scale = (GskScaleTransform *) next;