From 3bc3e140ddee3f274f0797c10cf7e33dd1b32074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 29 Jun 2019 09:39:20 +0200 Subject: [PATCH] transform: Add transform_bounds fast path for 2D_AFFINE transforms E.g. anything involving a scale. This is important when e.g. scrolling in the node list in the recorder, which scales every recorded node down to fit in the list. --- gsk/gsktransform.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c index 289e463bb7..9af2ce352b 100644 --- a/gsk/gsktransform.c +++ b/gsk/gsktransform.c @@ -1690,11 +1690,26 @@ gsk_transform_transform_bounds (GskTransform *self, } break; + case GSK_TRANSFORM_CATEGORY_2D_AFFINE: + { + float dx, dy, scale_x, scale_y; + + gsk_transform_to_affine (self, &scale_x, &scale_y, &dx, &dy); + + *out_rect = *rect; + out_rect->origin.x *= scale_x; + out_rect->origin.y *= scale_y; + out_rect->size.width *= scale_x; + out_rect->size.height *= scale_y; + out_rect->origin.x += dx; + out_rect->origin.y += dy; + } + break; + case GSK_TRANSFORM_CATEGORY_UNKNOWN: case GSK_TRANSFORM_CATEGORY_ANY: case GSK_TRANSFORM_CATEGORY_3D: case GSK_TRANSFORM_CATEGORY_2D: - case GSK_TRANSFORM_CATEGORY_2D_AFFINE: default: { graphene_matrix_t mat;