2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/graphics.h>
8 #include <proto/cybergraphics.h>
10 #include <cybergraphx/cybergraphics.h>
11 #include "intuition_intern.h"
12 /*****************************************************************************
15 #include <intuition/screens.h>
16 #include <proto/intuition.h>
18 AROS_LH3(struct ScreenBuffer
*, AllocScreenBuffer
,
21 AROS_LHA(struct Screen
*, screen
, A0
),
22 AROS_LHA(struct BitMap
*, bitmap
, A1
),
23 AROS_LHA(ULONG
, flags
, D0
),
26 struct IntuitionBase
*, IntuitionBase
, 128, Intuition
)
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.
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
60 Pointer to the allocated ScreenBuffer or NULL if function failed.
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.
74 FreeScreenBuffer(), ChangeScreenBuffer()
80 *****************************************************************************/
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
));
92 if ((ScreenBuffer
= AllocMem(sizeof (struct IntScreenBuffer
),
95 if ((ScreenBuffer
->sb
.sb_DBufInfo
=
96 AllocDBufInfo(&screen
->ViewPort
)))
101 if (flags
& SB_SCREEN_BITMAP
)
103 bitmap
= screen
->RastPort
.BitMap
;
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
);
117 FreeDBufInfo(ScreenBuffer
->sb
.sb_DBufInfo
);
118 FreeMem(ScreenBuffer
, sizeof(struct IntScreenBuffer
));
119 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: failed\n"));
126 ScreenBuffer
->sb
.sb_BitMap
= bitmap
;
128 if (flags
& SB_COPY_BITMAP
)
130 BltBitMap(screen
->RastPort
.BitMap
,
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"));
158 } /* AllocScreenBuffer */