summaryrefslogtreecommitdiff
path: root/frontends/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2017-02-13 17:46:20 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2017-02-13 17:46:20 +0000
commit075e9c0258bd75307a90b3e6bd576742bf212b08 (patch)
treed915cc2b8788b585e8123e9715ff623eed0f1717 /frontends/amiga
parentedaa9c29f22a550ddc7c8e1f02ff6d9dedf9a5b1 (diff)
downloadnetsurf-075e9c0258bd75307a90b3e6bd576742bf212b08.tar.gz
netsurf-075e9c0258bd75307a90b3e6bd576742bf212b08.tar.bz2
Alloc gui_global structure when initialising
Diffstat (limited to 'frontends/amiga')
-rw-r--r--frontends/amiga/bitmap.c22
-rw-r--r--frontends/amiga/corewindow.c20
-rw-r--r--frontends/amiga/corewindow.h2
-rw-r--r--frontends/amiga/gui.c30
-rwxr-xr-xfrontends/amiga/history_local.c7
-rw-r--r--frontends/amiga/plotters.c22
-rw-r--r--frontends/amiga/plotters.h6
-rw-r--r--frontends/amiga/print.c6
8 files changed, 60 insertions, 55 deletions
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 95e99aa5b..31448d6cc 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -727,29 +727,29 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
int plot_width;
int plot_height;
- struct gui_globals bm_globals;
+ struct gui_globals *bm_globals;
+
+ plot_width = MIN(content_get_width(content), bitmap->width);
+ plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
+ bitmap->width;
+
+ bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, true);
+ ami_clearclipreg(bm_globals);
struct redraw_context ctx = {
.interactive = false,
.background_images = true,
.plot = &amiplot,
- .priv = &bm_globals
+ .priv = bm_globals
};
- plot_width = MIN(content_get_width(content), bitmap->width);
- plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
- bitmap->width;
-
- ami_init_layers(&bm_globals, bitmap->width, bitmap->height, true);
- ami_clearclipreg(&bm_globals);
-
content_scaled_redraw(content, plot_width, plot_height, &ctx);
BltBitMapTags( BLITA_SrcX, 0,
BLITA_SrcY, 0,
BLITA_Width, bitmap->width,
BLITA_Height, bitmap->height,
- BLITA_Source, bm_globals.bm,
+ BLITA_Source, ami_plot_ra_get_bitmap(bm_globals),
BLITA_SrcType, BLITT_BITMAP,
BLITA_Dest, amiga_bitmap_get_buffer(bitmap),
BLITA_DestType, BLITT_ARGB32,
@@ -763,7 +763,7 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
/**\todo In theory we should be able to move the bitmap to our native area
to try to avoid re-conversion (at the expense of memory) */
- ami_free_layers(&bm_globals);
+ ami_plot_ra_free(bm_globals);
amiga_bitmap_set_opaque(bitmap, true);
#else
#warning FIXME for OS3 (in current state none of bitmap_render can work!)
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 15b0a6e73..0c85bafdd 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -219,8 +219,8 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
struct IBox *bbox;
ULONG pos_x, pos_y;
struct rect draw_rect;
- int tile_size_x = ami_cw->gg.width;
- int tile_size_y = ami_cw->gg.height;
+ int tile_size_x = ami_cw->gg->width;
+ int tile_size_y = ami_cw->gg->height;
int tile_x, tile_y, tile_w, tile_h;
int x = r->x0;
int y = r->y0;
@@ -231,7 +231,7 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
.interactive = true,
.background_images = true,
.plot = &amiplot,
- .priv = &ami_cw->gg
+ .priv = ami_cw->gg
};
if(ami_gui_get_space_box((Object *)ami_cw->objects[GID_CW_DRAW], &bbox) != NSERROR_OK) {
@@ -273,7 +273,7 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
#ifdef __amigaos4__
BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
- BLITA_Source, ami_cw->gg.bm,
+ BLITA_Source, ami_plot_ra_get_bitmap(ami_cw->gg),
BLITA_SrcX, 0,
BLITA_SrcY, 0,
BLITA_DestType, BLITT_RASTPORT,
@@ -284,7 +284,7 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
BLITA_Height, tile_h,
TAG_DONE);
#else
- BltBitMapRastPort(ami_cw->gg.bm, 0, 0,
+ BltBitMapRastPort(ami_plot_ra_get_bitmap(ami_cw->gg), 0, 0,
ami_cw->win->RPort, bbox->Left + tile_x - pos_x, bbox->Top + tile_y - pos_y,
tile_w, tile_h, 0xC0);
#endif
@@ -292,7 +292,7 @@ ami_cw_redraw_rect(struct ami_corewindow *ami_cw, struct rect *r)
}
ami_gui_free_space_box(bbox);
- ami_clearclipreg(&ami_cw->gg);
+ ami_clearclipreg(ami_cw->gg);
}
@@ -915,8 +915,8 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->dragging = false;
/* allocate drawing area etc */
- ami_init_layers(&ami_cw->gg, 100, 100, false); // force tiles to save memory
- ami_cw->gg.shared_pens = ami_AllocMinList();
+ ami_cw->gg = ami_plot_ra_alloc(100, 100, false); // force tiles to save memory
+ ami_cw->gg->shared_pens = ami_AllocMinList();
ami_cw->deferred_rects = NewObjList();
ami_cw->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
@@ -986,8 +986,8 @@ nserror ami_corewindow_fini(struct ami_corewindow *ami_cw)
#endif
/* release off-screen bitmap stuff */
- ami_plot_release_pens(ami_cw->gg.shared_pens);
- ami_free_layers(&ami_cw->gg);
+ ami_plot_release_pens(ami_cw->gg->shared_pens);
+ ami_plot_ra_free(ami_cw->gg);
/* free the window title */
ami_utf8_free(ami_cw->wintitle);
diff --git a/frontends/amiga/corewindow.h b/frontends/amiga/corewindow.h
index cfcd7fc5e..cc4fe4adb 100644
--- a/frontends/amiga/corewindow.h
+++ b/frontends/amiga/corewindow.h
@@ -76,7 +76,7 @@ struct ami_corewindow {
char *wintitle;
/** stuff for our off-screen render bitmap */
- struct gui_globals gg;
+ struct gui_globals *gg;
struct MinList *shared_pens;
/** drag status set by core */
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index a18d4d5b8..e6f23abe6 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -202,7 +202,7 @@ static BOOL locked_screen = FALSE;
static int screen_signal = -1;
static bool win_destroyed;
static STRPTR nsscreentitle;
-static struct gui_globals browserglob;
+static struct gui_globals *browserglob = NULL;
static struct MsgPort *applibport = NULL;
static uint32 ami_appid = 0;
@@ -885,7 +885,7 @@ static void ami_openscreen(void)
static void ami_openscreenfirst(void)
{
ami_openscreen();
- if(!browserglob.bm) ami_init_layers(&browserglob, 0, 0, false);
+ if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false);
ami_theme_throbber_setup();
}
@@ -3040,7 +3040,7 @@ static void gui_quit(void)
#endif
ami_arexx_cleanup();
- ami_free_layers(&browserglob);
+ ami_plot_ra_free(browserglob);
ami_font_fini();
ami_help_free();
@@ -3530,7 +3530,7 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
int tile_x_scale = (int)(tile_size_x / gwin->gw->scale);
int tile_y_scale = (int)(tile_size_y / gwin->gw->scale);
- browserglob.shared_pens = gwin->shared_pens; /* do we need this?? */
+ glob->shared_pens = gwin->shared_pens; /* do we need this?? */
if(top < 0) {
height += top;
@@ -3581,10 +3581,10 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
clip.y0 - (int)y,
&clip, ctx))
{
- ami_clearclipreg(&browserglob);
+ ami_clearclipreg(glob);
#ifdef __amigaos4__
BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
- BLITA_Source, browserglob.bm,
+ BLITA_Source, ami_plot_ra_get_bitmap(glob),
BLITA_SrcX, 0,
BLITA_SrcY, 0,
BLITA_DestType, BLITT_RASTPORT,
@@ -3595,7 +3595,7 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
BLITA_Height, (int)(clip.y1),
TAG_DONE);
#else
- BltBitMapRastPort(browserglob.bm, 0, 0, gwin->win->RPort,
+ BltBitMapRastPort(ami_plot_ra_get_bitmap(glob), 0, 0, gwin->win->RPort,
bbox->Left + (int)((x - sx) * gwin->gw->scale),
bbox->Top + (int)((y - sy) * gwin->gw->scale),
(int)(clip.x1), (int)(clip.y1), 0xC0);
@@ -3630,7 +3630,7 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw
.interactive = true,
.background_images = true,
.plot = &amiplot,
- .priv = &browserglob
+ .priv = browserglob
};
if(!g) return;
@@ -4900,7 +4900,7 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
.interactive = true,
.background_images = true,
.plot = &amiplot,
- .priv = &browserglob
+ .priv = browserglob
};
if(nsoption_bool(direct_render) == false)
@@ -4909,9 +4909,9 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
}
else
{
- browserglob.shared_pens = gwin->shared_pens;
- temprp = browserglob.rp;
- browserglob.rp = gwin->win->RPort;
+ browserglob->shared_pens = gwin->shared_pens;
+ temprp = browserglob->rp;
+ browserglob->rp = gwin->win->RPort;
clip.x0 = bbox->Left;
clip.y0 = bbox->Top;
clip.x1 = bbox->Left + bbox->Width;
@@ -4921,8 +4921,8 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
if(browser_window_redraw(gwin->gw->bw, clip.x0 - hcurrent, clip.y0 - vcurrent, &clip, &ctx))
{
- ami_clearclipreg(&browserglob);
- browserglob.rp = temprp;
+ ami_clearclipreg(browserglob);
+ browserglob->rp = temprp;
}
ami_reset_pointer(gwin);
@@ -5273,7 +5273,7 @@ static void gui_window_new_content(struct gui_window *g)
c = browser_window_get_content(g->bw);
else return;
- ami_clearclipreg(&browserglob);
+ ami_clearclipreg(browserglob);
g->shared->new_content = true;
g->scrollx = 0;
g->scrolly = 0;
diff --git a/frontends/amiga/history_local.c b/frontends/amiga/history_local.c
index 8cce869c9..8ebfc7e65 100755
--- a/frontends/amiga/history_local.c
+++ b/frontends/amiga/history_local.c
@@ -132,9 +132,7 @@ void ami_history_open(struct gui_window *gw)
if(!gw->hw)
{
gw->hw = calloc(1, sizeof(struct history_window));
- gw->hw->gg = calloc(1, sizeof(struct gui_globals));
-
- ami_init_layers(gw->hw->gg, scrn->Width, scrn->Height, false);
+ gw->hw->gg = ami_plot_ra_alloc(scrn->Width, scrn->Height, false);
gw->hw->gw = gw;
browser_window_history_size(gw->bw, &width, &height);
@@ -239,8 +237,7 @@ static bool ami_history_click(struct history_window *hw, uint16 code)
void ami_history_close(struct history_window *hw)
{
- ami_free_layers(hw->gg);
- free(hw->gg);
+ ami_plot_ra_free(hw->gg);
hw->gw->hw = NULL;
DisposeObject(hw->objects[OID_MAIN]);
ami_gui_win_list_remove(hw);
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index 0eea2ed48..1911b7d17 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -102,15 +102,14 @@ static bool palette_mapped = true; /* palette-mapped state for the screen */
/* Define the below to get additional debug */
#undef AMI_PLOTTER_DEBUG
-void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool force32bit)
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit)
{
- /* init shared bitmaps *
- * Height is set to screen width to give enough space for thumbnails *
- * Also applies to the further gfx/layers functions and memory below */
-
- int depth = 32;
+ /* init shared bitmaps */
+ int depth = 32;
struct BitMap *friend = NULL;
+ struct gui_globals *gg = malloc(sizeof(struct gui_globals));
+
if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
LOG("Screen depth = %d", depth);
@@ -214,9 +213,11 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
init_layers_count++;
LOG("Layer initialised (total: %d)", init_layers_count);
+
+ return gg;
}
-void ami_free_layers(struct gui_globals *gg)
+void ami_plot_ra_free(struct gui_globals *gg)
{
init_layers_count--;
@@ -240,6 +241,13 @@ void ami_free_layers(struct gui_globals *gg)
} else {
if(gg->bm) FreeBitMap(gg->bm);
}
+
+ free(gg);
+}
+
+struct BitMap *ami_plot_ra_get_bitmap(struct gui_globals *gg)
+{
+ return gg->bm;
}
void ami_clearclipreg(struct gui_globals *gg)
diff --git a/frontends/amiga/plotters.h b/frontends/amiga/plotters.h
index b92cdd4de..c82208f53 100644
--- a/frontends/amiga/plotters.h
+++ b/frontends/amiga/plotters.h
@@ -45,11 +45,13 @@ struct gui_globals
extern const struct plotter_table amiplot;
-void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool force32bit);
-void ami_free_layers(struct gui_globals *gg);
void ami_clearclipreg(struct gui_globals *gg);
void ami_plot_clear_bbox(struct RastPort *rp, struct IBox *bbox);
void ami_plot_release_pens(struct MinList *shared_pens);
bool ami_plot_screen_is_palettemapped(void);
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit);
+void ami_plot_ra_free(struct gui_globals *gg);
+struct BitMap *ami_plot_ra_get_bitmap(struct gui_globals *gg);
+
#endif
diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c
index 60a84e1c2..23f8eadae 100644
--- a/frontends/amiga/print.c
+++ b/frontends/amiga/print.c
@@ -498,8 +498,7 @@ bool ami_print_begin(struct print_settings *ps)
ami_print_info.gg = calloc(1, sizeof(struct gui_globals));
if(!ami_print_info.gg) return false;
- ami_init_layers(ami_print_info.gg,
- ami_print_info.PED->ped_MaxXDots,
+ ami_print_info.gg = ami_plot_ra_alloc(ami_print_info.PED->ped_MaxXDots,
ami_print_info.PED->ped_MaxYDots,
true);
@@ -521,8 +520,7 @@ bool ami_print_next_page(void)
void ami_print_end(void)
{
- ami_free_layers(ami_print_info.gg);
- free(ami_print_info.gg);
+ ami_plot_ra_free(ami_print_info.gg);
DisposeObject(ami_print_info.objects[OID_MAIN]);
ami_print_close_device();