aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/image.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-09-26 17:03:11 -0600
committerBrian <[email protected]>2007-09-26 17:03:11 -0600
commit324ecadbfdf9b944e059832f146451e4151dcb21 (patch)
treed10dd6af860f06059be726d8d742cca63761f308 /src/mesa/main/image.c
parentbad4e10af746ce16b730a3e7a4e2ff53ecb6d0f6 (diff)
Added new _mesa_clip_copytexsubimage() function to do avoid clipping down in the drivers.
This should probably be pulled into main-line Mesa...
Diffstat (limited to 'src/mesa/main/image.c')
-rw-r--r--src/mesa/main/image.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index ba46cdc1b17..ae3c82b8101 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -4625,6 +4625,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.