Move all the layers code into plotters.c and refactor to use gui_globals structure
Purge option_direct_render svn path=/trunk/netsurf/; revision=8425
This commit is contained in:
parent
9e5f6510ec
commit
801ef751af
90
amiga/gui.c
90
amiga/gui.c
|
@ -38,7 +38,6 @@
|
|||
#include "render/form.h"
|
||||
#include <graphics/rpattr.h>
|
||||
#include <libraries/gadtools.h>
|
||||
#include <proto/layers.h>
|
||||
#include <datatypes/pictureclass.h>
|
||||
#include "desktop/selection.h"
|
||||
#include "utils/utf8.h"
|
||||
|
@ -181,7 +180,6 @@ uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved);
|
|||
void ami_init_mouse_pointers(void);
|
||||
void ami_switch_tab(struct gui_window_2 *gwin,bool redraw);
|
||||
static void *myrealloc(void *ptr, size_t len, void *pw);
|
||||
void ami_init_layers(struct RastPort *rp);
|
||||
|
||||
STRPTR ami_locale_langs(void)
|
||||
{
|
||||
|
@ -581,28 +579,7 @@ void gui_init2(int argc, char** argv)
|
|||
if(notalreadyrunning)
|
||||
{
|
||||
ami_openscreen();
|
||||
|
||||
/* 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 */
|
||||
|
||||
browserglob.layerinfo = NewLayerInfo();
|
||||
browserglob.areabuf = AllocVec(100,MEMF_PRIVATE | MEMF_CLEAR);
|
||||
browserglob.tmprasbuf = AllocVec(scrn->Width*scrn->Width,MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
if(!option_direct_render)
|
||||
{
|
||||
browserglob.bm = p96AllocBitMap(scrn->Width,scrn->Width,32,
|
||||
BMF_INTERLEAVED, NULL, RGBFB_A8R8G8B8);
|
||||
|
||||
if(!browserglob.bm) warn_user("NoMemory","");
|
||||
|
||||
InitRastPort(&browserglob.rp);
|
||||
browserglob.rp.BitMap = browserglob.bm;
|
||||
|
||||
ami_init_layers(&browserglob.rp);
|
||||
}
|
||||
/* init shared bitmaps */
|
||||
ami_init_layers(&browserglob);
|
||||
}
|
||||
|
||||
if(argc) // argc==0 is started from wb
|
||||
|
@ -684,44 +661,6 @@ void gui_init2(int argc, char** argv)
|
|||
if(locked_screen) UnlockPubScreen(NULL,scrn);
|
||||
}
|
||||
|
||||
void ami_init_layers(struct RastPort *rp)
|
||||
{
|
||||
SetDrMd(rp,BGBACKFILL);
|
||||
|
||||
rp->Layer = CreateUpfrontLayer(browserglob.layerinfo,rp->BitMap,0,0,
|
||||
scrn->Width-1,scrn->Width-1,LAYERSIMPLE,NULL);
|
||||
|
||||
InstallLayerHook(rp->Layer,LAYERS_NOBACKFILL);
|
||||
|
||||
rp->AreaInfo = AllocVec(sizeof(struct AreaInfo),MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
if((!browserglob.areabuf) || (!rp->AreaInfo)) warn_user("NoMemory","");
|
||||
|
||||
InitArea(rp->AreaInfo,browserglob.areabuf,100/5);
|
||||
rp->TmpRas = AllocVec(sizeof(struct TmpRas),MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
if((!browserglob.tmprasbuf) || (!rp->TmpRas)) warn_user("NoMemory","");
|
||||
|
||||
InitTmpRas(rp->TmpRas,browserglob.tmprasbuf,scrn->Width*scrn->Width);
|
||||
glob = &browserglob;
|
||||
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
browserglob.surface = cairo_amigaos_surface_create(rp->BitMap);
|
||||
browserglob.cr = cairo_create(browserglob.surface);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ami_free_layers(struct RastPort *rp)
|
||||
{
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
cairo_destroy(browserglob.cr);
|
||||
cairo_surface_destroy(browserglob.surface);
|
||||
#endif
|
||||
DeleteLayer(0,rp->Layer);
|
||||
FreeVec(rp->TmpRas);
|
||||
FreeVec(rp->AreaInfo);
|
||||
}
|
||||
|
||||
void ami_update_quals(struct gui_window_2 *gwin)
|
||||
{
|
||||
uint32 quals = 0;
|
||||
|
@ -1581,11 +1520,7 @@ void gui_quit(void)
|
|||
|
||||
ami_arexx_cleanup();
|
||||
|
||||
if(!option_direct_render) ami_free_layers(&browserglob.rp);
|
||||
DisposeLayerInfo(browserglob.layerinfo);
|
||||
p96FreeBitMap(browserglob.bm);
|
||||
FreeVec(browserglob.tmprasbuf);
|
||||
FreeVec(browserglob.areabuf);
|
||||
ami_free_layers(&browserglob);
|
||||
|
||||
ami_close_fonts();
|
||||
|
||||
|
@ -2119,8 +2054,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
|
||||
gwin->shared->bw = bw;
|
||||
|
||||
if(option_direct_render) ami_init_layers(gwin->shared->win->RPort);
|
||||
|
||||
GetAttr(WINDOW_HorizObject,gwin->shared->objects[OID_MAIN],(ULONG *)&gwin->shared->objects[OID_HSCROLL]);
|
||||
GetAttr(WINDOW_VertObject,gwin->shared->objects[OID_MAIN],(ULONG *)&gwin->shared->objects[OID_VSCROLL]);
|
||||
|
||||
|
@ -2140,6 +2073,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
gwin->shared->node = AddObject(window_list,AMINS_WINDOW);
|
||||
gwin->shared->node->objstruct = gwin->shared;
|
||||
|
||||
glob = &browserglob;
|
||||
|
||||
return gwin;
|
||||
}
|
||||
|
||||
|
@ -2214,7 +2149,6 @@ void gui_window_destroy(struct gui_window *g)
|
|||
|
||||
curbw = NULL;
|
||||
|
||||
if(option_direct_render) ami_free_layers(g->shared->win->RPort);
|
||||
DisposeObject(g->shared->objects[OID_MAIN]);
|
||||
DelObject(g->shared->node);
|
||||
if(g->tab_node)
|
||||
|
@ -2348,8 +2282,7 @@ void ami_do_redraw_limits(struct gui_window *g, struct content *c,int x0, int y0
|
|||
|
||||
ami_clearclipreg(&browserglob.rp);
|
||||
|
||||
if(!option_direct_render)
|
||||
BltBitMapRastPort(browserglob.bm,x0-sx,y0-sy,g->shared->win->RPort,
|
||||
BltBitMapRastPort(browserglob.bm,x0-sx,y0-sy,g->shared->win->RPort,
|
||||
xoffset+x0-sx,yoffset+y0-sy,x1-x0,y1-y0,0x0C0);
|
||||
}
|
||||
|
||||
|
@ -2491,15 +2424,12 @@ void ami_do_redraw(struct gui_window_2 *g)
|
|||
|
||||
ami_clearclipreg(&browserglob.rp);
|
||||
|
||||
if(!option_direct_render)
|
||||
{
|
||||
Forbid();
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
Forbid();
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
BltBitMapRastPort(browserglob.bm,0,0,g->win->RPort,bbox->Left,bbox->Top,
|
||||
BltBitMapRastPort(browserglob.bm,0,0,g->win->RPort,bbox->Left,bbox->Top,
|
||||
bbox->Width,bbox->Height,0x0C0);
|
||||
Permit();
|
||||
}
|
||||
Permit();
|
||||
}
|
||||
|
||||
current_redraw_browser = NULL;
|
||||
|
@ -2936,8 +2866,6 @@ void gui_window_remove_caret(struct gui_window *g)
|
|||
int xs,ys;
|
||||
|
||||
if(!g) return;
|
||||
if(option_direct_render) return;
|
||||
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->shared->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
GetAttr(SCROLLER_Top,g->shared->objects[OID_HSCROLL],(ULONG *)&xs);
|
||||
|
|
19
amiga/gui.h
19
amiga/gui.h
|
@ -24,9 +24,7 @@
|
|||
#include "desktop/browser.h"
|
||||
#include <dos/dos.h>
|
||||
#include "desktop/gui.h"
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
#include <cairo/cairo.h>
|
||||
#endif
|
||||
#include "amiga/plotters.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -115,20 +113,6 @@ struct gui_window
|
|||
struct List dllist;
|
||||
};
|
||||
|
||||
struct gui_globals
|
||||
{
|
||||
struct BitMap *bm;
|
||||
struct RastPort rp;
|
||||
struct Layer_Info *layerinfo;
|
||||
APTR areabuf;
|
||||
APTR tmprasbuf;
|
||||
struct Rectangle rect;
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
#endif
|
||||
};
|
||||
|
||||
void ami_get_msg(void);
|
||||
void ami_update_pointer(struct Window *win, gui_pointer_shape shape);
|
||||
void ami_close_all_tabs(struct gui_window_2 *gwin);
|
||||
|
@ -147,6 +131,5 @@ struct FileRequester *savereq;
|
|||
struct MsgPort *sport;
|
||||
bool win_destroyed;
|
||||
struct browser_window *curbw;
|
||||
struct gui_globals *glob;
|
||||
struct gui_globals browserglob;
|
||||
#endif
|
||||
|
|
|
@ -39,7 +39,6 @@ extern char *option_recent_file;
|
|||
extern char *option_arexx_dir;
|
||||
extern char *option_download_dir;
|
||||
extern bool option_faster_scroll;
|
||||
extern bool option_direct_render;
|
||||
extern bool option_scale_quality;
|
||||
extern bool option_ask_overwrite;
|
||||
|
||||
|
@ -63,7 +62,6 @@ char *option_recent_file = 0; \
|
|||
char *option_arexx_dir = 0; \
|
||||
char *option_download_dir = 0; \
|
||||
bool option_faster_scroll = true; \
|
||||
bool option_direct_render = false; \
|
||||
bool option_scale_quality = false; \
|
||||
bool option_ask_overwrite = false; \
|
||||
|
||||
|
@ -87,7 +85,6 @@ bool option_ask_overwrite = false; \
|
|||
{ "arexx_dir", OPTION_STRING, &option_arexx_dir }, \
|
||||
{ "download_dir", OPTION_STRING, &option_download_dir }, \
|
||||
{ "faster_scroll", OPTION_BOOL, &option_faster_scroll}, \
|
||||
{ "debug_dr", OPTION_BOOL, &option_direct_render}, \
|
||||
{ "scale_quality", OPTION_BOOL, &option_scale_quality}, \
|
||||
{ "ask_overwrite", OPTION_BOOL, &option_ask_overwrite},
|
||||
#endif
|
||||
|
|
|
@ -17,16 +17,13 @@
|
|||
*/
|
||||
|
||||
#include "amiga/plotters.h"
|
||||
#include "amiga/gui.h"
|
||||
#include "amiga/bitmap.h"
|
||||
#include "amiga/font.h"
|
||||
#include <proto/Picasso96API.h>
|
||||
#include <proto/graphics.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <graphics/rpattr.h>
|
||||
#include <graphics/gfxmacros.h>
|
||||
#include "amiga/utf8.h"
|
||||
#include <proto/layers.h>
|
||||
#include "amiga/options.h"
|
||||
#include <graphics/blitattr.h>
|
||||
#include <graphics/composite.h>
|
||||
|
@ -34,6 +31,8 @@
|
|||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <proto/exec.h>
|
||||
#include "amiga/gui.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct BackFillMessage *bfmsg);
|
||||
|
||||
|
@ -108,6 +107,64 @@ void ami_cairo_set_dashed(cairo_t *cr)
|
|||
}
|
||||
#endif
|
||||
|
||||
void ami_init_layers(struct gui_globals *gg)
|
||||
{
|
||||
/* 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 */
|
||||
|
||||
gg->layerinfo = NewLayerInfo();
|
||||
gg->areabuf = AllocVec(100,MEMF_PRIVATE | MEMF_CLEAR);
|
||||
gg->tmprasbuf = AllocVec(scrn->Width*scrn->Width,MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
gg->bm = p96AllocBitMap(scrn->Width,scrn->Width,32,
|
||||
BMF_INTERLEAVED, NULL, RGBFB_A8R8G8B8);
|
||||
|
||||
if(!gg->bm) warn_user("NoMemory","");
|
||||
|
||||
InitRastPort(&gg->rp);
|
||||
gg->rp.BitMap = gg->bm;
|
||||
|
||||
SetDrMd(&gg->rp,BGBACKFILL);
|
||||
|
||||
gg->rp.Layer = CreateUpfrontLayer(gg->layerinfo,gg->rp.BitMap,0,0,
|
||||
scrn->Width-1,scrn->Width-1,LAYERSIMPLE,NULL);
|
||||
|
||||
InstallLayerHook(gg->rp.Layer,LAYERS_NOBACKFILL);
|
||||
|
||||
gg->rp.AreaInfo = AllocVec(sizeof(struct AreaInfo),MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
if((!gg->areabuf) || (!gg->rp.AreaInfo)) warn_user("NoMemory","");
|
||||
|
||||
InitArea(gg->rp.AreaInfo,gg->areabuf,100/5);
|
||||
gg->rp.TmpRas = AllocVec(sizeof(struct TmpRas),MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
if((!gg->tmprasbuf) || (!gg->rp.TmpRas)) warn_user("NoMemory","");
|
||||
|
||||
InitTmpRas(gg->rp.TmpRas,gg->tmprasbuf,scrn->Width*scrn->Width);
|
||||
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
gg->surface = cairo_amigaos_surface_create(gg->rp.BitMap);
|
||||
gg->cr = cairo_create(gg->surface);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ami_free_layers(struct gui_globals *gg)
|
||||
{
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
cairo_destroy(gg->cr);
|
||||
cairo_surface_destroy(gg->surface);
|
||||
#endif
|
||||
DeleteLayer(0,gg->rp.Layer);
|
||||
FreeVec(gg->rp.TmpRas);
|
||||
FreeVec(gg->rp.AreaInfo);
|
||||
|
||||
DisposeLayerInfo(gg->layerinfo);
|
||||
p96FreeBitMap(gg->bm);
|
||||
FreeVec(gg->tmprasbuf);
|
||||
FreeVec(gg->areabuf);
|
||||
}
|
||||
|
||||
bool ami_clg(colour c)
|
||||
{
|
||||
p96RectFill(&glob->rp,0,0,scrn->Width-1,scrn->Width-1,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2008 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/
|
||||
*
|
||||
|
@ -19,6 +19,25 @@
|
|||
#ifndef AMIGA_PLOTTERS_H
|
||||
#define AMIGA_PLOTTERS_H
|
||||
#include "desktop/plotters.h"
|
||||
#include <proto/layers.h>
|
||||
#include <proto/graphics.h>
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
#include <cairo/cairo.h>
|
||||
#endif
|
||||
|
||||
struct gui_globals
|
||||
{
|
||||
struct BitMap *bm;
|
||||
struct RastPort rp;
|
||||
struct Layer_Info *layerinfo;
|
||||
APTR areabuf;
|
||||
APTR tmprasbuf;
|
||||
struct Rectangle rect;
|
||||
#ifdef NS_AMIGA_CAIRO
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern const struct plotter_table amiplot;
|
||||
|
||||
|
@ -41,4 +60,9 @@ bool ami_group_end(void);
|
|||
bool ami_flush(void);
|
||||
bool ami_path(const float *p, unsigned int n, colour fill, float width,
|
||||
colour c, const float transform[6]);
|
||||
|
||||
void ami_init_layers(struct gui_globals *gg);
|
||||
void ami_free_layers(struct gui_globals *gg);
|
||||
|
||||
struct gui_globals *glob;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue