Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:35

0001 /************************************************************************
0002 
0003 Copyright 1987, 1998  The Open Group
0004 
0005 Permission to use, copy, modify, distribute, and sell this software and its
0006 documentation for any purpose is hereby granted without fee, provided that
0007 the above copyright notice appear in all copies and that both that
0008 copyright notice and this permission notice appear in supporting
0009 documentation.
0010 
0011 The above copyright notice and this permission notice shall be included in
0012 all copies or substantial portions of the Software.
0013 
0014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0017 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0018 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0019 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0020 
0021 Except as contained in this notice, the name of The Open Group shall not be
0022 used in advertising or otherwise to promote the sale, use or other dealings
0023 in this Software without prior written authorization from The Open Group.
0024 
0025 
0026 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
0027 
0028                         All Rights Reserved
0029 
0030 Permission to use, copy, modify, and distribute this software and its
0031 documentation for any purpose and without fee is hereby granted,
0032 provided that the above copyright notice appear in all copies and that
0033 both that copyright notice and this permission notice appear in
0034 supporting documentation, and that the name of Digital not be
0035 used in advertising or publicity pertaining to distribution of the
0036 software without specific, written prior permission.
0037 
0038 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
0039 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
0040 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
0041 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
0042 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
0043 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
0044 SOFTWARE.
0045 
0046 ************************************************************************/
0047 
0048 #ifndef _X11_XREGION_H_
0049 #define _X11_XREGION_H_
0050 
0051 typedef struct {
0052     short x1, x2, y1, y2;
0053 } Box, BOX, BoxRec, *BoxPtr;
0054 
0055 typedef struct {
0056     short x, y, width, height;
0057 }RECTANGLE, RectangleRec, *RectanglePtr;
0058 
0059 #define TRUE 1
0060 #define FALSE 0
0061 #define MAXSHORT 32767
0062 #define MINSHORT -MAXSHORT
0063 #ifndef MAX
0064 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
0065 #endif
0066 #ifndef MIN
0067 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
0068 #endif
0069 
0070 
0071 /*
0072  *   clip region
0073  */
0074 
0075 typedef struct _XRegion {
0076     long size;
0077     long numRects;
0078     BOX *rects;
0079     BOX extents;
0080 } REGION;
0081 
0082 /* Xutil.h contains the declaration:
0083  * typedef struct _XRegion *Region;
0084  */
0085 
0086 /*  1 if two BOXs overlap.
0087  *  0 if two BOXs do not overlap.
0088  *  Remember, x2 and y2 are not in the region
0089  */
0090 #define EXTENTCHECK(r1, r2) \
0091     ((r1)->x2 > (r2)->x1 && \
0092      (r1)->x1 < (r2)->x2 && \
0093      (r1)->y2 > (r2)->y1 && \
0094      (r1)->y1 < (r2)->y2)
0095 
0096 /*
0097  *  update region extents
0098  */
0099 #define EXTENTS(r,idRect){\
0100             if((r)->x1 < (idRect)->extents.x1)\
0101               (idRect)->extents.x1 = (r)->x1;\
0102             if((r)->y1 < (idRect)->extents.y1)\
0103               (idRect)->extents.y1 = (r)->y1;\
0104             if((r)->x2 > (idRect)->extents.x2)\
0105               (idRect)->extents.x2 = (r)->x2;\
0106             if((r)->y2 > (idRect)->extents.y2)\
0107               (idRect)->extents.y2 = (r)->y2;\
0108         }
0109 
0110 /*
0111  *   Check to see if there is enough memory in the present region.
0112  */
0113 #define MEMCHECK(reg, rect, firstrect){\
0114         if ((reg)->numRects >= ((reg)->size - 1)){\
0115           BoxPtr tmpRect = Xrealloc ((firstrect), \
0116                                      (2 * (sizeof(BOX)) * ((reg)->size))); \
0117           if (tmpRect == NULL) \
0118             return(0);\
0119           (firstrect) = tmpRect; \
0120           (reg)->size *= 2;\
0121           (rect) = &(firstrect)[(reg)->numRects];\
0122          }\
0123        }
0124 
0125 /*  this routine checks to see if the previous rectangle is the same
0126  *  or subsumes the new rectangle to add.
0127  */
0128 
0129 #define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
0130                (!(((Reg)->numRects > 0)&&\
0131                   ((R-1)->y1 == (Ry1)) &&\
0132                   ((R-1)->y2 == (Ry2)) &&\
0133                   ((R-1)->x1 <= (Rx1)) &&\
0134                   ((R-1)->x2 >= (Rx2))))
0135 
0136 /*  add a rectangle to the given Region */
0137 #define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
0138     if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
0139         CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
0140               (r)->x1 = (rx1);\
0141               (r)->y1 = (ry1);\
0142               (r)->x2 = (rx2);\
0143               (r)->y2 = (ry2);\
0144               EXTENTS((r), (reg));\
0145               (reg)->numRects++;\
0146               (r)++;\
0147             }\
0148         }
0149 
0150 
0151 
0152 /*  add a rectangle to the given Region */
0153 #define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
0154             if ((rx1 < rx2) && (ry1 < ry2) &&\
0155                 CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
0156               (r)->x1 = (rx1);\
0157               (r)->y1 = (ry1);\
0158               (r)->x2 = (rx2);\
0159               (r)->y2 = (ry2);\
0160               (reg)->numRects++;\
0161               (r)++;\
0162             }\
0163         }
0164 
0165 #define EMPTY_REGION(pReg) pReg->numRects = 0
0166 
0167 #define REGION_NOT_EMPTY(pReg) pReg->numRects
0168 
0169 #define INBOX(r, x, y) \
0170       ( ( ((r).x2 >  x)) && \
0171         ( ((r).x1 <= x)) && \
0172         ( ((r).y2 >  y)) && \
0173         ( ((r).y1 <= y)) )
0174 
0175 /*
0176  * number of points to buffer before sending them off
0177  * to scanlines() :  Must be an even number
0178  */
0179 #define NUMPTSTOBUFFER 200
0180 
0181 /*
0182  * used to allocate buffers for points and link
0183  * the buffers together
0184  */
0185 typedef struct _POINTBLOCK {
0186     XPoint pts[NUMPTSTOBUFFER];
0187     struct _POINTBLOCK *next;
0188 } POINTBLOCK;
0189 
0190 #endif /* _X11_XREGION_H_ */