grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / graphics / setregion.c
blob8c2d82fa8e2ec6f04c462aba66f9afd08131a27b
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: (AROS only) Graphics function SetRegion()
6 Lang: english
7 */
9 #include "graphics_intern.h"
10 #include <graphics/regions.h>
11 #include "intregions.h"
13 /*****************************************************************************
15 NAME */
16 #include <clib/graphics_protos.h>
18 AROS_LH2(BOOL, SetRegion,
20 /* SYNOPSIS */
21 AROS_LHA(struct Region *, src , A0),
22 AROS_LHA(struct Region *, dest, A1),
24 /* LOCATION */
25 struct GfxBase *, GfxBase, 181, Graphics)
27 /* FUNCTION
28 Sets the destination region to the source region.
29 Allocates necessary RegionRectangles if necessary
30 and deallocates any excessive RegionRectangles in
31 the destination Region. The source Region remains
32 untouched.
33 If the system runs out of memory during allocation
34 of RegionRectangles the destination Region will
37 INPUTS
39 RESULT
40 TRUE if everything went alright, FALSE otherwise
41 (out of memory).
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 NewRegion(), DisposeRegion()
52 INTERNALS
54 HISTORY
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
60 struct RegionRectangle * rrs, *rrd, *rrd_prev, *addr;
62 dest->bounds = src->bounds;
64 for
66 rrs = src->RegionRectangle, rrd = dest->RegionRectangle, rrd_prev = NULL;
67 rrs && rrd;
68 rrd_prev = rrd, rrs = rrs->Next, rrd = rrd->Next
71 rrd->bounds = rrs->bounds;
74 _DisposeRegionRectangleList(rrd, GfxBase);
76 if (rrd_prev)
77 addr = rrd_prev;
78 else
80 dest->RegionRectangle = NULL;
81 addr = dest->RegionRectangle;
84 if (!_LinkRegionRectangleList(rrs, &addr, GfxBase))
85 return FALSE;
87 if (!rrd_prev)
88 dest->RegionRectangle = addr ? &Chunk(addr)->FirstChunk->Rects[0].RR : NULL;
90 return TRUE;
92 AROS_LIBFUNC_EXIT
94 } /* SetRegion */