Instead of "eax" and "edx" in asm constraints use "a" and "d"
[tangerine.git] / rom / intuition / allocscreenbuffer.c
blob790de7ed0e538afea0ca59f92e135ba2f48d9cd4
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/graphics.h>
8 #include <proto/cybergraphics.h>
9 #include <exec/exec.h>
10 #include <cybergraphx/cybergraphics.h>
11 #include "intuition_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <intuition/screens.h>
16 #include <proto/intuition.h>
18 AROS_LH3(struct ScreenBuffer *, AllocScreenBuffer,
20 /* SYNOPSIS */
21 AROS_LHA(struct Screen *, screen, A0),
22 AROS_LHA(struct BitMap *, bitmap, A1),
23 AROS_LHA(ULONG , flags, D0),
25 /* LOCATION */
26 struct IntuitionBase *, IntuitionBase, 128, Intuition)
28 /* FUNCTION
29 Allocate a ScreenBuffer (and BitMap) for double or multiple
30 buffering in Intuition screens. Use this function to obtain a
31 ScreenBuffer for the screen's initial BitMap and for all other
32 BitMaps you want to swap in.
34 This function also allocates a DBufInfo from graphics.library
35 The returned ScreenBuffer contains a pointer to that DBufInfo.
36 See graphics.library/AllocDBufInfo() for more information on
37 how to use this struct to obtain info when it is safe to render
38 into an old buffer and when to switch.
40 INPUTS
41 screen - Screen to double-buffer
42 bitmap - You may pre-allocate a BitMap for CUSTOMBITMAP screens,
43 and pass the pointer to get a ScreenBuffer referring to it.
44 If you specify NULL, intuition will allocate the BitMap for
45 you. For non-CUSTOMBITMAP screens this parameter must be NULL.
46 flags - A combination of these flags:
47 SB_SCREEN_BITMAP for non-CUSTOMBITMAP screens to get a
48 ScreenBuffer referring to the screen's actual BitMap
49 (For CUSTOMBITMAP screens just pass the BitMap you used for
50 OpenScreen() as the bitmap parameter)
51 SB_COPY_BITMAP to copy the screen's BitMap intto the
52 ScreenBuffer's BitMap. Use this to get intuition rendered
53 stuff into your bitmap (such as menu-bars or gadgets).
54 May be omitted if the screen has no intuition rendered stuff,
55 as well as for allocating a ScreenBuffer for the screen's
56 initial BitMap.
59 RESULT
60 Pointer to the allocated ScreenBuffer or NULL if function failed.
62 NOTES
63 You may render into the resulting BitMap.
64 Use the sb_DBufInfo field to access graphics.library's ViewPort
65 buffering features to e.g check if it is safe to reuse the previous
66 BitMap. Otherwise you risk to write into the on-screen BitMap and
67 damage menu or gadget rendering.
69 EXAMPLE
71 BUGS
73 SEE ALSO
74 FreeScreenBuffer(), ChangeScreenBuffer()
76 INTERNALS
78 HISTORY
80 *****************************************************************************/
82 AROS_LIBFUNC_INIT
83 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
85 struct IntScreenBuffer *ScreenBuffer = NULL;
87 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: Screen 0x%lx BitMap 0x%lx Flags 0x%lx\n",
88 screen, bitmap, flags));
90 if (screen)
92 if ((ScreenBuffer = AllocMem(sizeof (struct IntScreenBuffer),
93 MEMF_CLEAR)))
95 if ((ScreenBuffer->sb.sb_DBufInfo =
96 AllocDBufInfo(&screen->ViewPort)))
98 if (!bitmap)
100 /* Get a bitmap */
101 if (flags & SB_SCREEN_BITMAP)
103 bitmap = screen->RastPort.BitMap;
105 else
107 ScreenBuffer->free_bitmap = TRUE;
109 bitmap = AllocBitMap(GetBitMapAttr(screen->RastPort.BitMap,BMA_WIDTH),
110 GetBitMapAttr(screen->RastPort.BitMap,BMA_HEIGHT),
111 GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH),
112 BMF_MINPLANES|BMF_DISPLAYABLE|BMF_CLEAR,
113 screen->RastPort.BitMap);
115 if (NULL == bitmap)
117 FreeDBufInfo(ScreenBuffer->sb.sb_DBufInfo);
118 FreeMem(ScreenBuffer, sizeof(struct IntScreenBuffer));
119 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: failed\n"));
121 return NULL;
126 ScreenBuffer->sb.sb_BitMap = bitmap;
128 if (flags & SB_COPY_BITMAP)
130 BltBitMap(screen->RastPort.BitMap,
133 bitmap,
136 screen->Width,
137 screen->Height,
138 0x0c0, /* copy */
140 NULL);
143 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: ScreenBuffer 0x%lx BitMap 0x%lx DBufInfo 0x%lx\n",
144 ScreenBuffer, bitmap, ScreenBuffer->sb.sb_DBufInfo));
146 return &ScreenBuffer->sb;
149 FreeMem(ScreenBuffer, sizeof(struct IntScreenBuffer));
153 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: no mem\n"));
155 return NULL;
157 AROS_LIBFUNC_EXIT
158 } /* AllocScreenBuffer */