[mutter] clutter/util: Add functions for managing cairo and clutter rects
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/util: Add functions for managing cairo and clutter rects
- Date: Fri, 1 Mar 2019 18:52:19 +0000 (UTC)
commit e5a9e9c93b42312e4305f603f50029a160670389
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri Mar 1 15:43:14 2019 +0100
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
clutter/clutter/clutter-private.h | 8 ++++++++
clutter/clutter/clutter-util.c | 26 ++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
---
diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h
index cbfaaa7f0..a5cd1fa19 100644
--- a/clutter/clutter/clutter-private.h
+++ b/clutter/clutter/clutter-private.h
@@ -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);
diff --git a/clutter/clutter/clutter-util.c b/clutter/clutter/clutter-util.c
index 49423e802..ed52b6977 100644
--- a/clutter/clutter/clutter-util.c
+++ b/clutter/clutter/clutter-util.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]