2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Header file for intregions.c
11 #include <graphics/gfxbase.h>
12 #include <graphics/regions.h>
15 BOOL
clearrectrect(struct Rectangle
* clearrect
, struct Rectangle
* rect
,
16 struct RegionRectangle
** erg
);
18 #define Bounds(x) (&(x)->bounds)
19 #define MinX(rr) (Bounds(rr)->MinX)
20 #define MaxX(rr) (Bounds(rr)->MaxX)
21 #define MinY(rr) (Bounds(rr)->MinY)
22 #define MaxY(rr) (Bounds(rr)->MaxY)
23 #define Width(rr) (MaxX(rr) - MinX(rr) + 1)
24 #define Height(rr) (MaxY(rr) - MinY(rr) + 1)
26 #define _DoRectsOverlap(Rect, x1, y1, x2, y2) \
28 y1 <= (Rect)->MaxY && \
29 y2 >= (Rect)->MinY && \
30 x1 <= (Rect)->MaxX && \
34 #define overlap(a,b) _DoRectsOverlap(&(a), (b).MinX, (b).MinY, (b).MaxX, (b).MaxY)
36 #define _AndRectRect(rect1, rect2, intersect) \
40 if (overlap(*(rect1), *(rect2))) \
42 (intersect)->MinX = MAX((rect1)->MinX, (rect2)->MinX); \
43 (intersect)->MinY = MAX((rect1)->MinY, (rect2)->MinY); \
44 (intersect)->MaxX = MIN((rect1)->MaxX, (rect2)->MaxX); \
45 (intersect)->MaxY = MIN((rect1)->MaxY, (rect2)->MaxY); \
55 #define _AreRectsEqual(Rect1, Rect2) \
57 (Rect1)->MinX == (Rect2)->MinX && \
58 (Rect1)->MinY == (Rect2)->MinY && \
59 (Rect1)->MaxX == (Rect2)->MaxX && \
60 (Rect1)->MaxY == (Rect2)->MaxY \
63 /* Checks whether the rectangle (x1, y1)-(x2, y2) is completely contained in Rect */
64 #define _IsRectInRect(Rect, x1, y1, x2, y2) \
66 y1 >= (Rect)->MinY && \
67 y2 <= (Rect)->MaxY && \
68 x1 >= (Rect)->MinX && \
72 #define _IsPointInRect(Rect, x, y) _IsRectInRect(Rect, (x), (y), (x), (y))
74 #define _SwapRegions(region1, region2) \
80 *region1 = *region2; \
84 #define _TranslateRect(rect, dx, dy) \
87 struct Rectangle *_rect = rect; \
90 (_rect)->MinX += _dx; \
91 (_rect)->MinY += _dy; \
92 (_rect)->MaxX += _dx; \
93 (_rect)->MaxY += _dy; \
96 #define _TranslateRegionRectangles(rr, dx, dy) \
99 struct RegionRectangle *_rr; \
101 for (_rr = rr; _rr; _rr = _rr->Next) \
102 _TranslateRect(&_rr->bounds, dx, dy); \
106 ** Important: ClearRegion calls InitRegion(). If you change something here
107 ** which should not be done in case of ClearRegion() then don't forget to
111 #define InitRegion(region) \
118 (region)->RegionRectangle = NULL; \
122 /* ugly hack, I know... */
125 typedef BOOL BandOperation
131 struct RegionRectangle
*Src1
,
132 struct RegionRectangle
*Src2
,
133 struct RegionRectangle
**DstPtr
,
134 struct RegionRectangle
**NextSrc1Ptr
,
135 struct RegionRectangle
**NextSrc2Ptr
,
136 struct GfxBase
*GfxBase
139 BOOL _DoOperationBandBand
141 BandOperation
*Operation
,
146 struct RegionRectangle
*Src1
,
147 struct RegionRectangle
*Src2
,
148 struct RegionRectangle
**DstPtr
,
149 struct Rectangle
*DstBounds
,
150 struct GfxBase
*GfxBase
153 extern BandOperation _OrBandBand
, _AndBandBand
, _ClearBandBand
;
157 #endif /* !INTREGIONS_H */