summaryrefslogtreecommitdiff
path: root/amiga/bitmap.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2009-02-25 19:56:04 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2009-02-25 19:56:04 +0000
commit781405d1952d9efe3a379e55c0384b7460e0f3a2 (patch)
tree4de2ade970cf219af922129e591438d06281b892 /amiga/bitmap.c
parenta604021839ddbd0da3314cc36c93589f2f3ebd24 (diff)
downloadnetsurf-781405d1952d9efe3a379e55c0384b7460e0f3a2.tar.gz
netsurf-781405d1952d9efe3a379e55c0384b7460e0f3a2.tar.bz2
Move native bitmap creation/caching routine into bitmap.c
svn path=/trunk/netsurf/; revision=6619
Diffstat (limited to 'amiga/bitmap.c')
-rw-r--r--amiga/bitmap.c107
1 files changed, 106 insertions, 1 deletions
diff --git a/amiga/bitmap.c b/amiga/bitmap.c
index 271f4af1b..47c2b424a 100644
--- a/amiga/bitmap.c
+++ b/amiga/bitmap.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -21,6 +21,8 @@
#include "amiga/bitmap.h"
#include <proto/exec.h>
#include <proto/picasso96api.h>
+#include <graphics/composite.h>
+#include "amiga/options.h"
/**
* Create a bitmap.
@@ -243,3 +245,106 @@ size_t bitmap_get_bpp(void *vbitmap)
assert(bitmap);
return 4;
}
+
+struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,struct BitMap *friendbm)
+{
+ struct RenderInfo ri;
+ struct BitMap *tbm = NULL;
+ struct RastPort trp;
+
+ if(bitmap->nativebm)
+ {
+ if((bitmap->nativebmwidth == width) && (bitmap->nativebmheight==height))
+ {
+ tbm = bitmap->nativebm;
+ return tbm;
+ }
+ else if((bitmap->nativebmwidth == bitmap->width) && (bitmap->nativebmheight==bitmap->height))
+ {
+ tbm = bitmap->nativebm;
+ }
+ else
+ {
+ if(bitmap->nativebm) p96FreeBitMap(bitmap->nativebm);
+ bitmap->nativebm = NULL;
+ }
+ }
+
+ if(!tbm)
+ {
+ ri.Memory = bitmap->pixdata;
+ ri.BytesPerRow = bitmap->width * 4;
+ ri.RGBFormat = RGBFB_R8G8B8A8;
+
+ tbm = p96AllocBitMap(bitmap->width,bitmap->height,32,0,friendbm,RGBFB_R8G8B8A8);
+ InitRastPort(&trp);
+ trp.BitMap = tbm;
+ p96WritePixelArray((struct RenderInfo *)&ri,0,0,&trp,0,0,bitmap->width,bitmap->height);
+
+ if(option_cache_bitmaps == 2)
+ {
+ bitmap->nativebm = tbm;
+ bitmap->nativebmwidth = bitmap->width;
+ bitmap->nativebmheight = bitmap->height;
+ }
+ }
+
+ if((bitmap->width != width) || (bitmap->height != height))
+ {
+ struct BitMap *scaledbm;
+ struct BitScaleArgs bsa;
+
+ scaledbm = p96AllocBitMap(width,height,32,BMF_DISPLAYABLE,friendbm,RGBFB_R8G8B8A8);
+
+ if(GfxBase->lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
+ {
+ CompositeTags(COMPOSITE_Src,tbm,scaledbm,
+ COMPTAG_ScaleX,COMP_FLOAT_TO_FIX(width/bitmap->width),
+ COMPTAG_ScaleY,COMP_FLOAT_TO_FIX(height/bitmap->height),
+ COMPTAG_Flags,COMPFLAG_IgnoreDestAlpha,
+ COMPTAG_DestX,0,
+ COMPTAG_DestY,0,
+ COMPTAG_DestWidth,width,
+ COMPTAG_DestHeight,height,
+ COMPTAG_OffsetX,0,
+ COMPTAG_OffsetY,0,
+ COMPTAG_FriendBitMap,friendbm,
+ TAG_DONE);
+ }
+ else /* do it the old-fashioned way. This is pretty slow, but probably
+ uses Composite() on OS4.1 anyway, so we're only saving a blit really. */
+ {
+ bsa.bsa_SrcX = 0;
+ bsa.bsa_SrcY = 0;
+ bsa.bsa_SrcWidth = bitmap->width;
+ bsa.bsa_SrcHeight = bitmap->height;
+ bsa.bsa_DestX = 0;
+ bsa.bsa_DestY = 0;
+// bsa.bsa_DestWidth = width;
+// bsa.bsa_DestHeight = height;
+ bsa.bsa_XSrcFactor = bitmap->width;
+ bsa.bsa_XDestFactor = width;
+ bsa.bsa_YSrcFactor = bitmap->height;
+ bsa.bsa_YDestFactor = height;
+ bsa.bsa_SrcBitMap = tbm;
+ bsa.bsa_DestBitMap = scaledbm;
+ bsa.bsa_Flags = 0;
+
+ BitMapScale(&bsa);
+ }
+
+ if(bitmap->nativebm != tbm) p96FreeBitMap(bitmap->nativebm);
+ p96FreeBitMap(tbm);
+ tbm = scaledbm;
+ bitmap->nativebm = NULL;
+
+ if(option_cache_bitmaps >= 1)
+ {
+ bitmap->nativebm = tbm;
+ bitmap->nativebmwidth = width;
+ bitmap->nativebmheight = height;
+ }
+ }
+
+ return tbm;
+}