NetSurf
Functions | Variables
plotters.c File Reference

RISC OS screen plotter implementation. More...

#include <stdbool.h>
#include <math.h>
#include "oslib/colourtrans.h"
#include "oslib/draw.h"
#include "oslib/os.h"
#include "utils/log.h"
#include "netsurf/plotters.h"
#include "riscos/bitmap.h"
#include "riscos/image.h"
#include "riscos/gui.h"
#include "riscos/font.h"
#include "riscos/oslib_pre7.h"
Include dependency graph for plotters.c:

Go to the source code of this file.

Functions

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 More...
 
static nserror ro_plot_clip (const struct redraw_context *ctx, const struct rect *clip)
 Sets a clip rectangle for subsequent plot operations. More...
 
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. More...
 
static nserror ro_plot_disc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
 Plots a circle. More...
 
static nserror ro_plot_line (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
 Plots a line. More...
 
static nserror ro_plot_rectangle (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
 Plots a rectangle. More...
 
static nserror ro_plot_polygon (const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
 Plot a polygon. More...
 
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. More...
 
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. More...
 
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. More...
 

Variables

int ro_plot_origin_x = 0
 
int ro_plot_origin_y = 0
 
struct rect ro_plot_clip_rect
 
bool ro_plot_patterned_lines = true
 One version of the A9home OS is incapable of drawing patterned lines. More...
 
const struct plotter_table ro_plotters
 RISC OS plotter operation table. More...
 

Detailed Description

RISC OS screen plotter implementation.

Definition in file plotters.c.

Function Documentation

◆ ro_plot_arc()

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 
)
static

Plots an arc.

plot an arc segment around (x,y), anticlockwise from angle1 to angle2. Angles are measured anticlockwise from horizontal, in degrees.

Parameters
ctxThe current redraw context.
styleStyle controlling the arc plot.
xThe x coordinate of the arc.
yThe y coordinate of the arc.
radiusThe radius of the arc.
angle1The start angle of the arc.
angle2The finish angle of the arc.
Returns
NSERROR_OK on success else error code.

Definition at line 176 of file plotters.c.

References plot_style_s::fill_colour, M_PI, NSERROR_INVALID, NSERROR_OK, NSLOG, ro_plot_origin_x, and ro_plot_origin_y.

◆ ro_plot_bitmap()

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 
)
static

Plot a bitmap.

Tiled plot of a bitmap image. (x,y) gives the top left coordinate of an explicitly placed tile. From this tile the image can repeat in all four directions – up, down, left and right – to the extents given by the current clip rectangle.

The bitmap_flags say whether to tile in the x and y directions. If not tiling in x or y directions, the single image is plotted. The width and height give the dimensions the image is to be scaled to.

Parameters
ctxThe current redraw context.
bitmapThe bitmap to plot
xThe x coordinate to plot the bitmap
yThe y coordiante to plot the bitmap
widthThe width of area to plot the bitmap into
heightThe height of area to plot the bitmap into
bgthe background colour to alpha blend into
flagsthe flags controlling the type of plot operation
Returns
NSERROR_OK on success else error code.

Definition at line 650 of file plotters.c.

References BITMAPF_REPEAT_X, BITMAPF_REPEAT_Y, buffer, bitmap::height, height, IMAGE_PLOT_TINCT_ALPHA, IMAGE_PLOT_TINCT_OPAQUE, image_redraw(), NSERROR_INVALID, NSERROR_OK, NSLOG, riscos_bitmap_get_buffer(), riscos_bitmap_get_opaque(), ro_plot_origin_x, ro_plot_origin_y, bitmap::sprite_area, bitmap::width, and width.

Here is the call graph for this function:

◆ ro_plot_clip()

static nserror ro_plot_clip ( const struct redraw_context ctx,
const struct rect clip 
)
static

Sets a clip rectangle for subsequent plot operations.

Parameters
ctxThe current redraw context.
clipThe rectangle to limit all subsequent plot operations within.
Returns
NSERROR_OK on success else error code.

Definition at line 109 of file plotters.c.

References clip(), NSERROR_BAD_SIZE, NSERROR_INVALID, NSERROR_OK, NSLOG, ro_plot_clip_rect, ro_plot_origin_x, ro_plot_origin_y, rect::x0, rect::x1, rect::y0, and rect::y1.

Here is the call graph for this function:

◆ ro_plot_disc()

static nserror ro_plot_disc ( const struct redraw_context ctx,
const plot_style_t style,
int  x,
int  y,
int  radius 
)
static

Plots a circle.

Plot a circle centered on (x,y), which is optionally filled.

Parameters
ctxThe current redraw context.
styleStyle controlling the circle plot.
xThe x coordinate of the circle.
yThe y coordinate of the circle.
radiusThe radius of the circle.
Returns
NSERROR_OK on success else error code.

Definition at line 243 of file plotters.c.

References plot_style_s::fill_colour, plot_style_s::fill_type, NSERROR_INVALID, NSERROR_OK, NSLOG, PLOT_OP_TYPE_NONE, ro_plot_origin_x, ro_plot_origin_y, plot_style_s::stroke_colour, and plot_style_s::stroke_type.

◆ ro_plot_draw_path()

static nserror ro_plot_draw_path ( const draw_path *const  path,
int  width,
colour  c,
bool  dotted,
bool  dashed 
)
static

plot a path on RISC OS

Definition at line 51 of file plotters.c.

References NSERROR_INVALID, NSERROR_OK, NSLOG, path(), ro_plot_patterned_lines, and width.

Referenced by ro_plot_line(), and ro_plot_rectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_plot_line()

static nserror ro_plot_line ( const struct redraw_context ctx,
const plot_style_t style,
const struct rect line 
)
static

Plots a line.

plot a line from (x0,y0) to (x1,y1). Coordinates are at centre of line width/thickness.

Parameters
ctxThe current redraw context.
styleStyle controlling the line plot.
lineA rectangle defining the line to be drawn
Returns
NSERROR_OK on success else error code.

Definition at line 318 of file plotters.c.

References line(), NSERROR_OK, path(), PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, plot_style_fixed_to_int, ro_plot_draw_path(), ro_plot_origin_x, ro_plot_origin_y, plot_style_s::stroke_colour, plot_style_s::stroke_type, and plot_style_s::stroke_width.

Here is the call graph for this function:

◆ ro_plot_path()

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] 
)
static

Plots a path.

Path plot consisting of cubic Bezier curves. Line and fill colour is controlled by the plot style.

Parameters
ctxThe current redraw context.
pstyleStyle controlling the path plot.
pelements of path
nnunber of elements on path
transformA transform to apply to the path.
Returns
NSERROR_OK on success else error code.

Definition at line 504 of file plotters.c.

References plot_style_s::fill_colour, NS_TRANSPARENT, NSERROR_INVALID, NSERROR_OK, NSLOG, path(), plot_style_fixed_to_int, PLOTTER_PATH_BEZIER, PLOTTER_PATH_CLOSE, PLOTTER_PATH_LINE, PLOTTER_PATH_MOVE, ro_plot_origin_x, ro_plot_origin_y, plot_style_s::stroke_colour, and plot_style_s::stroke_width.

Here is the call graph for this function:

◆ ro_plot_polygon()

static nserror ro_plot_polygon ( const struct redraw_context ctx,
const plot_style_t style,
const int *  p,
unsigned int  n 
)
static

Plot a polygon.

Plots a filled polygon with straight lines between points. The lines around the edge of the ploygon are not plotted. The polygon is filled with the non-zero winding rule.

Parameters
ctxThe current redraw context.
styleStyle controlling the polygon plot.
pverticies of polygon
nnumber of verticies.
Returns
NSERROR_OK on success else error code.

Definition at line 454 of file plotters.c.

References plot_style_s::fill_colour, NSERROR_INVALID, NSERROR_OK, NSLOG, path(), ro_plot_origin_x, and ro_plot_origin_y.

Here is the call graph for this function:

◆ ro_plot_rectangle()

static nserror ro_plot_rectangle ( const struct redraw_context ctx,
const plot_style_t style,
const struct rect rect 
)
static

Plots a rectangle.

The rectangle can be filled an outline or both controlled by the plot style The line can be solid, dotted or dashed. Top left corner at (x0,y0) and rectangle has given width and height.

Parameters
ctxThe current redraw context.
styleStyle controlling the rectangle plot.
rectA rectangle defining the line to be drawn
Returns
NSERROR_OK on success else error code.

Definition at line 363 of file plotters.c.

References colourtrans_USE_ECFS_GCOL, plot_style_s::fill_colour, plot_style_s::fill_type, NSERROR_INVALID, NSERROR_OK, NSLOG, path(), PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, plot_style_fixed_to_int, ro_plot_draw_path(), ro_plot_origin_x, ro_plot_origin_y, plot_style_s::stroke_colour, plot_style_s::stroke_type, plot_style_s::stroke_width, rect::x0, rect::x1, rect::y0, and rect::y1.

Here is the call graph for this function:

◆ ro_plot_text()

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 
)
static

Text plotting.

Parameters
ctxThe current redraw context.
fstyleplot style for this text
xx coordinate
yy coordinate
textUTF-8 string to plot
lengthlength of string, in bytes
Returns
NSERROR_OK on success else error code.

Definition at line 695 of file plotters.c.

References plot_font_style::background, plot_font_style::foreground, NSERROR_INVALID, NSERROR_OK, nsfont_paint(), NSLOG, ro_plot_origin_x, ro_plot_origin_y, and text().

Here is the call graph for this function:

Variable Documentation

◆ ro_plot_clip_rect

struct rect ro_plot_clip_rect

Definition at line 42 of file plotters.c.

Referenced by ro_cw_redraw(), ro_gui_window__redraw_rect(), and ro_plot_clip().

◆ ro_plot_origin_x

int ro_plot_origin_x = 0

◆ ro_plot_origin_y

int ro_plot_origin_y = 0

◆ ro_plot_patterned_lines

bool ro_plot_patterned_lines = true

One version of the A9home OS is incapable of drawing patterned lines.

Definition at line 45 of file plotters.c.

Referenced by gui_init(), and ro_plot_draw_path().

◆ ro_plotters

const struct plotter_table ro_plotters
Initial value:
= {
.rectangle = ro_plot_rectangle,
.line = ro_plot_line,
.polygon = ro_plot_polygon,
.clip = ro_plot_clip,
.text = ro_plot_text,
.disc = ro_plot_disc,
.arc = ro_plot_arc,
.bitmap = ro_plot_bitmap,
.path = ro_plot_path,
.option_knockout = true,
}
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.
Definition: plotters.c:504
static nserror ro_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plotters.c:109
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.
Definition: plotters.c:176
static nserror ro_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plotters.c:318
static nserror ro_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
Definition: plotters.c:454
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.
Definition: plotters.c:650
static nserror ro_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
Definition: plotters.c:363
static nserror ro_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
Definition: plotters.c:243
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.
Definition: plotters.c:695

RISC OS plotter operation table.

Definition at line 727 of file plotters.c.

Referenced by cookie_draw(), global_history_draw(), hotlist_draw(), print_document(), riscos_bitmap_render(), ro_gui_progress_bar_redraw_window(), ro_gui_status_bar_redraw(), ro_gui_url_bar_redraw(), ro_gui_window__redraw_rect(), ro_local_history_draw(), and ro_pageinfo_draw().