revert between 56095 -> 55830 in arch
[AROS.git] / workbench / classes / zune / texteditor / mcc / AllocBitMap.c
blobadb0e9fa67ca13fe891f196e6e5fdb1c79e2cf20
1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2014 TextEditor.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 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
19 $Id$
21 ***************************************************************************/
23 #include <exec/memory.h>
24 #include <proto/graphics.h>
25 #include <proto/exec.h>
27 #include "SDI_compiler.h"
29 #include "private.h"
30 #include "Debug.h"
32 #if 0
33 #define USE_OS3 (1)
34 #else
35 #define USE_OS3 (((struct Library *)GfxBase)->lib_Version >= 39)
36 #endif
38 /// MUIG_AllocBitMap()
39 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))
41 struct BitMap *bm = NULL;
43 ENTER();
45 #if defined(__amigaos4__)
46 bm = AllocBitMap(width,height,depth,flags,friend);
47 #elif defined(__MORPHOS__) || defined(__AROS__)
48 bm = AllocBitMap(width,height,depth,flags | BMF_MINPLANES | BMF_DISPLAYABLE, friend);
49 #else
50 if(USE_OS3)
52 if(friend != NULL)
54 // FindSemaphore() must be called in Forbid()den state
55 Forbid();
56 if(FindSemaphore((char *)"cybergraphics.library") != NULL &&
57 (GetBitMapAttr(friend,BMA_FLAGS) & BMF_INTERLEAVED) == 0)
58 flags |= BMF_MINPLANES;
59 else
60 friend = NULL;
61 Permit();
64 bm = AllocBitMap(width,height,depth,flags,friend);
66 else
68 if((bm = (struct BitMap *)AllocVec(sizeof(*bm), MEMF_CLEAR)) != NULL)
70 int i, plsize=RASSIZE(width,height);
72 InitBitMap(bm,depth,width,height);
74 if((bm->Planes[0] = AllocVec(plsize*depth,(flags & BMF_CLEAR) ? MEMF_CHIP|MEMF_CLEAR : MEMF_CHIP))) // !!!
76 for(i=1;i<depth;i++)
77 bm->Planes[i] = (PLANEPTR)(((ULONG)bm->Planes[i-1]) + plsize);
79 else
81 FreeVec(bm);
82 bm = NULL;
86 #endif
88 RETURN(bm);
89 return bm;
92 ///
93 /// MUIG_FreeBitMap()
94 void SAVEDS ASM MUIG_FreeBitMap(REG(a0, struct BitMap *bm))
96 ENTER();
98 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
99 FreeBitMap(bm);
100 #else
101 WaitBlit(); /* OCS/AGA need this before FreeBitMap() call */
103 if(USE_OS3)
105 FreeBitMap(bm);
107 else
109 FreeVec(bm->Planes[0]);
110 FreeVec(bm);
112 #endif
114 LEAVE();