diff --git a/mtk/mtk/mtk-rectangle.c b/mtk/mtk/mtk-rectangle.c index 70cf62c6c..83330b3e0 100644 --- a/mtk/mtk/mtk-rectangle.c +++ b/mtk/mtk/mtk-rectangle.c @@ -349,3 +349,22 @@ mtk_rectangle_from_graphene_rect (const graphene_rect_t *rect, } } } + +void +mtk_rectangle_crop_and_scale (const MtkRectangle *rect, + const graphene_rect_t *src_rect, + int dst_width, + int dst_height, + MtkRectangle *dest) +{ + graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y, + rect->width, rect->height); + + graphene_rect_scale (&tmp, + src_rect->size.width / dst_width, + src_rect->size.height / dst_height, + &tmp); + graphene_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y); + + mtk_rectangle_from_graphene_rect (&tmp, MTK_ROUNDING_STRATEGY_GROW, dest); +} \ No newline at end of file diff --git a/mtk/mtk/mtk-rectangle.h b/mtk/mtk/mtk-rectangle.h index 0c9215fba..e63a51436 100644 --- a/mtk/mtk/mtk-rectangle.h +++ b/mtk/mtk/mtk-rectangle.h @@ -124,3 +124,9 @@ void mtk_rectangle_from_graphene_rect (const graphene_rect_t *rect, MtkRoundingStrategy rounding_strategy, MtkRectangle *dest); +MTK_EXPORT +void mtk_rectangle_crop_and_scale (const MtkRectangle *rect, + const graphene_rect_t *src_rect, + int dst_width, + int dst_height, + MtkRectangle *dest); diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 655b32506..2eb98a7fe 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -1113,11 +1113,11 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex, inverted_dst_width = ceilf (viewport.size.width); inverted_dst_height = ceilf (viewport.size.height); - meta_rectangle_crop_and_scale (clip, - &inverted_viewport, - inverted_dst_width, - inverted_dst_height, - clip); + mtk_rectangle_crop_and_scale (clip, + &inverted_viewport, + inverted_dst_width, + inverted_dst_height, + clip); } meta_texture_mipmap_invalidate (stex->texture_mipmap); diff --git a/src/compositor/region-utils.c b/src/compositor/region-utils.c index 3748f92ff..037dc4f44 100644 --- a/src/compositor/region-utils.c +++ b/src/compositor/region-utils.c @@ -416,11 +416,11 @@ meta_region_crop_and_scale (MtkRegion *region, { rects[i] = mtk_region_get_rectangle (region, i); - meta_rectangle_crop_and_scale (&rects[i], - src_rect, - dst_width, - dst_height, - &rects[i]); + mtk_rectangle_crop_and_scale (&rects[i], + src_rect, + dst_width, + dst_height, + &rects[i]); } viewport_region = mtk_region_create_rectangles (rects, n_rects); diff --git a/src/core/boxes-private.h b/src/core/boxes-private.h index 4a9f9d093..3bc36138f 100644 --- a/src/core/boxes-private.h +++ b/src/core/boxes-private.h @@ -252,10 +252,4 @@ void meta_rectangle_transform (const MtkRectangle *rect, MetaMonitorTransform transform, int width, int height, - MtkRectangle *dest); - -void meta_rectangle_crop_and_scale (const MtkRectangle *rect, - graphene_rect_t *src_rect, - int dst_width, - int dst_height, - MtkRectangle *dest); + MtkRectangle *dest); \ No newline at end of file diff --git a/src/core/boxes.c b/src/core/boxes.c index 915ef9fb2..6b54318fe 100644 --- a/src/core/boxes.c +++ b/src/core/boxes.c @@ -1946,21 +1946,3 @@ meta_rectangle_transform (const MtkRectangle *rect, } } -void -meta_rectangle_crop_and_scale (const MtkRectangle *rect, - graphene_rect_t *src_rect, - int dst_width, - int dst_height, - MtkRectangle *dest) -{ - graphene_rect_t tmp = GRAPHENE_RECT_INIT (rect->x, rect->y, - rect->width, rect->height); - - graphene_rect_scale (&tmp, - src_rect->size.width / dst_width, - src_rect->size.height / dst_height, - &tmp); - graphene_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y); - - mtk_rectangle_from_graphene_rect (&tmp, MTK_ROUNDING_STRATEGY_GROW, dest); -}