diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/common.c | 6 | ||||
-rw-r--r-- | common/common.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/common/common.c b/common/common.c index 15be4d1b0a..d3dcb6171f 100644 --- a/common/common.c +++ b/common/common.c @@ -95,6 +95,12 @@ void mp_rect_union(struct mp_rect *rc, const struct mp_rect *rc2) rc->y1 = FFMAX(rc->y1, rc2->y1); } +// Returns whether or not a point is contained by rc +bool mp_rect_contains(struct mp_rect *rc, int x, int y) +{ + return rc->x0 <= x && x < rc->x1 && rc->y0 <= y && y < rc->y1; +} + // Set rc to the intersection of rc and src. // Return false if the result is empty. bool mp_rect_intersection(struct mp_rect *rc, const struct mp_rect *rc2) diff --git a/common/common.h b/common/common.h index 2151d03cd2..cc7093a4fc 100644 --- a/common/common.h +++ b/common/common.h @@ -75,6 +75,7 @@ struct mp_rect { void mp_rect_union(struct mp_rect *rc, const struct mp_rect *src); bool mp_rect_intersection(struct mp_rect *rc, const struct mp_rect *rc2); +bool mp_rect_contains(struct mp_rect *rc, int x, int y); int mp_snprintf_cat(char *str, size_t size, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); |