Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / graphics / freebitmap.c
blob732129bc9484f845c7433c7ac2985f380469af01
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Free the memory occupied by a BitMap.
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <exec/memory.h>
10 #include <proto/exec.h>
11 #include "graphics_intern.h"
12 #include "gfxfuncsupport.h"
14 /*****************************************************************************
16 NAME */
17 #include <graphics/gfx.h>
18 #include <proto/graphics.h>
20 AROS_LH1(void, FreeBitMap,
22 /* SYNOPSIS */
23 AROS_LHA(struct BitMap *, bm, A0),
25 /* LOCATION */
26 struct GfxBase *, GfxBase, 154, Graphics)
28 /* FUNCTION
29 Returns the memory occupied by the BitMap to the system.
31 INPUTS
32 bm - The result of AllocBitMap(). Must be non-NULL.
34 RESULT
35 None.
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 AllocBitMap(), AllocRaster(), FreeRaster()
46 INTERNALS
48 HISTORY
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
54 if (!bm) return;
56 ASSERT_VALID_PTR(bm);
58 if (bm->pad != 0 || (bm->Flags & BMF_AROS_HIDD))
60 if (HIDD_BM_FLAGS(bm) & HIDD_BMF_SHARED_PIXTAB)
62 /* NULL colormap otherwise bitmap killing also kills
63 the colormap object of the bitmap object
64 from which we shared it = to which it belongs */
66 HIDD_BM_SetColorMap(HIDD_BM_OBJ(bm), NULL);
68 else if (HIDD_BM_FLAGS(bm) & HIDD_BMF_SCREEN_BITMAP) // (bm->Flags & BMF_DISPLAYABLE)
70 FreeVec(HIDD_BM_PIXTAB(bm));
73 HIDD_Gfx_DisposeBitMap(SDD(GfxBase)->gfxhidd, (OOP_Object *)HIDD_BM_OBJ(bm));
75 FreeMem(bm, sizeof (struct BitMap));
77 else
79 ULONG plane;
80 ULONG width;
82 width = bm->BytesPerRow * 8;
84 for (plane=0; plane < bm->Depth; plane ++)
86 /* Take care of two special cases: plane pointers containing NULL or -1
87 * are supported by BltBitMap() as all 0's and all 1's planes
89 if (bm->Planes[plane] && bm->Planes[plane] != (PLANEPTR)-1)
91 ASSERT_VALID_PTR(bm->Planes[plane]);
92 FreeRaster (bm->Planes[plane], width, bm->Rows);
96 FreeMem (bm, sizeof(struct BitMap) +
97 ((bm->Depth > 8) ? (bm->Depth - 8) * sizeof(PLANEPTR) : 0));
100 AROS_LIBFUNC_EXIT
101 } /* FreeBitMap */