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>
16 If 1, code will assume such rects to be like an empty region
18 If 0, code reacts on such rects in a probably undefined matter
19 and things like layers.library might freak out if an app for
20 example tries to install a clip rectangle (region) with maxx < minx
21 and/or maxy < miny. Causing apps to render outside of layer/window
26 #define CHECK_EVIL_RECTS 1
30 #define IS_RECT_EVIL(rect) \
32 ((rect)->MaxX < (rect)->MinX) || \
33 ((rect)->MaxY < (rect)->MinY) \
36 #define ARE_COORDS_EVIL(minx,miny,maxx,maxy) \
38 ((maxx) < (minx)) || \
44 #define IS_RECT_EVIL(rect) 0
45 #define ARE_COORDS_EVIL(minx,miny,maxx,maxy) 0
50 BOOL
clearrectrect(struct Rectangle
* clearrect
, struct Rectangle
* rect
,
51 struct RegionRectangle
** erg
);
53 #define Bounds(x) (&(x)->bounds)
54 #define MinX(rr) (Bounds(rr)->MinX)
55 #define MaxX(rr) (Bounds(rr)->MaxX)
56 #define MinY(rr) (Bounds(rr)->MinY)
57 #define MaxY(rr) (Bounds(rr)->MaxY)
58 #define Width(rr) (MaxX(rr) - MinX(rr) + 1)
59 #define Height(rr) (MaxY(rr) - MinY(rr) + 1)
61 #define _DoRectsOverlap(Rect, x1, y1, x2, y2) \
63 y1 <= (Rect)->MaxY && \
64 y2 >= (Rect)->MinY && \
65 x1 <= (Rect)->MaxX && \
69 #define overlap(a,b) _DoRectsOverlap(&(a), (b).MinX, (b).MinY, (b).MaxX, (b).MaxY)
71 #define _AndRectRect(rect1, rect2, intersect) \
75 if (overlap(*(rect1), *(rect2))) \
77 (intersect)->MinX = MAX((rect1)->MinX, (rect2)->MinX); \
78 (intersect)->MinY = MAX((rect1)->MinY, (rect2)->MinY); \
79 (intersect)->MaxX = MIN((rect1)->MaxX, (rect2)->MaxX); \
80 (intersect)->MaxY = MIN((rect1)->MaxY, (rect2)->MaxY); \
90 #define _AreRectsEqual(Rect1, Rect2) \
92 (Rect1)->MinX == (Rect2)->MinX && \
93 (Rect1)->MinY == (Rect2)->MinY && \
94 (Rect1)->MaxX == (Rect2)->MaxX && \
95 (Rect1)->MaxY == (Rect2)->MaxY \
98 /* Checks whether the rectangle (x1, y1)-(x2, y2) is completely contained in Rect */
99 #define _IsRectInRect(Rect, x1, y1, x2, y2) \
101 y1 >= (Rect)->MinY && \
102 y2 <= (Rect)->MaxY && \
103 x1 >= (Rect)->MinX && \
107 #define _IsPointInRect(Rect, x, y) _IsRectInRect(Rect, (x), (y), (x), (y))
109 #define _SwapRegions(region1, region2) \
115 *region1 = *region2; \
119 #define _TranslateRect(rect, dx, dy) \
122 struct Rectangle *_rect = rect; \
125 (_rect)->MinX += _dx; \
126 (_rect)->MinY += _dy; \
127 (_rect)->MaxX += _dx; \
128 (_rect)->MaxY += _dy; \
131 #define _TranslateRegionRectangles(rr, dx, dy) \
134 struct RegionRectangle *_rr; \
136 for (_rr = rr; _rr; _rr = _rr->Next) \
137 _TranslateRect(&_rr->bounds, dx, dy); \
141 ** Important: ClearRegion calls InitRegion(). If you change something here
142 ** which should not be done in case of ClearRegion() then don't forget to
146 #define InitRegion(region) \
153 (region)->RegionRectangle = NULL; \
157 /* ugly hack, I know... */
160 typedef BOOL BandOperation
166 struct RegionRectangle
*Src1
,
167 struct RegionRectangle
*Src2
,
168 struct RegionRectangle
**DstPtr
,
169 struct RegionRectangle
**NextSrc1Ptr
,
170 struct RegionRectangle
**NextSrc2Ptr
,
171 struct GfxBase
*GfxBase
174 BOOL _DoOperationBandBand
176 BandOperation
*Operation
,
181 struct RegionRectangle
*Src1
,
182 struct RegionRectangle
*Src2
,
183 struct RegionRectangle
**DstPtr
,
184 struct Rectangle
*DstBounds
,
185 struct GfxBase
*GfxBase
188 extern BandOperation _OrBandBand
, _AndBandBand
, _ClearBandBand
;
192 #endif /* !INTREGIONS_H */