2 Copyright © 1995-2007, 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 *****************************************************************************/
84 struct IntScreenBuffer
*ScreenBuffer
= NULL
;
86 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: Screen 0x%lx BitMap 0x%lx Flags 0x%lx\n",
87 screen
, bitmap
, flags
));
91 if ((ScreenBuffer
= AllocMem(sizeof (struct IntScreenBuffer
),
94 if ((ScreenBuffer
->sb
.sb_DBufInfo
=
95 AllocDBufInfo(&screen
->ViewPort
)))
100 if (flags
& SB_SCREEN_BITMAP
)
102 bitmap
= screen
->RastPort
.BitMap
;
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
);
116 FreeDBufInfo(ScreenBuffer
->sb
.sb_DBufInfo
);
117 FreeMem(ScreenBuffer
, sizeof(struct IntScreenBuffer
));
118 DEBUG_ALLOCSCREENBUFFER(dprintf("AllocScreenBuffer: failed\n"));
125 ScreenBuffer
->sb
.sb_BitMap
= bitmap
;
127 if (flags
& SB_COPY_BITMAP
)
129 BltBitMap(screen
->RastPort
.BitMap
,
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"));
157 } /* AllocScreenBuffer */