2008-08-02 18:31:32 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "amiga/plotters.h"
|
|
|
|
#include "amiga/gui.h"
|
|
|
|
#include "amiga/bitmap.h"
|
2008-08-10 13:57:41 +04:00
|
|
|
#include "amiga/font.h"
|
2008-08-02 18:31:32 +04:00
|
|
|
#include <proto/Picasso96API.h>
|
2008-08-07 22:44:28 +04:00
|
|
|
#include <proto/graphics.h>
|
2008-08-02 18:31:32 +04:00
|
|
|
#include <intuition/intuition.h>
|
2008-08-07 22:44:28 +04:00
|
|
|
#include <graphics/rpattr.h>
|
|
|
|
|
2008-08-10 13:57:41 +04:00
|
|
|
#include <proto/exec.h> // for debugprintf only
|
|
|
|
|
2008-08-07 22:44:28 +04:00
|
|
|
static clipx,clipy;
|
2008-08-02 18:31:32 +04:00
|
|
|
|
|
|
|
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,
|
2008-08-07 22:44:28 +04:00
|
|
|
NULL, //ami_group_start,
|
|
|
|
NULL, //ami_group_end,
|
|
|
|
ami_flush, // optional
|
2008-08-02 18:31:32 +04:00
|
|
|
ami_path
|
|
|
|
};
|
|
|
|
|
|
|
|
bool ami_clg(colour c)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("clg %lx\n",c);
|
2008-08-07 22:44:28 +04:00
|
|
|
|
|
|
|
p96RectFill(currp,0,0,clipx,clipy,
|
|
|
|
p96EncodeColor(RGBFB_A8B8G8R8,c));
|
|
|
|
|
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_rectangle(int x0, int y0, int width, int height,
|
|
|
|
int line_width, colour c, bool dotted, bool dashed)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
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);
|
|
|
|
|
2008-08-07 22:44:28 +04:00
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_line(int x0, int y0, int x1, int y1, int width,
|
|
|
|
colour c, bool dotted, bool dashed)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("line\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
|
|
|
|
TAG_DONE);
|
|
|
|
Move(currp,x0,y0);
|
|
|
|
Draw(currp,x1,y1); // NB: does not support width,dotted,dashed
|
2008-08-10 13:57:41 +04:00
|
|
|
/*There is the line pattern in the rastport, would that help? There are macros in graphics/gfxmacros.h that do it. */
|
2008-08-07 22:44:28 +04:00
|
|
|
|
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_polygon(int *p, unsigned int n, colour fill)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("poly\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_fill(int x0, int y0, int x1, int y1, colour c)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("fill\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
p96RectFill(currp,x0,y0,x1,y1,
|
|
|
|
p96EncodeColor(RGBFB_A8B8G8R8,c));
|
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_clip(int x0, int y0, int x1, int y1)
|
|
|
|
{
|
2008-08-07 22:44:28 +04:00
|
|
|
clipx=x1;
|
|
|
|
clipy=y1;
|
|
|
|
|
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_text(int x, int y, const struct css_style *style,
|
|
|
|
const char *text, size_t length, colour bg, colour c)
|
|
|
|
{
|
2008-08-07 22:44:28 +04:00
|
|
|
/* copied from css/css.h - need to open the correct font here
|
|
|
|
* font properties *
|
|
|
|
css_font_family font_family;
|
|
|
|
struct {
|
|
|
|
css_font_size_type size;
|
|
|
|
union {
|
|
|
|
struct css_length length;
|
|
|
|
float absolute;
|
|
|
|
float percent;
|
|
|
|
} value;
|
|
|
|
} font_size;
|
|
|
|
css_font_style font_style;
|
|
|
|
css_font_variant font_variant;
|
|
|
|
css_font_weight font_weight;
|
|
|
|
*/
|
2008-08-10 13:57:41 +04:00
|
|
|
ami_open_font(style);
|
2008-08-07 22:44:28 +04:00
|
|
|
|
|
|
|
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
|
|
|
|
RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
|
2008-08-10 13:57:41 +04:00
|
|
|
// RPTAG_Font,tfont,
|
2008-08-07 22:44:28 +04:00
|
|
|
TAG_DONE);
|
|
|
|
Move(currp,x,y);
|
|
|
|
Text(currp,text,length);
|
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_disc(int x, int y, int radius, colour c, bool filled)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("disc\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
|
|
|
|
TAG_DONE);
|
|
|
|
DrawEllipse(currp,x,y,radius,radius); // NB: does not support fill, need to use AreaCircle for that
|
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_arc(int x, int y, int radius, int angle1, int angle2,
|
|
|
|
colour c)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
/* http://www.crbond.com/primitives.htm
|
|
|
|
CommonFuncsPPC.lha */
|
|
|
|
DebugPrintF("arc\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_bitmap(int x, int y, int width, int height,
|
|
|
|
struct bitmap *bitmap, colour bg)
|
|
|
|
{
|
|
|
|
struct RenderInfo ri;
|
|
|
|
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("bitmap plotter\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
|
|
|
|
// ami_fill(x,y,x+width,y+height,bg);
|
|
|
|
|
2008-08-02 18:31:32 +04:00
|
|
|
ri.Memory = bitmap->pixdata;
|
2008-08-07 22:44:28 +04:00
|
|
|
ri.BytesPerRow = bitmap->width * 4;
|
2008-08-07 23:05:44 +04:00
|
|
|
ri.RGBFormat = RGBFB_R8G8B8A8;
|
2008-08-07 22:44:28 +04:00
|
|
|
|
|
|
|
p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x,y,width,height);
|
2008-08-02 18:31:32 +04:00
|
|
|
|
2008-08-07 22:44:28 +04:00
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_bitmap_tile(int x, int y, int width, int height,
|
|
|
|
struct bitmap *bitmap, colour bg,
|
|
|
|
bool repeat_x, bool repeat_y)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
struct RenderInfo ri;
|
|
|
|
|
|
|
|
DebugPrintF("bitmap tile plotter\n");
|
|
|
|
/* not implemented properly - needs to tile! */
|
|
|
|
|
|
|
|
ri.Memory = bitmap->pixdata;
|
|
|
|
ri.BytesPerRow = bitmap->width * 4;
|
|
|
|
ri.RGBFormat = RGBFB_R8G8B8A8;
|
|
|
|
|
|
|
|
p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x,y,width,height);
|
|
|
|
|
2008-08-07 22:44:28 +04:00
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_group_start(const char *name)
|
|
|
|
{
|
|
|
|
/** optional */
|
2008-08-07 22:44:28 +04:00
|
|
|
return false;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_group_end(void)
|
|
|
|
{
|
|
|
|
/** optional */
|
2008-08-07 22:44:28 +04:00
|
|
|
return false;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_flush(void)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("flush\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ami_path(float *p, unsigned int n, colour fill, float width,
|
|
|
|
colour c, float *transform)
|
|
|
|
{
|
2008-08-10 13:57:41 +04:00
|
|
|
DebugPrintF("path\n");
|
2008-08-07 22:44:28 +04:00
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|