From a61d0fa7531a895bbd1f631c9714d58517dd5de3 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Wed, 25 Feb 2009 00:26:46 +0000 Subject: The native bitmap caching was eating memory, this should be correct now. svn path=/trunk/netsurf/; revision=6616 --- amiga/plotters.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'amiga/plotters.c') diff --git a/amiga/plotters.c b/amiga/plotters.c index afb2948be..1f1ed04d2 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -32,6 +32,7 @@ #include #include "utils/log.h" #include +#include #ifndef M_PI /* For some reason we don't always get this from math.h */ #define M_PI 3.14159265358979323846 @@ -548,8 +549,9 @@ bool ami_bitmap_tile(int x, int y, int width, int height, struct RenderInfo ri; ULONG xf,yf,wf,hf; int max_width,max_height; - struct BitMap *tbm; + struct BitMap *tbm = NULL; struct RastPort trp; + bool gotscaledbm = false; /* SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg), @@ -561,18 +563,23 @@ bool ami_bitmap_tile(int x, int y, int width, int height, if(bitmap->nativebm) { - if((bitmap->nativebmwidth != width) || (bitmap->nativebmheight != height)) + if((bitmap->nativebmwidth == width) && (bitmap->nativebmheight==height)) { - p96FreeBitMap(bitmap->nativebm); - bitmap->nativebm = NULL; + tbm = bitmap->nativebm; + gotscaledbm = true; } - else + else if((bitmap->nativebmwidth == bitmap->width) && (bitmap->nativebmheight==bitmap->height)) { tbm = bitmap->nativebm; } + else + { + if(bitmap->nativebm) p96FreeBitMap(bitmap->nativebm); + bitmap->nativebm = NULL; + } } - if(!bitmap->nativebm) + if(!tbm && !gotscaledbm) { ri.Memory = bitmap->pixdata; ri.BytesPerRow = bitmap->width * 4; @@ -583,7 +590,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height, trp.BitMap = tbm; p96WritePixelArray((struct RenderInfo *)&ri,0,0,&trp,0,0,bitmap->width,bitmap->height); - if((option_cache_bitmaps == 2) && (bitmap->height == height && bitmap->width == width)) + if(option_cache_bitmaps == 2) { bitmap->nativebm = tbm; bitmap->nativebmwidth = bitmap->width; @@ -591,13 +598,9 @@ bool ami_bitmap_tile(int x, int y, int width, int height, } } - if((bitmap->nativebm) && (bitmap->nativebmwidth == width) && (bitmap->nativebmheight==height)) - { - tbm = bitmap->nativebm; - } - else + if((bitmap->width != width) || (bitmap->height != height)) { - if((bitmap->width != width) || (bitmap->height != height)) + if(!gotscaledbm) { struct BitMap *scaledbm; struct BitScaleArgs bsa; @@ -641,8 +644,10 @@ bool ami_bitmap_tile(int x, int y, int width, int height, BitMapScale(&bsa); } + if(bitmap->nativebm != tbm) p96FreeBitMap(bitmap->nativebm); p96FreeBitMap(tbm); tbm = scaledbm; + bitmap->nativebm = NULL; if(option_cache_bitmaps >= 1) { @@ -667,6 +672,8 @@ bool ami_bitmap_tile(int x, int y, int width, int height, for (xf = x; xf < glob.rect.MaxX; xf += width) { for (yf = y; yf < glob.rect.MaxY; yf += height) { + assert(tbm); + BltBitMapTags(BLITA_Width,width, BLITA_Height,height, BLITA_Source,tbm, -- cgit v1.2.3