diff options
author | Brian <[email protected]> | 2007-09-26 17:03:11 -0600 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2008-09-23 16:59:56 -0700 |
commit | 03bafd1f9fa000abdb794b2ae344a68840c83201 (patch) | |
tree | bb590699fa0aedde46bdc22f7a891694b43c2561 /src/mesa/main/image.c | |
parent | a97226352fb8063d4d0084523312b4880dae5ac7 (diff) |
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)
Diffstat (limited to 'src/mesa/main/image.c')
-rw-r--r-- | src/mesa/main/image.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index c09cd967cb2..651ebe1b7c0 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -5103,6 +5103,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). * \return GL_FALSE if rect is totally clipped, GL_TRUE otherwise. |