21#include <proto/exec.h>
22#include <proto/intuition.h>
23#include <proto/layers.h>
24#include <proto/graphics.h>
26#include <intuition/intuition.h>
27#include <graphics/rpattr.h>
28#include <graphics/gfxmacros.h>
29#include <graphics/gfxbase.h>
32#include <graphics/blitattr.h>
33#include <graphics/composite.h>
101#define M_PI 3.14159265358979323846
104#define PATT_DOT 0xAAAA
105#define PATT_DASH 0xCCCC
106#define PATT_LINE 0xFFFF
111#define AREA_SIZE 25000
117 struct BitMap *
friend = NULL;
122 if(force32bit ==
false) depth = GetBitMapAttr(
scrn->RastPort.BitMap, BMA_DEPTH);
123 NSLOG(netsurf, INFO,
"Screen depth = %d", depth);
135 NSLOG(netsurf, INFO,
"Set bitmap format to 0xAARRGGBB (native endian) (PMA)");
145 NSLOG(netsurf, INFO,
"Set bitmap format to 0xAARRGGBB (native endian)");
154 NSLOG(netsurf, INFO,
"Set bitmap format to 0xAARRGGBB (native endian) (PMA)");
163 friend =
scrn->RastPort.BitMap;
167 if((depth > 8) && (force32bit ==
false))
friend =
scrn->RastPort.BitMap;
202 if((depth >= 24) && (force32bit ==
false))
friend =
scrn->RastPort.BitMap;
209 gg->
rp = malloc(
sizeof(
struct RastPort));
212 InitRastPort(gg->
rp);
213 gg->
rp->BitMap = gg->
bm;
217 gg->
rp->Layer = CreateUpfrontLayer(gg->
layerinfo,gg->
rp->BitMap,0,0,
220 InstallLayerHook(gg->
rp->Layer,LAYERS_NOBACKFILL);
222 gg->
rp->AreaInfo = malloc(
sizeof(
struct AreaInfo));
227 gg->
rp->TmpRas = malloc(
sizeof(
struct TmpRas));
240 if(alloc_pen_list ==
true) {
246 gg->
apen = 0x00000000;
247 gg->
open = 0x00000000;
252 NSLOG(netsurf, INFO,
"Layer initialised (total: %d)",
270 if(gg->
rp->Layer != NULL) DeleteLayer(0, gg->
rp->Layer);
271 free(gg->
rp->TmpRas);
272 free(gg->
rp->AreaInfo);
313 struct Region *reg = NULL;
316 reg = InstallClipRegion(gg->
rp->Layer,NULL);
317 if(reg) DisposeRegion(reg);
324 gg->
apen = 0x00000000;
325 gg->
open = 0x00000000;
335 LONG pen = ObtainBestPenA(
scrn->ViewPort.ColorMap,
336 (colr & 0x000000ff) << 24,
337 (colr & 0x0000ff00) << 16,
338 (colr & 0x00ff0000) << 8,
341 if(pen == -1)
NSLOG(netsurf, INFO,
342 "WARNING: Cannot allocate pen for ABGR:%lx", colr);
344 if((shared_pens != NULL) && (
pool_pens != NULL)) {
347 AddTail((
struct List *)shared_pens, (
struct Node *)node);
351 ReleasePen(
scrn->ViewPort.ColorMap, pen);
362 if(shared_pens == NULL)
return;
368 ReleasePen(
scrn->ViewPort.ColorMap,
node->pen);
369 Remove((
struct Node *)
node);
371 }
while((
node = nnode));
376 if(glob->
apen == colr)
return;
395 if(glob->
open == colr)
return;
399 SetRPAttrs(rp, RPTAG_OPenColor,
414 if((bbox == NULL) || (rp == NULL))
return;
416 EraseRect(rp, bbox->Left, bbox->Top,
417 bbox->Width + bbox->Left, bbox->Height + bbox->Top);
421static void ami_arc_gfxlib(
struct RastPort *rp,
int x,
int y,
int radius,
int angle1,
int angle2)
423 float angle1_r = (float)(angle1) * (
M_PI / 180.0);
424 float angle2_r = (float)(angle2) * (
M_PI / 180.0);
435 x1 = (int)(cos(b) * (float)radius);
436 y1 = (int)(sin(b) * (float)radius);
437 Move(rp, x0 + x1, y0 - y1);
439 for(angle = (b + step); angle <= c; angle += step) {
440 x1 = (int)(cos(angle) * (float)radius);
441 y1 = (int)(sin(angle) * (float)radius);
442 Draw(rp, x0 + x1, y0 - y1);
451 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_bitmap()");
461 (x > glob->
rect.MaxX) ||
462 (y > glob->
rect.MaxY)) {
471 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] ami_bitmap() got native bitmap");
474 if (__builtin_expect((GfxBase->LibNode.lib_Version >= 53) &&
476 uint32 comptype = COMPOSITE_Src_Over_Dest;
477 uint32 compflags = COMPFLAG_IgnoreDestAlpha;
479 compflags |= COMPFLAG_SrcAlphaOverride;
480 comptype = COMPOSITE_Src;
483 CompositeTags(comptype,tbm,glob->
rp->BitMap,
484 COMPTAG_Flags, compflags,
485 COMPTAG_DestX,glob->
rect.MinX,
486 COMPTAG_DestY,glob->
rect.MinY,
487 COMPTAG_DestWidth,glob->
rect.MaxX - glob->
rect.MinX + 1,
488 COMPTAG_DestHeight,glob->
rect.MaxY - glob->
rect.MinY + 1,
489 COMPTAG_SrcWidth,
width,
493 COMPTAG_FriendBitMap,
scrn->RastPort.BitMap,
498 ULONG tag, tag_data, minterm = 0xc0;
510 BltBitMapTags(BLITA_Width,
width,
516 BLITA_SrcType,BLITT_BITMAP,
517 BLITA_DestType,BLITT_RASTPORT,
518 BLITA_Minterm, minterm,
523 BltMaskBitMapRastPort(tbm, 0, 0, glob->
rp, x, y,
width,
height, minterm, tag_data);
525 BltBitMapRastPort(tbm, 0, 0, glob->
rp, x, y,
width,
height, 0xc0);
545 for (xf = -bfbm->
offsetx; xf < msg->Bounds.MaxX; xf += bfbm->
width) {
546 for (yf = -bfbm->
offsety; yf < msg->Bounds.MaxY; yf += bfbm->
height) {
548 if(__builtin_expect((GfxBase->LibNode.lib_Version >= 53) &&
550 CompositeTags(COMPOSITE_Src_Over_Dest, bfbm->
bm, rp->BitMap,
551 COMPTAG_Flags, COMPFLAG_IgnoreDestAlpha,
552 COMPTAG_DestX, msg->Bounds.MinX,
553 COMPTAG_DestY, msg->Bounds.MinY,
554 COMPTAG_DestWidth, msg->Bounds.MaxX - msg->Bounds.MinX + 1,
555 COMPTAG_DestHeight, msg->Bounds.MaxY - msg->Bounds.MinY + 1,
556 COMPTAG_SrcWidth, bfbm->
width,
557 COMPTAG_SrcHeight, bfbm->
height,
560 COMPTAG_FriendBitMap,
scrn->RastPort.BitMap,
565 ULONG tag, tag_data, minterm = 0xc0;
573 if((tag_data = (ULONG)bfbm->
mask))
577 BltBitMapTags(BLITA_Width, bfbm->
width,
578 BLITA_Height, bfbm->
height,
579 BLITA_Source, bfbm->
bm,
583 BLITA_SrcType, BLITT_BITMAP,
584 BLITA_DestType, BLITT_RASTPORT,
585 BLITA_Minterm, minterm,
590 BltMaskBitMapRastPort(bfbm->
bm, 0, 0, rp, xf, yf,
593 BltBitMapRastPort(bfbm->
bm, 0, 0, rp, xf, yf,
605 p->x = pow((1 - t), 3) * a->x + 3 * t * pow((1 -t), 2) * b->x + 3 * (1-t) * pow(t, 2)* c->x + pow (t, 3)* d->x;
606 p->y = pow((1 - t), 3) * a->y + 3 * t * pow((1 -t), 2) * b->y + 3 * (1-t) * pow(t, 2)* c->y + pow (t, 3)* d->y;
629 struct Region *reg = NULL;
631 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_clip()");
633 if (glob->
rp->Layer) {
641 OrRectRegion(reg,&glob->
rect);
643 reg = InstallClipRegion(glob->
rp->Layer,reg);
673 int x,
int y,
int radius,
int angle1,
int angle2)
675 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_arc()");
679 if (angle2 < angle1) {
705 int x,
int y,
int radius)
707 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_disc()");
713 AreaCircle(glob->
rp,x,y,radius);
719 DrawEllipse(glob->
rp,x,y,radius,radius);
742 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_line()");
768 glob->
rp->PenWidth = 1;
769 glob->
rp->PenHeight = 1;
794 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_rectangle()");
829 glob->
rp->PenWidth = 1;
830 glob->
rp->PenHeight = 1;
858 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_polygon()");
864 if (AreaMove(glob->
rp,p[0],p[1]) == -1) {
865 NSLOG(netsurf, INFO,
"AreaMove: vector list full");
868 for (
uint32 k = 1; k < n; k++) {
869 if (AreaDraw(glob->
rp,p[k*2],p[(k*2)+1]) == -1) {
870 NSLOG(netsurf, INFO,
"AreaDraw: vector list full");
874 if (AreaEnd(glob->
rp) == -1) {
875 NSLOG(netsurf, INFO,
"AreaEnd: error");
900 const float transform[6])
903 struct bez_point start_p = {0, 0}, cur_p = {0, 0}, p_a, p_b, p_c, p_r;
905 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_path()");
914 NSLOG(netsurf, INFO,
"Path does not start with move");
932 for (i = 0; i < n; ) {
935 if (AreaMove(glob->
rp, p[i+1], p[i+2]) == -1) {
937 "AreaMove: vector list full");
940 Move(glob->
rp, p[i+1], p[i+2]);
950 if (AreaEnd(glob->
rp) == -1) {
951 NSLOG(netsurf, INFO,
"AreaEnd: error");
954 Draw(glob->
rp, start_p.
x, start_p.
y);
959 if (AreaDraw(glob->
rp, p[i+1], p[i+2]) == -1) {
961 "AreaDraw: vector list full");
964 Draw(glob->
rp, p[i+1], p[i+2]);
977 for (
float t = 0.0; t <= 1.0; t += 0.1) {
978 ami_bezier(&cur_p, &p_a, &p_b, &p_c, t, &p_r);
980 if (AreaDraw(glob->
rp, p_r.x, p_r.y) == -1) {
982 "AreaDraw: vector list full");
985 Draw(glob->
rp, p_r.x, p_r.y);
992 NSLOG(netsurf, INFO,
"bad path command %f", p[i]);
1042 int xf,yf,xm,ym,oy,ox;
1043 struct BitMap *tbm = NULL;
1044 struct Hook *bfh = NULL;
1049 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_bitmap_tile()");
1057 if (!(repeat_x || repeat_y)) {
1077 for (; ox > 0; ox -=
width)
1080 for (; oy > 0; oy -=
height);
1089 xf = glob->
rect.MaxX;
1090 xm = glob->
rect.MinX;
1097 yf = glob->
rect.MaxY;
1098 ym = glob->
rect.MinY;
1105 bfh = CreateBackFillHook(BFHA_BitMap,tbm,
1121 bfh = calloc(1,
sizeof(
struct Hook));
1122 bfh->h_Entry = (HOOKFUNC)ami_bitmap_tile_hook;
1123 bfh->h_SubEntry = 0;
1124 bfh->h_Data = &bfbm;
1127 InstallLayerHook(glob->
rp->Layer,bfh);
1128 EraseRect(glob->
rp,xm,ym,xf,yf);
1129 InstallLayerHook(glob->
rp->Layer,LAYERS_NOBACKFILL);
1133 DeleteBackFillHook(bfh);
1166 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_text()");
1170 if (__builtin_expect(
ami_nsfont == NULL, 0)) {
1190 .option_knockout =
true,
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
static struct Screen * scrn
nserror amiga_warn_user(const char *warning, const char *detail)
Warn the user of an event.
const struct plotter_table amiplot
bool ami_plot_screen_is_palettemapped(void)
void ami_plot_ra_free(struct gui_globals *gg)
Free a plotter render area.
static nserror ami_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
struct BitMap * ami_plot_ra_get_bitmap(struct gui_globals *gg)
Get a drawing BitMap associated with a render area.
void ami_plot_clear_bbox(struct RastPort *rp, struct IBox *bbox)
static bool palette_mapped
HOOKF(void, ami_bitmap_tile_hook, struct RastPort *, rp, struct BackFillMessage *)
static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr)
static nserror ami_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
static nserror ami_arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
static void ami_bezier(struct bez_point *restrict a, struct bez_point *restrict b, struct bez_point *restrict c, struct bez_point *restrict d, float t, struct bez_point *restrict p)
struct RastPort * ami_plot_ra_get_rastport(struct gui_globals *gg)
Get RastPort associated with a render area.
static nserror ami_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
static nserror ami_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
void ami_plot_ra_set_pen_list(struct gui_globals *gg, struct MinList *pen_list)
Set a list of shared pens for a render area to use Only relevant for palette-mapped screens.
void ami_plot_ra_get_size(struct gui_globals *gg, int *width, int *height)
Get size of BitMap associated with a render area.
static void ami_plot_setopen(struct gui_globals *glob, struct RastPort *rp, ULONG colr)
static nserror ami_path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static void ami_arc_gfxlib(struct RastPort *rp, int x, int y, int radius, int angle1, int angle2)
static void ami_plot_setapen(struct gui_globals *glob, struct RastPort *rp, ULONG colr)
void ami_clearclipreg(struct gui_globals *gg)
static int init_layers_count
static nserror ami_text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
struct gui_globals * ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
Alloc a plotter render area.
static nserror ami_bitmap(struct gui_globals *glob, int x, int y, int width, int height, struct bitmap *bitmap)
void ami_plot_release_pens(struct MinList *shared_pens)
static nserror ami_bitmap_tile(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
static nserror ami_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
nserror
Enumeration of error codes.
@ NSERROR_INVALID
Invalid data.
struct BitMap * ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, bool palette_mapped, struct BitMap *friendbm)
int bitmap_get_width(void *bitmap)
get width of a bitmap.
int bitmap_get_height(void *bitmap)
get height of a bitmap.
PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height, struct BitMap *n_bm)
bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm)
Test if a BitMap is owned by a bitmap.
bool amiga_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
const struct ami_font_functions * ami_nsfont
struct MinList * ami_AllocMinList(void)
List abstraction as OS3 appears to have problems with NewMinList()
void bitmap_set_format(const bitmap_fmt_t *bitmap_format)
Set client bitmap format.
@ BITMAP_LAYOUT_ARGB8888
32-bit ARGB (0xAARRGGBB).
#define ns_color_to_nscss(c)
Convert a NetSurf color to a CSS colour primitive.
Core mouse and pointer states.
unsigned long bitmap_flags_t
Interface to platform-specific graphical user interface window operations.
#define NSLOG(catname, level, logmsg, args...)
#define ami_memory_chip_free(p)
#define ami_memory_chip_alloc(s)
#define ami_memory_itempool_create(s)
#define ami_memory_itempool_alloc(p, s)
#define ami_memory_itempool_free(p, i, s)
#define ami_memory_itempool_delete(p)
struct Node * GetHead(struct List *list)
struct Node * GetSucc(struct Node *node)
Minimal compatibility header for AmigaOS 3.
#define BLITA_UseSrcAlpha
#define IsMinListEmpty(L)
#define plot_style_fixed_to_int(v)
@ PLOT_OP_TYPE_NONE
No operation.
@ PLOT_OP_TYPE_DASH
Dashed plot.
@ PLOT_OP_TYPE_DOT
Dotted plot.
@ PLOT_OP_TYPE_SOLID
Solid colour.
#define NS_TRANSPARENT
Transparent colour value.
void ami_rtg_freebitmap(struct BitMap *bm)
struct BitMap * ami_rtg_allocbitmap(ULONG width, ULONG height, ULONG depth, ULONG flags, struct BitMap *friend, RGBFTYPE format)
Abstract RTG functions for newer/older/non-P96 systems.
ULONG(* text)(struct RastPort *rp, const char *string, ULONG length, const plot_font_style_t *fstyle, ULONG x, ULONG y, bool aa)
RISC OS wimp toolkit bitmap.
struct MinList * shared_pens
struct Layer_Info * layerinfo
colour foreground
Colour of text.
Plot style for stroke/fill plotters.
colour fill_colour
Colour of fill.
plot_style_fixed stroke_width
Width of stroke, in pixels.
plot_operation_type_t fill_type
Fill plot type.
colour stroke_colour
Colour of stroke.
plot_operation_type_t stroke_type
Stroke plot type.
Plotter operations table.
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
void * priv
Private context.
uint32_t colour
Colour type: XBGR.
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Interface to a number of general purpose functionality.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.