summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@armlinux.org.uk>2018-07-03 12:31:31 +0100
committerRussell King <rmk@armlinux.org.uk>2018-07-13 19:27:23 +0100
commit69ef4cb4abe7f70ea28cda4d62276253eab8796a (patch)
treebe49ebe2ad848b2ff57e2bb1e11c864b409c6a00
parent6b17923a24508061bfa94cc701ee0351527008a0 (diff)
common: add box_init(), box_width() and box_height() helpers
Add a helper to initialise a box from a position + size, and to obtain the width and height from an existing box. Signed-off-by: Russell King <rmk@armlinux.org.uk>
-rw-r--r--common/boxutil.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/boxutil.h b/common/boxutil.h
index ae8d17b..55f725c 100644
--- a/common/boxutil.h
+++ b/common/boxutil.h
@@ -6,6 +6,24 @@
#include "miscstruct.h"
#include "utils.h"
+static inline void box_init(BoxPtr out, int x, int y, int w, int h)
+{
+ out->x1 = x;
+ out->x2 = x + w;
+ out->y1 = y;
+ out->y2 = y + h;
+}
+
+static inline int box_width(const BoxRec *b)
+{
+ return b->x2 - b->x1;
+}
+
+static inline int box_height(const BoxRec *b)
+{
+ return b->y2 - b->y1;
+}
+
static inline Bool __box_intersect(BoxPtr out, const BoxRec *a, const BoxRec *b)
{
out->x1 = maxt(a->x1, b->x1);