Make hostlib test build again.
[AROS.git] / rom / graphics / orrectregion.c
blob7d283f75b0140ef994fc7f447aa9f92bc71b525d
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function OrRectRegion()
6 Lang: english
7 */
9 #include <exec/memory.h>
10 #include <graphics/regions.h>
11 #include <proto/exec.h>
13 #include "graphics_intern.h"
14 #include "intregions.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/graphics.h>
21 AROS_LH2(BOOL, OrRectRegion,
23 /* SYNOPSIS */
24 AROS_LHA(struct Region *, Reg, A0),
25 AROS_LHA(struct Rectangle *, Rect, A1),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 85, Graphics)
30 /* FUNCTION
31 Add the given Rectangle to the given Region (if not
32 already there)
34 INPUTS
35 region - pointer to Region structure
36 rectangle - pointer to Rectangle structure
38 RESULT
39 TRUE if the operation was successful, else FALSE
40 (out of memory)
42 NOTES
43 All relevant data is copied, you may throw away the
44 given rectangle after calling this function
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 AndRectRegion(), XorRectRegion(), ClearRectRegion()
53 INTERNALS
55 HISTORY
56 27-11-96 digulla automatically created from
57 graphics_lib.fd and clib/graphics_protos.h
58 16-01-97 mreckt initial version
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 if (IS_RECT_EVIL(Rect)) return TRUE;
66 if (Reg->RegionRectangle)
68 /* Region is not empty. Do the complete algorithm. */
69 struct Region Res;
70 struct RegionRectangle rr;
72 InitRegion(&Res);
74 rr.bounds = *Rect;
75 rr.Next = NULL;
76 rr.Prev = NULL;
78 if (_DoOperationBandBand(_OrBandBand,
79 MinX(Reg), 0, MinY(Reg), 0,
80 Reg->RegionRectangle, &rr, &Res.RegionRectangle, &Res.bounds, GfxBase))
82 ClearRegion(Reg);
84 *Reg = Res;
85 _TranslateRegionRectangles(Res.RegionRectangle, -MinX(&Res), -MinY(&Res));
87 return TRUE;
90 else
92 /* Optimized version for empty destination Region. Just add a single rectangle. */
93 struct RegionRectangle *rr = _NewRegionRectangle(&Reg->RegionRectangle, GfxBase);
95 if (rr)
97 Reg->bounds = *Rect;
99 rr->bounds.MinX = 0;
100 rr->bounds.MinY = 0;
101 rr->bounds.MaxX = Rect->MaxX - Rect->MinX;
102 rr->bounds.MaxY = Rect->MaxY - Rect->MinY;
104 return TRUE;
108 return FALSE;
110 AROS_LIBFUNC_EXIT
111 } /* OrRectRegion */