summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Weigelt, metux IT consult <enrico.weigelt@gr13.net>2016-06-30 17:45:43 +0200
committerUli Schlachter <psychon@znc.in>2016-07-02 13:35:34 +0200
commitb23c2291d8fdebd417697d5b70f31226632e3a1e (patch)
tree3f18cf35800efd44a80fe904563a3ad4d579d149
parentae403448af410984852aeff76278dc96e7141b9e (diff)
core: helper inline for rect->box conversion
Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt@gr13.net> Signed-off-by: Uli Schlachter <psychon@znc.in>
-rw-r--r--src/cairo-box-inline.h10
-rw-r--r--src/cairo-clip-boxes.c11
2 files changed, 12 insertions, 9 deletions
diff --git a/src/cairo-box-inline.h b/src/cairo-box-inline.h
index d6b994127..59e5a0d5f 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 7bcbeb191..f9ccfcb7c 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);
}