Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / graphics / andrectregionnd.c
blobb0dfb5d5ee820e9c67a9dbc9442ffe705abd47bd
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function AndRectRegion()
6 Lang: english
7 */
8 #include "graphics_intern.h"
9 #include <graphics/regions.h>
10 #include <proto/exec.h>
11 #include <clib/macros.h>
12 #include "intregions.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/graphics.h>
19 AROS_LH2(struct Region *, AndRectRegionND,
21 /* SYNOPSIS */
22 AROS_LHA(struct Region *, Reg, A0),
23 AROS_LHA(struct Rectangle *, Rect, A1),
25 /* LOCATION */
26 struct GfxBase *, GfxBase, 107, Graphics)
28 /* FUNCTION
29 Remove everything inside 'region' that is outside 'rectangle'
31 INPUTS
32 region - pointer to Region structure
33 rectangle - pointer to Rectangle structure
35 RESULT
36 The resulting region or NULL in case there's no enough free memory
38 NOTES
40 BUGS
42 SEE ALSO
43 AndRegionRegion(), OrRectRegion(), XorRectRegion(), ClearRectRegion()
44 NewRegion()
46 INTERNALS
48 HISTORY
49 27-11-96 digulla automatically created from
50 graphics_lib.fd and clib/graphics_protos.h
51 16-01-97 mreckt initial version
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct Region *Res;
59 if (IS_RECT_EVIL(Rect))
61 return NewRegion();
66 /* Is the region empty? */
67 !Reg->RegionRectangle ||
69 /* Does the rectangle completely cover the region? */
70 Rect->MinX <= MinX(Reg) &&
71 Rect->MinY <= MinY(Reg) &&
72 Rect->MaxX >= MaxX(Reg) &&
73 Rect->MaxY >= MaxY(Reg)
77 return CopyRegion(Reg);
80 Res = NewRegion();
82 if (Res)
84 struct RegionRectangle rr;
86 rr.bounds = *Rect;
87 rr.Next = NULL;
88 rr.Prev = NULL;
92 _DoOperationBandBand
94 _AndBandBand,
95 MinX(Reg),
97 MinY(Reg),
99 Reg->RegionRectangle,
100 &rr,
101 &Res->RegionRectangle,
102 &Res->bounds,
103 GfxBase
107 _TranslateRegionRectangles(Res->RegionRectangle, -MinX(Res), -MinY(Res));
109 else
111 DisposeRegion(Res);
112 Res = NULL;
116 return Res;
118 AROS_LIBFUNC_EXIT
119 } /* AndRectRegion */