summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJocelyn Falempe <jfalempe@redhat.com>2024-08-22 09:33:55 +0200
committerJocelyn Falempe <jfalempe@redhat.com>2024-08-23 16:47:56 +0200
commit4b570ac2eb54f66ff64f2864be6303b8d67cc7f9 (patch)
treec754858277a4e1c493a600efa0d65d07b03568dc /include
parent6133cf70725049344a679f85df27d146a2d995ea (diff)
drm/rect: Add drm_rect_overlap()
Check if two rectangles overlap. It's a bit similar to drm_rect_intersect() but this won't modify the rectangle. Simplifies a bit drm_panic. Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patchwork.freedesktop.org/patch/msgid/20240822073852.562286-3-jfalempe@redhat.com
Diffstat (limited to 'include')
-rw-r--r--include/drm/drm_rect.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/drm/drm_rect.h b/include/drm/drm_rect.h
index 73fcb899a01d..46f09cf68458 100644
--- a/include/drm/drm_rect.h
+++ b/include/drm/drm_rect.h
@@ -238,6 +238,21 @@ static inline void drm_rect_fp_to_int(struct drm_rect *dst,
drm_rect_height(src) >> 16);
}
+/**
+ * drm_rect_overlap - Check if two rectangles overlap
+ * @a: first rectangle
+ * @b: second rectangle
+ *
+ * RETURNS:
+ * %true if the rectangles overlap, %false otherwise.
+ */
+static inline bool drm_rect_overlap(const struct drm_rect *a,
+ const struct drm_rect *b)
+{
+ return (a->x2 > b->x1 && b->x2 > a->x1 &&
+ a->y2 > b->y1 && b->y2 > a->y1);
+}
+
bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);
bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst,
const struct drm_rect *clip);