summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-30 16:57:35 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-30 16:57:35 +0000
commit277262bf46571df9f542b21543829b10344e719d (patch)
tree0e39c19562f5b604006402ea629e87653ddccdbd /amiga
parent35befab994bff3736579fa0dcd096918f8516d05 (diff)
downloadnetsurf-277262bf46571df9f542b21543829b10344e719d.tar.gz
netsurf-277262bf46571df9f542b21543829b10344e719d.tar.bz2
Added support for scaling bitmaps, filled polygons, filled circles and clipping.
Fixes major display issues with eg. www.bbc.co.uk amongst others. svn path=/trunk/netsurf/; revision=5221
Diffstat (limited to 'amiga')
-rwxr-xr-xamiga/gui.c115
-rwxr-xr-xamiga/gui.h9
-rwxr-xr-xamiga/plotters.c131
3 files changed, 174 insertions, 81 deletions
diff --git a/amiga/gui.c b/amiga/gui.c
index 989849dd3..6a1573b59 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -472,23 +472,55 @@ void ami_get_msg(void)
switch(subnum)
{
BPTR fh=0;
+ char fname[1024];
case 0:
- save_as_text(gwin->bw->current_content,"ram:ns_text");
+ if(AslRequestTags(filereq,
+ ASLFR_TitleText,messages_get("NetSurf"),
+ ASLFR_Screen,scrn,
+ ASLFR_DoSaveMode,TRUE,
+ ASLFR_InitialFile,FilePart(gwin->bw->current_content->url),
+ TAG_DONE))
+ {
+ strlcpy(&fname,filereq->fr_Drawer,1024);
+ AddPart(&fname,filereq->fr_File,1024);
+ save_as_text(gwin->bw->current_content,&fname);
+ }
break;
case 1:
- if(fh = FOpen("ram:ns_source",MODE_NEWFILE,0))
+ if(AslRequestTags(filereq,
+ ASLFR_TitleText,messages_get("NetSurf"),
+ ASLFR_Screen,scrn,
+ ASLFR_DoSaveMode,TRUE,
+ ASLFR_InitialFile,FilePart(gwin->bw->current_content->url),
+ TAG_DONE))
{
- FWrite(fh,gwin->bw->current_content->source_data,1,gwin->bw->current_content->source_size);
- FClose(fh);
+ strlcpy(&fname,filereq->fr_Drawer,1024);
+ AddPart(&fname,filereq->fr_File,1024);
+ if(fh = FOpen(&fname,MODE_NEWFILE,0))
+ {
+ FWrite(fh,gwin->bw->current_content->source_data,1,gwin->bw->current_content->source_size);
+ FClose(fh);
+ }
}
break;
case 2:
#ifdef WITH_PDF_EXPORT
- pdf_set_scale(DEFAULT_EXPORT_SCALE);
- save_as_pdf(gwin->bw->current_content,"ram:ns_pdf");
+ if(AslRequestTags(filereq,
+ ASLFR_TitleText,messages_get("NetSurf"),
+ ASLFR_Screen,scrn,
+ ASLFR_DoSaveMode,TRUE,
+ ASLFR_InitialFile,FilePart(gwin->bw->current_content->url),
+ TAG_DONE))
+ {
+ strlcpy(&fname,filereq->fr_Drawer,1024);
+ AddPart(&fname,filereq->fr_File,1024);
+ save_as_text(gwin->bw->current_content,&fname);
+ pdf_set_scale(DEFAULT_EXPORT_SCALE);
+ save_as_pdf(gwin->bw->current_content,&fname);
+ }
#endif
break;
}
@@ -927,6 +959,16 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
gwin->rp.BitMap = gwin->bm;
SetDrMd(currp,BGBACKFILL);
+ gwin->layerinfo = NewLayerInfo();
+ gwin->rp.Layer = CreateUpfrontLayer(gwin->layerinfo,gwin->bm,0,0,scrn->Width-1,scrn->Height-1,0,NULL);
+
+ gwin->areabuf = AllocVec(100,MEMF_CLEAR);
+ gwin->rp.AreaInfo = AllocVec(sizeof(struct AreaInfo),MEMF_CLEAR);
+ InitArea(gwin->rp.AreaInfo,gwin->areabuf,100/5);
+ gwin->rp.TmpRas = AllocVec(sizeof(struct TmpRas),MEMF_CLEAR);
+ gwin->tmprasbuf = AllocVec(scrn->Width*scrn->Height,MEMF_CLEAR);
+ InitTmpRas(gwin->rp.TmpRas,gwin->tmprasbuf,scrn->Width*scrn->Height);
+
GetRPAttrs(&gwin->rp,RPTAG_Font,&origrpfont,TAG_DONE);
GetAttr(WINDOW_HorizObject,gwin->objects[OID_MAIN],(ULONG *)&gwin->objects[OID_HSCROLL]);
@@ -960,7 +1002,13 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
void gui_window_destroy(struct gui_window *g)
{
DisposeObject(g->objects[OID_MAIN]);
+ DeleteLayer(0,g->rp.Layer);
+ DisposeLayerInfo(g->layerinfo);
p96FreeBitMap(g->bm);
+ FreeVec(g->rp.TmpRas);
+ FreeVec(g->rp.AreaInfo);
+ FreeVec(g->tmprasbuf);
+ FreeVec(g->areabuf);
DelObject(g->node);
// FreeVec(g); should be freed by DelObject()
@@ -981,7 +1029,7 @@ void gui_window_set_title(struct gui_window *g, const char *title)
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
{
- DebugPrintF("REDRAW\n");
+// DebugPrintF("REDRAW\n");
}
void gui_window_redraw_window(struct gui_window *g)
@@ -1001,7 +1049,7 @@ void gui_window_update_box(struct gui_window *g,
GetAttr(SCROLLER_Top,g->objects[OID_HSCROLL],&hcurrent);
GetAttr(SCROLLER_Top,g->objects[OID_VSCROLL],&vcurrent);
- DebugPrintF("DOING REDRAW\n");
+// DebugPrintF("DOING REDRAW\n");
c = g->bw->current_content;
@@ -1049,16 +1097,17 @@ void gui_window_update_box(struct gui_window *g,
void ami_do_redraw(struct gui_window *g)
{
+ struct Region *reg = NULL;
+ struct Rectangle rect;
struct content *c;
ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
struct IBox *bbox;
- struct Region *region;
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
GetAttr(SCROLLER_Top,g->objects[OID_HSCROLL],&hcurrent);
GetAttr(SCROLLER_Top,g->objects[OID_VSCROLL],&vcurrent);
- DebugPrintF("DOING REDRAW\n");
+// DebugPrintF("DOING REDRAW\n");
c = g->bw->current_content;
@@ -1068,14 +1117,22 @@ void ami_do_redraw(struct gui_window *g)
current_redraw_browser = g->bw;
currp = &g->rp;
+
/*
- layerinfo = NewLayerInfo();
- layer = CreateLayer(layerinfo,LAYA_BitMap,g->bm,LAYA_StayTop,TRUE,
-LAYA_MinX,0,LAYA_MinY,0,LAYA_MaxX,1024,LAYA_MaxY,768,TAG_DONE);
- currp = layer->rp;
-// region = NewRegion();
-// InstallClipRegion(layer,region);
+ reg = NewRegion();
+
+ rect.MinX = 0;
+ rect.MinY = 0;
+ rect.MaxX = 1023;
+ rect.MaxY = 767;
+
+ OrRectRegion(reg,&rect);
+
+ InstallClipRegion(g->rp.Layer,reg);
*/
+
+// currp = g->rp.Layer->rp;
+
width=bbox->Width;
height=bbox->Height;
xoffset=bbox->Left;
@@ -1110,16 +1167,18 @@ LAYA_MinX,0,LAYA_MinY,0,LAYA_MaxX,1024,LAYA_MaxY,768,TAG_DONE);
current_redraw_browser = NULL;
currp = &dummyrp;
-/*
-// InstallClipRegion(layer,NULL);
-// DisposeRegion(region);
- DeleteLayer(0,layer);
- DisposeLayerInfo(layerinfo);
-*/
+
+
ami_update_buttons(g);
BltBitMapRastPort(g->bm,0,0,g->win->RPort,xoffset,yoffset,width,height,0x0C0);
+ reg = InstallClipRegion(g->rp.Layer,NULL);
+ if(reg) DisposeRegion(reg);
+
+// DeleteLayer(0,g->rp.Layer);
+/**/
+
g->redraw_required = false;
g->redraw_data = NULL;
}
@@ -1263,16 +1322,18 @@ void gui_window_remove_caret(struct gui_window *g)
void gui_window_new_content(struct gui_window *g)
{
- DebugPrintF("new content\n");
+// DebugPrintF("new content\n");
}
bool gui_window_scroll_start(struct gui_window *g)
{
+ DebugPrintF("scroll start\n");
}
bool gui_window_box_scroll_start(struct gui_window *g,
int x0, int y0, int x1, int y1)
{
+ DebugPrintF("box scroll start\n");
}
bool gui_window_frame_resize_start(struct gui_window *g)
@@ -1293,7 +1354,7 @@ struct gui_download_window *gui_download_window_create(const char *url,
const char *mime_type, struct fetch *fetch,
unsigned int total_size, struct gui_window *gui)
{
- char *fname = AllocVec(1024,MEMF_CLEAR);
+ char fname[1024];
struct gui_download_window *dw;
APTR va[3];
@@ -1304,8 +1365,8 @@ struct gui_download_window *gui_download_window_create(const char *url,
ASLFR_InitialFile,FilePart(url),
TAG_DONE))
{
- strlcpy(fname,filereq->fr_Drawer,1024);
- AddPart(fname,filereq->fr_File,1024);
+ strlcpy(&fname,filereq->fr_Drawer,1024);
+ AddPart(&fname,filereq->fr_File,1024);
}
else return NULL;
@@ -1318,7 +1379,7 @@ struct gui_download_window *gui_download_window_create(const char *url,
va[1] = dw->size;
va[2] = 0;
- if(!(dw->fh = FOpen(fname,MODE_NEWFILE,0)))
+ if(!(dw->fh = FOpen(&fname,MODE_NEWFILE,0)))
{
FreeVec(dw);
return NULL;
diff --git a/amiga/gui.h b/amiga/gui.h
index a138cda6d..0bb1a352b 100755
--- a/amiga/gui.h
+++ b/amiga/gui.h
@@ -55,7 +55,7 @@ struct gui_download_window {
Object *objects[OID_LAST];
struct Gadget *gadgets[GID_LAST];
struct nsObject *node;
- bool pad;
+ ULONG pad[2];
BPTR fh;
uint32 size;
uint32 downloaded;
@@ -67,9 +67,13 @@ struct gui_window {
struct Gadget *gadgets[GID_LAST];
struct nsObject *node;
bool redraw_required;
+ struct List *tab_bw_list;
struct browser_window *bw;
struct BitMap *bm;
struct RastPort rp;
+ struct Layer_Info *layerinfo;
+ APTR areabuf;
+ APTR tmprasbuf;
struct Hook scrollerhook;
struct Hook popuphook;
struct form_control *control;
@@ -80,9 +84,6 @@ struct gui_window {
int c_h;
};
-//struct gui_window *curwin;
struct RastPort *currp;
struct TextFont *origrpfont;
-struct Layer *layer;
-struct Layer_Info *layerinfo;
#endif
diff --git a/amiga/plotters.c b/amiga/plotters.c
index 57f37e0aa..38b572607 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -26,10 +26,7 @@
#include <graphics/rpattr.h>
#include <graphics/gfxmacros.h>
#include "amiga/utf8.h"
-
-#include <proto/exec.h> // for debugprintf only
-
-static clipx0=0,clipx1=0,clipy0=0,clipy1=0;
+#include <proto/layers.h>
#define PATT_DOT 0xAAAA
#define PATT_DASH 0xCCCC
@@ -50,33 +47,24 @@ const struct plotter_table amiplot = {
ami_bitmap_tile,
NULL, //ami_group_start,
NULL, //ami_group_end,
- ami_flush, // optional
+ NULL, //ami_flush, // optional
ami_path,
true // option_knockout
};
bool ami_clg(colour c)
{
- DebugPrintF("clg %lx\n",c);
-
SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
TAG_DONE);
ClearScreen(currp);
-/*
- p96RectFill(currp,clipx0,clipy0,clipx1,clipy1,
- p96EncodeColor(RGBFB_A8B8G8R8,c));
-*/
-
return true;
}
bool ami_rectangle(int x0, int y0, int width, int height,
int line_width, colour c, bool dotted, bool dashed)
{
- DebugPrintF("rect\n");
-
currp->PenWidth = line_width;
currp->PenHeight = line_width;
@@ -102,8 +90,6 @@ bool ami_rectangle(int x0, int y0, int width, int height,
bool ami_line(int x0, int y0, int x1, int y1, int width,
colour c, bool dotted, bool dashed)
{
- DebugPrintF("line\n");
-
currp->PenWidth = width;
currp->PenHeight = width;
@@ -128,24 +114,28 @@ bool ami_polygon(int *p, unsigned int n, colour fill)
int k;
ULONG cx,cy;
- DebugPrintF("poly\n");
+ //DebugPrintF("poly\n");
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,fill),
+ RPTAG_OPenColor,p96EncodeColor(RGBFB_A8B8G8R8,fill),
TAG_DONE);
- Move(currp,p[0],p[1]);
+ AreaMove(currp,p[0],p[1]);
for(k=1;k<n;k++)
{
- Draw(currp,p[k*2],p[(k*2)+1]);
+ AreaDraw(currp,p[k*2],p[(k*2)+1]);
}
+ AreaEnd(currp);
+ BNDRYOFF(currp);
+
return true;
}
bool ami_fill(int x0, int y0, int x1, int y1, colour c)
{
- DebugPrintF("fill %ld,%ld,%ld,%ld\n",x0,y0,x1,y1);
+ //DebugPrintF("fill %ld,%ld,%ld,%ld\n",x0,y0,x1,y1);
p96RectFill(currp,x0,y0,x1,y1,
p96EncodeColor(RGBFB_A8B8G8R8,c));
@@ -155,13 +145,24 @@ bool ami_fill(int x0, int y0, int x1, int y1, colour c)
bool ami_clip(int x0, int y0, int x1, int y1)
{
-/* to do - need to actually clip to this region using layers.library */
+ struct Region *reg = NULL;
+ struct Rectangle rect;
- DebugPrintF("clip\n");
- clipx0=x0;
- clipy0=y0;
- clipx1=x1;
- clipy1=y1;
+ if(currp->Layer)
+ {
+ reg = NewRegion();
+
+ rect.MinX = x0;
+ rect.MinY = y0;
+ rect.MaxX = x1-1;
+ rect.MaxY = y1-1;
+
+ OrRectRegion(reg,&rect);
+
+ reg = InstallClipRegion(currp->Layer,reg);
+
+ if(reg) DisposeRegion(reg);
+ }
return true;
}
@@ -174,18 +175,22 @@ bool ami_text(int x, int y, const struct css_style *style,
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
-// RPTAG_OPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
// RPTAG_Font,tfont,
TAG_DONE);
utf8_to_local_encoding(text,length,&buffer);
-// ami_utf8_to_any(text,length,&buffer);
if(!buffer) return true;
+/* Below function prints Unicode text direct to the RastPort.
+ * This is commented out due to lack of SDK which allows me to perform blits
+ * that respect the Alpha channel. The code below that (and above) convert to
+ * system default charset and write the text using graphics.library functions.
+ *
+ * ami_unicode_text(currp,text,length,style,x,y,c);
+ */
Move(currp,x,y);
Text(currp,buffer,strlen(buffer));
-// Text(currp,text,length);
ami_close_font(tfont);
ami_utf8_free(buffer);
@@ -195,24 +200,18 @@ bool ami_text(int x, int y, const struct css_style *style,
bool ami_disc(int x, int y, int radius, colour c, bool filled)
{
- struct AreaInfo ai;
- APTR buf[10];
-
- DebugPrintF("disc\n");
-
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
TAG_DONE);
-/* see rkrm
if(filled)
{
-// InitArea(&ai,&buf,2);
AreaCircle(currp,x,y,radius);
-// AreaEnd(currp);
+ AreaEnd(currp);
+ }
+ else
+ {
+ DrawEllipse(currp,x,y,radius,radius); // NB: does not support fill, need to use AreaCircle for that
}
-*/
-
- DrawEllipse(currp,x,y,radius,radius); // NB: does not support fill, need to use AreaCircle for that
return true;
}
@@ -222,7 +221,12 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2,
{
/* http://www.crbond.com/primitives.htm
CommonFuncsPPC.lha */
- DebugPrintF("arc\n");
+ //DebugPrintF("arc\n");
+
+ SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
+ TAG_DONE);
+
+// DrawArc(currp,x,y,(float)angle1,(float)angle2,radius);
return true;
}
@@ -232,10 +236,6 @@ bool ami_bitmap(int x, int y, int width, int height,
{
struct RenderInfo ri;
-DebugPrintF("bitmap plotter %ld %ld %ld %ld (%ld %ld)\n",x,y,width,height,bitmap->width,bitmap->height);
-
-/* needs to also scale */
-
// ami_fill(x,y,x+width,y+height,bg);
SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
@@ -245,7 +245,39 @@ DebugPrintF("bitmap plotter %ld %ld %ld %ld (%ld %ld)\n",x,y,width,height,bitmap
ri.BytesPerRow = bitmap->width * 4;
ri.RGBFormat = RGBFB_R8G8B8A8;
- p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x,y,width,height);
+ if((bitmap->width != width) || (bitmap->height != height))
+ {
+ struct BitMap *tbm;
+ struct RastPort trp;
+ struct BitScaleArgs bsa;
+
+ tbm = p96AllocBitMap(bitmap->width,bitmap->height,32,0,currp->BitMap,RGBFB_R8G8B8A8);
+ InitRastPort(&trp);
+ trp.BitMap = tbm;
+ p96WritePixelArray((struct RenderInfo *)&ri,0,0,&trp,0,0,bitmap->width,bitmap->height);
+ bsa.bsa_SrcX = 0;
+ bsa.bsa_SrcY = 0;
+ bsa.bsa_SrcWidth = bitmap->width;
+ bsa.bsa_SrcHeight = bitmap->height;
+ bsa.bsa_DestX = x;
+ bsa.bsa_DestY = y;
+ bsa.bsa_DestWidth = width;
+ bsa.bsa_DestHeight = height;
+ bsa.bsa_XSrcFactor = bitmap->width;
+ bsa.bsa_XDestFactor = width;
+ bsa.bsa_YSrcFactor = bitmap->height;
+ bsa.bsa_YDestFactor = height;
+ bsa.bsa_SrcBitMap = tbm;
+ bsa.bsa_DestBitMap = currp->BitMap;
+ bsa.bsa_Flags = 0;
+
+ BitMapScale(&bsa);
+ p96FreeBitMap(tbm);
+ }
+ else
+ {
+ p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x,y,width,height);
+ }
return true;
}
@@ -257,7 +289,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
struct RenderInfo ri;
ULONG xf,yf,wf,hf;
-DebugPrintF("bitmap tile plotter\n");
+//DebugPrintF("bitmap tile plotter\n");
SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
TAG_DONE);
@@ -292,7 +324,6 @@ if(repeat_y) printf("repeaty\n");
hf=bitmap->height;
}
-//printf("%ld %ld %ld\n",xf,width,bitmap->width);
p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x+xf,y+yf,wf,hf);
}
}
@@ -314,13 +345,13 @@ bool ami_group_end(void)
bool ami_flush(void)
{
- DebugPrintF("flush\n");
+ //DebugPrintF("flush\n");
return true;
}
bool ami_path(float *p, unsigned int n, colour fill, float width,
colour c, float *transform)
{
- DebugPrintF("path\n");
+/* Not implemented yet - unable to locate website which requires this plotter! */
return true;
}