#define MAX(a,b) ((a) > (b) ? (a) : (b))
static const box_type_t _pixman_region_emptyBox = {0, 0, 0, 0};
-static const pixman_region16_data_t _pixman_region_emptyData = {0, 0};
-static const pixman_region16_data_t _pixman_brokendata = {0, 0};
+static const region_data_type_t _pixman_region_emptyData = {0, 0};
+static const region_data_type_t _pixman_brokendata = {0, 0};
static box_type_t *pixman_region_emptyBox = (box_type_t *)&_pixman_region_emptyBox;
-static pixman_region16_data_t *pixman_region_emptyData = (pixman_region16_data_t *)&_pixman_region_emptyData;
-static pixman_region16_data_t *pixman_brokendata = (pixman_region16_data_t *)&_pixman_brokendata;
+static region_data_type_t *pixman_region_emptyData = (region_data_type_t *)&_pixman_region_emptyData;
+static region_data_type_t *pixman_brokendata = (region_data_type_t *)&_pixman_brokendata;
/* This function exists only to make it possible to preserve the X ABI - it should
* go away at first opportunity.
*/
void
PREFIX(pixman_region_set_static_pointers) (box_type_t *empty_box,
- pixman_region16_data_t *empty_data,
- pixman_region16_data_t *broken_data)
+ region_data_type_t *empty_data,
+ region_data_type_t *broken_data)
{
pixman_region_emptyBox = empty_box;
pixman_region_emptyData = empty_data;
}
static pixman_bool_t
-pixman_break (pixman_region16_t *pReg);
+pixman_break (region_type_t *pReg);
/*
* The functions in this file implement the Region abstraction used extensively
if (n > UINT32_MAX / sizeof(box_type_t))
return 0;
- if (sizeof(pixman_region16_data_t) > UINT32_MAX - size)
+ if (sizeof(region_data_type_t) > UINT32_MAX - size)
return 0;
- return size + sizeof(pixman_region16_data_t);
+ return size + sizeof(region_data_type_t);
}
static void *
#define DOWNSIZE(reg,numRects) \
if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
{ \
- pixman_region16_data_t * NewData; \
+ region_data_type_t * NewData; \
size_t data_size = PIXREGION_SZOF(numRects); \
if (!data_size) \
NewData = NULL; \
else \
- NewData = (pixman_region16_data_t *)realloc((reg)->data, data_size); \
+ NewData = (region_data_type_t *)realloc((reg)->data, data_size); \
if (NewData) \
{ \
NewData->size = (numRects); \
pixman_bool_t
PREFIX(pixman_region_equal) (reg1, reg2)
- pixman_region16_t * reg1;
- pixman_region16_t * reg2;
+ region_type_t * reg1;
+ region_type_t * reg2;
{
int i;
box_type_t *rects1;
int
PREFIX(pixman_region16_print) (rgn)
- pixman_region16_t * rgn;
+ region_type_t * rgn;
{
int num, size;
int i;
void
-PREFIX(pixman_region_init) (pixman_region16_t *region)
+PREFIX(pixman_region_init) (region_type_t *region)
{
region->extents = *pixman_region_emptyBox;
region->data = pixman_region_emptyData;
}
void
-PREFIX(pixman_region_init_rect) (pixman_region16_t *region,
+PREFIX(pixman_region_init_rect) (region_type_t *region,
int x, int y, unsigned int width, unsigned int height)
{
region->extents.x1 = x;
}
void
-PREFIX(pixman_region_init_with_extents) (pixman_region16_t *region, box_type_t *extents)
+PREFIX(pixman_region_init_with_extents) (region_type_t *region, box_type_t *extents)
{
region->extents = *extents;
region->data = NULL;
}
void
-PREFIX(pixman_region_fini) (pixman_region16_t *region)
+PREFIX(pixman_region_fini) (region_type_t *region)
{
good (region);
freeData (region);
}
int
-PREFIX(pixman_region_n_rects) (pixman_region16_t *region)
+PREFIX(pixman_region_n_rects) (region_type_t *region)
{
return PIXREGION_NUM_RECTS (region);
}
box_type_t *
-PREFIX(pixman_region_rects) (pixman_region16_t *region)
+PREFIX(pixman_region_rects) (region_type_t *region)
{
return PIXREGION_RECTS (region);
}
box_type_t *
-PREFIX(pixman_region_rectangles) (pixman_region16_t *region,
+PREFIX(pixman_region_rectangles) (region_type_t *region,
int *n_rects)
{
if (n_rects)
}
static pixman_bool_t
-pixman_break (pixman_region16_t *region)
+pixman_break (region_type_t *region)
{
freeData (region);
region->extents = *pixman_region_emptyBox;
}
static pixman_bool_t
-pixman_rect_alloc (pixman_region16_t * region, int n)
+pixman_rect_alloc (region_type_t * region, int n)
{
- pixman_region16_data_t *data;
+ region_data_type_t *data;
if (!region->data)
{
if (!data_size)
data = NULL;
else
- data = (pixman_region16_data_t *)realloc(region->data, PIXREGION_SZOF(n));
+ data = (region_data_type_t *)realloc(region->data, PIXREGION_SZOF(n));
if (!data)
return pixman_break (region);
region->data = data;
}
pixman_bool_t
-PREFIX(pixman_region_copy) (pixman_region16_t *dst, pixman_region16_t *src)
+PREFIX(pixman_region_copy) (region_type_t *dst, region_type_t *src)
{
good(dst);
good(src);
*/
static inline int
pixman_coalesce (
- pixman_region16_t * region, /* Region to coalesce */
+ region_type_t * region, /* Region to coalesce */
int prevStart, /* Index of start of previous band */
int curStart) /* Index of start of current band */
{
static inline pixman_bool_t
pixman_region_appendNonO (
- pixman_region16_t * region,
+ region_type_t * region,
box_type_t * r,
box_type_t * rEnd,
int y1,
*/
typedef pixman_bool_t (*OverlapProcPtr)(
- pixman_region16_t *region,
+ region_type_t *region,
box_type_t *r1,
box_type_t *r1End,
box_type_t *r2,
static pixman_bool_t
pixman_op(
- pixman_region16_t *newReg, /* Place to store result */
- pixman_region16_t * reg1, /* First region in operation */
- pixman_region16_t * reg2, /* 2d region in operation */
+ region_type_t *newReg, /* Place to store result */
+ region_type_t * reg1, /* First region in operation */
+ region_type_t * reg2, /* 2d region in operation */
OverlapProcPtr overlapFunc, /* Function to call for over-
* lapping bands */
int appendNon1, /* Append non-overlapping bands */
box_type_t * r2End; /* End of 2d region */
short ybot; /* Bottom of intersection */
short ytop; /* Top of intersection */
- pixman_region16_data_t * oldData; /* Old data for newReg */
+ region_data_type_t * oldData; /* Old data for newReg */
int prevBand; /* Index of start of
* previous band in newReg */
int curBand; /* Index of start of current
assert(r1 != r1End);
assert(r2 != r2End);
- oldData = (pixman_region16_data_t *)NULL;
+ oldData = (region_data_type_t *)NULL;
if (((newReg == reg1) && (newSize > 1)) ||
((newReg == reg2) && (numRects > 1)))
{
{
newReg->extents = *PIXREGION_BOXPTR(newReg);
freeData(newReg);
- newReg->data = (pixman_region16_data_t *)NULL;
+ newReg->data = (region_data_type_t *)NULL;
}
else
{
*-----------------------------------------------------------------------
*/
static void
-pixman_set_extents (pixman_region16_t *region)
+pixman_set_extents (region_type_t *region)
{
box_type_t *box, *boxEnd;
*/
/*ARGSUSED*/
static pixman_bool_t
-pixman_region_intersectO (pixman_region16_t *region,
+pixman_region_intersectO (region_type_t *region,
box_type_t *r1,
box_type_t *r1End,
box_type_t *r2,
}
pixman_bool_t
-PREFIX(pixman_region_intersect) (pixman_region16_t * newReg,
- pixman_region16_t * reg1,
- pixman_region16_t * reg2)
+PREFIX(pixman_region_intersect) (region_type_t * newReg,
+ region_type_t * reg1,
+ region_type_t * reg2)
{
good(reg1);
good(reg2);
newReg->extents.x2 = MIN(reg1->extents.x2, reg2->extents.x2);
newReg->extents.y2 = MIN(reg1->extents.y2, reg2->extents.y2);
freeData(newReg);
- newReg->data = (pixman_region16_data_t *)NULL;
+ newReg->data = (region_data_type_t *)NULL;
}
else if (!reg2->data && SUBSUMES(®2->extents, ®1->extents))
{
*/
static pixman_bool_t
pixman_region_unionO (
- pixman_region16_t *region,
+ region_type_t *region,
box_type_t *r1,
box_type_t *r1End,
box_type_t *r2,
* single rectangle
*/
pixman_bool_t
-PREFIX(pixman_region_union_rect) (pixman_region16_t *dest,
- pixman_region16_t *source,
+PREFIX(pixman_region_union_rect) (region_type_t *dest,
+ region_type_t *source,
int x, int y,
unsigned int width, unsigned int height)
{
- pixman_region16_t region;
+ region_type_t region;
if (!width || !height)
return PREFIX(pixman_region_copy) (dest, source);
}
pixman_bool_t
-PREFIX(pixman_region_union) (pixman_region16_t *newReg,
- pixman_region16_t *reg1,
- pixman_region16_t *reg2)
+PREFIX(pixman_region_union) (region_type_t *newReg,
+ region_type_t *reg1,
+ region_type_t *reg2)
{
int overlap; /* result ignored */
*
*/
pixman_bool_t
-PREFIX(pixman_region_append) (pixman_region16_t * dstrgn,
- pixman_region16_t * rgn)
+PREFIX(pixman_region_append) (region_type_t * dstrgn,
+ region_type_t * rgn)
{
int numRects, dnumRects, size;
box_type_t *new, *old;
if (!rgn->data && (dstrgn->data == pixman_region_emptyData))
{
dstrgn->extents = rgn->extents;
- dstrgn->data = (pixman_region16_data_t *)NULL;
+ dstrgn->data = (region_data_type_t *)NULL;
return TRUE;
}
*/
pixman_bool_t
-PREFIX(pixman_region_validate) (pixman_region16_t * badreg,
+PREFIX(pixman_region_validate) (region_type_t * badreg,
int *pOverlap)
{
/* Descriptor for regions under construction in Step 2. */
typedef struct {
- pixman_region16_t reg;
+ region_type_t reg;
int prevBand;
int curBand;
} RegionInfo;
int i; /* Index into rects */
int j; /* Index into ri */
RegionInfo *rit; /* &ri[j] */
- pixman_region16_t * reg; /* ri[j].reg */
+ region_type_t * reg; /* ri[j].reg */
box_type_t * box; /* Current box in rects */
box_type_t * riBox; /* Last box in ri[j].reg */
- pixman_region16_t * hreg; /* ri[j_half].reg */
+ region_type_t * hreg; /* ri[j_half].reg */
pixman_bool_t ret = TRUE;
*pOverlap = FALSE;
if ((numRects) == 1)
{
freeData(badreg);
- badreg->data = (pixman_region16_data_t *) NULL;
+ badreg->data = (region_data_type_t *) NULL;
}
else
{
rit->prevBand = 0;
rit->curBand = 0;
rit->reg.extents = *box;
- rit->reg.data = (pixman_region16_data_t *)NULL;
+ rit->reg.data = (region_data_type_t *)NULL;
if (!pixman_rect_alloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
goto bail;
NextRect: ;
if (reg->data->numRects == 1) /* keep unions happy below */
{
freeData(reg);
- reg->data = (pixman_region16_data_t *)NULL;
+ reg->data = (region_data_type_t *)NULL;
}
}
/*ARGSUSED*/
static pixman_bool_t
pixman_region_subtractO (
- pixman_region16_t * region,
+ region_type_t * region,
box_type_t * r1,
box_type_t * r1End,
box_type_t * r2,
*-----------------------------------------------------------------------
*/
pixman_bool_t
-PREFIX(pixman_region_subtract) (pixman_region16_t * regD,
- pixman_region16_t * regM,
- pixman_region16_t * regS)
+PREFIX(pixman_region_subtract) (region_type_t * regD,
+ region_type_t * regM,
+ region_type_t * regS)
{
int overlap; /* result ignored */
*-----------------------------------------------------------------------
*/
pixman_bool_t
-PREFIX(pixman_region_inverse) (pixman_region16_t * newReg, /* Destination region */
- pixman_region16_t * reg1, /* Region to invert */
+PREFIX(pixman_region_inverse) (region_type_t * newReg, /* Destination region */
+ region_type_t * reg1, /* Region to invert */
box_type_t * invRect) /* Bounding box for inversion */
{
- pixman_region16_t invReg; /* Quick and dirty region made from the
+ region_type_t invReg; /* Quick and dirty region made from the
* bounding box */
int overlap; /* result ignored */
return pixman_break (newReg);
newReg->extents = *invRect;
freeData(newReg);
- newReg->data = (pixman_region16_data_t *)NULL;
+ newReg->data = (region_data_type_t *)NULL;
return TRUE;
}
do yucky substraction for overlaps, and
just throw away rectangles in region 2 that aren't in region 1 */
invReg.extents = *invRect;
- invReg.data = (pixman_region16_data_t *)NULL;
+ invReg.data = (region_data_type_t *)NULL;
if (!pixman_op(newReg, &invReg, reg1, pixman_region_subtractO, TRUE, FALSE, &overlap))
return FALSE;
*/
pixman_region_overlap_t
-PREFIX(pixman_region_contains_rectangle) (pixman_region16_t * region,
+PREFIX(pixman_region_contains_rectangle) (region_type_t * region,
box_type_t * prect)
{
int x;
*/
void
-PREFIX(pixman_region_translate) (pixman_region16_t * region, int x, int y)
+PREFIX(pixman_region_translate) (region_type_t * region, int x, int y)
{
int x1, x2, y1, y2;
int nbox;
{
region->extents = *PIXREGION_BOXPTR(region);
freeData(region);
- region->data = (pixman_region16_data_t *)NULL;
+ region->data = (region_data_type_t *)NULL;
}
else
pixman_set_extents(region);
/* XXX: Do we need this?
static pixman_bool_t
-pixman_region16_data_copy(pixman_region16_t * dst, pixman_region16_t * src)
+pixman_region16_data_copy(region_type_t * dst, region_type_t * src)
{
good(dst);
good(src);
if (!src->data || !src->data->size)
{
freeData(dst);
- dst->data = (pixman_region16_data_t *)NULL;
+ dst->data = (region_data_type_t *)NULL;
return TRUE;
}
if (!dst->data || (dst->data->size < src->data->numRects))
*/
void
-PREFIX(pixman_region_reset) (pixman_region16_t *region, box_type_t *box)
+PREFIX(pixman_region_reset) (region_type_t *region, box_type_t *box)
{
good(region);
assert(box->x1<=box->x2);
assert(box->y1<=box->y2);
region->extents = *box;
freeData(region);
- region->data = (pixman_region16_data_t *)NULL;
+ region->data = (region_data_type_t *)NULL;
}
/* box is "return" value */
int
-PREFIX(pixman_region_contains_point) (pixman_region16_t * region,
+PREFIX(pixman_region_contains_point) (region_type_t * region,
int x, int y,
box_type_t * box)
{
}
int
-PREFIX(pixman_region_not_empty) (pixman_region16_t * region)
+PREFIX(pixman_region_not_empty) (region_type_t * region)
{
good(region);
return(!PIXREGION_NIL(region));
/* XXX: Do we need this?
static int
-pixman_region16_broken(pixman_region16_t * region)
+pixman_region16_broken(region_type_t * region)
{
good(region);
return (PIXREGION_NAR(region));
*/
void
-PREFIX(pixman_region_empty) (pixman_region16_t * region)
+PREFIX(pixman_region_empty) (region_type_t * region)
{
good(region);
freeData(region);
}
box_type_t *
-PREFIX(pixman_region_extents) (pixman_region16_t * region)
+PREFIX(pixman_region_extents) (region_type_t * region)
{
good(region);
return(®ion->extents);
returns the number of new, clipped scanlines.
*/
-#ifdef XXX_DO_WE_NEED_THIS
-static int
-pixman_region16_clip_spans(
- pixman_region16_t *prgnDst,
- point_type_t *ppt,
- int *pwidth,
- int nspans,
- point_type_t *pptNew,
- int *pwidthNew,
- int fSorted)
-{
- point_type_t *pptLast;
- int *pwidthNewStart; /* the vengeance of Xerox! */
- int y, x1, x2;
- int numRects;
-
- good(prgnDst);
- pptLast = ppt + nspans;
- pwidthNewStart = pwidthNew;
-
- if (!prgnDst->data)
- {
- /* Do special fast code with clip boundaries in registers(?) */
- /* It doesn't pay much to make use of fSorted in this case,
- so we lump everything together. */
-
- int clipx1, clipx2, clipy1, clipy2;
-
- clipx1 = prgnDst->extents.x1;
- clipy1 = prgnDst->extents.y1;
- clipx2 = prgnDst->extents.x2;
- clipy2 = prgnDst->extents.y2;
-
- for (; ppt != pptLast; ppt++, pwidth++)
- {
- y = ppt->y;
- x1 = ppt->x;
- if (clipy1 <= y && y < clipy2)
- {
- x2 = x1 + *pwidth;
- if (x1 < clipx1) x1 = clipx1;
- if (x2 > clipx2) x2 = clipx2;
- if (x1 < x2)
- {
- /* part of span in clip rectangle */
- pptNew->x = x1;
- pptNew->y = y;
- *pwidthNew = x2 - x1;
- pptNew++;
- pwidthNew++;
- }
- }
- } /* end for */
-
- }
- else if ((numRects = prgnDst->data->numRects))
- {
- /* Have to clip against many boxes */
- box_type_t *pboxBandStart, *pboxBandEnd;
- box_type_t *pbox;
- box_type_t *pboxLast;
- int clipy1, clipy2;
-
- /* In this case, taking advantage of sorted spans gains more than
- the sorting costs. */
- if ((! fSorted) && (nspans > 1))
- QuickSortSpans(ppt, pwidth, nspans);
-
- pboxBandStart = PIXREGION_BOXPTR(prgnDst);
- pboxLast = pboxBandStart + numRects;
-
- NextBand();
-
- for (; ppt != pptLast; )
- {
- y = ppt->y;
- if (y < clipy2)
- {
- /* span is in the current band */
- pbox = pboxBandStart;
- x1 = ppt->x;
- x2 = x1 + *pwidth;
- do
- { /* For each box in band */
- int newx1, newx2;
-
- newx1 = x1;
- newx2 = x2;
- if (newx1 < pbox->x1) newx1 = pbox->x1;
- if (newx2 > pbox->x2) newx2 = pbox->x2;
- if (newx1 < newx2)
- {
- /* Part of span in clip rectangle */
- pptNew->x = newx1;
- pptNew->y = y;
- *pwidthNew = newx2 - newx1;
- pptNew++;
- pwidthNew++;
- }
- pbox++;
- } while (pbox != pboxBandEnd);
- ppt++;
- pwidth++;
- }
- else
- {
- /* Move to next band, adjust ppt as needed */
- pboxBandStart = pboxBandEnd;
- if (pboxBandStart == pboxLast)
- break; /* We're completely done */
- NextBand();
- }
- }
- }
- return (pwidthNew - pwidthNewStart);
-}
-
-/* find the band in a region with the most rectangles */
-static int
-pixman_region16_find_max_band(pixman_region16_t * prgn)
-{
- int nbox;
- box_type_t * pbox;
- int nThisBand;
- int nMaxBand = 0;
- short yThisBand;
-
- good(prgn);
- nbox = PIXREGION_NUM_RECTS(prgn);
- pbox = PIXREGION_RECTS(prgn);
-
- while(nbox > 0)
- {
- yThisBand = pbox->y1;
- nThisBand = 0;
- while((nbox > 0) && (pbox->y1 == yThisBand))
- {
- nbox--;
- pbox++;
- nThisBand++;
- }
- if (nThisBand > nMaxBand)
- nMaxBand = nThisBand;
- }
- return (nMaxBand);
-}
-#endif /* XXX_DO_WE_NEED_THIS */
-
-
pixman_bool_t
PREFIX(pixman_region_selfcheck) (reg)
- pixman_region16_t * reg;
+ region_type_t * reg;
{
int i, numRects;
}
pixman_bool_t
-PREFIX(pixman_region_init_rects) (pixman_region16_t *region,
+PREFIX(pixman_region_init_rects) (region_type_t *region,
box_type_t *boxes, int count)
{
int overlap;