tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / intuition / freescreenbuffer.c
blobb94900e0694f385e2a1d50d40934dfa4190566f3
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 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);
97 else
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));
114 AROS_LIBFUNC_EXIT
115 } /* FreeScreenBuffer */