region: Move Region.apply_matrix_transform_expand to Mtk

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3501>
This commit is contained in:
Bilal Elmoussaoui 2024-01-08 20:31:50 +01:00 committed by Marge Bot
parent 4d53e4d156
commit 39aeb81a8b
7 changed files with 41 additions and 41 deletions

View File

@ -435,3 +435,36 @@ mtk_region_crop_and_scale (MtkRegion *region,
return viewport_region;
}
MtkRegion *
mtk_region_apply_matrix_transform_expand (const MtkRegion *region,
graphene_matrix_t *transform)
{
MtkRegion *transformed_region;
MtkRectangle *rects;
int n_rects, i;
if (graphene_matrix_is_identity (transform))
return mtk_region_copy (region);
n_rects = mtk_region_num_rectangles (region);
MTK_RECTANGLE_CREATE_ARRAY_SCOPED (n_rects, rects);
for (i = 0; i < n_rects; i++)
{
graphene_rect_t transformed_rect, rect;
MtkRectangle int_rect;
int_rect = mtk_region_get_rectangle (region, i);
rect = mtk_rectangle_to_graphene_rect (&int_rect);
graphene_matrix_transform_bounds (transform, &rect, &transformed_rect);
mtk_rectangle_from_graphene_rect (&transformed_rect,
MTK_ROUNDING_STRATEGY_GROW,
&rects[i]);
}
transformed_region = mtk_region_create_rectangles (rects, n_rects);
return transformed_region;
}

View File

@ -124,4 +124,8 @@ MtkRegion * mtk_region_crop_and_scale (MtkRegion *region,
int dst_width,
int dst_height);
MTK_EXPORT
MtkRegion * mtk_region_apply_matrix_transform_expand (const MtkRegion *region,
graphene_matrix_t *transform);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MtkRegion, mtk_region_unref)

View File

@ -53,7 +53,7 @@ region_apply_transform_expand_maybe_ref (MtkRegion *region,
if (mtk_region_is_empty (region))
return mtk_region_ref (region);
return meta_region_apply_matrix_transform_expand (region, transform);
return mtk_region_apply_matrix_transform_expand (region, transform);
}
/**

View File

@ -492,7 +492,7 @@ meta_surface_actor_is_obscured_on_stage_view (MetaSurfaceActor *self,
stage,
&transform);
intersection_region = meta_region_apply_matrix_transform_expand (unobscured_region, &transform);
intersection_region = mtk_region_apply_matrix_transform_expand (unobscured_region, &transform);
clutter_stage_view_get_layout (stage_view, &stage_rect);
mtk_region_intersect_rectangle (intersection_region,

View File

@ -120,7 +120,7 @@ meta_window_group_paint (ClutterActor *actor,
* multihead setup with mismatched monitor sizes, we could intersect this
* with an accurate union of the monitors to avoid painting shadows that are
* visible only in the holes. */
clip_region = meta_region_apply_matrix_transform_expand (redraw_clip,
clip_region = mtk_region_apply_matrix_transform_expand (redraw_clip,
&stage_to_actor);
meta_cullable_cull_redraw_clip (META_CULLABLE (window_group), clip_region);

View File

@ -343,36 +343,3 @@ meta_region_transform (const MtkRegion *region,
return transformed_region;
}
MtkRegion *
meta_region_apply_matrix_transform_expand (const MtkRegion *region,
graphene_matrix_t *transform)
{
int n_rects, i;
MtkRectangle *rects;
MtkRegion *transformed_region;
if (graphene_matrix_is_identity (transform))
return mtk_region_copy (region);
n_rects = mtk_region_num_rectangles (region);
MTK_RECTANGLE_CREATE_ARRAY_SCOPED (n_rects, rects);
for (i = 0; i < n_rects; i++)
{
graphene_rect_t transformed_rect, rect;
MtkRectangle int_rect;
int_rect = mtk_region_get_rectangle (region, i);
rect = mtk_rectangle_to_graphene_rect (&int_rect);
graphene_matrix_transform_bounds (transform, &rect, &transformed_rect);
mtk_rectangle_from_graphene_rect (&transformed_rect,
MTK_ROUNDING_STRATEGY_GROW,
&rects[i]);
}
transformed_region = mtk_region_create_rectangles (rects, n_rects);
return transformed_region;
}

View File

@ -101,7 +101,3 @@ MtkRegion * meta_region_transform (const MtkRegion *region,
MetaMonitorTransform transform,
int width,
int height);
MtkRegion *
meta_region_apply_matrix_transform_expand (const MtkRegion *region,
graphene_matrix_t *transform);