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>
97#define M_PI 3.14159265358979323846
100#define PATT_DOT 0xAAAA
101#define PATT_DASH 0xCCCC
102#define PATT_LINE 0xFFFF
107#define AREA_SIZE 25000
113 struct BitMap *
friend = NULL;
118 if(force32bit ==
false) depth = GetBitMapAttr(
scrn->RastPort.BitMap, BMA_DEPTH);
119 NSLOG(netsurf, INFO,
"Screen depth = %d", depth);
131 NSLOG(netsurf, INFO,
"Set bitmap format to 0xAARRGGBB (native endian) (PMA)");
141 NSLOG(netsurf, INFO,
"Set bitmap format to 0xAARRGGBB (native endian)");
150 NSLOG(netsurf, INFO,
"Set bitmap format to 0xAARRGGBB (native endian) (PMA)");
159 friend =
scrn->RastPort.BitMap;
163 if((depth > 8) && (force32bit ==
false))
friend =
scrn->RastPort.BitMap;
198 if((depth >= 24) && (force32bit ==
false))
friend =
scrn->RastPort.BitMap;
205 gg->
rp = malloc(
sizeof(
struct RastPort));
208 InitRastPort(gg->
rp);
209 gg->
rp->BitMap = gg->
bm;
213 gg->
rp->Layer = CreateUpfrontLayer(gg->
layerinfo,gg->
rp->BitMap,0,0,
216 InstallLayerHook(gg->
rp->Layer,LAYERS_NOBACKFILL);
218 gg->
rp->AreaInfo = malloc(
sizeof(
struct AreaInfo));
223 gg->
rp->TmpRas = malloc(
sizeof(
struct TmpRas));
236 if(alloc_pen_list ==
true) {
249 NSLOG(netsurf, INFO,
"Layer initialised (total: %d)",
267 if(gg->
rp->Layer != NULL) {
269 struct Region *reg = InstallClipRegion(gg->
rp->Layer,NULL);
270 if(reg) DisposeRegion(reg);
273 DeleteLayer(0, gg->
rp->Layer);
275 free(gg->
rp->TmpRas);
276 free(gg->
rp->AreaInfo);
317 struct Region *reg = NewRegion();
324 OrRectRegion(reg, &gg->
rect);
325 reg = InstallClipRegion(gg->
rp->Layer, reg);
326 if(reg) DisposeRegion(reg);
337 LONG pen = ObtainBestPenA(
scrn->ViewPort.ColorMap,
338 (colr & 0x000000ff) << 24,
339 (colr & 0x0000ff00) << 16,
340 (colr & 0x00ff0000) << 8,
343 if(pen == -1)
NSLOG(netsurf, INFO,
344 "WARNING: Cannot allocate pen for ABGR:%lx", colr);
346 if((shared_pens != NULL) && (
pool_pens != NULL)) {
349 AddTail((
struct List *)shared_pens, (
struct Node *)node);
353 ReleasePen(
scrn->ViewPort.ColorMap, pen);
364 if(shared_pens == NULL)
return;
370 ReleasePen(
scrn->ViewPort.ColorMap,
node->pen);
371 Remove((
struct Node *)
node);
373 }
while((
node = nnode));
395 SetRPAttrs(rp, RPTAG_OPenColor,
408 if((bbox == NULL) || (rp == NULL))
return;
410 EraseRect(rp, bbox->Left, bbox->Top,
411 bbox->Width + bbox->Left, bbox->Height + bbox->Top);
415static void ami_arc_gfxlib(
struct RastPort *rp,
int x,
int y,
int radius,
int angle1,
int angle2)
417 float angle1_r = (float)(angle1) * (
M_PI / 180.0);
418 float angle2_r = (float)(angle2) * (
M_PI / 180.0);
429 x1 = (int)(cos(b) * (float)radius);
430 y1 = (int)(sin(b) * (float)radius);
431 Move(rp, x0 + x1, y0 - y1);
433 for(angle = (b + step); angle <= c; angle += step) {
434 x1 = (int)(cos(angle) * (float)radius);
435 y1 = (int)(sin(angle) * (float)radius);
436 Draw(rp, x0 + x1, y0 - y1);
445 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_bitmap()");
455 (x > glob->
rect.MaxX) ||
456 (y > glob->
rect.MaxY)) {
465 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] ami_bitmap() got native bitmap");
468 if (__builtin_expect((GfxBase->LibNode.lib_Version >= 53) &&
470 uint32 comptype = COMPOSITE_Src_Over_Dest;
471 uint32 compflags = COMPFLAG_IgnoreDestAlpha;
473 compflags |= COMPFLAG_SrcAlphaOverride;
474 comptype = COMPOSITE_Src;
477 CompositeTags(comptype,tbm,glob->
rp->BitMap,
478 COMPTAG_Flags, compflags,
479 COMPTAG_DestX,glob->
rect.MinX,
480 COMPTAG_DestY,glob->
rect.MinY,
481 COMPTAG_DestWidth,glob->
rect.MaxX - glob->
rect.MinX + 1,
482 COMPTAG_DestHeight,glob->
rect.MaxY - glob->
rect.MinY + 1,
483 COMPTAG_SrcWidth,
width,
487 COMPTAG_FriendBitMap,
scrn->RastPort.BitMap,
492 ULONG tag = TAG_IGNORE, tag_data, minterm = 0xc0;
508 BltBitMapTags(BLITA_Width,
width,
514 BLITA_SrcType,BLITT_BITMAP,
515 BLITA_DestType,BLITT_RASTPORT,
516 BLITA_Minterm, minterm,
522 BltMaskBitMapRastPort(tbm, 0, 0, glob->
rp, x, y,
width,
height, minterm, tag_data);
524 BltBitMapRastPort(tbm, 0, 0, glob->
rp, x, y,
width,
height, 0xc0);
539 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;
540 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;
563 struct Region *reg = NULL;
565 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_clip()");
567 if (glob->
rp->Layer) {
575 OrRectRegion(reg,&glob->
rect);
577 reg = InstallClipRegion(glob->
rp->Layer,reg);
607 int x,
int y,
int radius,
int angle1,
int angle2)
609 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_arc()");
613 if (angle2 < angle1) {
639 int x,
int y,
int radius)
641 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_disc()");
647 AreaCircle(glob->
rp,x,y,radius);
653 DrawEllipse(glob->
rp,x,y,radius,radius);
676 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_line()");
702 glob->
rp->PenWidth = 1;
703 glob->
rp->PenHeight = 1;
728 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_rectangle()");
763 glob->
rp->PenWidth = 1;
764 glob->
rp->PenHeight = 1;
792 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_polygon()");
798 if (AreaMove(glob->
rp,p[0],p[1]) == -1) {
799 NSLOG(netsurf, INFO,
"AreaMove: vector list full");
802 for (
uint32 k = 1; k < n; k++) {
803 if (AreaDraw(glob->
rp,p[k*2],p[(k*2)+1]) == -1) {
804 NSLOG(netsurf, INFO,
"AreaDraw: vector list full");
808 if (AreaEnd(glob->
rp) == -1) {
809 NSLOG(netsurf, INFO,
"AreaEnd: error");
834 const float transform[6])
837 struct bez_point start_p = {0, 0}, cur_p = {0, 0}, p_a, p_b, p_c, p_r;
839 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_path()");
848 NSLOG(netsurf, INFO,
"Path does not start with move");
866 for (i = 0; i < n; ) {
869 if (AreaMove(glob->
rp, p[i+1], p[i+2]) == -1) {
871 "AreaMove: vector list full");
874 Move(glob->
rp, p[i+1], p[i+2]);
884 if (AreaEnd(glob->
rp) == -1) {
885 NSLOG(netsurf, INFO,
"AreaEnd: error");
888 Draw(glob->
rp, start_p.
x, start_p.
y);
893 if (AreaDraw(glob->
rp, p[i+1], p[i+2]) == -1) {
895 "AreaDraw: vector list full");
898 Draw(glob->
rp, p[i+1], p[i+2]);
911 for (
float t = 0.0; t <= 1.0; t += 0.1) {
912 ami_bezier(&cur_p, &p_a, &p_b, &p_c, t, &p_r);
914 if (AreaDraw(glob->
rp, p_r.x, p_r.y) == -1) {
916 "AreaDraw: vector list full");
919 Draw(glob->
rp, p_r.x, p_r.y);
926 NSLOG(netsurf, INFO,
"bad path command %f", p[i]);
976 int xf,yf,xm,ym,oy,ox;
977 struct BitMap *tbm = NULL;
981 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_bitmap_tile()");
989 if (!(repeat_x || repeat_y)) {
1011 for (; ox > 0; ox -=
width)
1014 for (; oy > 0; oy -=
height);
1023 xf = glob->
rect.MaxX;
1024 xm = glob->
rect.MinX;
1031 yf = glob->
rect.MaxY;
1032 ym = glob->
rect.MinY;
1039 for (x = -ox; x <= xf; x +=
width) {
1040 for (y = -oy; y <= yf; y +=
height) {
1043 if(__builtin_expect((GfxBase->LibNode.lib_Version >= 53) &&
1046 CompositeTags(COMPOSITE_Src_Over_Dest, tbm, glob->
rp->BitMap,
1047 COMPTAG_Flags, COMPFLAG_IgnoreDestAlpha,
1048 COMPTAG_DestX, glob->
rect.MinX,
1049 COMPTAG_DestY, glob->
rect.MinY,
1050 COMPTAG_DestWidth, glob->
rect.MaxX - glob->
rect.MinX + 1,
1051 COMPTAG_DestHeight, glob->
rect.MaxY - glob->
rect.MinY + 1,
1052 COMPTAG_SrcWidth,
width,
1053 COMPTAG_SrcHeight,
height,
1056 COMPTAG_FriendBitMap,
scrn->RastPort.BitMap,
1061 ULONG tag = TAG_IGNORE, tag_data, minterm = 0xc0;
1078 BltBitMapTags(BLITA_Width,
width,
1083 BLITA_Dest, glob->
rp,
1086 BLITA_SrcType, BLITT_BITMAP,
1087 BLITA_DestType, BLITT_RASTPORT,
1088 BLITA_Minterm, minterm,
1093 BltMaskBitMapRastPort(tbm, 0, 0, glob->
rp, x, y,
1096 BltBitMapRastPort(tbm, 0, 0, glob->
rp, x, y,
1132 NSLOG(plot, DEEPDEBUG,
"[ami_plotter] Entered ami_text()");
1136 if (__builtin_expect(
ami_nsfont == NULL, 0)) {
1156 .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
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.
static nserror ami_bitmap(struct gui_globals *glob, int x, int y, int width, int height, struct bitmap *bitmap, colour bg)
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.
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.
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)
struct BitMap * ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, bool palette_mapped, struct BitMap *friendbm, colour bg)
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.
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.