clutter/util: Add functions for managing cairo and clutter rects

Utility functions to easily convert from ClutterRect to cairo int rects and
vice-versa.

And add ability to offset a cairo rect.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
This commit is contained in:
Marco Trevisan (Treviño) 2019-03-01 15:43:14 +01:00
parent a8c972cd6b
commit e5a9e9c93b
2 changed files with 34 additions and 0 deletions

View File

@ -249,6 +249,14 @@ void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
ClutterRect *dest);
void _clutter_util_rectangle_int_extents (const ClutterRect *src,
cairo_rectangle_int_t *dest);
void _clutter_util_rectangle_offset (const cairo_rectangle_int_t *src,
int x,
int y,
cairo_rectangle_int_t *dest);
void _clutter_util_rectangle_union (const cairo_rectangle_int_t *src1,
const cairo_rectangle_int_t *src2,
cairo_rectangle_int_t *dest);

View File

@ -120,6 +120,32 @@ void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
};
}
void _clutter_util_rectangle_int_extents (const ClutterRect *src,
cairo_rectangle_int_t *dest)
{
ClutterRect tmp = *src;
clutter_rect_clamp_to_pixel (&tmp);
*dest = (cairo_rectangle_int_t) {
.x = tmp.origin.x,
.y = tmp.origin.y,
.width = tmp.size.width,
.height = tmp.size.height,
};
}
void _clutter_util_rectangle_offset (const cairo_rectangle_int_t *src,
int x,
int y,
cairo_rectangle_int_t *dest)
{
*dest = *src;
dest->x += x;
dest->y += y;
}
/*< private >
* _clutter_util_rectangle_union:
* @src1: first rectangle to union