2 Copyright © 1995-2001, 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 *****************************************************************************/
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
;
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
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
;