summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/utils.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h
index 79f45ebf25d..e66cdc34bae 100644
--- a/src/gallium/drivers/swr/rasterizer/core/utils.h
+++ b/src/gallium/drivers/swr/rasterizer/core/utils.h
@@ -29,6 +29,7 @@
#include <string.h>
#include <type_traits>
+#include <algorithm>
#include "common/os.h"
#include "common/simdintrin.h"
#include "common/swr_assert.h"
@@ -95,6 +96,23 @@ OSALIGNLINE(struct) BBOX
{
return !(*this == rhs);
}
+
+ BBOX& Intersect(const BBOX& other)
+ {
+ this->top = std::max(this->top, other.top);
+ this->bottom = std::min(this->bottom, other.bottom);
+ this->left = std::max(this->left, other.left);
+ this->right = std::min(this->right, other.right);
+
+ if (right - left < 0 ||
+ bottom - top < 0)
+ {
+ // Zero area
+ top = bottom = left = right = 0;
+ }
+
+ return *this;
+ }
};
struct simdBBox