From 38c4ac5a1d25d96087bfe1e3d02816feaa6b8bf9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Sat, 12 May 2007 17:58:50 -0400 Subject: [PATCH] Export a pixman_region_selfcheck --- pixman/pixman-region.c | 94 ++++++++++++++++++++++++++------------------------ pixman/pixman.h | 1 + 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c index fd41feb..da7e4bd 100644 --- a/pixman/pixman-region.c +++ b/pixman/pixman-region.c @@ -277,52 +277,6 @@ pixman_region16_print(rgn) return(num); } -static pixman_bool_t -pixman_region16_valid(reg) - pixman_region16_t * reg; -{ - int i, numRects; - - if ((reg->extents.x1 > reg->extents.x2) || - (reg->extents.y1 > reg->extents.y2)) - return FALSE; - numRects = PIXREGION_NUM_RECTS(reg); - if (!numRects) - return ((reg->extents.x1 == reg->extents.x2) && - (reg->extents.y1 == reg->extents.y2) && - (reg->data->size || (reg->data == &pixman_region_emptyData))); - else if (numRects == 1) - return (!reg->data); - else - { - pixman_box16_t * pboxP, pboxN; - pixman_box16_t box; - - pboxP = PIXREGION_RECTS(reg); - box = *pboxP; - box.y2 = pboxP[numRects-1].y2; - pboxN = pboxP + 1; - for (i = numRects; --i > 0; pboxP++, pboxN++) - { - if ((pboxN->x1 >= pboxN->x2) || - (pboxN->y1 >= pboxN->y2)) - return FALSE; - if (pboxN->x1 < box.x1) - box.x1 = pboxN->x1; - if (pboxN->x2 > box.x2) - box.x2 = pboxN->x2; - if ((pboxN->y1 < pboxP->y1) || - ((pboxN->y1 == pboxP->y1) && - ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2)))) - return FALSE; - } - return ((box.x1 == reg->extents.x1) && - (box.x2 == reg->extents.x2) && - (box.y1 == reg->extents.y1) && - (box.y2 == reg->extents.y2)); - } -} - #endif /* DEBUG_PIXREGION */ void @@ -2549,3 +2503,51 @@ pixman_region16_find_max_band(pixman_region16_t * prgn) return (nMaxBand); } #endif /* XXX_DO_WE_NEED_THIS */ + + +pixman_bool_t +pixman_region_selfcheck (reg) + pixman_region16_t * reg; +{ + int i, numRects; + + if ((reg->extents.x1 > reg->extents.x2) || + (reg->extents.y1 > reg->extents.y2)) + return FALSE; + numRects = PIXREGION_NUM_RECTS(reg); + if (!numRects) + return ((reg->extents.x1 == reg->extents.x2) && + (reg->extents.y1 == reg->extents.y2) && + (reg->data->size || (reg->data == pixman_region_emptyData))); + else if (numRects == 1) + return (!reg->data); + else + { + pixman_box16_t * pboxP, * pboxN; + pixman_box16_t box; + + pboxP = PIXREGION_RECTS(reg); + box = *pboxP; + box.y2 = pboxP[numRects-1].y2; + pboxN = pboxP + 1; + for (i = numRects; --i > 0; pboxP++, pboxN++) + { + if ((pboxN->x1 >= pboxN->x2) || + (pboxN->y1 >= pboxN->y2)) + return FALSE; + if (pboxN->x1 < box.x1) + box.x1 = pboxN->x1; + if (pboxN->x2 > box.x2) + box.x2 = pboxN->x2; + if ((pboxN->y1 < pboxP->y1) || + ((pboxN->y1 == pboxP->y1) && + ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2)))) + return FALSE; + } + return ((box.x1 == reg->extents.x1) && + (box.x2 == reg->extents.x2) && + (box.y1 == reg->extents.y1) && + (box.y2 == reg->extents.y2)); + } +} + diff --git a/pixman/pixman.h b/pixman/pixman.h index 1a235b7..5375ebe 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -287,6 +287,7 @@ const pixman_box16_t * pixman_region_rectangles (pixman_region16_t *region, int *n_rects); pixman_bool_t pixman_region_equal (pixman_region16_t *region1, pixman_region16_t *region2); +pixman_bool_t pixman_region_selfcheck (pixman_region16_t *region); /* * Images -- 2.7.4