Direct rendering. Testing only; has problems with inline image placement, grey

background for all text, won't work with Cairo renderer, may crash with certain
gfx lib operations (AreaFill).  However, seems to be much faster in 16-bit mode than
off-screen buffered rendering.

svn path=/trunk/netsurf/; revision=11913
This commit is contained in:
Chris Young 2011-03-05 14:36:55 +00:00
parent 912b3bcde8
commit f892e59d76
4 changed files with 154 additions and 102 deletions

View File

@ -165,6 +165,8 @@ void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys);
ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin);
ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2);
void ami_try_quit(void);
void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
int x0, int y0, int x1, int y1);
STRPTR ami_locale_langs(void)
{
@ -2852,9 +2854,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
glob = &browserglob;
if(locked_screen) UnlockPubScreen(NULL,scrn);
//if (search_web_ico() == NULL)
search_web_retrieve_ico(false);
search_web_retrieve_ico(false);
return gwin;
}
@ -3097,6 +3097,8 @@ void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
ULONG cur_tab = 0;
ULONG sx, sy;
struct rect clip;
struct RastPort *temprp;
int posx, posy;
if(!g) return;
if(browser_window_redraw_ready(bw) == false) return;
@ -3121,29 +3123,47 @@ void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
xoffset=bbox->Left;
yoffset=bbox->Top;
plot=amiplot;
glob = &browserglob;
if((y1<sy) || (y0>sy+height)) return;
if((x1<sx) || (x0>sx+width)) return;
if((x0-(int)sx)<0) x0 = sx;
if((y0-(int)sy)<0) y0 = sy;
/* Check this - xoffset/yoffset are window-relative, not bitmap-relative */
if((x1-x0)+(xoffset+x0-sx)>(width)) x1 = (width-(x0-sx)+x0);
if((y1-y0)+(yoffset+y0-sy)>(height)) y1 = (height-(y0-sy)+y0);
plot = amiplot;
glob = &browserglob;
glob->scale = bw->scale;
clip.x0 = (x0 - sx);
clip.y0 = (y0 - sy);
clip.x1 = (x1 - sx);
clip.y1 = (y1 - sy);
if(option_direct_render == false)
{
clip.x0 = (x0 - sx);
clip.y0 = (y0 - sy);
clip.x1 = (x1 - sx);
clip.y1 = (y1 - sy);
posx = - sx;
posy = - sy;
}
else
{
temprp = browserglob.rp;
browserglob.rp = g->shared->win->RPort;
clip.x0 = (x0 - sx) + bbox->Left;
clip.y0 = (y0 - sy) + bbox->Top;
clip.x1 = (x1 - sx) + bbox->Left;
clip.y1 = (y1 - sy) + bbox->Top;
posx = bbox->Left - sx; /* wrong */
posy = bbox->Top - sy; /* wrong */
}
if(browser_window_redraw(bw, -sx, -sy, &clip))
if(browser_window_redraw(bw, posx, posy, &clip))
{
ami_clearclipreg(&browserglob);
if(option_direct_render == false)
{
/* This is identical to the below, but for some reason doesn't blit anything.
* Probably some values are wrong and BltBitMapTags is fussier.
@ -3169,6 +3189,11 @@ void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw,
(x1 - x0) * g->shared->bw->scale,
(y1 - y0) * g->shared->bw->scale,
0x0C0);
}
else
{
browserglob.rp = temprp;
}
}
current_redraw_browser = NULL;
@ -3209,6 +3234,7 @@ void ami_do_redraw(struct gui_window_2 *g)
struct IBox *bbox;
ULONG oldh=g->oldh,oldv=g->oldv;
bool morescroll = false;
struct RastPort *temprp;
if(browser_window_redraw_ready(g->bw) == false) return;
@ -3224,8 +3250,6 @@ void ami_do_redraw(struct gui_window_2 *g)
height=bbox->Height;
xoffset=bbox->Left;
yoffset=bbox->Top;
plot = amiplot;
glob = &browserglob;
if(g->bw->reformat_pending)
{
@ -3287,28 +3311,49 @@ void ami_do_redraw(struct gui_window_2 *g)
{
struct rect clip;
clip.x0 = 0;
clip.y0 = 0;
clip.x1 = width + hcurrent;
clip.y1 = height + vcurrent;
plot = amiplot;
glob = &browserglob;
glob->scale = g->bw->scale;
if(browser_window_redraw(g->bw, -hcurrent, -vcurrent, &clip))
if(option_direct_render == false)
{
clip.x0 = 0;
clip.y0 = 0;
clip.x1 = width + hcurrent;
clip.y1 = height + vcurrent;
}
else
{
temprp = browserglob.rp;
browserglob.rp = g->win->RPort;
clip.x0 = bbox->Left;
clip.y0 = bbox->Top;
clip.x1 = bbox->Left + bbox->Width;
clip.y1 = bbox->Top + bbox->Height;
}
if(browser_window_redraw(g->bw, clip.x0 - hcurrent, clip.y0 - vcurrent, &clip))
{
ami_clearclipreg(&browserglob);
BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
BLITA_Source, browserglob.bm,
BLITA_SrcX, 0,
BLITA_SrcY, 0,
BLITA_DestType, BLITT_RASTPORT,
BLITA_Dest, g->win->RPort,
BLITA_DestX, bbox->Left,
BLITA_DestY, bbox->Top,
BLITA_Width, bbox->Width,
BLITA_Height, bbox->Height,
TAG_DONE);
if(option_direct_render == false)
{
BltBitMapTags(BLITA_SrcType, BLITT_BITMAP,
BLITA_Source, browserglob.bm,
BLITA_SrcX, 0,
BLITA_SrcY, 0,
BLITA_DestType, BLITT_RASTPORT,
BLITA_Dest, g->win->RPort,
BLITA_DestX, bbox->Left,
BLITA_DestY, bbox->Top,
BLITA_Width, bbox->Width,
BLITA_Height, bbox->Height,
TAG_DONE);
}
else
{
browserglob.rp = temprp;
}
}
}

View File

@ -64,6 +64,7 @@ extern int option_cookies_window_ypos;
extern int option_cookies_window_xsize;
extern int option_cookies_window_ysize;
extern int option_cairo_renderer;
extern bool option_direct_render;
#define EXTRA_OPTION_DEFINE \
char *option_url_file = 0; \
@ -110,6 +111,7 @@ int option_cookies_window_ypos = 0; \
int option_cookies_window_xsize = 0; \
int option_cookies_window_ysize = 0; \
int option_cairo_renderer = 1; \
bool option_direct_render = false; \
#define EXTRA_OPTION_TABLE \
{ "url_file", OPTION_STRING, &option_url_file }, \
@ -155,5 +157,6 @@ int option_cairo_renderer = 1; \
{ "cookies_window_ypos", OPTION_INTEGER, &option_cookies_window_ypos}, \
{ "cookies_window_xsize", OPTION_INTEGER, &option_cookies_window_xsize}, \
{ "cookies_window_ysize", OPTION_INTEGER, &option_cookies_window_ysize}, \
{ "cairo_renderer", OPTION_INTEGER, &option_cairo_renderer},
{ "cairo_renderer", OPTION_INTEGER, &option_cairo_renderer}, \
{ "direct_render", OPTION_BOOL, &option_direct_render},
#endif

View File

@ -130,33 +130,36 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
gg->tmprasbuf = AllocVec(width*height,MEMF_PRIVATE | MEMF_CLEAR);
gg->bm = p96AllocBitMap(width, height, 32,
BMF_INTERLEAVED, friend, RGBFB_A8R8G8B8);
BMF_INTERLEAVED, friend, RGBFB_A8R8G8B8);
if(!gg->bm) warn_user("NoMemory","");
InitRastPort(&gg->rp);
gg->rp.BitMap = gg->bm;
gg->rp = AllocVec(sizeof(struct RastPort), MEMF_PRIVATE | MEMF_CLEAR);
if(!gg->rp) warn_user("NoMemory","");
SetDrMd(&gg->rp,BGBACKFILL);
InitRastPort(gg->rp);
gg->rp->BitMap = gg->bm;
gg->rp.Layer = CreateUpfrontLayer(gg->layerinfo,gg->rp.BitMap,0,0,
/* Is all this safe to do to an existing window RastPort? */
SetDrMd(gg->rp,BGBACKFILL);
gg->rp->Layer = CreateUpfrontLayer(gg->layerinfo,gg->rp->BitMap,0,0,
width-1, height-1, LAYERSIMPLE, NULL);
InstallLayerHook(gg->rp.Layer,LAYERS_NOBACKFILL);
InstallLayerHook(gg->rp->Layer,LAYERS_NOBACKFILL);
gg->rp.AreaInfo = AllocVec(sizeof(struct AreaInfo),MEMF_PRIVATE | MEMF_CLEAR);
gg->rp->AreaInfo = AllocVec(sizeof(struct AreaInfo),MEMF_PRIVATE | MEMF_CLEAR);
if((!gg->areabuf) || (!gg->rp.AreaInfo)) warn_user("NoMemory","");
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);
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","");
if((!gg->tmprasbuf) || (!gg->rp->TmpRas)) warn_user("NoMemory","");
InitTmpRas(gg->rp.TmpRas, gg->tmprasbuf, width*height);
InitTmpRas(gg->rp->TmpRas, gg->tmprasbuf, width*height);
#ifdef NS_AMIGA_CAIRO
gg->surface = cairo_amigaos_surface_create(gg->rp.BitMap);
gg->surface = cairo_amigaos_surface_create(gg->rp->BitMap);
gg->cr = cairo_create(gg->surface);
#endif
}
@ -167,21 +170,22 @@ void ami_free_layers(struct gui_globals *gg)
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);
DeleteLayer(0,gg->rp->Layer);
FreeVec(gg->rp->TmpRas);
FreeVec(gg->rp->AreaInfo);
FreeVec(gg->tmprasbuf);
FreeVec(gg->areabuf);
DisposeLayerInfo(gg->layerinfo);
FreeVec(gg->rp);
p96FreeBitMap(gg->bm);
}
void ami_clearclipreg(struct gui_globals *gg)
{
struct Region *reg = NULL;
reg = InstallClipRegion(gg->rp.Layer,NULL);
reg = InstallClipRegion(gg->rp->Layer,NULL);
if(reg) DisposeRegion(reg);
gg->rect.MinX = 0;
@ -200,10 +204,10 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
if(option_cairo_renderer < 2)
{
SetRPAttrs(&glob->rp, RPTAG_APenColor,
SetRPAttrs(glob->rp, RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
TAG_DONE);
RectFill(&glob->rp, x0, y0, x1-1, y1-1);
RectFill(glob->rp, x0, y0, x1-1, y1-1);
}
else
{
@ -222,37 +226,37 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
if(option_cairo_renderer < 2)
{
glob->rp.PenWidth = style->stroke_width;
glob->rp.PenHeight = style->stroke_width;
glob->rp->PenWidth = style->stroke_width;
glob->rp->PenHeight = style->stroke_width;
switch (style->stroke_type) {
case PLOT_OP_TYPE_SOLID: /**< Solid colour */
default:
glob->rp.LinePtrn = PATT_LINE;
glob->rp->LinePtrn = PATT_LINE;
break;
case PLOT_OP_TYPE_DOT: /**< Doted plot */
glob->rp.LinePtrn = PATT_DOT;
glob->rp->LinePtrn = PATT_DOT;
break;
case PLOT_OP_TYPE_DASH: /**< dashed plot */
glob->rp.LinePtrn = PATT_DASH;
glob->rp->LinePtrn = PATT_DASH;
break;
}
SetRPAttrs(&glob->rp,
SetRPAttrs(glob->rp,
RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
TAG_DONE);
Move(&glob->rp, x0,y0);
Draw(&glob->rp, x1, y0);
Draw(&glob->rp, x1, y1);
Draw(&glob->rp, x0, y1);
Draw(&glob->rp, x0, y0);
Move(glob->rp, x0,y0);
Draw(glob->rp, x1, y0);
Draw(glob->rp, x1, y1);
Draw(glob->rp, x0, y1);
Draw(glob->rp, x0, y0);
glob->rp.PenWidth = 1;
glob->rp.PenHeight = 1;
glob->rp.LinePtrn = PATT_LINE;
glob->rp->PenWidth = 1;
glob->rp->PenHeight = 1;
glob->rp->LinePtrn = PATT_LINE;
}
else
{
@ -295,34 +299,34 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
if(option_cairo_renderer < 2)
{
glob->rp.PenWidth = style->stroke_width;
glob->rp.PenHeight = style->stroke_width;
glob->rp->PenWidth = style->stroke_width;
glob->rp->PenHeight = style->stroke_width;
switch (style->stroke_type) {
case PLOT_OP_TYPE_SOLID: /**< Solid colour */
default:
glob->rp.LinePtrn = PATT_LINE;
glob->rp->LinePtrn = PATT_LINE;
break;
case PLOT_OP_TYPE_DOT: /**< Doted plot */
glob->rp.LinePtrn = PATT_DOT;
glob->rp->LinePtrn = PATT_DOT;
break;
case PLOT_OP_TYPE_DASH: /**< dashed plot */
glob->rp.LinePtrn = PATT_DASH;
glob->rp->LinePtrn = PATT_DASH;
break;
}
SetRPAttrs(&glob->rp,
SetRPAttrs(glob->rp,
RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
TAG_DONE);
Move(&glob->rp,x0,y0);
Draw(&glob->rp,x1,y1);
Move(glob->rp,x0,y0);
Draw(glob->rp,x1,y1);
glob->rp.PenWidth = 1;
glob->rp.PenHeight = 1;
glob->rp.LinePtrn = PATT_LINE;
glob->rp->PenWidth = 1;
glob->rp->PenHeight = 1;
glob->rp->LinePtrn = PATT_LINE;
}
else
{
@ -373,7 +377,7 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style)
{
ULONG cx,cy;
SetRPAttrs(&glob->rp,
SetRPAttrs(glob->rp,
RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
RPTAG_OPenColor,
@ -381,15 +385,15 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style)
// RPTAG_OPenColor,0xffffffff,
TAG_DONE);
AreaMove(&glob->rp,p[0],p[1]);
AreaMove(glob->rp,p[0],p[1]);
for(k=1;k<n;k++)
{
AreaDraw(&glob->rp,p[k*2],p[(k*2)+1]);
AreaDraw(glob->rp,p[k*2],p[(k*2)+1]);
}
AreaEnd(&glob->rp);
BNDRYOFF(&glob->rp);
AreaEnd(glob->rp);
BNDRYOFF(glob->rp);
}
else
{
@ -418,7 +422,7 @@ bool ami_clip(const struct rect *clip)
struct Region *reg = NULL;
if(glob->rp.Layer)
if(glob->rp->Layer)
{
reg = NewRegion();
@ -429,7 +433,7 @@ bool ami_clip(const struct rect *clip)
OrRectRegion(reg,&glob->rect);
reg = InstallClipRegion(glob->rp.Layer,reg);
reg = InstallClipRegion(glob->rp->Layer,reg);
if(reg) DisposeRegion(reg);
}
@ -454,7 +458,7 @@ bool ami_text(int x, int y, const char *text, size_t length,
LOG(("[ami_plotter] Entered ami_text()"));
#endif
ami_unicode_text(&glob->rp,text,length,fstyle,x,y);
ami_unicode_text(glob->rp,text,length,fstyle,x,y);
return true;
}
@ -467,21 +471,21 @@ bool ami_disc(int x, int y, int radius, const plot_style_t *style)
if(option_cairo_renderer < 2)
{
if (style->fill_type != PLOT_OP_TYPE_NONE) {
SetRPAttrs(&glob->rp,
SetRPAttrs(glob->rp,
RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
TAG_DONE);
AreaCircle(&glob->rp,x,y,radius);
AreaEnd(&glob->rp);
AreaCircle(glob->rp,x,y,radius);
AreaEnd(glob->rp);
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
SetRPAttrs(&glob->rp,
SetRPAttrs(glob->rp,
RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
TAG_DONE);
DrawEllipse(&glob->rp,x,y,radius,radius);
DrawEllipse(glob->rp,x,y,radius,radius);
}
}
else
@ -536,12 +540,12 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_
/* http://www.crbond.com/primitives.htm
CommonFuncsPPC.lha */
SetRPAttrs(&glob->rp,
SetRPAttrs(glob->rp,
RPTAG_APenColor,
p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
TAG_DONE);
// DrawArc(&glob->rp,x,y,(float)angle1,(float)angle2,radius);
// DrawArc(glob->rp,x,y,(float)angle1,(float)angle2,radius);
}
return true;
}
@ -562,7 +566,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
(y > glob->rect.MaxY))
return true;
tbm = ami_getcachenativebm(bitmap,width,height,glob->rp.BitMap);
tbm = ami_getcachenativebm(bitmap,width,height,glob->rp->BitMap);
if(!tbm) return true;
@ -576,7 +580,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
if(!bitmap->opaque)
comptype = COMPOSITE_Src_Over_Dest;
CompositeTags(comptype,tbm,glob->rp.BitMap,
CompositeTags(comptype,tbm,glob->rp->BitMap,
COMPTAG_Flags,COMPFLAG_IgnoreDestAlpha,
COMPTAG_DestX,glob->rect.MinX,
COMPTAG_DestY,glob->rect.MinY,
@ -593,7 +597,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
BltBitMapTags(BLITA_Width,width,
BLITA_Height,height,
BLITA_Source,tbm,
BLITA_Dest,&glob->rp,
BLITA_Dest,glob->rp,
BLITA_DestX,x,
BLITA_DestY,y,
BLITA_SrcType,BLITT_BITMAP,
@ -635,7 +639,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
if((bitmap->opaque == false) && (bitmap->width == 1) && (bitmap->height == 1))
return true;
tbm = ami_getcachenativebm(bitmap,width,height,glob->rp.BitMap);
tbm = ami_getcachenativebm(bitmap,width,height,glob->rp->BitMap);
if(!tbm) return true;
@ -697,11 +701,11 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
bfh->h_Data = &bfbm;
}
InstallLayerHook(glob->rp.Layer,bfh);
InstallLayerHook(glob->rp->Layer,bfh);
EraseRect(&glob->rp,xm,ym,xf,yf);
EraseRect(glob->rp,xm,ym,xf,yf);
InstallLayerHook(glob->rp.Layer,LAYERS_NOBACKFILL);
InstallLayerHook(glob->rp->Layer,LAYERS_NOBACKFILL);
if(bitmap->opaque) DeleteBackFillHook(bfh);
else FreeVec(bfh);

View File

@ -28,7 +28,7 @@
struct gui_globals
{
struct BitMap *bm;
struct RastPort rp;
struct RastPort *rp;
struct Layer_Info *layerinfo;
APTR areabuf;
APTR tmprasbuf;