mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-21 03:32:35 +03:00
Allocate bitmap structures using an itempool
This commit is contained in:
parent
b002ba7357
commit
e6b827979b
@ -52,13 +52,16 @@ enum {
|
||||
AMI_NSBM_PALETTEMAPPED
|
||||
};
|
||||
|
||||
APTR pool_bitmap = NULL;
|
||||
|
||||
/* exported function documented in amiga/bitmap.h */
|
||||
void *amiga_bitmap_create(int width, int height, unsigned int state)
|
||||
{
|
||||
struct bitmap *bitmap;
|
||||
|
||||
bitmap = AllocVecTagList(sizeof(struct bitmap), NULL);
|
||||
|
||||
if(pool_bitmap == NULL) pool_bitmap = ami_misc_itempool_create(sizeof(struct bitmap));
|
||||
|
||||
bitmap = ami_misc_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
|
||||
if(bitmap == NULL) return NULL;
|
||||
|
||||
bitmap->pixdata = ami_misc_allocvec_clear(width*height*4, 0xff);
|
||||
@ -128,7 +131,7 @@ void amiga_bitmap_destroy(void *bitmap)
|
||||
bm->native_mask = NULL;
|
||||
bm->dto = NULL;
|
||||
|
||||
FreeVec(bm);
|
||||
ami_misc_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
|
||||
bm = NULL;
|
||||
}
|
||||
}
|
||||
@ -557,6 +560,12 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
|
||||
}
|
||||
}
|
||||
|
||||
void ami_bitmap_fini(void)
|
||||
{
|
||||
if(pool_bitmap) ami_misc_itempool_delete(pool_bitmap);
|
||||
pool_bitmap = NULL;
|
||||
}
|
||||
|
||||
static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
|
||||
{
|
||||
struct redraw_context ctx = {
|
||||
|
@ -54,6 +54,11 @@ PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width,
|
||||
Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap);
|
||||
struct bitmap *ami_bitmap_from_datatype(char *filename);
|
||||
|
||||
/**
|
||||
* Cleanup bitmap allocations
|
||||
*/
|
||||
void ami_bitmap_fini(void);
|
||||
|
||||
/**
|
||||
* Create a bitmap.
|
||||
*
|
||||
|
@ -5681,6 +5681,7 @@ int main(int argc, char** argv)
|
||||
FreeSysObject(ASOT_PORT, schedulermsgport);
|
||||
|
||||
ami_object_fini();
|
||||
ami_bitmap_fini();
|
||||
ami_libs_close();
|
||||
|
||||
return RETURN_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user