fix debug
[AROS.git] / rom / graphics / clearregionregionnd.c
blob136fbc328f8393f5069a30a7a685099e894c791b
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function AndRegionRegion()
6 Lang: english
7 */
9 #include <graphics/regions.h>
11 #include "graphics_intern.h"
12 #include "intregions.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/graphics.h>
19 AROS_LH2(struct Region *, ClearRegionRegionND,
21 /* SYNOPSIS */
22 AROS_LHA(struct Region *, R1, A0),
23 AROS_LHA(struct Region *, R2, A1),
25 /* LOCATION */
26 struct GfxBase *, GfxBase, 193, Graphics)
28 /* FUNCTION
29 Clear the given Region region1 from the given Region region2.
31 INPUTS
32 region1 - pointer to a region structure
33 region2 - pointer to a region structure
35 RESULT
36 The resulting region or NULL in case there's no enough free memory
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
45 XorRegionRegion(), OrRegionRegion()
47 INTERNALS
49 HISTORY
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 struct Region *R3 = NewRegion();
57 if (!R3)
59 /* Out of memory, failed */
60 return NULL;
63 if (!R2->RegionRectangle)
65 /* R2 is already empty, nothing to clear */
66 return R3;
69 if (!R1->RegionRectangle ||
70 !overlap(R1->bounds, R2->bounds))
72 /* R2 is not empty, but there's nothing to clear. Make a plain copy. */
73 if (_CopyRegionRectangles(R2, R3, GfxBase))
74 return R3;
76 else
78 /* Some other case, do the complete algorighm */
79 if (_DoOperationBandBand(_ClearBandBand,
80 MinX(R1), MinX(R2), MinY(R1), MinY(R2),
81 R1->RegionRectangle, R2->RegionRectangle, &R3->RegionRectangle, &R3->bounds, GfxBase))
83 _TranslateRegionRectangles(R3->RegionRectangle, -MinX(R3), -MinY(R3));
84 return R3;
88 DisposeRegion(R3);
89 return NULL;
91 AROS_LIBFUNC_EXIT