/* * Copyright 2008 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * * NetSurf is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * NetSurf is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "amiga/plotters.h" #include "amiga/gui.h" #include "amiga/bitmap.h" #include "amiga/font.h" #include #include #include #include #include #include "amiga/utf8.h" #include // for debugprintf only static clipx0=0,clipx1=0,clipy0=0,clipy1=0; #define PATT_DOT 0xAAAA #define PATT_DASH 0xCCCC #define PATT_LINE 0xFFFF struct plotter_table plot; const struct plotter_table amiplot = { ami_clg, ami_rectangle, ami_line, ami_polygon, ami_fill, ami_clip, ami_text, ami_disc, ami_arc, ami_bitmap, ami_bitmap_tile, NULL, //ami_group_start, NULL, //ami_group_end, 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; currp->LinePtrn = PATT_LINE; if(dotted) currp->LinePtrn = PATT_DOT; if(dashed) currp->LinePtrn = PATT_DASH; SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c), TAG_DONE); Move(currp,x0,y0); Draw(currp,x0+width,y0); Draw(currp,x0+width,y0+height); Draw(currp,x0,y0+height); Draw(currp,x0,y0); currp->PenWidth = 1; currp->PenHeight = 1; currp->LinePtrn = PATT_LINE; return true; } 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; currp->LinePtrn = PATT_LINE; if(dotted) currp->LinePtrn = PATT_DOT; if(dashed) currp->LinePtrn = PATT_DASH; SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c), TAG_DONE); Move(currp,x0,y0); Draw(currp,x1,y1); currp->PenWidth = 1; currp->PenHeight = 1; currp->LinePtrn = PATT_LINE; return true; } bool ami_polygon(int *p, unsigned int n, colour fill) { int k; ULONG cx,cy; DebugPrintF("poly\n"); SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,fill), TAG_DONE); Move(currp,p[0],p[1]); for(k=1;kwidth,bitmap->height); /* needs to also scale */ // ami_fill(x,y,x+width,y+height,bg); SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg), TAG_DONE); ri.Memory = bitmap->pixdata; ri.BytesPerRow = bitmap->width * 4; ri.RGBFormat = RGBFB_R8G8B8A8; p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x,y,width,height); return true; } bool ami_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, bool repeat_x, bool repeat_y, struct content *content) { struct RenderInfo ri; ULONG xf,yf,wf,hf; DebugPrintF("bitmap tile plotter\n"); SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg), TAG_DONE); ri.Memory = bitmap->pixdata; ri.BytesPerRow = bitmap->width * 4; ri.RGBFormat = RGBFB_R8G8B8A8; /* if(repeat_x) printf("repeatx\n"); if(repeat_y) printf("repeaty\n"); */ for(xf=0;xfwidth) { for(yf=0;yfheight) { if(width > xf+bitmap->width) { wf = width-(xf+bitmap->width); } else { wf=bitmap->width; } if(height > yf+bitmap->height) { hf = height-(yf+bitmap->height); } else { 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); } } return true; } bool ami_group_start(const char *name) { /** optional */ return false; } bool ami_group_end(void) { /** optional */ return false; } bool ami_flush(void) { DebugPrintF("flush\n"); return true; } bool ami_path(float *p, unsigned int n, colour fill, float width, colour c, float *transform) { DebugPrintF("path\n"); return true; }