26#include "oslib/colourtrans.h"
27#include "oslib/draw.h"
57 static const draw_line_style line_style = {
64 draw_dash_pattern dash = { 0, 1, { 512 } };
65 const draw_dash_pattern *dash_pattern = 0;
73 dash.elements[0] = 512 *
width;
76 dash.elements[0] = 1536 *
width;
81 error = xcolourtrans_set_gcol(c << 8, 0, os_ACTION_OVERWRITE, 0, 0);
83 NSLOG(netsurf, INFO,
"xcolourtrans_set_gcol: 0x%x: %s",
84 error->errnum, error->errmess);
88 error = xdraw_stroke(
path, 0, 0, 0,
width * 2 * 256,
89 &line_style, dash_pattern);
91 NSLOG(netsurf, INFO,
"xdraw_stroke: 0x%x: %s", error->errnum,
114 int clip_x0 =
clip->x0 * 2;
115 int clip_y0 =
clip->y1 * 2;
116 int clip_x1 =
clip->x1 * 2;
117 int clip_y1 =
clip->y0 * 2;
132 if (clip_x1 < clip_x0 || clip_y1 < clip_y0) {
133 NSLOG(netsurf, INFO,
"bad clip rectangle %i %i %i %i",
134 clip_x0, clip_y0, clip_x1, clip_y1);
138 buf[0] = os_VDU_SET_GRAPHICS_WINDOW;
140 buf[2] = clip_x0 >> 8;
142 buf[4] = clip_y0 >> 8;
144 buf[6] = clip_x1 >> 8;
146 buf[8] = clip_y1 >> 8;
148 error = xos_writen(buf, 9);
150 NSLOG(netsurf, INFO,
"xos_writen: 0x%x: %s", error->errnum,
178 int x,
int y,
int radius,
int angle1,
int angle2)
188 error = xcolourtrans_set_gcol(style->
fill_colour << 8, 0,
189 os_ACTION_OVERWRITE, 0, 0);
192 NSLOG(netsurf, INFO,
"xcolourtrans_set_gcol: 0x%x: %s",
193 error->errnum, error->errmess);
197 t = ((double)angle1 *
M_PI) / 180.0;
198 sx = (x + (int)(radius * cos(t)));
199 sy = (y + (int)(radius * sin(t)));
201 t = ((double)angle2 *
M_PI) / 180.0;
202 ex = (x + (int)(radius * cos(t)));
203 ey = (y + (int)(radius * sin(t)));
205 error = xos_plot(os_MOVE_TO, x, y);
207 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s", error->errnum,
212 error = xos_plot(os_MOVE_TO, sx, sy);
214 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s", error->errnum,
219 error = xos_plot(os_PLOT_ARC | os_PLOT_TO, ex, ey);
221 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s", error->errnum,
245 int x,
int y,
int radius)
249 error = xcolourtrans_set_gcol(style->
fill_colour << 8, 0,
250 os_ACTION_OVERWRITE, 0, 0);
253 "xcolourtrans_set_gcol: 0x%x: %s",
258 error = xos_plot(os_MOVE_TO,
262 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s",
263 error->errnum, error->errmess);
266 error = xos_plot(os_PLOT_CIRCLE | os_PLOT_BY, radius * 2, 0);
268 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s",
269 error->errnum, error->errmess);
277 os_ACTION_OVERWRITE, 0, 0);
280 "xcolourtrans_set_gcol: 0x%x: %s",
285 error = xos_plot(os_MOVE_TO,
289 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s",
290 error->errnum, error->errmess);
293 error = xos_plot(os_PLOT_CIRCLE_OUTLINE | os_PLOT_BY,
297 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s",
298 error->errnum, error->errmess);
369 error = xcolourtrans_set_gcol(style->
fill_colour << 8,
371 os_ACTION_OVERWRITE, 0, 0);
374 "xcolourtrans_set_gcol: 0x%x: %s",
380 error = xos_plot(os_MOVE_TO,
384 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s",
385 error->errnum, error->errmess);
389 error = xos_plot(os_PLOT_RECTANGLE | os_PLOT_TO,
393 NSLOG(netsurf, INFO,
"xos_plot: 0x%x: %s",
394 error->errnum, error->errmess);
463 for (i = 0; i != n; i++) {
464 path[i * 3 + 0] = draw_LINE_TO;
468 path[0] = draw_MOVE_TO;
469 path[n * 3] = draw_END_PATH;
472 error = xcolourtrans_set_gcol(style->
fill_colour << 8,
473 0, os_ACTION_OVERWRITE, 0, 0);
475 NSLOG(netsurf, INFO,
"xcolourtrans_set_gcol: 0x%x: %s",
476 error->errnum, error->errmess);
479 error = xdraw_fill((draw_path *)
path, 0, 0, 0);
481 NSLOG(netsurf, INFO,
"xdraw_fill: 0x%x: %s", error->errnum,
508 const float transform[6])
510 static const draw_line_style line_style = {
527 NSLOG(netsurf, INFO,
"path doesn't start with a move");
531 path = malloc(
sizeof *
path * (n + 10));
533 NSLOG(netsurf, INFO,
"out of memory");
537 for (i = 0; i < n; ) {
539 path[i] = draw_MOVE_TO;
540 path[i + 1] = p[i + 1] * 2 * 256;
541 path[i + 2] = -p[i + 2] * 2 * 256;
544 path[i] = draw_CLOSE_LINE;
547 path[i] = draw_LINE_TO;
548 path[i + 1] = p[i + 1] * 2 * 256;
549 path[i + 2] = -p[i + 2] * 2 * 256;
552 path[i] = draw_BEZIER_TO;
553 path[i + 1] = p[i + 1] * 2 * 256;
554 path[i + 2] = -p[i + 2] * 2 * 256;
555 path[i + 3] = p[i + 3] * 2 * 256;
556 path[i + 4] = -p[i + 4] * 2 * 256;
557 path[i + 5] = p[i + 5] * 2 * 256;
558 path[i + 6] = -p[i + 6] * 2 * 256;
561 NSLOG(netsurf, INFO,
"bad path command %f", p[i]);
565 path[i] = draw_END_PATH;
568 trfm.entries[0][0] = transform[0] * 0x10000;
569 trfm.entries[0][1] = transform[1] * 0x10000;
570 trfm.entries[1][0] = transform[2] * 0x10000;
571 trfm.entries[1][1] = transform[3] * 0x10000;
576 error = xcolourtrans_set_gcol(pstyle->
fill_colour << 8, 0,
577 os_ACTION_OVERWRITE, 0, 0);
580 "xcolourtrans_set_gcol: 0x%x: %s",
586 error = xdraw_fill((draw_path *)
path, 0, &trfm, 0);
588 NSLOG(netsurf, INFO,
"xdraw_stroke: 0x%x: %s",
589 error->errnum, error->errmess);
596 os_ACTION_OVERWRITE, 0, 0);
599 "xcolourtrans_set_gcol: 0x%x: %s",
605 error = xdraw_stroke((draw_path *)
path, 0, &trfm, 0,
610 NSLOG(netsurf, INFO,
"xdraw_stroke: 0x%x: %s",
611 error->errnum, error->errmess);
662 NSLOG(netsurf, INFO,
"bitmap_get_buffer failed");
704 error = xcolourtrans_set_font_colours(font_CURRENT,
709 "xcolourtrans_set_font_colours: 0x%x: %s",
737 .option_knockout =
true,
static osspriteop_area * buffer
The buffer characteristics.
nserror
Enumeration of error codes.
@ NSERROR_BAD_SIZE
Bad size.
@ NSERROR_INVALID
Invalid data.
bool nsfont_paint(const plot_font_style_t *fstyle, const char *string, size_t length, int x, int y)
Render a string.
unsigned char * riscos_bitmap_get_buffer(void *vbitmap)
Return a pointer to the pixel data in a bitmap.
bool riscos_bitmap_get_opaque(void *vbitmap)
Gets whether a bitmap should be plotted opaque.
bool image_redraw(osspriteop_area *area, int x, int y, int req_width, int req_height, int width, int height, colour background_colour, bool repeatx, bool repeaty, bool background, image_type type)
Plot an image at the given coordinates using the method specified.
@ IMAGE_PLOT_TINCT_OPAQUE
Target independent plotting interface.
unsigned long bitmap_flags_t
#define NSLOG(catname, level, logmsg, args...)
Backward compatible defines to make NetSurf buildable with pre-OSLib 7 releases.
#define colourtrans_USE_ECFS_GCOL
#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.
#define NS_TRANSPARENT
Transparent colour value.
static nserror ro_plot_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 nserror ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
struct rect ro_plot_clip_rect
static nserror ro_plot_arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
const struct plotter_table ro_plotters
RISC OS plotter operation table.
bool ro_plot_patterned_lines
One version of the A9home OS is incapable of drawing patterned lines.
static nserror ro_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static nserror ro_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
static nserror ro_plot_bitmap(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 ro_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
static nserror ro_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
static nserror ro_plot_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 ro_plot_draw_path(const draw_path *const path, int width, colour c, bool dotted, bool dashed)
plot a path on RISC OS
RISC OS wimp toolkit bitmap.
struct osspriteop_area * sprite_area
Uncompressed data, or NULL.
int height
height of bitmap
colour foreground
Colour of text.
colour background
Background colour to blend to, if appropriate.
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.
uint32_t colour
Colour type: XBGR.
static nserror 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 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.