From 4513abd584038e2e0aef09218164434ee91a5313 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Mon, 8 Jan 2024 20:16:24 +0100 Subject: [PATCH] region: Move rectangle helper macro to Mtk Rename it to Rectangle prefix to avoid confusion with MtkRegion Part-of: --- mtk/mtk/mtk-rectangle.h | 9 +++++++++ src/compositor/region-utils.c | 17 ++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mtk/mtk/mtk-rectangle.h b/mtk/mtk/mtk-rectangle.h index 5354cd94b..2463d3b08 100644 --- a/mtk/mtk/mtk-rectangle.h +++ b/mtk/mtk/mtk-rectangle.h @@ -36,6 +36,15 @@ typedef enum _MtkRoundingStrategy } MtkRoundingStrategy; +#define MTK_RECTANGLE_MAX_STACK_RECTS 256 + +#define MTK_RECTANGLE_CREATE_ARRAY_SCOPED(n_rects, rects) \ + g_autofree MtkRectangle *G_PASTE(__n, __LINE__) = NULL; \ + if (n_rects < MTK_RECTANGLE_MAX_STACK_RECTS) \ + rects = g_newa (MtkRectangle, n_rects); \ + else \ + rects = G_PASTE(__n, __LINE__) = g_new (MtkRectangle, n_rects); + /** * MtkRectangle: * @x: X coordinate of the top-left corner diff --git a/src/compositor/region-utils.c b/src/compositor/region-utils.c index 037dc4f44..00a7421bc 100644 --- a/src/compositor/region-utils.c +++ b/src/compositor/region-utils.c @@ -26,15 +26,6 @@ #include -#define META_REGION_MAX_STACK_RECTS 256 - -#define META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED(n_rects, rects) \ - g_autofree MtkRectangle *G_PASTE(__n, __LINE__) = NULL; \ - if (n_rects < META_REGION_MAX_STACK_RECTS) \ - rects = g_newa (MtkRectangle, n_rects); \ - else \ - rects = G_PASTE(__n, __LINE__) = g_new (MtkRectangle, n_rects); - /* MetaRegionBuilder */ /* Various algorithms in this file require unioning together a set of rectangles @@ -197,7 +188,7 @@ meta_region_scale (MtkRegion *region, return mtk_region_copy (region); n_rects = mtk_region_num_rectangles (region); - META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects); + MTK_RECTANGLE_CREATE_ARRAY_SCOPED (n_rects, rects); for (i = 0; i < n_rects; i++) { rects[i] = mtk_region_get_rectangle (region, i); @@ -363,7 +354,7 @@ meta_region_transform (const MtkRegion *region, return mtk_region_copy (region); n_rects = mtk_region_num_rectangles (region); - META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects); + MTK_RECTANGLE_CREATE_ARRAY_SCOPED (n_rects, rects); for (i = 0; i < n_rects; i++) { rects[i] = mtk_region_get_rectangle (region, i); @@ -411,7 +402,7 @@ meta_region_crop_and_scale (MtkRegion *region, } n_rects = mtk_region_num_rectangles (region); - META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects); + MTK_RECTANGLE_CREATE_ARRAY_SCOPED (n_rects, rects); for (i = 0; i < n_rects; i++) { rects[i] = mtk_region_get_rectangle (region, i); @@ -440,7 +431,7 @@ meta_region_apply_matrix_transform_expand (const MtkRegion *region, return mtk_region_copy (region); n_rects = mtk_region_num_rectangles (region); - META_REGION_CREATE_RECTANGLE_ARRAY_SCOPED (n_rects, rects); + MTK_RECTANGLE_CREATE_ARRAY_SCOPED (n_rects, rects); for (i = 0; i < n_rects; i++) { graphene_rect_t transformed_rect, rect;