r4493@vps: verhaegs | 2007-04-19 14:44:00 -0400
[AROS.git] / rom / graphics / freegbuffers.c
bloba38003053c2ef1be44f855356998d977a4bba6e8
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function FreeGBuffers()
6 Lang: english
7 */
8 #include <graphics/gels.h>
9 #include <graphics/rastport.h>
10 #include "graphics_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <proto/graphics.h>
17 AROS_LH3(void, FreeGBuffers,
19 /* SYNOPSIS */
20 AROS_LHA(struct AnimOb *, anOb, A0),
21 AROS_LHA(struct RastPort *, rp, A1),
22 AROS_LHA(BOOL , db, D0),
24 /* LOCATION */
25 struct GfxBase *, GfxBase, 100, Graphics)
27 /* FUNCTION
28 Deallocate all buffers for a whole AnimOb. In particular this
29 means getting buffers for
30 - BorderLine
31 - SaveBuffer
32 - CollMask
33 - ImageShadow (points to the same memory as CollMask does)
34 - if db is set to TRUE the user wants double-buffering, so we need
35 - DBufPacket
36 - BufBuffer
38 INPUTS
39 anOb = pointer to AnimOb structure to be added to list of
40 AnimObs
41 rp = pointer to a valid RastPort with initialized GelsInfo
42 structure
43 db = TRUE when double-buffering is wanted
45 RESULT
47 NOTES
48 A call to GetGBuffers() that resulted in a partially allocation
49 of the required buffers will result in a deallocation of these
50 buffers. (Possible incompatibility with the real thing, though)
52 EXAMPLE
54 BUGS
56 SEE ALSO
57 GetGBuffers() graphics/rastport.h graphics/gels.h
59 INTERNALS
60 See FreeGBuffers() !!
62 HISTORY
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
67 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
69 struct AnimComp * CurAnimComp = anOb -> HeadComp;
71 /* visit all the components of this AnimOb */
72 while (NULL != CurAnimComp)
74 struct AnimComp * CurSeqAnimComp = CurAnimComp;
75 /* visit all the sequences of a component
76 the sequences are connected like a ring!! */
79 struct Bob * CurBob = CurSeqAnimComp -> AnimBob;
80 struct VSprite * CurVSprite = CurBob -> BobVSprite;
81 long memsize;
83 /* Attention: width of a Bob/VSprite is the number of *words* it
84 uses for it's width */
86 /* deallocate height*(width*2) bytes of Chip-Ram for the ImageShadow */
87 memsize = (CurVSprite -> Height) *
88 (CurVSprite -> Width) * 2;
89 if (NULL != CurBob -> ImageShadow)
90 FreeMem(CurBob -> ImageShadow, memsize);
92 /* CollMask could point to the same memory as ImageShadow but
93 is not necessarly the same */
94 if (CurBob -> ImageShadow != CurVSprite -> CollMask)
95 FreeMem(CurVSprite -> CollMask, memsize);
97 CurBob -> ImageShadow = NULL;
98 CurVSprite -> CollMask = NULL;
100 /* deallocate height*(width*2)*depth bytes of Chip-Ram for
101 the SaveBuffer */
102 memsize *= (CurVSprite -> Depth);
103 if (NULL != CurBob -> SaveBuffer)
105 FreeMem(CurBob -> SaveBuffer, memsize);
106 CurBob -> SaveBuffer = NULL;
110 /* deallocate width bytes for BorderLine */
111 if (NULL != CurVSprite -> BorderLine)
113 FreeMem(CurVSprite -> BorderLine, CurVSprite -> Width * 2);
114 CurVSprite -> BorderLine = NULL;
117 /* were we using double buffering for this AnimOb? */
118 if (TRUE == db && NULL != CurBob -> DBuffer)
120 /* BufBuffer needed as much memory as SaveBuffer */
121 /* memsize still contains the size of memory required for SaveBuffer */
122 if (NULL != CurBob -> DBuffer -> BufBuffer)
123 FreeMem(CurBob -> DBuffer -> BufBuffer, memsize);
125 /* deallocate the DBufPacket structure */
126 FreeMem(CurBob -> DBuffer, sizeof(struct DBufPacket));
127 CurBob -> DBuffer = NULL;
130 /* go to the next sequence of this component */
131 CurSeqAnimComp = CurSeqAnimComp -> NextSeq;
133 while (CurAnimComp != CurSeqAnimComp);
135 /* go to next component */
136 CurAnimComp = CurAnimComp -> NextComp;
139 AROS_LIBFUNC_EXIT
140 } /* FreeGBuffers */