xserver-multidpi/include/regionstr.h

289 lines
7.8 KiB
C
Raw Normal View History

2003-11-14 16:54:54 +01:00
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
2003-11-14 16:54:54 +01:00
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
2003-11-14 16:54:54 +01:00
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
2003-11-14 16:54:54 +01:00
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
2003-11-14 17:49:22 +01:00
2003-11-14 16:54:54 +01:00
#ifndef REGIONSTRUCT_H
#define REGIONSTRUCT_H
typedef struct pixman_region16 RegionRec, *RegionPtr;
2003-11-14 16:54:54 +01:00
#include "miscstruct.h"
/* Return values from RectIn() */
#define rgnOUT 0
#define rgnIN 1
#define rgnPART 2
#define NullRegion ((RegionPtr)0)
/*
2003-11-14 16:54:54 +01:00
* clip region
*/
typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
2003-11-14 16:54:54 +01:00
extern _X_EXPORT BoxRec RegionEmptyBox;
extern _X_EXPORT RegDataRec RegionEmptyData;
extern _X_EXPORT RegDataRec RegionBrokenData;
2003-11-14 16:54:54 +01:00
#define RegionNil(reg) ((reg)->data && !(reg)->data->numRects)
2003-11-14 17:49:22 +01:00
/* not a region */
#define RegionNar(reg) ((reg)->data == &RegionBrokenData)
#define RegionNumRects(reg) ((reg)->data ? (reg)->data->numRects : 1)
#define RegionSize(reg) ((reg)->data ? (reg)->data->size : 0)
#define RegionRects(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
2003-11-14 16:54:54 +01:00
: &(reg)->extents)
#define RegionBoxptr(reg) ((BoxPtr)((reg)->data + 1))
#define RegionBox(reg,i) (&RegionBoxptr(reg)[i])
#define RegionTop(reg) RegionBox(reg, (reg)->data->numRects)
#define RegionEnd(reg) RegionBox(reg, (reg)->data->numRects - 1)
#define RegionSizeof(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
2003-11-14 16:54:54 +01:00
#define RegionCreate(_rect, _size) \
RegionCreate(_rect, _size)
2003-11-14 16:54:54 +01:00
#define RegionCopy(dst, src) \
RegionCopy(dst, src)
2003-11-14 16:54:54 +01:00
#define RegionDestroy(_pReg) \
RegionDestroy(_pReg)
2003-11-14 16:54:54 +01:00
#define RegionIntersect(newReg, reg1, reg2) \
RegionIntersect(newReg, reg1, reg2)
2003-11-14 16:54:54 +01:00
#define RegionUnion(newReg, reg1, reg2) \
RegionUnion(newReg, reg1, reg2)
2003-11-14 16:54:54 +01:00
#define RegionSubtract(newReg, reg1, reg2) \
RegionSubtract(newReg, reg1, reg2)
2003-11-14 16:54:54 +01:00
#define RegionInverse(newReg, reg1, invRect) \
RegionInverse(newReg, reg1, invRect)
2003-11-14 16:54:54 +01:00
#define RegionTranslate(_pReg, _x, _y) \
RegionTranslate(_pReg, _x, _y)
2003-11-14 16:54:54 +01:00
#define RegionContainsRect(_pReg, prect) \
RegionContainsRect(_pReg, prect)
2003-11-14 16:54:54 +01:00
#define RegionContainsPoint(_pReg, _x, _y, prect) \
RegionContainsPoint(_pReg, _x, _y, prect)
2003-11-14 16:54:54 +01:00
#define RegionAppend(dstrgn, rgn) \
RegionAppend(dstrgn, rgn)
2003-11-14 16:54:54 +01:00
#define RegionValidate(badreg, pOverlap) \
RegionValidate(badreg, pOverlap)
2003-11-14 16:54:54 +01:00
#define BitmapToRegion(_pScreen, pPix) \
2003-11-14 16:54:54 +01:00
(*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
#define RegionFromRects(nrects, prect, ctype) \
RegionFromRects(nrects, prect, ctype)
#define RegionEqual(_pReg1, _pReg2) \
RegionEqual(_pReg1, _pReg2)
2003-11-14 16:54:54 +01:00
#define RegionBreak(_pReg) \
RegionBreak(_pReg)
2003-11-14 17:49:22 +01:00
#define RegionInit(_pReg, _rect, _size) \
2003-11-14 16:54:54 +01:00
{ \
if ((_rect) != NULL) \
{ \
(_pReg)->extents = *(_rect); \
(_pReg)->data = (RegDataPtr)NULL; \
} \
else \
{ \
(_pReg)->extents = RegionEmptyBox; \
if (((_size) > 1) && ((_pReg)->data = \
(RegDataPtr)malloc(RegionSizeof(_size)))) \
{ \
(_pReg)->data->size = (_size); \
(_pReg)->data->numRects = 0; \
} \
else \
(_pReg)->data = &RegionEmptyData; \
} \
}
2003-11-14 16:54:54 +01:00
#define RegionUninit(_pReg) \
2003-11-14 16:54:54 +01:00
{ \
2003-11-14 17:49:22 +01:00
if ((_pReg)->data && (_pReg)->data->size) { \
free((_pReg)->data); \
2003-11-14 17:49:22 +01:00
(_pReg)->data = NULL; \
} \
2003-11-14 16:54:54 +01:00
}
#define RegionReset(_pReg, _pBox) \
2003-11-14 16:54:54 +01:00
{ \
(_pReg)->extents = *(_pBox); \
RegionUninit(_pReg); \
2003-11-14 16:54:54 +01:00
(_pReg)->data = (RegDataPtr)NULL; \
}
#define RegionNotEmpty(_pReg) \
!RegionNil(_pReg)
2003-11-14 16:54:54 +01:00
#define RegionBroken(_pReg) \
RegionNar(_pReg)
2003-11-14 17:49:22 +01:00
#define RegionEmpty(_pReg) \
2003-11-14 16:54:54 +01:00
{ \
RegionUninit(_pReg); \
2003-11-14 16:54:54 +01:00
(_pReg)->extents.x2 = (_pReg)->extents.x1; \
(_pReg)->extents.y2 = (_pReg)->extents.y1; \
(_pReg)->data = &RegionEmptyData; \
2003-11-14 16:54:54 +01:00
}
#define RegionExtents(_pReg) \
2006-03-28 02:18:31 +02:00
(&(_pReg)->extents)
#define RegionNull(_pReg) \
{ \
(_pReg)->extents = RegionEmptyBox; \
(_pReg)->data = &RegionEmptyData; \
}
2003-11-14 16:54:54 +01:00
/* moved from mi.h */
extern _X_EXPORT void InitRegions (void);
extern _X_EXPORT RegionPtr RegionCreate(
2003-11-14 16:54:54 +01:00
BoxPtr /*rect*/,
int /*size*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT void RegionDestroy(
RegionPtr /*pReg*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionCopy(
2003-11-14 16:54:54 +01:00
RegionPtr /*dst*/,
RegionPtr /*src*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionIntersect(
2003-11-14 16:54:54 +01:00
RegionPtr /*newReg*/,
RegionPtr /*reg1*/,
RegionPtr /*reg2*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionUnion(
2003-11-14 16:54:54 +01:00
RegionPtr /*newReg*/,
RegionPtr /*reg1*/,
RegionPtr /*reg2*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionAppend(
2003-11-14 16:54:54 +01:00
RegionPtr /*dstrgn*/,
RegionPtr /*rgn*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionValidate(
2003-11-14 16:54:54 +01:00
RegionPtr /*badreg*/,
Bool * /*pOverlap*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT RegionPtr RegionFromRects(
2003-11-14 16:54:54 +01:00
int /*nrects*/,
xRectanglePtr /*prect*/,
int /*ctype*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionSubtract(
2003-11-14 16:54:54 +01:00
RegionPtr /*regD*/,
RegionPtr /*regM*/,
RegionPtr /*regS*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionInverse(
2003-11-14 16:54:54 +01:00
RegionPtr /*newReg*/,
RegionPtr /*reg1*/,
BoxPtr /*invRect*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT int RegionContainsRect(
2003-11-14 16:54:54 +01:00
RegionPtr /*region*/,
BoxPtr /*prect*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT void RegionTranslate(
2003-11-14 16:54:54 +01:00
RegionPtr /*pReg*/,
int /*x*/,
int /*y*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionBreak(
RegionPtr /*pReg*/);
2003-11-14 17:49:22 +01:00
extern _X_EXPORT Bool RegionContainsPoint(
2003-11-14 16:54:54 +01:00
RegionPtr /*pReg*/,
int /*x*/,
int /*y*/,
BoxPtr /*box*/);
extern _X_EXPORT Bool RegionEqual(
RegionPtr /*pReg1*/,
RegionPtr /*pReg2*/);
2003-11-14 16:54:54 +01:00
extern _X_EXPORT Bool RegionRectAlloc(
RegionPtr /*pRgn*/,
int /*n*/
);
2003-11-14 16:54:54 +01:00
#ifdef DEBUG
extern _X_EXPORT Bool RegionIsValid(
RegionPtr /*prgn*/
);
#endif
2003-11-14 16:54:54 +01:00
extern _X_EXPORT void RegionPrint(
RegionPtr /*pReg*/);
extern _X_EXPORT int RegionClipSpans(
RegionPtr /*prgnDst*/,
DDXPointPtr /*ppt*/,
int * /*pwidth*/,
int /*nspans*/,
DDXPointPtr /*pptNew*/,
int * /*pwidthNew*/,
int /*fSorted*/
);
2003-11-14 16:54:54 +01:00
#endif /* REGIONSTRUCT_H */