mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 05:38:16 +02:00
add driClipRectToFramebuffer helper function
This commit is contained in:
parent
844cdaf461
commit
7ed58285ab
2 changed files with 37 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,4 +51,8 @@ extern GLboolean driCheckDriDdxDrmVersions( __DRIscreenPrivate *sPriv,
|
|||
const char * driver_name, int dri_major, int dri_minor,
|
||||
int ddx_major, int ddx_minor, int drm_major, int drm_minor );
|
||||
|
||||
extern GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
|
||||
GLint *x, GLint *y,
|
||||
GLsizei *width, GLsizei *height );
|
||||
|
||||
#endif /* DRI_DEBUG_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue