From c359b9400b720f9ee175154a1ffa542b5ccc2d97 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 5 Aug 2012 15:16:02 +0100 Subject: Palette-mapped bitmap support --- amiga/bitmap.c | 35 +++++++++++++++++++++++++++++++++-- amiga/bitmap.h | 4 ++++ amiga/plotters.c | 26 ++++++++++++++++---------- 3 files changed, 53 insertions(+), 12 deletions(-) (limited to 'amiga') diff --git a/amiga/bitmap.c b/amiga/bitmap.c index ce665aaf7..5377adf3c 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -117,7 +117,11 @@ void bitmap_destroy(void *bitmap) if(bm) { - if(bm->nativebm) p96FreeBitMap(bm->nativebm); + if((bm->nativebm) && (bm->dto == NULL)) + p96FreeBitMap(bm->nativebm); + + if(bm->dto) DisposeDTObject(bm->dto); + FreeVec(bm->pixdata); bm->pixdata = NULL; FreeVec(bm); @@ -160,8 +164,13 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags) void bitmap_modified(void *bitmap) { struct bitmap *bm = bitmap; - p96FreeBitMap(bm->nativebm); + if((bm->nativebm) && (bm->dto == NULL)) + p96FreeBitMap(bm->nativebm); + + if(bm->dto) DisposeDTObject(bm->dto); bm->nativebm = NULL; + bm->dto = NULL; + bm->native_mask = NULL; } @@ -454,3 +463,25 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s return tbm; } + +struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap, + int width, int height) +{ + struct BitMap *dtbm; + + if(bitmap->dto == NULL) + bitmap->dto = ami_datatype_object_from_bitmap(bitmap); + + SetDTAttrs(bitmap->dto, NULL, NULL, + PDTA_Screen, scrn, + TAG_DONE); + + if(DoDTMethod(bitmap->dto, 0, 0, DTM_PROCLAYOUT, 0, 1)) { + GetDTAttrs(bitmap->dto, + PDTA_DestBitMap, &dtbm, + PDTA_MaskPlane, &bitmap->native_mask, + TAG_END); + } +/* TODO: support scaling */ + return dtbm; +} diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 41d488e28..3153ee7da 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -35,12 +35,16 @@ struct bitmap { struct BitMap *nativebm; int nativebmwidth; int nativebmheight; + APTR native_mask; + Object *dto; char *url; /* temporary storage space */ char *title; /* temporary storage space */ ULONG *icondata; /* for appicons */ }; struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,struct BitMap *friendbm); +struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap, int width, int height); + Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap); struct bitmap *ami_bitmap_from_datatype(char *filename); #endif diff --git a/amiga/plotters.c b/amiga/plotters.c index 85376381d..6d0f2cde1 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -619,15 +619,19 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma (y > glob->rect.MaxY)) return true; - tbm = ami_getcachenativebm(bitmap,width,height,glob->rp->BitMap); - + if(palette_mapped == false) { + tbm = ami_getcachenativebm(bitmap, width, height, glob->rp->BitMap); + } else { + tbm = ami_bitmap_get_palettemapped(bitmap, width, height); + } + if(!tbm) return true; #ifdef AMI_PLOTTER_DEBUG LOG(("[ami_plotter] ami_bitmap() got native bitmap")); #endif - if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1) + if((GfxBase->LibNode.lib_Version >= 53) && (palette_mapped == false)) { uint32 comptype = COMPOSITE_Src; if(!bitmap->opaque) @@ -660,7 +664,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma TAG_DONE); } - if(tbm != bitmap->nativebm) + if((bitmap->dto == NULL) && (tbm != bitmap->nativebm)) { p96FreeBitMap(tbm); } @@ -676,8 +680,6 @@ bool ami_bitmap_tile(int x, int y, int width, int height, LOG(("[ami_plotter] Entered ami_bitmap_tile()")); #endif - if(palette_mapped == true) return true; - int xf,yf,xm,ym,oy,ox; struct BitMap *tbm = NULL; struct Hook *bfh = NULL; @@ -689,13 +691,17 @@ bool ami_bitmap_tile(int x, int y, int width, int height, if(!(repeat_x || repeat_y)) return ami_bitmap(x, y, width, height, bitmap); - +if(palette_mapped == true) return true; // stop trailling into tiled mode for now /* If it is a one pixel transparent image, we are wasting our time */ if((bitmap->opaque == false) && (bitmap->width == 1) && (bitmap->height == 1)) return true; - tbm = ami_getcachenativebm(bitmap,width,height,glob->rp->BitMap); - + if(palette_mapped == false) { + tbm = ami_getcachenativebm(bitmap,width,height,glob->rp->BitMap); + } else { + tbm = ami_bitmap_get_palettemapped(bitmap, width, height); + } + if(!tbm) return true; ox = x; @@ -764,7 +770,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height, if(bitmap->opaque) DeleteBackFillHook(bfh); else FreeVec(bfh); - if(tbm != bitmap->nativebm) + if((bitmap->dto == NULL) && (tbm != bitmap->nativebm)) { p96FreeBitMap(tbm); } -- cgit v1.2.3