diff options
author | Keith Whitwell <[email protected]> | 2003-12-11 19:06:32 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2003-12-11 19:06:32 +0000 |
commit | 7ed58285abede813fbf5fa0a2e29982043f1bbbe (patch) | |
tree | a1b7dc8b8464aae4ac8a445ac7fffe4b49d90843 /src/mesa/drivers/dri/common/utils.c | |
parent | 844cdaf461e3e181bcf1d4c0ba79ef5c4140cb4e (diff) |
add driClipRectToFramebuffer helper function
Diffstat (limited to 'src/mesa/drivers/dri/common/utils.c')
-rw-r--r-- | src/mesa/drivers/dri/common/utils.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index 0d21ceda562..4276854224d 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -184,3 +184,36 @@ driCheckDriDdxDrmVersions(__DRIscreenPrivate *sPriv, return GL_TRUE; } + +GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer, + GLint *x, GLint *y, + GLsizei *width, GLsizei *height ) +{ + /* left clipping */ + if (*x < buffer->_Xmin) { + *width -= (buffer->_Xmin - *x); + *x = buffer->_Xmin; + } + + /* right clipping */ + if (*x + *width > buffer->_Xmax) + *width -= (*x + *width - buffer->_Xmax - 1); + + if (*width <= 0) + return GL_FALSE; + + /* bottom clipping */ + if (*y < buffer->_Ymin) { + *height -= (buffer->_Ymin - *y); + *y = buffer->_Ymin; + } + + /* top clipping */ + if (*y + *height > buffer->_Ymax) + *height -= (*y + *height - buffer->_Ymax - 1); + + if (*height <= 0) + return GL_FALSE; + + return GL_TRUE; +} |