summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2001-02-22 17:59:24 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2001-02-22 17:59:24 +0000
commitdab76b4dc585f5833003ff3a0e53c256bf974d47 (patch)
treeddd38e72931c043d007a6be7c21557c2050c5f33 /src
parentea83bacf9cd05825daf56369279b185dab3d2632 (diff)
improvements to regions_overlap() function
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_copypix.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index 4c4d000317..46971b4654 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -1,4 +1,4 @@
-/* $Id: s_copypix.c,v 1.11 2001/02/20 16:42:26 brianp Exp $ */
+/* $Id: s_copypix.c,v 1.12 2001/02/22 17:59:24 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -47,23 +47,43 @@
/*
- * Determine if there's overlap in an image copy
+ * Determine if there's overlap in an image copy.
+ * This test also compensates for the fact that copies are done from
+ * bottom to top and overlaps can sometimes be handled correctly
+ * without making a temporary image copy.
*/
static GLboolean
-regions_overlap(int srcx, int srcy, int dstx, int dsty, int width, int height,
- float zoomX, float zoomY)
+regions_overlap(GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty,
+ GLint width, GLint height,
+ GLfloat zoomX, GLfloat zoomY)
{
- if ((srcx > dstx + (width * zoomX) + 1) || (srcx + width + 1 < dstx)) {
- return GL_FALSE;
- }
- else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) {
- return GL_FALSE;
- }
- else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) {
- return GL_FALSE;
+ if (zoomX == 1.0 && zoomY == 1.0) {
+ /* no zoom */
+ if (srcx >= dstx + width || (srcx + width <= dstx)) {
+ return GL_FALSE;
+ }
+ else if (srcy < dsty) { /* this is OK */
+ return GL_FALSE;
+ }
+ else {
+ return GL_TRUE;
+ }
}
else {
- return GL_TRUE;
+ /* add one pixel of slop when zooming, just to be safe */
+ if ((srcx > dstx + (width * zoomX) + 1) || (srcx + width + 1 < dstx)) {
+ return GL_FALSE;
+ }
+ else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) {
+ return GL_FALSE;
+ }
+ else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) {
+ return GL_FALSE;
+ }
+ else {
+ return GL_TRUE;
+ }
}
}