add some more debug. bump versions of components being adapted for 64bit support.
[AROS.git] / rom / intuition / freescreenbuffer.c
bloba12e866623c40450728561b86dfd5fdfb0a2d52d
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Desc: Intuition function FreeScreenBuffer()
7 Lang: english
8 */
9 #include <graphics/rastport.h>
10 #include <proto/graphics.h>
11 #include "intuition_intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <intuition/screens.h>
17 #include <proto/intuition.h>
19 AROS_LH2(void, FreeScreenBuffer,
21 /* SYNOPSIS */
22 AROS_LHA(struct Screen * , screen, A0),
23 AROS_LHA(struct ScreenBuffer *, screenbuffer, A1),
25 /* LOCATION */
26 struct IntuitionBase *, IntuitionBase, 129, Intuition)
28 /* FUNCTION
29 Frees a ScreenBuffer allocated by AllocScreenBuffer() and releases
30 associated resources. You have to call this before closing your
31 screen.
33 INPUTS
34 screen - The screen this screenbuffer belongs to
35 screenbuffer - The screenbuffer obtained by AllocScreenBuffer().
36 It is safe to pass NULL.
38 RESULT
39 None.
41 NOTES
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.
49 EXAMPLE
51 BUGS
53 SEE ALSO
54 AllocScreenBuffer(), ChangeScreenBuffer()
56 INTERNALS
58 *****************************************************************************/
60 AROS_LIBFUNC_INIT
62 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
63 DEBUG_FREESCREENBUFFER(dprintf("FreeScreenBuffer: Screen 0x%lx ScreenBuffer 0x%lx\n",
64 screen, screenbuffer));
66 if (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 memset( &safereply, 0, sizeof( safereply ) );
80 safereply.mp_Node.ln_Type = NT_MSGPORT;
81 safereply.mp_Flags = PA_SIGNAL;
82 safereply.mp_SigTask = FindTask(NULL);
83 safereply.mp_SigBit = SIGB_INTUITION;
84 NEWLIST(&(safereply.mp_MsgList));
86 IS(screen)->RestoreDBufInfo->dbi_SafeMessage.mn_ReplyPort = &safereply;
88 scb.sb_BitMap = IS(screen)->AllocatedBitMap;
89 scb.sb_DBufInfo = IS(screen)->RestoreDBufInfo;
91 ChangeScreenBuffer(screen, &scb);
93 while (!GetMsg(&safereply))
95 Wait(1L << SIGB_INTUITION);
98 else
100 /* AllocScreenBuffer ensures this is allocated, so... */
101 dprintf("MAJOR BUG: screenbuffer allocated for a wrong screen!?\n");
105 FreeDBufInfo(screenbuffer->sb_DBufInfo);
107 if (((struct IntScreenBuffer *)screenbuffer)->free_bitmap)
109 FreeBitMap(screenbuffer->sb_BitMap);
112 FreeMem(screenbuffer, sizeof(struct IntScreenBuffer));
115 AROS_LIBFUNC_EXIT
116 } /* FreeScreenBuffer */