Added rect_in_region function.

This commit is contained in:
Alexandre Julliard 2004-09-01 22:49:14 +00:00
parent 80bba3bd61
commit edc90a9f9c
2 changed files with 18 additions and 0 deletions

View File

@ -775,3 +775,20 @@ int point_in_region( struct region *region, int x, int y )
}
return 0;
}
/* check if the given rectangle is (at least partially) inside the region */
int rect_in_region( struct region *region, const rectangle_t *rect )
{
const rectangle_t *ptr, *end;
for (ptr = region->rects, end = region->rects + region->num_rects; ptr < end; ptr++)
{
if (ptr->top > rect->bottom) return 0;
if (ptr->bottom <= rect->top) continue;
/* now we are in the correct band */
if (ptr->left > rect->right) return 0;
if (ptr->right <= rect->left) continue;
return 1;
}
return 0;
}

View File

@ -84,6 +84,7 @@ extern struct region *subtract_region( struct region *dst, const struct region *
extern struct region *union_region( struct region *dst, const struct region *src1,
const struct region *src2 );
extern int point_in_region( struct region *region, int x, int y );
extern int rect_in_region( struct region *region, const rectangle_t *rect );
static inline struct region *create_empty_region(void) { return create_region( NULL, 0 ); }
/* window functions */