Mesa (master): mesa: Add a new helper function _mesa_regions_overlap()

Anuj Phogat aphogat at kemper.freedesktop.org
Mon Jun 29 20:19:44 UTC 2015


Module: Mesa
Branch: master
Commit: 7f282d05a11e0c29bddc1fac8c7028c7e823234f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f282d05a11e0c29bddc1fac8c7028c7e823234f

Author: Anuj Phogat <anuj.phogat at gmail.com>
Date:   Fri Jun  5 19:18:19 2015 -0700

mesa: Add a new helper function _mesa_regions_overlap()

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/blit.c |   26 ++++++++++++++++++++++++++
 src/mesa/main/blit.h |    6 ++++++
 2 files changed, 32 insertions(+)

diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index db8fee5..4765198 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -37,6 +37,7 @@
 #include "framebuffer.h"
 #include "glformats.h"
 #include "mtypes.h"
+#include "macros.h"
 #include "state.h"
 
 
@@ -59,6 +60,31 @@ find_attachment(const struct gl_framebuffer *fb,
 
 
 /**
+ * \return true if two regions overlap, false otherwise
+ */
+bool
+_mesa_regions_overlap(int srcX0, int srcY0,
+                      int srcX1, int srcY1,
+                      int dstX0, int dstY0,
+                      int dstX1, int dstY1)
+{
+   if (MAX2(srcX0, srcX1) < MIN2(dstX0, dstX1))
+      return false; /* dst completely right of src */
+
+   if (MAX2(dstX0, dstX1) < MIN2(srcX0, srcX1))
+      return false; /* dst completely left of src */
+
+   if (MAX2(srcY0, srcY1) < MIN2(dstY0, dstY1))
+      return false; /* dst completely above src */
+
+   if (MAX2(dstY0, dstY1) < MIN2(srcY0, srcY1))
+      return false; /* dst completely below src */
+
+   return true; /* some overlap */
+}
+
+
+/**
  * Helper function for checking if the datatypes of color buffers are
  * compatible for glBlitFramebuffer.  From the 3.1 spec, page 198:
  *
diff --git a/src/mesa/main/blit.h b/src/mesa/main/blit.h
index 54b946e..88dd4a9 100644
--- a/src/mesa/main/blit.h
+++ b/src/mesa/main/blit.h
@@ -28,6 +28,12 @@
 
 #include "glheader.h"
 
+extern bool
+_mesa_regions_overlap(int srcX0, int srcY0,
+                      int srcX1, int srcY1,
+                      int dstX0, int dstY0,
+                      int dstX1, int dstY1);
+
 extern void
 _mesa_blit_framebuffer(struct gl_context *ctx,
                        struct gl_framebuffer *readFb,




More information about the mesa-commit mailing list