summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2015-01-20 20:36:14 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2015-01-20 20:36:14 +0000
commite3af7f334303b36414c3a7c39dec22ec179dbd09 (patch)
tree43db743d171d374bc5d2ef60147e9e3a0c2e6daf
parentd0f7247ea67491b4bfae28cb90538b68c6f83d70 (diff)
downloadnetsurf-e3af7f334303b36414c3a7c39dec22ec179dbd09.tar.gz
netsurf-e3af7f334303b36414c3a7c39dec22ec179dbd09.tar.bz2
Abstract P96 functions away so we can decide what to use at run-time.
This allows us to avoid opening P96 on OS4.1FE in future, and not require it to be installed on OS3.
-rw-r--r--amiga/Makefile.target2
-rw-r--r--amiga/bitmap.c16
-rw-r--r--amiga/gui.c6
-rw-r--r--amiga/libs.c14
-rw-r--r--amiga/os3support.h4
-rwxr-xr-xamiga/plotters.c19
6 files changed, 30 insertions, 31 deletions
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index ec478260d..a9de6eec0 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -73,7 +73,7 @@ S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \
launch.c search.c history_local.c download.c iff_dr2d.c \
sslcert.c gui_options.c print.c theme.c drag.c icon.c libs.c \
datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \
- stringview/stringview.c stringview/urlhistory.c \
+ stringview/stringview.c stringview/urlhistory.c rtg.c \
agclass/amigaguide_class.c fs_backing_store.c os3support.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
diff --git a/amiga/bitmap.c b/amiga/bitmap.c
index b7eb129db..ec6ce79a1 100644
--- a/amiga/bitmap.c
+++ b/amiga/bitmap.c
@@ -41,6 +41,7 @@
#include "amiga/bitmap.h"
#include "amiga/download.h"
#include "amiga/misc.h"
+#include "amiga/rtg.h"
/**
* Create a bitmap.
@@ -122,7 +123,7 @@ void bitmap_destroy(void *bitmap)
if(bm)
{
if((bm->nativebm) && (bm->dto == NULL)) {
- p96FreeBitMap(bm->nativebm);
+ ami_rtg_freebitmap(bm->nativebm);
}
if(bm->dto) {
@@ -180,7 +181,7 @@ void bitmap_modified(void *bitmap) {
struct bitmap *bm = bitmap;
if((bm->nativebm) && (bm->dto == NULL))
- p96FreeBitMap(bm->nativebm);
+ ami_rtg_freebitmap(bm->nativebm);
if(bm->dto) DisposeDTObject(bm->dto);
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
@@ -408,7 +409,7 @@ static struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width,
}
else
{
- if(bitmap->nativebm) p96FreeBitMap(bitmap->nativebm);
+ if(bitmap->nativebm) ami_rtg_freebitmap(bitmap->nativebm);
bitmap->nativebm = NULL;
}
}
@@ -419,10 +420,11 @@ static struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width,
ri.BytesPerRow = bitmap->width * 4;
ri.RGBFormat = AMI_BITMAP_FORMAT;
- if((tbm = p96AllocBitMap(bitmap->width, bitmap->height, 32, 0,
+ if((tbm = ami_rtg_allocbitmap(bitmap->width, bitmap->height, 32, 0,
friendbm, AMI_BITMAP_FORMAT))) {
InitRastPort(&trp);
trp.BitMap = tbm;
+ /*\todo abstract p96WritePixelArray */
p96WritePixelArray((struct RenderInfo *)&ri, 0, 0, &trp, 0, 0,
bitmap->width, bitmap->height);
}
@@ -440,7 +442,7 @@ static struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width,
struct BitMap *scaledbm;
struct BitScaleArgs bsa;
- scaledbm = p96AllocBitMap(width, height, 32, BMF_DISPLAYABLE,
+ scaledbm = ami_rtg_allocbitmap(width, height, 32, BMF_DISPLAYABLE,
friendbm, AMI_BITMAP_FORMAT);
if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
@@ -482,8 +484,8 @@ static struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width,
BitMapScale(&bsa);
}
- if(bitmap->nativebm != tbm) p96FreeBitMap(bitmap->nativebm);
- p96FreeBitMap(tbm);
+ if(bitmap->nativebm != tbm) ami_rtg_freebitmap(bitmap->nativebm);
+ ami_rtg_freebitmap(tbm);
tbm = scaledbm;
bitmap->nativebm = NULL;
diff --git a/amiga/gui.c b/amiga/gui.c
index eeb39421d..5d0504c8a 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -35,7 +35,6 @@
#include <proto/keymap.h>
#include <proto/locale.h>
#ifdef __amigaos4__
-#include <proto/Picasso96API.h>
#include <proto/popupmenu.h>
#endif
#include <proto/utility.h>
@@ -142,6 +141,7 @@
#include "amiga/plotters.h"
#include "amiga/plugin_hack.h"
#include "amiga/print.h"
+#include "amiga/rtg.h"
#include "amiga/schedule.h"
#include "amiga/search.h"
#include "amiga/theme.h"
@@ -2844,7 +2844,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
gwin->win, NULL, STRINGA_TextVal, "", TAG_DONE);
- p96RectFill(gwin->win->RPort, bbox->Left, bbox->Top,
+ ami_rtg_rectfill(gwin->win->RPort, bbox->Left, bbox->Top,
bbox->Width+bbox->Left, bbox->Height+bbox->Top, 0xffffffff);
ami_gui_free_space_box(bbox);
@@ -2859,7 +2859,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
{
gui_window_set_icon(gwin->gw, gwin->gw->favicon);
- p96RectFill(gwin->win->RPort, bbox->Left, bbox->Top,
+ ami_rtg_rectfill(gwin->win->RPort, bbox->Left, bbox->Top,
bbox->Width+bbox->Left, bbox->Height+bbox->Top, 0xffffffff);
browser_window_update(gwin->gw->bw, false);
diff --git a/amiga/libs.c b/amiga/libs.c
index 9ac9589c3..b964d8f2f 100644
--- a/amiga/libs.c
+++ b/amiga/libs.c
@@ -37,7 +37,7 @@
} else { \
LOG(("Failed to open %s v%d", LIB, LIBVER)); \
if(FAIL == true) { \
- STRPTR error = ASPrintf("Unable to open %s v%d", LIB, LIBVER); \
+ STRPTR error = ASPrintf("Unable to open %s v%d (fatal error)", LIB, LIBVER); \
ami_misc_fatal_error(error); \
FreeVec(error); \
return false; \
@@ -58,7 +58,7 @@
} else { \
LOG(("Failed to open %s v%d", LIB, LIBVER)); \
if(FAIL == true) { \
- STRPTR error = ASPrintf("Unable to open %s v%d", LIB, LIBVER); \
+ STRPTR error = ASPrintf("Unable to open %s v%d (fatal error)", LIB, LIBVER); \
ami_misc_fatal_error(error); \
FreeVec(error); \
return false; \
@@ -76,7 +76,6 @@
#ifdef __amigaos4__
AMINS_LIB_STRUCT(Application);
-AMINS_LIB_STRUCT(P96);
#else
struct UtilityBase *UtilityBase; /* AMINS_LIB_STRUCT(Utility) */
#endif
@@ -91,6 +90,7 @@ AMINS_LIB_STRUCT(Intuition);
AMINS_LIB_STRUCT(Keymap);
AMINS_LIB_STRUCT(Layers);
AMINS_LIB_STRUCT(Locale);
+AMINS_LIB_STRUCT(P96);
AMINS_LIB_STRUCT(Workbench);
AMINS_LIB_STRUCT(ARexx);
@@ -120,7 +120,6 @@ bool ami_libs_open(void)
#ifdef __amigaos4__
/* Libraries only needed on OS4 */
AMINS_LIB_OPEN("application.library", 53, Application, "application", 2, false)
- AMINS_LIB_OPEN("Picasso96API.library", 0, P96, "main", 1, true)
#else
/* Libraries we get automatically on OS4 but not OS3 */
AMINS_LIB_OPEN("utility.library", 37, Utility, "main", 1, true)
@@ -139,6 +138,11 @@ bool ami_libs_open(void)
AMINS_LIB_OPEN("locale.library", 37, Locale, "main", 1, true)
AMINS_LIB_OPEN("workbench.library", 37, Workbench, "main", 1, true)
+ /*\todo This is down here as we need to check the graphics.library version
+ * before opening. If it is sufficiently new enough we can avoid using P96
+ */
+ AMINS_LIB_OPEN("Picasso96API.library", 0, P96, "main", 1, false)
+
/* NB: timer.device is opened in schedule.c (ultimately by the scheduler process).
* The library base and interface are obtained there, rather than here, due to
* the additional complexities of opening devices, which aren't important here
@@ -213,10 +217,10 @@ void ami_libs_close(void)
AMINS_LIB_CLOSE(Keymap)
AMINS_LIB_CLOSE(Layers)
AMINS_LIB_CLOSE(Locale)
+ AMINS_LIB_CLOSE(P96)
AMINS_LIB_CLOSE(Workbench)
#ifdef __amigaos4__
AMINS_LIB_CLOSE(Application)
- AMINS_LIB_CLOSE(P96)
#else
AMINS_LIB_CLOSE(Utility)
#endif
diff --git a/amiga/os3support.h b/amiga/os3support.h
index a8c5abad2..a329cc9c5 100644
--- a/amiga/os3support.h
+++ b/amiga/os3support.h
@@ -150,9 +150,7 @@
#define ShowWindow(...) (void)0
/* P96 */
-#define p96FreeBitMap(B) FreeBitMap(B)
-#define p96AllocBitMap(W,H,D,FL,FR,FM) AllocBitMap(W,H,D,FL,FR)
-#define p96RectFill(RP,X,Y,XW,YH,C) RectFill(RP,X,Y,XW,YH) /* Needs pen */
+#define p96WritePixelArray (void)0 /* TODO - see rtg.c */
/* Utility */
#define SetMem memset
diff --git a/amiga/plotters.c b/amiga/plotters.c
index eaf775183..58aee5a90 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -18,9 +18,6 @@
#include "amiga/os3support.h"
-#ifdef __amigaos4__
-#include <proto/Picasso96API.h>
-#endif
#include <proto/exec.h>
#include <proto/intuition.h>
@@ -134,10 +131,10 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
gg->bm = AllocBitMap(width, height, depth,
BMF_INTERLEAVED | BMF_DISPLAYABLE, friend);
} else {
- gg->bm = p96AllocBitMap(width, height, 32,
+ gg->bm = ami_rtg_allocbitmap(width, height, 32,
BMF_INTERLEAVED | BMF_DISPLAYABLE, friend, RGBFB_A8R8G8B8);
}
-
+
if(!gg->bm) warn_user("NoMemory","");
gg->rp = AllocVecTagList(sizeof(struct RastPort), NULL);
@@ -167,8 +164,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
void ami_free_layers(struct gui_globals *gg)
{
- if(gg->rp)
- {
+ if(gg->rp) {
DeleteLayer(0,gg->rp->Layer);
FreeVec(gg->rp->TmpRas);
FreeVec(gg->rp->AreaInfo);
@@ -179,7 +175,7 @@ void ami_free_layers(struct gui_globals *gg)
FreeVec(gg->areabuf);
DisposeLayerInfo(gg->layerinfo);
if(palette_mapped == false) {
- p96FreeBitMap(gg->bm);
+ ami_rtg_freebitmap(gg->bm);
} else {
FreeBitMap(gg->bm);
}
@@ -550,9 +546,8 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
#endif
}
- if((bitmap->dto == NULL) && (tbm != bitmap->nativebm))
- {
- p96FreeBitMap(tbm);
+ if((bitmap->dto == NULL) && (tbm != bitmap->nativebm)) {
+ ami_rtg_freebitmap(tbm);
}
return true;
@@ -654,7 +649,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
if((bitmap->dto == NULL) && (tbm != bitmap->nativebm))
{
- p96FreeBitMap(tbm);
+ ami_rtg_freebitmap(tbm);
}
#else
#warning FIXME: bitmap tiling uses backfill hooks