Add helper function to calculate the area of the intersection of two rectangles.

This commit is contained in:
Michel Dänzer
2006-09-28 14:08:38 +00:00
parent 941c866739
commit 638ece315f
2 changed files with 15 additions and 0 deletions

View File

@@ -421,6 +421,19 @@ driCheckDriDdxDrmVersions2(const char * driver_name,
GLint
driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 )
{
if (rect2.x1 > rect1.x1) rect1.x1 = rect2.x1;
if (rect2.x2 < rect1.x2) rect1.x2 = rect2.x2;
if (rect2.y1 > rect1.y1) rect1.y1 = rect2.y1;
if (rect2.y2 < rect1.y2) rect1.y2 = rect2.y2;
if (rect1.x1 > rect1.x2 || rect1.y1 > rect1.y2) return 0;
return (rect1.x2 - rect1.x1) * (rect1.y2 - rect1.y1);
}
GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer, GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
GLint *x, GLint *y, GLint *x, GLint *y,
GLsizei *width, GLsizei *height ) GLsizei *width, GLsizei *height )

View File

@@ -106,6 +106,8 @@ extern GLboolean driCheckDriDdxDrmVersions3(const char * driver_name,
const __DRIversion * ddxActual, const __DRIutilversion2 * ddxExpected, const __DRIversion * ddxActual, const __DRIutilversion2 * ddxExpected,
const __DRIversion * drmActual, const __DRIversion * drmExpected); const __DRIversion * drmActual, const __DRIversion * drmExpected);
extern GLint driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 );
extern GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer, extern GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
GLint *x, GLint *y, GLint *x, GLint *y,
GLsizei *width, GLsizei *height ); GLsizei *width, GLsizei *height );