Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / graphics / freegbuffers.c
blobeb0401c67bd24baecadcb49835273ecb1b030eb5
1 /*
2 Copyright © 1995-2007, 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
68 struct AnimComp * CurAnimComp = anOb -> HeadComp;
70 /* visit all the components of this AnimOb */
71 while (NULL != CurAnimComp)
73 struct AnimComp * CurSeqAnimComp = CurAnimComp;
74 /* visit all the sequences of a component
75 the sequences are connected like a ring!! */
78 struct Bob * CurBob = CurSeqAnimComp -> AnimBob;
79 struct VSprite * CurVSprite = CurBob -> BobVSprite;
80 long memsize;
82 /* Attention: width of a Bob/VSprite is the number of *words* it
83 uses for it's width */
85 /* deallocate height*(width*2) bytes of Chip-Ram for the ImageShadow */
86 memsize = (CurVSprite -> Height) *
87 (CurVSprite -> Width) * 2;
88 if (NULL != CurBob -> ImageShadow)
89 FreeMem(CurBob -> ImageShadow, memsize);
91 /* CollMask could point to the same memory as ImageShadow but
92 is not necessarly the same */
93 if (CurBob -> ImageShadow != CurVSprite -> CollMask)
94 FreeMem(CurVSprite -> CollMask, memsize);
96 CurBob -> ImageShadow = NULL;
97 CurVSprite -> CollMask = NULL;
99 /* deallocate height*(width*2)*depth bytes of Chip-Ram for
100 the SaveBuffer */
101 memsize *= (CurVSprite -> Depth);
102 if (NULL != CurBob -> SaveBuffer)
104 FreeMem(CurBob -> SaveBuffer, memsize);
105 CurBob -> SaveBuffer = NULL;
109 /* deallocate width bytes for BorderLine */
110 if (NULL != CurVSprite -> BorderLine)
112 FreeMem(CurVSprite -> BorderLine, CurVSprite -> Width * 2);
113 CurVSprite -> BorderLine = NULL;
116 /* were we using double buffering for this AnimOb? */
117 if (db && NULL != CurBob -> DBuffer)
119 /* BufBuffer needed as much memory as SaveBuffer */
120 /* memsize still contains the size of memory required for SaveBuffer */
121 if (NULL != CurBob -> DBuffer -> BufBuffer)
122 FreeMem(CurBob -> DBuffer -> BufBuffer, memsize);
124 /* deallocate the DBufPacket structure */
125 FreeMem(CurBob -> DBuffer, sizeof(struct DBufPacket));
126 CurBob -> DBuffer = NULL;
129 /* go to the next sequence of this component */
130 CurSeqAnimComp = CurSeqAnimComp -> NextSeq;
132 while (CurAnimComp != CurSeqAnimComp);
134 /* go to next component */
135 CurAnimComp = CurAnimComp -> NextComp;
138 AROS_LIBFUNC_EXIT
139 } /* FreeGBuffers */