23 #include <proto/exec.h> 25 #include <graphics/blitattr.h> 26 #include <graphics/composite.h> 28 #include <graphics/gfxbase.h> 29 #include <proto/datatypes.h> 30 #include <datatypes/pictureclass.h> 31 #include <proto/dos.h> 32 #include <proto/intuition.h> 33 #include <proto/utility.h> 35 #include <proto/guigfx.h> 36 #include <guigfx/guigfx.h> 37 #include <render/render.h> 39 #include <inline/guigfx.h> 43 #include <exec/extmem.h> 44 #include <sys/param.h> 64 #ifdef AMI_NS_TRIANGLE_SCALING 65 #undef AMI_NS_TRIANGLE_SCALING 98 #define VTX(I,X,Y,S,T) vtx[I].x = X; vtx[I].y = Y; vtx[I].s = S; vtx[I].t = T; vtx[I].w = 1.0f; 99 #define VTX_RECT(SX,SY,SW,SH,DX,DY,DW,DH) \ 100 VTX(0, DX, DY, SX, SY); \ 101 VTX(1, DX + DW, DY, SX + SW, SY); \ 102 VTX(2, DX, DY + DH, SX, SY + SH); \ 103 VTX(3, DX + DW, DY, SX + SW, SY); \ 104 VTX(4, DX, DY + DH, SX, SY + SH); \ 105 VTX(5, DX + DW, DY + DH, SX + SW, SY + SH); 118 if(bitmap == NULL)
return NULL;
120 bitmap->
size = width * height * 4;
126 ASOEXTMEM_Size, &size64,
127 ASOEXTMEM_AllocationPolicy, EXTMEMPOLICY_IMMEDIATE,
132 memset(pixdata, 0xff, bitmap->
size);
150 bitmap->
title = NULL;
164 "Unmapping ExtMem object %p for bitmap %p",
176 struct bitmap *bm =
bitmap;
182 "Mapping ExtMem object %p for bitmap %p",
199 struct bitmap *bm =
bitmap;
203 return ((bm->
width)*4);
215 struct bitmap *bm =
bitmap;
265 if((DoDTMethod(dto, 0, 0, DTM_PROCLAYOUT, 0, 1)) == 0) {
270 err =
SaveDTObjectA(dto, NULL, NULL, path, DTWM_IFF, FALSE, NULL);
271 DisposeDTObject(dto);
274 if(err == 0)
return false;
282 struct bitmap *bm =
bitmap;
302 struct bitmap *bm =
bitmap;
311 struct bitmap *bm =
bitmap;
320 if ((*bmi & 0x000000ffU) != 0x000000ffU)
return false;
330 struct bitmap *bm =
bitmap;
340 struct bitmap *bm =
bitmap;
357 struct bitmap *bm =
bitmap;
371 if(bm == NULL)
return;
374 for(
int i = 0; i < (bm->
width * bm->
height); i++) {
375 data[i] = (data[i] << 8) | (data[i] >> 24);
381 if(bm == NULL)
return;
384 for(
int i = 0; i < (bm->
width * bm->
height); i++) {
385 data[i] = (data[ i] >> 8) | (data[i] << 24);
395 printf(
"Width=%ld, Height=%ld, Opaque=%s\nnativebm=%lx, width=%ld, height=%ld\n",
399 for(y = 0; y < bitmap->
height; y++) {
400 for(x = 0; x < bitmap->
width; x++) {
401 printf(
"%lx ", bm[(y*bitmap->
width) + x]);
411 struct BitMapHeader *bmhd;
413 if((dto = NewDTObject(NULL,
414 DTA_SourceType,DTST_RAM,
415 DTA_GroupID,GID_PICTURE,
417 PDTA_DestMode,PMODE_V43,
420 if(GetDTAttrs(dto,PDTA_BitMapHeader,&bmhd,TAG_DONE))
424 bmhd->bmh_Depth = (UBYTE)32;
428 SetDTAttrs(dto,NULL,NULL,
430 DTA_ObjAnnotation,bitmap->
title,
434 PDTA_SourceMode,PMODE_V43,
449 struct bitmap *bm = NULL;
451 if((dto = NewDTObject(filename,
452 DTA_GroupID, GID_PICTURE,
453 PDTA_DestMode, PMODE_V43,
456 struct BitMapHeader *bmh;
458 if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE))
464 bmh->bmh_Width, bmh->bmh_Height);
468 DisposeDTObject(dto);
477 struct BitMap *restrict tbm = NULL;
497 if(tbm == NULL)
return NULL;
505 if(tbm == NULL)
return NULL;
507 if(GuiGFXBase != NULL) {
511 ULONG dithermode = DITHERMODE_NONE;
514 dithermode = DITHERMODE_EDD;
516 dithermode = DITHERMODE_FS;
523 scrn->ViewPort.ColorMap,
524 GGFX_DitherMode, dithermode,
527 APTR ddh = CreateDirectDrawHandle(bitmap->
drawhandle,
529 width, height, NULL);
532 DeleteDirectDrawHandle(ddh);
564 if((bitmap->
width != width) || (bitmap->
height != height)) {
565 struct BitMap *restrict scaledbm;
566 struct BitScaleArgs bsa;
573 if(__builtin_expect(((GfxBase->LibNode.lib_Version >= 53) &&
579 uint32 err = COMPERR_Success;
580 #ifdef AMI_NS_TRIANGLE_SCALING 584 flags = COMPFLAG_HardwareOnly;
585 if(
nsoption_bool(scale_quality) ==
true) flags |= COMPFLAG_SrcFilter;
587 err = CompositeTags(COMPOSITE_Src, tbm, scaledbm,
588 COMPTAG_VertexArray, vtx,
589 COMPTAG_VertexFormat, COMPVF_STW0_Present,
590 COMPTAG_NumTriangles, 2,
591 COMPTAG_Flags, flags,
592 COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
595 if (err != COMPERR_Success) {
597 "Composite error %ld - falling back",
606 if(
nsoption_bool(scale_quality) ==
true) flags |= COMPFLAG_SrcFilter;
608 err = CompositeTags(COMPOSITE_Src, tbm, scaledbm,
609 COMPTAG_ScaleX, COMP_FLOAT_TO_FIX((
float)width/bitmap->
width),
610 COMPTAG_ScaleY, COMP_FLOAT_TO_FIX((
float)height/bitmap->
height),
611 COMPTAG_Flags, flags,
612 COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
616 "Fallback returned error %ld", err);
623 bsa.bsa_SrcWidth = bitmap->
width;
624 bsa.bsa_SrcHeight = bitmap->
height;
627 bsa.bsa_XSrcFactor = bitmap->
width;
628 bsa.bsa_XDestFactor =
width;
629 bsa.bsa_YSrcFactor = bitmap->
height;
630 bsa.bsa_YDestFactor =
height;
631 bsa.bsa_SrcBitMap = tbm;
632 bsa.bsa_DestBitMap = scaledbm;
658 int width,
int height,
struct BitMap *friendbm)
668 int height,
struct BitMap *n_bm)
675 if((height != bitmap->
height) || (width != bitmap->
width))
return NULL;
679 bm_width = GetBitMapAttr(n_bm, BMA_WIDTH);
680 bpr = RASSIZE(bm_width, 1);
681 bitmap->
native_mask = AllocRaster(bm_width, height);
685 for(x=0; x<
width; x++) {
686 if ((*bmi & 0x000000ffU) <= (ULONG)
nsoption_int(mask_alpha)) maskbit = 0;
690 maskbit << (7 - (x % 8));
698 int width,
int height,
struct BitMap *friendbm)
708 int width,
int height,
bool palette_mapped,
struct BitMap *friendbm)
710 if(bitmap == NULL)
return NULL;
712 if(__builtin_expect(palette_mapped ==
true, 0)) {
728 NSLOG(netsurf, INFO,
"Entering bitmap_render");
735 plot_height = ((plot_width * bitmap->
height) + (bitmap->
width / 2)) /
743 .background_images =
true,
750 BltBitMapTags( BLITA_SrcX, 0,
752 BLITA_Width, bitmap->
width,
753 BLITA_Height, bitmap->
height,
755 BLITA_SrcType, BLITT_BITMAP,
757 BLITA_DestType, BLITT_ARGB32,
758 BLITA_DestBytesPerRow, 4 * bitmap->
width,
771 #warning FIXME for OS3 (in current state none of bitmap_render can work!) 779 if(bm->
url != NULL)
return;
785 if(bm->
title != NULL)
return;
786 bm->
title = strdup(title);
802 if(bm->
nativebm == nbm)
return true;
bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags)
Save a bitmap in the platform's native format.
struct gui_globals * ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
Alloc a plotter render area.
void * amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
int bitmap_get_height(void *bitmap)
get height of a bitmap.
void ami_clearclipreg(struct gui_globals *gg)
struct BitMap * ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, bool palette_mapped, struct BitMap *friendbm)
#define AllocSysObjectTags(A, B, C, D)
static bool guigfx_warned
Interface to utility string handling.
Localised message support (interface).
Public content interface.
Abstract RTG functions for newer/older/non-P96 systems.
void amiga_bitmap_set_opaque(void *bitmap, bool opaque)
Sets whether a bitmap should be plotted opaque.
PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height, struct BitMap *n_bm)
void * ami_memory_clear_alloc(size_t size, UBYTE value)
static struct gui_bitmap_table bitmap_table
#define SaveDTObjectA(O, W, R, F, M, I, A)
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
static struct Screen * scrn
struct gui_bitmap_table * amiga_bitmap_table
void ami_bitmap_free_icondata(struct bitmap *bm)
Free an icondata pointer.
static void amiga_bitmap_unmap_buffer(void *p)
static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
#define ami_memory_itempool_create(s)
#define nsoption_int(OPTION)
Get the value of an integer option.
bool interactive
Redraw to show interactive features.
Option reading and saving interface.
#define VTX_RECT(SX, SY, SW, SH, DX, DY, DW, DH)
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
nserror
Enumeration of error codes.
void amiga_bitmap_destroy(void *bitmap)
Free a bitmap.
int height
height of bitmap
void ami_plot_ra_free(struct gui_globals *gg)
Free a plotter render area.
bool amiga_bitmap_test_opaque(void *bitmap)
Tests whether a bitmap has an opaque alpha channel.
static struct BitMap * ami_bitmap_get_truecolour(struct bitmap *bitmap, int width, int height, struct BitMap *friendbm)
Content which corresponds to a single URL.
struct BitMap * ami_plot_ra_get_bitmap(struct gui_globals *gg)
Get a drawing BitMap associated with a render area.
static struct BitMap * ami_bitmap_get_palettemapped(struct bitmap *bitmap, int width, int height, struct BitMap *friendbm)
#define NSLOG(catname, level, logmsg, args...)
Object * ami_datatype_object_from_bitmap(struct bitmap *bitmap)
static void ami_bitmap_argb_to_rgba(struct bitmap *bm)
struct BitMap * ami_rtg_allocbitmap(ULONG width, ULONG height, ULONG depth, ULONG flags, struct BitMap *friend, RGBFTYPE format)
RISC OS wimp toolkit bitmap.
void amiga_bitmap_modified(void *bitmap)
The bitmap image has changed, so flush any persistant cache.
#define AMI_BITMAP_SCALE_ICON
void ami_rtg_writepixelarray(UBYTE *pixdata, struct BitMap *bm, ULONG width, ULONG height, ULONG bpr, ULONG format)
size_t amiga_bitmap_get_rowstride(void *bitmap)
Find the width of a pixel row in bytes.
gui_bitmap_flags
Bitmap creation flags.
bool amiga_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
const struct plotter_table amiplot
bool opaque
Whether the bitmap is opaque.
nserror amiga_warn_user(const char *warning, const char *detail)
Warn the user of an event.
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
Set an icondata pointer.
static void ami_bitmap_rgba_to_argb(struct bitmap *bm)
struct bitmap * ami_bitmap_from_datatype(char *filename)
unsigned char * amiga_bitmap_get_buffer(void *bitmap)
Return a pointer to the pixel data in a bitmap.
bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm)
Test if a BitMap is owned by a bitmap.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
struct ExtMemIFace * iextmem
nserror ami_schedule(int t, void(*callback)(void *p), void *p)
Schedule a callback.
int content_get_width(struct hlcache_handle *h)
Retrieve width of content.
Generic bitmap handling interface.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
#define ami_memory_itempool_alloc(p, s)
int bitmap_get_width(void *bitmap)
get width of a bitmap.
#define ami_memory_itempool_delete(p)
#define AMI_BITMAP_FORMAT
static struct BitMap * ami_bitmap_get_generic(struct bitmap *bitmap, int width, int height, struct BitMap *restrict friendbm, int type)
#define ami_memory_clear_free(p)
bool content_scaled_redraw(struct hlcache_handle *h, int width, int height, const struct redraw_context *ctx)
Redraw a content with scale set for horizontal fit.
static bool palette_mapped
void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url)
Set bitmap URL.
void ami_bitmap_fini(void)
Cleanup bitmap allocations.
Minimal compatibility header for AmigaOS 3.
NetSurf URL handling (interface).
struct nsurl nsurl
NetSurf URL object.
void ami_rtg_freebitmap(struct BitMap *bm)
#define ami_memory_itempool_free(p, i, s)
#define nsoption_bool(OPTION)
Get the value of a boolean option.
void FreeSysObject(ULONG type, APTR obj)
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
void *(* create)(int width, int height, enum gui_bitmap_flags flags)
Create a new bitmap.
void ami_bitmap_set_title(struct bitmap *bm, const char *title)
Set bitmap title.