1
0
Fork 0

boxes: Move Rectangle.crop_and_scale to Mtk

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3501>
This commit is contained in:
Bilal Elmoussaoui 2024-01-06 19:36:22 +01:00 committed by Marge Bot
parent abe47769b7
commit 59457dff81
6 changed files with 36 additions and 35 deletions

View file

@ -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);
}

View file

@ -124,3 +124,9 @@ void mtk_rectangle_from_graphene_rect (const graphene_rect_t *rect,
MtkRoundingStrategy rounding_strategy, MtkRoundingStrategy rounding_strategy,
MtkRectangle *dest); 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);

View file

@ -1113,11 +1113,11 @@ meta_shaped_texture_update_area (MetaShapedTexture *stex,
inverted_dst_width = ceilf (viewport.size.width); inverted_dst_width = ceilf (viewport.size.width);
inverted_dst_height = ceilf (viewport.size.height); inverted_dst_height = ceilf (viewport.size.height);
meta_rectangle_crop_and_scale (clip, mtk_rectangle_crop_and_scale (clip,
&inverted_viewport, &inverted_viewport,
inverted_dst_width, inverted_dst_width,
inverted_dst_height, inverted_dst_height,
clip); clip);
} }
meta_texture_mipmap_invalidate (stex->texture_mipmap); meta_texture_mipmap_invalidate (stex->texture_mipmap);

View file

@ -416,11 +416,11 @@ meta_region_crop_and_scale (MtkRegion *region,
{ {
rects[i] = mtk_region_get_rectangle (region, i); rects[i] = mtk_region_get_rectangle (region, i);
meta_rectangle_crop_and_scale (&rects[i], mtk_rectangle_crop_and_scale (&rects[i],
src_rect, src_rect,
dst_width, dst_width,
dst_height, dst_height,
&rects[i]); &rects[i]);
} }
viewport_region = mtk_region_create_rectangles (rects, n_rects); viewport_region = mtk_region_create_rectangles (rects, n_rects);

View file

@ -252,10 +252,4 @@ void meta_rectangle_transform (const MtkRectangle *rect,
MetaMonitorTransform transform, MetaMonitorTransform transform,
int width, int width,
int height, int height,
MtkRectangle *dest); MtkRectangle *dest);
void meta_rectangle_crop_and_scale (const MtkRectangle *rect,
graphene_rect_t *src_rect,
int dst_width,
int dst_height,
MtkRectangle *dest);

View file

@ -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);
}