diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-08-05 21:29:57 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-08-05 21:29:57 +0100 |
commit | 82c4ea7686747dbb202ceefd660b1a8574ed5669 (patch) | |
tree | 64245e8878928e82b72fa180b0d699bc5ee7c647 | |
parent | a423eb712dc387b879f62826fd36325110470ec8 (diff) | |
download | netsurf-82c4ea7686747dbb202ceefd660b1a8574ed5669.tar.gz netsurf-82c4ea7686747dbb202ceefd660b1a8574ed5669.tar.bz2 |
add to list, and release pens
-rwxr-xr-x | amiga/plotters.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/amiga/plotters.c b/amiga/plotters.c index ab880dbca..5825f4c41 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -54,6 +54,11 @@ struct bfbitmap { APTR mask; }; +struct ami_plot_pen { + struct MinNode node; + ULONG pen; +}; + bool palette_mapped = false; #ifndef M_PI /* For some reason we don't always get this from math.h */ @@ -228,8 +233,9 @@ void ami_clearclipreg(struct gui_globals *gg) gg->rect.MaxY = scrn->Height-1; } -ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colour) +static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colour) { + struct ami_plot_pen *node; ULONG pen = ObtainBestPenA(scrn->ViewPort.ColorMap, (colour & 0x000000ff) << 24, (colour & 0x0000ff00) << 16, @@ -237,18 +243,33 @@ ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colour) NULL); if(pen == -1) LOG(("WARNING: Cannot allocate pen for ABGR:%lx", colour)); + + if(node = (struct ami_plot_pen *)AllocVec(sizeof(struct ami_plot_pen), + MEMF_PRIVATE | MEMF_CLEAR)) { + AddTail((struct List *)shared_pens, (struct Node *)node); + } - /* TODO: add allocated pen to list */ - return pen; } void ami_plot_release_pens(struct MinList *shared_pens) { - /* TODO: trawl through list releasing pens */ + struct ami_plot_pen *node; + struct ami_plot_pen *nnode; + + if(IsMinListEmpty(shared_pens)) return; + node = (struct ami_plot_pen *)GetHead((struct List *)shared_pens); + + do + { + nnode = (struct ami_plot_pen *)GetSucc((struct Node *)node); + ReleasePen(scrn->ViewPort.ColorMap, node->pen); + Remove((struct Node *)node); + FreeVec(node); + }while(node = nnode); } -void ami_plot_setapen(ULONG colour) +static void ami_plot_setapen(ULONG colour) { if(palette_mapped == false) { SetRPAttrs(glob->rp, RPTAG_APenColor, @@ -260,7 +281,7 @@ void ami_plot_setapen(ULONG colour) } } -void ami_plot_setopen(ULONG colour) +static void ami_plot_setopen(ULONG colour) { if(palette_mapped == false) { SetRPAttrs(glob->rp, RPTAG_OPenColor, |