NetSurf
Macros | Functions | Variables
plotters.cpp File Reference

BeOS/Haiku implementation target independent plotting. More...

#include <math.h>
#include <BeBuild.h>
#include <Bitmap.h>
#include <GraphicsDefs.h>
#include <Region.h>
#include <View.h>
#include <Shape.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
#include "netsurf/plotters.h"
#include "beos/font.h"
#include "beos/gui.h"
#include "beos/plotters.h"
#include "beos/bitmap.h"
Include dependency graph for plotters.cpp:

Go to the source code of this file.

Macros

#define __STDBOOL_H__   1
 

Functions

BView * nsbeos_current_gc (void)
 
BView * nsbeos_current_gc_lock (void)
 
void nsbeos_current_gc_unlock (void)
 
void nsbeos_current_gc_set (BView *view)
 
static nserror nsbeos_plot_bbitmap (int x, int y, int width, int height, BBitmap *b, colour bg)
 
static BPoint transform_pt (float x, float y, const float transform[6])
 
rgb_color nsbeos_rgb_colour (colour c)
 
void nsbeos_set_colour (colour c)
 
void nsbeos_plot_caret (int x, int y, int h)
 Plot a caret. More...
 
static nserror nsbeos_plot_clip (const struct redraw_context *ctx, const struct rect *ns_clip)
 Sets a clip rectangle for subsequent plot operations. More...
 
static nserror nsbeos_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 nsbeos_plot_disc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
 Plots a circle. More...
 
static nserror nsbeos_plot_line (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
 Plots a line. More...
 
static nserror nsbeos_plot_rectangle (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *nsrect)
 Plots a rectangle. More...
 
static nserror nsbeos_plot_polygon (const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
 Plot a polygon. More...
 
static nserror nsbeos_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 nsbeos_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 nsbeos_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

BView * current_view
 
static const pattern kDottedPattern
 
static const pattern kDashedPattern
 
static const rgb_color kBlackColor
 
const struct plotter_table nsbeos_plotters
 beos plotter operation table More...
 

Detailed Description

BeOS/Haiku implementation target independent plotting.

Definition in file plotters.cpp.

Macro Definition Documentation

◆ __STDBOOL_H__

#define __STDBOOL_H__   1

Definition at line 26 of file plotters.cpp.

Function Documentation

◆ nsbeos_current_gc()

BView * nsbeos_current_gc ( void  )

Definition at line 70 of file plotters.cpp.

References current_view.

Referenced by bitmap_render(), nsbeos_plot_arc(), nsbeos_plot_bbitmap(), nsbeos_plot_bitmap(), nsbeos_plot_caret(), nsbeos_plot_clip(), nsbeos_plot_disc(), nsbeos_plot_line(), nsbeos_plot_path(), nsbeos_plot_polygon(), nsbeos_plot_rectangle(), nsbeos_set_colour(), and nsfont_paint().

Here is the caller graph for this function:

◆ nsbeos_current_gc_lock()

BView * nsbeos_current_gc_lock ( void  )

Definition at line 76 of file plotters.cpp.

References current_view, and view.

◆ nsbeos_current_gc_set()

void nsbeos_current_gc_set ( BView *  view)

Definition at line 93 of file plotters.cpp.

References current_view, and view.

Referenced by bitmap_render(), gui_window_remove_caret(), nsbeos_redraw_caret(), and nsbeos_window_expose_event().

Here is the caller graph for this function:

◆ nsbeos_current_gc_unlock()

void nsbeos_current_gc_unlock ( void  )

Definition at line 85 of file plotters.cpp.

References current_view.

◆ nsbeos_plot_arc()

static nserror nsbeos_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 266 of file plotters.cpp.

References beos_warn_user(), plot_style_s::fill_colour, nsbeos_current_gc(), nsbeos_set_colour(), NSERROR_INVALID, NSERROR_OK, and view.

Here is the call graph for this function:

◆ nsbeos_plot_bbitmap()

static nserror nsbeos_plot_bbitmap ( int  x,
int  y,
int  width,
int  height,
BBitmap *  b,
colour  bg 
)
static

Definition at line 101 of file plotters.cpp.

References beos_warn_user(), height, nsbeos_current_gc(), NSERROR_INVALID, NSERROR_OK, view, and width.

Referenced by nsbeos_plot_bitmap().

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

◆ nsbeos_plot_bitmap()

static nserror nsbeos_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 624 of file plotters.cpp.

References beos_warn_user(), BITMAPF_REPEAT_X, BITMAPF_REPEAT_Y, cliprect, height, nsbeos_bitmap_get_pretile_x(), nsbeos_bitmap_get_pretile_xy(), nsbeos_bitmap_get_pretile_y(), nsbeos_bitmap_get_primary(), nsbeos_current_gc(), nsbeos_plot_bbitmap(), NSERROR_INVALID, NSERROR_OK, view, and width.

Here is the call graph for this function:

◆ nsbeos_plot_caret()

void nsbeos_plot_caret ( int  x,
int  y,
int  h 
)

Plot a caret.

It is assumed that the plotters have been set up.

Definition at line 194 of file plotters.cpp.

References B_DOCUMENT_TEXT_COLOR, kBlackColor, nsbeos_current_gc(), and view.

Referenced by nsbeos_window_expose_event().

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

◆ nsbeos_plot_clip()

static nserror nsbeos_plot_clip ( const struct redraw_context ctx,
const struct rect ns_clip 
)
static

Sets a clip rectangle for subsequent plot operations.

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

Definition at line 225 of file plotters.cpp.

References beos_warn_user(), clip(), nsbeos_current_gc(), NSERROR_INVALID, NSERROR_OK, view, rect::x0, rect::x1, rect::y0, and rect::y1.

Here is the call graph for this function:

◆ nsbeos_plot_disc()

static nserror nsbeos_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.
xx coordinate of circle centre.
yy coordinate of circle centre.
radiuscircle radius.
Returns
NSERROR_OK on success else error code.

Definition at line 304 of file plotters.cpp.

References beos_warn_user(), plot_style_s::fill_colour, plot_style_s::fill_type, nsbeos_current_gc(), nsbeos_set_colour(), NSERROR_INVALID, NSERROR_OK, PLOT_OP_TYPE_NONE, and view.

Here is the call graph for this function:

◆ nsbeos_plot_line()

static nserror nsbeos_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.

< Solid colour

< Doted plot

< dashed plot

Definition at line 342 of file plotters.cpp.

References beos_warn_user(), kDashedPattern, kDottedPattern, line(), nsbeos_current_gc(), nsbeos_set_colour(), NSERROR_OK, PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_SOLID, plot_style_fixed_to_float, plot_style_s::stroke_colour, plot_style_s::stroke_type, plot_style_s::stroke_width, and view.

Here is the call graph for this function:

◆ nsbeos_plot_path()

static nserror nsbeos_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 525 of file plotters.cpp.

References plot_style_s::fill_colour, NS_TRANSPARENT, nsbeos_current_gc(), nsbeos_rgb_colour(), NSERROR_INVALID, NSERROR_OK, NSLOG, plot_style_fixed_to_float, PLOTTER_PATH_BEZIER, PLOTTER_PATH_CLOSE, PLOTTER_PATH_LINE, PLOTTER_PATH_MOVE, plot_style_s::stroke_colour, plot_style_s::stroke_width, transform_pt(), and view.

Here is the call graph for this function:

◆ nsbeos_plot_polygon()

static nserror nsbeos_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 479 of file plotters.cpp.

References beos_warn_user(), plot_style_s::fill_colour, NS_TRANSPARENT, nsbeos_current_gc(), nsbeos_set_colour(), NSERROR_INVALID, NSERROR_OK, and view.

Here is the call graph for this function:

◆ nsbeos_plot_rectangle()

static nserror nsbeos_plot_rectangle ( const struct redraw_context ctx,
const plot_style_t style,
const struct rect nsrect 
)
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.
nsrectA rectangle defining the line to be drawn
Returns
NSERROR_OK on success else error code.

< Solid colour

< Doted plot

< dashed plot

Definition at line 401 of file plotters.cpp.

References beos_warn_user(), plot_style_s::fill_colour, plot_style_s::fill_type, kDashedPattern, kDottedPattern, nsbeos_current_gc(), nsbeos_set_colour(), NSERROR_INVALID, NSERROR_OK, PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, PLOT_OP_TYPE_SOLID, plot_style_fixed_to_float, plot_style_s::stroke_colour, plot_style_s::stroke_type, plot_style_s::stroke_width, view, rect::x0, rect::x1, rect::y0, and rect::y1.

Here is the call graph for this function:

◆ nsbeos_plot_text()

static nserror nsbeos_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 721 of file plotters.cpp.

References NSERROR_INVALID, NSERROR_OK, nsfont_paint(), and text().

Here is the call graph for this function:

◆ nsbeos_rgb_colour()

rgb_color nsbeos_rgb_colour ( colour  c)

Definition at line 169 of file plotters.cpp.

References NS_TRANSPARENT.

Referenced by gui_set_clipboard(), nsbeos_plot_path(), nsbeos_set_colour(), and nsfont_paint().

Here is the caller graph for this function:

◆ nsbeos_set_colour()

void nsbeos_set_colour ( colour  c)

Definition at line 181 of file plotters.cpp.

References nsbeos_current_gc(), nsbeos_rgb_colour(), and view.

Referenced by nsbeos_plot_arc(), nsbeos_plot_disc(), nsbeos_plot_line(), nsbeos_plot_polygon(), and nsbeos_plot_rectangle().

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

◆ transform_pt()

static BPoint transform_pt ( float  x,
float  y,
const float  transform[6] 
)
static

Definition at line 151 of file plotters.cpp.

Referenced by nsbeos_plot_path().

Here is the caller graph for this function:

Variable Documentation

◆ current_view

BView* current_view

◆ kBlackColor

const rgb_color kBlackColor
static
Initial value:
= {
0, 0, 0, 255
}

Definition at line 62 of file plotters.cpp.

Referenced by nsbeos_plot_caret().

◆ kDashedPattern

const pattern kDashedPattern
static
Initial value:
= {
0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33
}

Definition at line 58 of file plotters.cpp.

Referenced by nsbeos_plot_line(), and nsbeos_plot_rectangle().

◆ kDottedPattern

const pattern kDottedPattern
static
Initial value:
= {
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa
}

Definition at line 55 of file plotters.cpp.

Referenced by nsbeos_plot_line(), and nsbeos_plot_rectangle().

◆ nsbeos_plotters

const struct plotter_table nsbeos_plotters
Initial value:
= {
NULL,
NULL,
NULL,
true
}
static nserror nsbeos_plot_clip(const struct redraw_context *ctx, const struct rect *ns_clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plotters.cpp:225
static nserror nsbeos_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.cpp:624
static nserror nsbeos_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.cpp:266
static nserror nsbeos_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plotters.cpp:342
static nserror nsbeos_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
Definition: plotters.cpp:304
static nserror nsbeos_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
Definition: plotters.cpp:479
static nserror nsbeos_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.cpp:721
static nserror nsbeos_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *nsrect)
Plots a rectangle.
Definition: plotters.cpp:401
static nserror nsbeos_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.cpp:525

beos plotter operation table

Definition at line 739 of file plotters.cpp.

Referenced by bitmap_render(), and nsbeos_window_expose_event().