Support new libnsgif by adding bitmap flag BITMAP_ABGR.
This tells big endian systems that the data is in ABGR instead of RGBA. It should be ignored on little endian systems! Add support in Amiga platform code. -> All platform code that could be compiled for big endian systems will need to be updated to recognise BITMAP_ABGR. This includes GTK and Framebuffer frontends. Both BITMAP_ABGR *and* the endianness of the host will most likely need to be checked and the allocated bitmap format and/or bitmap plotter changed to handle ABGR component order. svn path=/trunk/netsurf/; revision=9108
This commit is contained in:
parent
3cbbdeb91c
commit
d197e03bf2
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2008,2009 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/
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||||
*
|
*
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include <proto/dos.h>
|
#include <proto/dos.h>
|
||||||
#include <proto/intuition.h>
|
#include <proto/intuition.h>
|
||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
|
#include <graphics/blitattr.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a bitmap.
|
* Create a bitmap.
|
||||||
|
@ -53,6 +54,9 @@ void *bitmap_create(int width, int height, unsigned int state)
|
||||||
bitmap->height = height;
|
bitmap->height = height;
|
||||||
if(state & BITMAP_OPAQUE) bitmap->opaque = true;
|
if(state & BITMAP_OPAQUE) bitmap->opaque = true;
|
||||||
else bitmap->opaque = false;
|
else bitmap->opaque = false;
|
||||||
|
|
||||||
|
if(state & BITMAP_ABGR) bitmap->format = RGBFB_A8B8G8R8;
|
||||||
|
else bitmap->format = RGBFB_R8G8B8A8;
|
||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
@ -294,10 +298,46 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
|
||||||
PDTA_SourceMode,PMODE_V43,
|
PDTA_SourceMode,PMODE_V43,
|
||||||
TAG_DONE);
|
TAG_DONE);
|
||||||
|
|
||||||
|
if(bitmap->format == RGBFB_A8B8G8R8)
|
||||||
|
{
|
||||||
|
struct RenderInfo ri;
|
||||||
|
struct RastPort trp;
|
||||||
|
UBYTE *argb_pixarray = AllocVec(bmhd->bmh_Width * bmhd->bmh_Height *
|
||||||
|
bitmap_get_bpp(bitmap), MEMF_CLEAR);
|
||||||
|
struct BitMap *tbm = ami_getcachenativebm(bitmap, bmhd->bmh_Width,
|
||||||
|
bmhd->bmh_Height, NULL);
|
||||||
|
|
||||||
|
if(argb_pixarray)
|
||||||
|
{
|
||||||
|
ri.Memory = argb_pixarray;
|
||||||
|
ri.BytesPerRow = bitmap_get_rowstride(bitmap);
|
||||||
|
ri.RGBFormat = RGBFB_A8R8G8B8;
|
||||||
|
|
||||||
|
InitRastPort(&trp);
|
||||||
|
trp.BitMap = tbm;
|
||||||
|
|
||||||
|
p96ReadPixelArray((struct RenderInfo *)&ri, 0, 0, &trp, 0, 0,
|
||||||
|
bmhd->bmh_Width, bmhd->bmh_Height);
|
||||||
|
|
||||||
|
if(tbm != bitmap->nativebm)
|
||||||
|
{
|
||||||
|
p96FreeBitMap(tbm);
|
||||||
|
}
|
||||||
|
|
||||||
|
IDoMethod(dto,PDTM_WRITEPIXELARRAY,argb_pixarray,
|
||||||
|
PBPAFMT_ARGB,bitmap_get_rowstride(bitmap),0,0,
|
||||||
|
bitmap_get_width(bitmap),bitmap_get_height(bitmap));
|
||||||
|
|
||||||
|
FreeVec(argb_pixarray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
IDoMethod(dto,PDTM_WRITEPIXELARRAY,bitmap_get_buffer(bitmap),
|
IDoMethod(dto,PDTM_WRITEPIXELARRAY,bitmap_get_buffer(bitmap),
|
||||||
PBPAFMT_RGBA,bitmap_get_rowstride(bitmap),0,0,
|
PBPAFMT_RGBA,bitmap_get_rowstride(bitmap),0,0,
|
||||||
bitmap_get_width(bitmap),bitmap_get_height(bitmap));
|
bitmap_get_width(bitmap),bitmap_get_height(bitmap));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
@ -332,13 +372,15 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s
|
||||||
{
|
{
|
||||||
ri.Memory = bitmap->pixdata;
|
ri.Memory = bitmap->pixdata;
|
||||||
ri.BytesPerRow = bitmap->width * 4;
|
ri.BytesPerRow = bitmap->width * 4;
|
||||||
ri.RGBFormat = RGBFB_R8G8B8A8;
|
ri.RGBFormat = bitmap->format;
|
||||||
|
|
||||||
if(tbm = p96AllocBitMap(bitmap->width,bitmap->height,32,0,friendbm,RGBFB_R8G8B8A8))
|
if(tbm = p96AllocBitMap(bitmap->width, bitmap->height, 32, 0,
|
||||||
|
friendbm, bitmap->format))
|
||||||
{
|
{
|
||||||
InitRastPort(&trp);
|
InitRastPort(&trp);
|
||||||
trp.BitMap = tbm;
|
trp.BitMap = tbm;
|
||||||
p96WritePixelArray((struct RenderInfo *)&ri,0,0,&trp,0,0,bitmap->width,bitmap->height);
|
p96WritePixelArray((struct RenderInfo *)&ri, 0, 0, &trp, 0, 0,
|
||||||
|
bitmap->width, bitmap->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(option_cache_bitmaps == 2)
|
if(option_cache_bitmaps == 2)
|
||||||
|
@ -354,7 +396,8 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s
|
||||||
struct BitMap *scaledbm;
|
struct BitMap *scaledbm;
|
||||||
struct BitScaleArgs bsa;
|
struct BitScaleArgs bsa;
|
||||||
|
|
||||||
scaledbm = p96AllocBitMap(width,height,32,BMF_DISPLAYABLE,friendbm,RGBFB_R8G8B8A8);
|
scaledbm = p96AllocBitMap(width, height, 32, BMF_DISPLAYABLE,
|
||||||
|
friendbm, bitmap->format);
|
||||||
|
|
||||||
if(GfxBase->lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
|
if(GfxBase->lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <exec/types.h>
|
#include <exec/types.h>
|
||||||
#include <proto/graphics.h>
|
#include <proto/graphics.h>
|
||||||
#include <intuition/classusr.h>
|
#include <intuition/classusr.h>
|
||||||
|
#include <libraries/Picasso96.h>
|
||||||
|
|
||||||
struct bitmap {
|
struct bitmap {
|
||||||
int width;
|
int width;
|
||||||
|
@ -30,6 +31,7 @@ struct bitmap {
|
||||||
struct BitMap *nativebm;
|
struct BitMap *nativebm;
|
||||||
int nativebmwidth;
|
int nativebmwidth;
|
||||||
int nativebmheight;
|
int nativebmheight;
|
||||||
|
RGBFTYPE format;
|
||||||
char *url; /* temporary storage space */
|
char *url; /* temporary storage space */
|
||||||
char *title; /* temporary storage space */
|
char *title; /* temporary storage space */
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,11 @@
|
||||||
#define BITMAP_CLEAR_MEMORY (1 << 3) /** memory should be wiped */
|
#define BITMAP_CLEAR_MEMORY (1 << 3) /** memory should be wiped */
|
||||||
#define BITMAP_SUSPENDED (1 << 4) /** currently suspended */
|
#define BITMAP_SUSPENDED (1 << 4) /** currently suspended */
|
||||||
#define BITMAP_READY (1 << 5) /** fully initialised */
|
#define BITMAP_READY (1 << 5) /** fully initialised */
|
||||||
|
#define BITMAP_ABGR (1 << 6) /** This bitmap is in ABGR format on
|
||||||
|
big-endian platforms (if not set,
|
||||||
|
bitmap is RGBA). This flag has
|
||||||
|
no relevance on LE platforms,
|
||||||
|
where data is always ABGR */
|
||||||
|
|
||||||
#define BITMAP_SAVE_FULL_ALPHA (1 << 0) /** save with full alpha channel (if not opaque) */
|
#define BITMAP_SAVE_FULL_ALPHA (1 << 0) /** save with full alpha channel (if not opaque) */
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ void nsgif_animate(void *p)
|
||||||
*/
|
*/
|
||||||
void *nsgif_bitmap_create(int width, int height)
|
void *nsgif_bitmap_create(int width, int height)
|
||||||
{
|
{
|
||||||
return bitmap_create(width, height, BITMAP_NEW);
|
return bitmap_create(width, height, BITMAP_NEW | BITMAP_ABGR);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue