summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_rect.h
diff options
context:
space:
mode:
authorChristoph Bumiller <[email protected]>2014-11-17 16:58:26 +0100
committerEmil Velikov <[email protected]>2014-11-18 02:02:54 +0000
commit7d2573b5376bb4f9ce9a50e0b965e06032b135a9 (patch)
treec0aacc067ef66163991650fdba3a1b2413cef2d1 /src/gallium/auxiliary/util/u_rect.h
parentcb49132166faf4c8668b09a300bd9e3877327a33 (diff)
gallium/auxiliary: add contained and rect checks (v6)
v3: thanks to Brian, improved coding style, also glennk helped spot few things (unsigned -> int, two constify) v4: thanks Ilia improved function, dropped u_box_clip_3d v5: incorporated rest of Gregor proposed changes,clean ups v6: u_box_clip_2d simplify proposed by Ilia Mirkin Acked-by: Jose Fonseca <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: David Heidelberg <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util/u_rect.h')
-rw-r--r--src/gallium/auxiliary/util/u_rect.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_rect.h b/src/gallium/auxiliary/util/u_rect.h
index dd87f81f37b..cf29dff0d02 100644
--- a/src/gallium/auxiliary/util/u_rect.h
+++ b/src/gallium/auxiliary/util/u_rect.h
@@ -30,6 +30,7 @@
#define U_RECT_H
#include "pipe/p_compiler.h"
+#include "util/u_math.h"
#ifdef __cplusplus
extern "C" {
@@ -67,6 +68,12 @@ u_rect_find_intersection(const struct u_rect *a,
}
+static INLINE int
+u_rect_area(const struct u_rect *r)
+{
+ return (r->x1 - r->x0) * (r->y1 - r->y0);
+}
+
static INLINE void
u_rect_possible_intersection(const struct u_rect *a,
struct u_rect *b)
@@ -79,6 +86,17 @@ u_rect_possible_intersection(const struct u_rect *a,
}
}
+/* Set @d to a rectangle that covers both @a and @b.
+ */
+static INLINE void
+u_rect_union(struct u_rect *d, const struct u_rect *a, const struct u_rect *b)
+{
+ d->x0 = MIN2(a->x0, b->x0);
+ d->y0 = MIN2(a->y0, b->y0);
+ d->x1 = MAX2(a->x1, b->x1);
+ d->y1 = MAX2(a->y1, b->y1);
+}
+
#ifdef __cplusplus
}
#endif