diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:17:30 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:17:30 +0000 |
commit | ca11beabae33eb59fb981b8adf50b1d47a2a98f0 (patch) | |
tree | 3e4691a396e6e54cd54224a190663d5cf976625b /lib/mesa/src/gallium/auxiliary/util/u_box.h | |
parent | 27c8a50e8bbde7d28b1fc46d715a4c469e24f2c4 (diff) |
Import Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/util/u_box.h')
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/util/u_box.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_box.h b/lib/mesa/src/gallium/auxiliary/util/u_box.h index b3f478e7b..764bf5037 100644 --- a/lib/mesa/src/gallium/auxiliary/util/u_box.h +++ b/lib/mesa/src/gallium/auxiliary/util/u_box.h @@ -119,6 +119,45 @@ u_box_volume_3d(const struct pipe_box *box) return (int64_t)box->width * box->height * box->depth; } +/* Aliasing of @dst permitted. Supports empty width */ +static inline void +u_box_union_1d(struct pipe_box *dst, + const struct pipe_box *a, const struct pipe_box *b) +{ + int x, width; + + if (a->width == 0) { + x = b->x; + width = b->width; + } else if (b->width == 0) { + x = a->x; + width = a->width; + } else { + x = MIN2(a->x, b->x); + width = MAX2(a->x + a->width, b->x + b->width) - x; + } + + dst->x = x; + dst->width = width; +} + +/* Aliasing of @dst permitted. */ +static inline void +u_box_intersect_1d(struct pipe_box *dst, + const struct pipe_box *a, const struct pipe_box *b) +{ + int x; + + x = MAX2(a->x, b->x); + + dst->width = MIN2(a->x + a->width, b->x + b->width) - x; + dst->x = x; + if (dst->width <= 0) { + dst->x = 0; + dst->width = 0; + } +} + /* Aliasing of @dst permitted. */ static inline void u_box_union_2d(struct pipe_box *dst, |