1
0
Fork 0

region: Move rectangle helper macro to Mtk

Rename it to Rectangle prefix to avoid confusion with MtkRegion

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3501>
This commit is contained in:
Bilal Elmoussaoui 2024-01-08 20:16:24 +01:00 committed by Marge Bot
parent 6f9e75b6f2
commit 4513abd584
2 changed files with 13 additions and 13 deletions

View file

@ -36,6 +36,15 @@ typedef enum _MtkRoundingStrategy
} 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: * MtkRectangle:
* @x: X coordinate of the top-left corner * @x: X coordinate of the top-left corner

View file

@ -26,15 +26,6 @@
#include <math.h> #include <math.h>
#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 */ /* MetaRegionBuilder */
/* Various algorithms in this file require unioning together a set of rectangles /* 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); return mtk_region_copy (region);
n_rects = mtk_region_num_rectangles (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++) for (i = 0; i < n_rects; i++)
{ {
rects[i] = mtk_region_get_rectangle (region, i); rects[i] = mtk_region_get_rectangle (region, i);
@ -363,7 +354,7 @@ meta_region_transform (const MtkRegion *region,
return mtk_region_copy (region); return mtk_region_copy (region);
n_rects = mtk_region_num_rectangles (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++) for (i = 0; i < n_rects; i++)
{ {
rects[i] = mtk_region_get_rectangle (region, 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); 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++) for (i = 0; i < n_rects; i++)
{ {
rects[i] = mtk_region_get_rectangle (region, 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); return mtk_region_copy (region);
n_rects = mtk_region_num_rectangles (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++) for (i = 0; i < n_rects; i++)
{ {
graphene_rect_t transformed_rect, rect; graphene_rect_t transformed_rect, rect;