Nonsense removed: upper case and lower case the same time.
[AROS.git] / rom / graphics / intregions.h
blob59f028cc8bbf5875d11faee6ab9f151af1ce3fda
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Header file for intregions.c
6 Lang: english
7 */
8 #ifndef INTREGIONS_H
9 #define INTREGIONS_H
11 #include <graphics/gfxbase.h>
12 #include <graphics/regions.h>
14 /* CHECK_EVIL_RECTS:
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
22 and possibly crash.
26 #define CHECK_EVIL_RECTS 1
28 #if CHECK_EVIL_RECTS
30 #define IS_RECT_EVIL(rect) \
31 ( \
32 ((rect)->MaxX < (rect)->MinX) || \
33 ((rect)->MaxY < (rect)->MinY) \
36 #define ARE_COORDS_EVIL(minx,miny,maxx,maxy) \
37 ( \
38 ((maxx) < (minx)) || \
39 ((maxy) < (miny)) \
42 #else
44 #define IS_RECT_EVIL(rect) 0
45 #define ARE_COORDS_EVIL(minx,miny,maxx,maxy) 0
47 #endif
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) \
62 ( \
63 y1 <= (Rect)->MaxY && \
64 y2 >= (Rect)->MinY && \
65 x1 <= (Rect)->MaxX && \
66 x2 >= (Rect)->MinX \
69 #define overlap(a,b) _DoRectsOverlap(&(a), (b).MinX, (b).MinY, (b).MaxX, (b).MaxY)
71 #define _AndRectRect(rect1, rect2, intersect) \
72 ({ \
73 BOOL res; \
75 if (overlap(*(rect1), *(rect2))) \
76 { \
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); \
82 res = TRUE; \
83 } \
84 else \
85 res = FALSE; \
87 res; \
90 #define _AreRectsEqual(Rect1, Rect2) \
91 ( \
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 && \
104 x2 <= (Rect)->MaxX \
107 #define _IsPointInRect(Rect, x, y) _IsRectInRect(Rect, (x), (y), (x), (y))
109 #define _SwapRegions(region1, region2) \
110 do \
112 struct Region tmp; \
114 tmp = *region1; \
115 *region1 = *region2; \
116 *region2 = tmp; \
117 } while (0);
119 #define _TranslateRect(rect, dx, dy) \
120 do \
122 struct Rectangle *_rect = rect; \
123 WORD _dx = dx; \
124 WORD _dy = dy; \
125 (_rect)->MinX += _dx; \
126 (_rect)->MinY += _dy; \
127 (_rect)->MaxX += _dx; \
128 (_rect)->MaxY += _dy; \
129 } while(0)
131 #define _TranslateRegionRectangles(rr, dx, dy) \
132 if (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
143 ** fix ClearRegion!
146 #define InitRegion(region) \
147 do \
149 MinX(region) = 0; \
150 MinY(region) = 0; \
151 MaxX(region) = 0; \
152 MaxY(region) = 0; \
153 (region)->RegionRectangle = NULL; \
154 } while (0)
157 /* ugly hack, I know... */
158 #ifndef GfxBase
160 typedef BOOL BandOperation
162 LONG OffX1,
163 LONG OffX2,
164 LONG MinY,
165 LONG MaxY,
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,
177 LONG OffX1,
178 LONG OffX2,
179 LONG OffY1,
180 LONG OffY2,
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;
190 #endif
192 #endif /* !INTREGIONS_H */