[cairo] [PATCH v8 05/71] core: helper inline for rect->box conversion

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Thu Jun 30 15:45:43 UTC 2016


Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
 src/cairo-box-inline.h | 10 ++++++++++
 src/cairo-clip-boxes.c | 11 ++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/cairo-box-inline.h b/src/cairo-box-inline.h
index 406102a..c20c28f 100644
--- a/src/cairo-box-inline.h
+++ b/src/cairo-box-inline.h
@@ -57,6 +57,16 @@ _cairo_box_from_integers (cairo_box_t *box, int x, int y, int w, int h)
     box->p2.y = _cairo_fixed_from_int (y + h);
 }
 
+static inline void
+_cairo_box_from_rectangle_int(cairo_box_t *box,
+			      const cairo_rectangle_int_t *rect)
+{
+    box->p1.x = _cairo_fixed_from_int (rect->x);
+    box->p1.y = _cairo_fixed_from_int (rect->y);
+    box->p2.x = _cairo_fixed_from_int (rect->x + rect->width);
+    box->p2.y = _cairo_fixed_from_int (rect->y + rect->height);
+}
+
 /* assumes box->p1 is top-left, p2 bottom-right */
 static inline void
 _cairo_box_add_point (cairo_box_t *box,
diff --git a/src/cairo-clip-boxes.c b/src/cairo-clip-boxes.c
index 7bcbeb1..abf634e 100644
--- a/src/cairo-clip-boxes.c
+++ b/src/cairo-clip-boxes.c
@@ -119,11 +119,7 @@ _cairo_clip_contains_rectangle (const cairo_clip_t *clip,
 {
     cairo_box_t box;
 
-    box.p1.x = _cairo_fixed_from_int (rect->x);
-    box.p1.y = _cairo_fixed_from_int (rect->y);
-    box.p2.x = _cairo_fixed_from_int (rect->x + rect->width);
-    box.p2.y = _cairo_fixed_from_int (rect->y + rect->height);
-
+    _cairo_box_from_rectangle_int(&box, rect);
     return _cairo_clip_contains_rectangle_box (clip, rect, &box);
 }
 
@@ -347,10 +343,7 @@ _cairo_clip_intersect_rectangle (cairo_clip_t       *clip,
     if (r->width == 0 || r->height == 0)
 	return _cairo_clip_set_all_clipped (clip);
 
-    box.p1.x = _cairo_fixed_from_int (r->x);
-    box.p1.y = _cairo_fixed_from_int (r->y);
-    box.p2.x = _cairo_fixed_from_int (r->x + r->width);
-    box.p2.y = _cairo_fixed_from_int (r->y + r->height);
+    _cairo_box_from_rectangle_int(&box, r);
 
     return _cairo_clip_intersect_rectangle_box (clip, r, &box);
 }
-- 
2.6.4.442.g545299f



More information about the cairo mailing list