posixc.library: convert path unix2amiga in rmdir before passing to stdcio remove
[AROS.git] / rom / graphics / clearrectregionnd.c
blob9124a49239065dae8711db6a1bf5ec66ca37bfc9
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 *, ClearRectRegionND,
23 /* SYNOPSIS */
24 AROS_LHA(struct Region *, Reg, A0),
25 AROS_LHA(struct Rectangle *, Rect, A1),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 192, Graphics)
30 /* FUNCTION
31 Clear the given Rectangle from the given Region
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 (!Res)
62 return NULL;
64 if (!Reg->RegionRectangle ||
65 IS_RECT_EVIL(Rect) ||
66 !overlap(*Rect, Reg->bounds))
68 /* Nothing to clear. Make a plain copy. */
69 if (!_CopyRegionRectangles(Reg, Res, GfxBase))
71 DisposeRegion(Res);
72 Res = NULL;
76 else if (Rect->MinX > MinX(Reg) || Rect->MinY > MinY(Reg) ||
77 Rect->MaxX < MaxX(Reg) || Rect->MaxY < MaxY(Reg))
79 /* Partial overlapping detected. Do the complete algorithm. */
80 struct RegionRectangle rr;
82 rr.bounds = *Rect;
83 rr.Next = NULL;
84 rr.Prev = NULL;
88 _DoOperationBandBand
90 _ClearBandBand,
92 MinX(Reg),
94 MinY(Reg),
95 &rr,
96 Reg->RegionRectangle,
97 &Res->RegionRectangle,
98 &Res->bounds,
99 GfxBase
103 _TranslateRegionRectangles(Res->RegionRectangle, -MinX(Res), -MinY(Res));
105 else
107 DisposeRegion(Res);
108 Res = NULL;
111 /* If neither of two cases above were true, we've removed everything (Rect completely covers Reg). Return empty Res. */
113 return Res;
115 AROS_LIBFUNC_EXIT
116 } /* AndRectRegion */