summaryrefslogtreecommitdiff
path: root/amiga/plotters.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-01-24 00:00:27 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2016-01-24 00:00:27 +0000
commit452d8ce5127f60f0d54a504f6fb9fba1846f058f (patch)
tree134ed13941ba466dff190a7ea6cef027a5992eb8 /amiga/plotters.c
parent9c57ddf0b2db90b989fd06b1be0c4d692e071d7f (diff)
downloadnetsurf-452d8ce5127f60f0d54a504f6fb9fba1846f058f.tar.gz
netsurf-452d8ce5127f60f0d54a504f6fb9fba1846f058f.tar.bz2
Use itempools for storing our pen locks
Diffstat (limited to 'amiga/plotters.c')
-rw-r--r--amiga/plotters.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/amiga/plotters.c b/amiga/plotters.c
index d241dd408..95c285c60 100644
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -70,7 +70,9 @@ struct bez_point {
float y;
};
-bool palette_mapped = false;
+static bool palette_mapped = false;
+static int init_layers_count = 0;
+static APTR pool_pens = NULL;
#ifndef M_PI /* For some reason we don't always get this from math.h */
#define M_PI 3.14159265358979323846
@@ -181,10 +183,23 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
if((!gg->tmprasbuf) || (!gg->rp->TmpRas)) warn_user("NoMemory","");
InitTmpRas(gg->rp->TmpRas, gg->tmprasbuf, width*height);
+
+ if((palette_mapped == true) && (pool_pens == NULL)) {
+ pool_pens = ami_misc_itempool_create(sizeof(struct ami_plot_pen));
+ }
+
+ init_layers_count++;
}
void ami_free_layers(struct gui_globals *gg)
{
+ init_layers_count--;
+
+ if((init_layers_count == 0) && (pool_pens != NULL)) {
+ ami_misc_itempool_delete(pool_pens);
+ pool_pens = NULL;
+ }
+
if(gg->rp) {
DeleteLayer(0,gg->rp->Layer);
FreeVec(gg->rp->TmpRas);
@@ -226,8 +241,8 @@ static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr)
if(pen == -1) LOG("WARNING: Cannot allocate pen for ABGR:%lx", colr);
- if(shared_pens != NULL) {
- if((node = (struct ami_plot_pen *)AllocVecTagList(sizeof(struct ami_plot_pen), NULL))) {
+ if((shared_pens != NULL) && (pool_pens != NULL)) {
+ if((node = (struct ami_plot_pen *)ami_misc_itempool_alloc(pool_pens, sizeof(struct ami_plot_pen)))) {
node->pen = pen;
AddTail((struct List *)shared_pens, (struct Node *)node);
}
@@ -251,7 +266,7 @@ void ami_plot_release_pens(struct MinList *shared_pens)
nnode = (struct ami_plot_pen *)GetSucc((struct Node *)node);
ReleasePen(scrn->ViewPort.ColorMap, node->pen);
Remove((struct Node *)node);
- FreeVec(node);
+ ami_misc_itempool_free(pool_pens, node, sizeof(struct ami_plot_pen));
} while((node = nnode));
}