MUI/BetterString: Move SDI*.h headers to include/SDI/SDI_*.h
[AROS.git] / workbench / classes / zune / betterstring / mcc / AllocBitMap.c
blobfa2c1f605caf690ce1d8d1fa29e7884d5a94bd97
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2009 by BetterString.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
19 $Id$
21 ***************************************************************************/
23 #include <exec/memory.h>
24 #include <exec/libraries.h>
25 #include <proto/graphics.h>
26 #include <proto/exec.h>
28 #include <SDI/SDI_compiler.h>
30 #if 0
31 #define USE_OS3 (1)
32 #else
33 #define USE_OS3 (((struct Library *)GfxBase)->lib_Version >= 39)
34 #endif
36 struct BitMap * SAVEDS ASM MUIG_AllocBitMap(REG(d0, LONG width), REG(d1, LONG height), REG(d2, LONG depth), REG(d3, LONG flags), REG(a0, struct BitMap *friend))
38 #if defined(__amigaos4__)
39 return AllocBitMap(width,height,depth,flags,friend);
40 #elif defined(__MORPHOS__) || defined(__AROS__)
41 // FIXME: check if this is correct for AROS
42 return AllocBitMap(width,height,depth,flags|BMF_MINPLANES|BMF_DISPLAYABLE,friend);
43 #else
44 if(USE_OS3)
46 if(friend != NULL)
48 // FindSemaphore() must be called in Forbid()den state
49 Forbid();
50 if(FindSemaphore((STRPTR)"cybergraphics.library") != NULL
51 && (GetBitMapAttr(friend,BMA_FLAGS) & BMF_INTERLEAVED) == 0)
52 flags |= BMF_MINPLANES;
53 else
54 friend = NULL;
55 Permit();
58 return AllocBitMap(width,height,depth,flags,friend);
60 else
62 struct BitMap *bm = AllocMem(sizeof(struct BitMap), MEMF_CLEAR);
64 if(bm != NULL)
66 int i, plsize=RASSIZE(width,height);
68 InitBitMap(bm,depth,width,height);
70 if((bm->Planes[0] = AllocVec(plsize*depth,(flags & BMF_CLEAR) ? MEMF_CHIP|MEMF_CLEAR : MEMF_CHIP))) // !!!
72 for(i=1;i<depth;i++)
73 bm->Planes[i] = (PLANEPTR)(((ULONG)bm->Planes[i-1]) + plsize);
75 return bm;
77 else
79 FreeMem(bm,sizeof(struct BitMap));
83 return NULL;
85 #endif
89 VOID SAVEDS ASM MUIG_FreeBitMap(REG(a0, struct BitMap *bm))
91 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
92 FreeBitMap(bm);
93 #else
94 WaitBlit(); /* OCS/AGA require manual synchronisation */
96 if(USE_OS3)
98 FreeBitMap(bm);
100 else
102 FreeVec(bm->Planes[0]);
103 FreeMem(bm,sizeof(struct BitMap));
105 #endif