mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 00:40:15 +03:00
Palette-mapped bitmap support
This commit is contained in:
parent
a46c5ae09f
commit
c359b9400b
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user