From 41497aeb8b25b72c1443d63168ea18adfae72751 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 4 Sep 2020 12:51:11 -0400 Subject: [PATCH] Add gsk_matrix_transform_rect This is a projecting version of the corresponding graphene api. While we are at it, rewrite gsk_matrix_transform_bounds() to use gsk_matrix_transform_rect(). --- gsk/gsktransform.c | 27 ++++++++++++++------------- gsk/gsktransformprivate.h | 4 +++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c index 337a27ed12..2bd1bdc920 100644 --- a/gsk/gsktransform.c +++ b/gsk/gsktransform.c @@ -2204,13 +2204,11 @@ gsk_matrix_transform_point3d (const graphene_matrix_t *m, } void -gsk_matrix_transform_bounds (const graphene_matrix_t *m, - const graphene_rect_t *r, - graphene_rect_t *res) +gsk_matrix_transform_rect (const graphene_matrix_t *m, + const graphene_rect_t *r, + graphene_quad_t *res) { graphene_point_t ret[4]; - float min_x, min_y; - float max_x, max_y; graphene_rect_t rr; graphene_rect_normalize_r (r, &rr); @@ -2233,12 +2231,15 @@ gsk_matrix_transform_bounds (const graphene_matrix_t *m, #undef TRANSFORM_POINT - /* FIXME: graphene doesn't export a fast way to do this */ - min_x = MIN (MIN (ret[0].x, ret[1].x), MIN (ret[2].x, ret[3].x)); - min_y = MIN (MIN (ret[0].y, ret[1].y), MIN (ret[2].y, ret[3].y)); - - max_x = MAX (MAX (ret[0].x, ret[1].x), MAX (ret[2].x, ret[3].x)); - max_y = MAX (MAX (ret[0].y, ret[1].y), MAX (ret[2].y, ret[3].y)); - - graphene_rect_init (res, min_x, min_y, max_x - min_x, max_y - min_y); + graphene_quad_init (res, &ret[0], &ret[1], &ret[2], &ret[3]); +} +void +gsk_matrix_transform_bounds (const graphene_matrix_t *m, + const graphene_rect_t *r, + graphene_rect_t *res) +{ + graphene_quad_t q; + + gsk_matrix_transform_rect (m, r, &q); + graphene_quad_bounds (&q, res); } diff --git a/gsk/gsktransformprivate.h b/gsk/gsktransformprivate.h index 2c2f97448c..9f88e9a002 100644 --- a/gsk/gsktransformprivate.h +++ b/gsk/gsktransformprivate.h @@ -41,7 +41,9 @@ void gsk_matrix_transform_point3d (const graphene_matrix_t *m, void gsk_matrix_transform_bounds (const graphene_matrix_t *m, const graphene_rect_t *r, graphene_rect_t *res); - +void gsk_matrix_transform_rect (const graphene_matrix_t *m, + const graphene_rect_t *r, + graphene_quad_t *res); G_END_DECLS