From 03bafd1f9fa000abdb794b2ae344a68840c83201 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 26 Sep 2007 17:03:11 -0600 Subject: Added new _mesa_clip_copytexsubimage() function to do avoid clipping down in the drivers. This should probably be pulled into main-line Mesa... (cherry picked from commit 324ecadbfdf9b944e059832f146451e4151dcb21) --- src/mesa/main/image.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/mesa/main/image.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index c09cd967cb..651ebe1b7c 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -5102,6 +5102,37 @@ _mesa_clip_readpixels(const GLcontext *ctx, } +/** + * Do clipping for a glCopyTexSubImage call. + * The framebuffer source region might extend outside the framebuffer + * bounds. Clip the source region against the framebuffer bounds and + * adjust the texture/dest position and size accordingly. + * + * \return GL_FALSE if region is totally clipped, GL_TRUE otherwise. + */ +GLboolean +_mesa_clip_copytexsubimage(const GLcontext *ctx, + GLint *destX, GLint *destY, + GLint *srcX, GLint *srcY, + GLsizei *width, GLsizei *height) +{ + const struct gl_framebuffer *fb = ctx->ReadBuffer; + const GLint srcX0 = *srcX, srcY0 = *srcY; + + if (_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, fb->_Xmax, fb->_Ymax, + srcX, srcY, width, height)) { + *destX = *destX + *srcX - srcX0; + *destY = *destY + *srcY - srcY0; + + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + /** * Clip the rectangle defined by (x, y, width, height) against the bounds * specified by [xmin, xmax) and [ymin, ymax). -- cgit v1.2.3