Call "Avail FLUSH" as part of runtime tests.
[AROS.git] / rom / graphics / andrectregionnd.c
blob8bedb242f49ba699b43b0bc6e7892986c45b4ba1
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function AndRectRegion()
6 Lang: english
7 */
9 #include <graphics/regions.h>
10 #include <proto/exec.h>
11 #include <clib/macros.h>
13 #include "graphics_intern.h"
14 #include "intregions.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/graphics.h>
21 AROS_LH2(struct Region *, AndRectRegionND,
23 /* SYNOPSIS */
24 AROS_LHA(struct Region *, Reg, A0),
25 AROS_LHA(struct Rectangle *, Rect, A1),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 186, Graphics)
30 /* FUNCTION
31 Remove everything inside 'region' that is outside 'rectangle'
33 INPUTS
34 region - pointer to Region structure
35 rectangle - pointer to Rectangle structure
37 RESULT
38 The resulting region or NULL in case there's no enough free memory
40 NOTES
42 BUGS
44 SEE ALSO
45 AndRegionRegion(), OrRectRegion(), XorRectRegion(), ClearRectRegion()
46 NewRegion()
48 INTERNALS
50 HISTORY
51 27-11-96 digulla automatically created from
52 graphics_lib.fd and clib/graphics_protos.h
53 16-01-97 mreckt initial version
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
59 struct Region *Res = NewRegion();
61 if (IS_RECT_EVIL(Rect))
63 return Res;
66 if (!Reg->RegionRectangle)
68 /* The region is already empty, return empty copy */
69 return Res;
72 if (Res)
74 if (Rect->MinX <= MinX(Reg) &&
75 Rect->MinY <= MinY(Reg) &&
76 Rect->MaxX >= MaxX(Reg) &&
77 Rect->MaxY >= MaxY(Reg))
79 /* The rectangle completely covers the region. Make a plain copy. */
80 if (_CopyRegionRectangles(Reg, Res, GfxBase))
81 return Res;
83 else
85 struct RegionRectangle rr;
87 rr.bounds = *Rect;
88 rr.Next = NULL;
89 rr.Prev = NULL;
91 if (_DoOperationBandBand(_AndBandBand,
92 MinX(Reg), 0, MinY(Reg), 0,
93 Reg->RegionRectangle, &rr, &Res->RegionRectangle, &Res->bounds, GfxBase))
95 _TranslateRegionRectangles(Res->RegionRectangle, -MinX(Res), -MinY(Res));
97 return Res;
101 DisposeRegion(Res);
104 return NULL;
106 AROS_LIBFUNC_EXIT
107 } /* AndRectRegion */