move delay code into separate function.
[AROS.git] / rom / hyperlayers / beginupdate.c
blobb5ddcdf372a22d9a76472fb779cbddcb02b3d85b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <aros/libcall.h>
9 #include <graphics/clip.h>
10 #include <exec/types.h>
11 #include <proto/exec.h>
12 #include <graphics/layers.h>
13 #include <proto/graphics.h>
14 #include <proto/layers.h>
15 #include "layers_intern.h"
16 #include "basicfuncs.h"
18 /*****************************************************************************
20 NAME */
22 AROS_LH1(LONG, BeginUpdate,
24 /* SYNOPSIS */
25 AROS_LHA(struct Layer *, l, A0),
27 /* LOCATION */
28 struct LayersBase *, LayersBase, 13, Layers)
30 /* FUNCTION
31 Converts the damage list to ClipRects and exchanges the
32 two lists for faster redrawing. This routine allows a
33 faster update of the display as it will only be rendered
34 in the damaged areas.
35 This routine will automatically lock the layer to prevent
36 changes.
38 INPUTS
39 l - pointer to layer
41 RESULT
42 TRUE if damage list conversion was successful
43 FALSE if list could not be converted.
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 EndUpdate()
54 INTERNALS
56 HISTORY
57 27-11-96 digulla automatically created from
58 layers_lib.fd and clib/layers_protos.h
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 struct Region *damage_region, *visible_damage_region;
65 /*
66 ** Convert the list of regionrectangles in the damage list
67 ** to a cliprect list.
70 LockLayer(0, l);
72 l->cr2 = l->ClipRect;
75 if (l->ClipRegion)
76 damage_region = AndRegionRegionND(l->ClipRegion, l->DamageList);
77 else
79 damage_region = NewRegion();
80 if (damage_region)
82 if (!OrRegionRegion(l->DamageList, damage_region))
84 DisposeRegion(damage_region);
85 damage_region = NULL;
90 if (!damage_region)
92 /* CHECKME: Should we really unlock on error? */
93 UnlockLayer(l);
94 return FALSE;
97 /* The DamageList is in layer coords. So convert it to screen coords */
99 _TranslateRect(&damage_region->bounds, l->bounds.MinX, l->bounds.MinY);
101 AndRectRegion(damage_region, &l->bounds);
103 visible_damage_region = AndRegionRegionND(l->VisibleRegion, damage_region);
104 AndRegionRegion(l->visibleshape, visible_damage_region);
106 if (l->shaperegion)
108 _TranslateRect(&visible_damage_region->bounds, -l->bounds.MinX, -l->bounds.MinY);
109 AndRegionRegion(l->shaperegion, visible_damage_region);
110 _TranslateRect(&visible_damage_region->bounds, l->bounds.MinX, l->bounds.MinY);
113 l->ClipRect = _CreateClipRectsFromRegion(visible_damage_region,
115 FALSE,
116 damage_region,
117 LayersBase);
119 if (IS_SMARTREFRESH(l))
121 _CopyClipRectsToClipRects(l,
122 l->cr2,
123 l->ClipRect,
126 FALSE,
127 FALSE,
128 FALSE,
129 LayersBase);
133 DisposeRegion(damage_region);
134 DisposeRegion(visible_damage_region);
137 ** Must not set flag before InstallClipRegion!!! Keep this order!!!
139 l-> Flags |= LAYERUPDATING;
141 return TRUE;
143 AROS_LIBFUNC_EXIT
144 } /* BeginUpdate */