2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function FreeGBuffers()
8 #include <graphics/gels.h>
9 #include <graphics/rastport.h>
10 #include "graphics_intern.h"
12 /*****************************************************************************
15 #include <proto/graphics.h>
17 AROS_LH3(void, FreeGBuffers
,
20 AROS_LHA(struct AnimOb
*, anOb
, A0
),
21 AROS_LHA(struct RastPort
*, rp
, A1
),
22 AROS_LHA(BOOL
, db
, D0
),
25 struct GfxBase
*, GfxBase
, 100, Graphics
)
28 Deallocate all buffers for a whole AnimOb. In particular this
29 means getting buffers for
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
39 anOb = pointer to AnimOb structure to be added to list of
41 rp = pointer to a valid RastPort with initialized GelsInfo
43 db = TRUE when double-buffering is wanted
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)
57 GetGBuffers(), graphics/rastport.h, graphics/gels.h
64 *****************************************************************************/
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
;
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
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
;