diff options
author | Michel Dänzer <[email protected]> | 2006-09-28 14:08:38 +0000 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2006-09-28 14:08:38 +0000 |
commit | 638ece315f4ee7be7f0fe0a0acd2550b4ccb8a7d (patch) | |
tree | 67eb42867b84c00b3e9276ed52675919f9f85300 /src/mesa/drivers/dri/common/utils.c | |
parent | 941c8667394a3ea5b4793d988796e0f397390626 (diff) |
Add helper function to calculate the area of the intersection of two rectangles.
Diffstat (limited to 'src/mesa/drivers/dri/common/utils.c')
-rw-r--r-- | src/mesa/drivers/dri/common/utils.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index 74ed299a628..6a189e72858 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -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, GLint *x, GLint *y, GLsizei *width, GLsizei *height ) |