diff --git a/mtk/mtk/mtk-region.c b/mtk/mtk/mtk-region.c index d132ead3d..78651efea 100644 --- a/mtk/mtk/mtk-region.c +++ b/mtk/mtk/mtk-region.c @@ -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; +} diff --git a/mtk/mtk/mtk-region.h b/mtk/mtk/mtk-region.h index f4f6dcfec..831a583bd 100644 --- a/mtk/mtk/mtk-region.h +++ b/mtk/mtk/mtk-region.h @@ -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) diff --git a/src/compositor/meta-cullable.c b/src/compositor/meta-cullable.c index 7279f4ff3..7b6cd2b68 100644 --- a/src/compositor/meta-cullable.c +++ b/src/compositor/meta-cullable.c @@ -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); } /** diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c index c5d75fa45..1c10b850f 100644 --- a/src/compositor/meta-surface-actor.c +++ b/src/compositor/meta-surface-actor.c @@ -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, diff --git a/src/compositor/meta-window-group.c b/src/compositor/meta-window-group.c index bb59264c5..b88648f54 100644 --- a/src/compositor/meta-window-group.c +++ b/src/compositor/meta-window-group.c @@ -120,8 +120,8 @@ 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, - &stage_to_actor); + clip_region = mtk_region_apply_matrix_transform_expand (redraw_clip, + &stage_to_actor); meta_cullable_cull_redraw_clip (META_CULLABLE (window_group), clip_region); diff --git a/src/compositor/region-utils.c b/src/compositor/region-utils.c index 981e843c8..c5bf39c97 100644 --- a/src/compositor/region-utils.c +++ b/src/compositor/region-utils.c @@ -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; -} diff --git a/src/compositor/region-utils.h b/src/compositor/region-utils.h index 7613aa9ec..c62192ffa 100644 --- a/src/compositor/region-utils.h +++ b/src/compositor/region-utils.h @@ -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);