summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontends/amiga/bitmap.c76
-rwxr-xr-xfrontends/amiga/dist/NetSurf.guide2
-rw-r--r--frontends/amiga/gui.c7
-rw-r--r--frontends/amiga/options.h5
4 files changed, 81 insertions, 9 deletions
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index c6e23b241..5b5d6bb1e 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -40,6 +40,7 @@
#endif
#ifdef __amigaos4__
+#include <exec/extmem.h>
#include <sys/param.h>
#endif
#include "assert.h"
@@ -57,6 +58,7 @@
#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/rtg.h"
+#include "amiga/schedule.h"
// disable use of "triangle mode" for scaling
#ifdef AMI_NS_TRIANGLE_SCALING
@@ -67,6 +69,8 @@ struct bitmap {
int width;
int height;
UBYTE *pixdata;
+ struct ExtMemIFace *iextmem;
+ uint32 size;
bool opaque;
int native;
struct BitMap *nativebm;
@@ -113,7 +117,25 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
bitmap = ami_memory_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
if(bitmap == NULL) return NULL;
- bitmap->pixdata = ami_memory_clear_alloc(width*height*4, 0xff);
+ bitmap->size = width * height * 4;
+
+#ifdef __amigaos4__
+ if(nsoption_bool(use_extmem) == true) {
+ uint64 size64 = bitmap->size;
+ bitmap->iextmem = AllocSysObjectTags(ASOT_EXTMEM,
+ ASOEXTMEM_Size, &size64,
+ ASOEXTMEM_AllocationPolicy, EXTMEMPOLICY_IMMEDIATE,
+ TAG_END);
+
+ bitmap->pixdata = NULL;
+ UBYTE *pixdata = amiga_bitmap_get_buffer(bitmap);
+ memset(pixdata, 0xff, bitmap->size);
+ } else
+#endif
+ {
+ bitmap->pixdata = ami_memory_clear_alloc(bitmap->size, 0xff);
+ }
+
bitmap->width = width;
bitmap->height = height;
@@ -133,11 +155,36 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
return bitmap;
}
+static void amiga_bitmap_unmap_buffer(void *p)
+{
+#ifdef __amigaos4__
+ struct bitmap *bm = p;
+
+ if((nsoption_bool(use_extmem) == true) && (bm->pixdata != NULL)) {
+ LOG("Unmapping ExtMem object %p for bitmap %p", bm->iextmem, bm);
+ bm->iextmem->Unmap(bm->pixdata, bm->size);
+ bm->pixdata = NULL;
+ }
+#endif
+}
/* exported function documented in amiga/bitmap.h */
unsigned char *amiga_bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
+
+#ifdef __amigaos4__
+ if(nsoption_bool(use_extmem) == true) {
+ if(bm->pixdata == NULL) {
+ LOG("Mapping ExtMem object %p for bitmap %p", bm->iextmem, bm);
+ bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0);
+ }
+
+ /* unmap the buffer after one second */
+ ami_schedule(1000, amiga_bitmap_unmap_buffer, bm);
+ }
+#endif
+
return bm->pixdata;
}
@@ -169,8 +216,19 @@ void amiga_bitmap_destroy(void *bitmap)
}
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
- if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
- ami_memory_clear_free(bm->pixdata);
+
+#ifdef __amigaos4__
+ if(nsoption_bool(use_extmem) == true) {
+ ami_schedule(-1, amiga_bitmap_unmap_buffer, bm);
+ amiga_bitmap_unmap_buffer(bm);
+ FreeSysObject(ASOT_EXTMEM, bm->iextmem);
+ bm->iextmem = NULL;
+ } else
+#endif
+ {
+ if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
+ ami_memory_clear_free(bm->pixdata);
+ }
if(bm->url) nsurl_unref(bm->url);
if(bm->title) free(bm->title);
@@ -218,9 +276,12 @@ void amiga_bitmap_modified(void *bitmap)
{
struct bitmap *bm = bitmap;
- if((bm->nativebm)) // && (bm->native == AMI_NSBM_TRUECOLOUR))
- ami_rtg_freebitmap(bm->nativebm);
-
+#ifdef __amigaos4__
+ /* unmap the buffer after 0.5s - we might need it imminently */
+ ami_schedule(500, amiga_bitmap_unmap_buffer, bm);
+#endif
+
+ if(bm->nativebm) ami_rtg_freebitmap(bm->nativebm);
if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
bm->nativebm = NULL;
@@ -645,6 +706,7 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
int width, int height, struct BitMap *friendbm)
{
if(bitmap == NULL) return NULL;
+ LOG("Getting native BitMap for %p", bitmap);
if(__builtin_expect(ami_plot_screen_is_palettemapped() == true, 0)) {
return ami_bitmap_get_palettemapped(bitmap, width, height, friendbm);
@@ -662,6 +724,8 @@ void ami_bitmap_fini(void)
static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
{
#ifdef __amigaos4__
+ LOG("Entering bitmap_render");
+
struct redraw_context ctx = {
.interactive = false,
.background_images = true,
diff --git a/frontends/amiga/dist/NetSurf.guide b/frontends/amiga/dist/NetSurf.guide
index dd2f46d0e..754cdbeb9 100755
--- a/frontends/amiga/dist/NetSurf.guide
+++ b/frontends/amiga/dist/NetSurf.guide
@@ -145,7 +145,7 @@ There are a couple of Amiga-specific options which can only be changed directly
@{b}web_search_width@{ub} Defaults to 0. Larger values will increase the size of the web search gadget next to the URL bar.
@{b}mask_alpha@{ub} Threshold to use when determining which alpha values to convert to full transparency (0 - 255, where 255 will convert even opaque pixels to transparent). Defaults to 0. This is only used in palette-mapped modes where alpha blending is not currently supported.
@{b}tab_new_session{ub} If NetSurf is already running, this will cause any passed URLs to open in a new tab rather than a new window.
-
+@{b}use_extmem@{ub} Defaults to 1 (enabled). Setting to 0 will prevent NetSurf using Extended Memory to store uncompressed images - this may have a performance benefit and no disadvantage for <2GB configurations. OS4.1FEU1 only.
@{b}url_file@{ub} Path to URL database file
@{b}hotlist_file@{ub} Path to Hotlist file
@{b}arexx_dir@{ub} Path to ARexx scripts dir
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index a51d8c2db..ba0a786e3 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2015 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2016 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -616,6 +616,11 @@ static nserror ami_set_options(struct nsoption_s *defaults)
/* Some OS-specific overrides */
#ifdef __amigaos4__
+ if(!LIB_IS_AT_LEAST((struct Library *)SysBase, 53, 89)) {
+ /* Disable ExtMem usage pre-OS4.1FEU1 */
+ nsoption_set_bool(use_extmem, false);
+ }
+
if(codeset == 0) codeset = 4; /* ISO-8859-1 */
const char *encname = (const char *)ObtainCharsetInfo(DFCS_NUMBER, codeset,
DFCS_MIMENAME);
diff --git a/frontends/amiga/options.h b/frontends/amiga/options.h
index 3aa845140..b5b2b3b07 100644
--- a/frontends/amiga/options.h
+++ b/frontends/amiga/options.h
@@ -89,8 +89,11 @@ NSOPTION_INTEGER(monitor_aspect_x, 0)
NSOPTION_INTEGER(monitor_aspect_y, 0)
NSOPTION_BOOL(accept_lang_locale, true)
NSOPTION_STRING(local_charset, "ISO-8859-1")
+#ifdef __amigaos4__
+/* Options relevant for OS4 only */
+NSOPTION_BOOL(use_extmem, true)
+#else
/* Options relevant for OS3 only */
-#ifndef __amigaos4__
NSOPTION_BOOL(friend_bitmap, false)
#endif