From: Brian Paul Date: Thu, 22 Feb 2001 17:59:24 +0000 (+0000) Subject: improvements to regions_overlap() function X-Git-Tag: 062012170305~27441 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dab76b4dc585f5833003ff3a0e53c256bf974d47;p=profile%2Fivi%2Fmesa.git improvements to regions_overlap() function --- diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 4c4d000..46971b4 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; + } } }