Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / intuition / allocscreenbuffer.c
blobe9bd913f2b723b345aceca84f32720f27fcf7b41
1 /*
2 Copyright © 1995-2007, 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
84 struct IntScreenBuffer *ScreenBuffer = NULL;
86 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: Screen 0x%lx BitMap 0x%lx Flags 0x%lx\n",
87 screen, bitmap, flags));
89 if (screen)
91 if ((ScreenBuffer = AllocMem(sizeof (struct IntScreenBuffer),
92 MEMF_CLEAR)))
94 if ((ScreenBuffer->sb.sb_DBufInfo =
95 AllocDBufInfo(&screen->ViewPort)))
97 if (!bitmap)
99 /* Get a bitmap */
100 if (flags & SB_SCREEN_BITMAP)
102 bitmap = screen->RastPort.BitMap;
104 else
106 ScreenBuffer->free_bitmap = TRUE;
108 bitmap = AllocBitMap(GetBitMapAttr(screen->RastPort.BitMap,BMA_WIDTH),
109 GetBitMapAttr(screen->RastPort.BitMap,BMA_HEIGHT),
110 GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH),
111 BMF_MINPLANES|BMF_DISPLAYABLE|BMF_CLEAR,
112 screen->RastPort.BitMap);
114 if (NULL == bitmap)
116 FreeDBufInfo(ScreenBuffer->sb.sb_DBufInfo);
117 FreeMem(ScreenBuffer, sizeof(struct IntScreenBuffer));
118 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: failed\n"));
120 return NULL;
125 ScreenBuffer->sb.sb_BitMap = bitmap;
127 if (flags & SB_COPY_BITMAP)
129 BltBitMap(screen->RastPort.BitMap,
132 bitmap,
135 screen->Width,
136 screen->Height,
137 0x0c0, /* copy */
139 NULL);
142 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: ScreenBuffer 0x%lx BitMap 0x%lx DBufInfo 0x%lx\n",
143 ScreenBuffer, bitmap, ScreenBuffer->sb.sb_DBufInfo));
145 return &ScreenBuffer->sb;
148 FreeMem(ScreenBuffer, sizeof(struct IntScreenBuffer));
152 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: no mem\n"));
154 return NULL;
156 AROS_LIBFUNC_EXIT
157 } /* AllocScreenBuffer */