2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
6 Desc: Intuition function FreeScreenBuffer()
9 #include <graphics/rastport.h>
10 #include <proto/graphics.h>
11 #include "intuition_intern.h"
13 /*****************************************************************************
16 #include <intuition/screens.h>
17 #include <proto/intuition.h>
19 AROS_LH2(void, FreeScreenBuffer
,
22 AROS_LHA(struct Screen
* , screen
, A0
),
23 AROS_LHA(struct ScreenBuffer
*, screenbuffer
, A1
),
26 struct IntuitionBase
*, IntuitionBase
, 129, Intuition
)
29 Frees a ScreenBuffer allocated by AllocScreenBuffer() and releases
30 associated resources. You have to call this before closing your
34 screen - The screen this screenbuffer belongs to
35 screenbuffer - The screenbuffer obtained by AllocScreenBuffer().
36 It is safe to pass NULL.
42 When used SB_SCREEN_BITMAP on allocating the ScreenBuffer
43 (ie. the ScreenBuffer only refers to the screen's BitMap) you must
44 FreeScreenBuffer() the ScreenBuffer before closing the screen.
45 Intuition will recognize when FreeScreenBuffer() is called for the
46 currently installed ScreenBuffer that it must not free the BitMap.
47 This is left to the CloseScreen() function.
54 AllocScreenBuffer(), ChangeScreenBuffer()
58 *****************************************************************************/
62 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
63 DEBUG_FREESCREENBUFFER(dprintf("FreeScreenBuffer: Screen 0x%lx ScreenBuffer 0x%lx\n",
64 screen
, screenbuffer
));
68 if (((struct IntScreenBuffer
*)screenbuffer
)->free_bitmap
&&
69 (screen
->RastPort
.BitMap
== screenbuffer
->sb_BitMap
))
71 DEBUG_FREESCREENBUFFER(dprintf("freescreenbuffer: Restoring original bitmap! RestoreDBInfo %0xlx\n",
72 IS(screen
)->RestoreDBufInfo
));
74 if (IS(screen
)->RestoreDBufInfo
)
76 struct MsgPort safereply
;
77 struct ScreenBuffer scb
;
79 safereply
.mp_Node
.ln_Type
= NT_MSGPORT
;
80 safereply
.mp_Flags
= PA_SIGNAL
;
81 safereply
.mp_SigTask
= FindTask(NULL
);
82 safereply
.mp_SigBit
= SIGB_INTUITION
;
83 NEWLIST(&(safereply
.mp_MsgList
));
85 IS(screen
)->RestoreDBufInfo
->dbi_SafeMessage
.mn_ReplyPort
= &safereply
;
87 scb
.sb_BitMap
= IS(screen
)->AllocatedBitMap
;
88 scb
.sb_DBufInfo
= IS(screen
)->RestoreDBufInfo
;
90 ChangeScreenBuffer(screen
, &scb
);
92 while (!GetMsg(&safereply
))
94 Wait(1L << SIGB_INTUITION
);
99 /* AllocScreenBuffer ensures this is allocated, so... */
100 dprintf("MAJOR BUG: screenbuffer allocated for a wrong screen!?\n");
104 FreeDBufInfo(screenbuffer
->sb_DBufInfo
);
106 if (((struct IntScreenBuffer
*)screenbuffer
)->free_bitmap
)
108 FreeBitMap(screenbuffer
->sb_BitMap
);
111 FreeMem(screenbuffer
, sizeof(struct IntScreenBuffer
));
115 } /* FreeScreenBuffer */