From da9f17aa78b7b41424a546a2cf8b2a785f9a030f Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 9 Jan 2010 00:11:35 +0000 Subject: strip legacy plotter interface cleanup line plotting interface move plotter interface structs to apropriate header svn path=/trunk/libnsfb/; revision=9798 --- include/frontend.h | 1 + include/libnsfb.h | 15 --------- include/libnsfb_legacy_plot.h | 74 ------------------------------------------- include/libnsfb_plot.h | 42 +++++++++++++++++++++++- include/nsfb_plot.h | 5 ++- 5 files changed, 44 insertions(+), 93 deletions(-) delete mode 100644 include/libnsfb_legacy_plot.h (limited to 'include') diff --git a/include/frontend.h b/include/frontend.h index f477996..fba407f 100644 --- a/include/frontend.h +++ b/include/frontend.h @@ -1,6 +1,7 @@ /* libnsfb framebuffer frontend support */ #include "libnsfb.h" +#include "libnsfb_plot.h" #include "nsfb.h" /* frontend default options */ diff --git a/include/libnsfb.h b/include/libnsfb.h index 41490ad..8174350 100644 --- a/include/libnsfb.h +++ b/include/libnsfb.h @@ -15,21 +15,6 @@ typedef struct nsfb_cursor_s nsfb_cursor_t; typedef struct nsfb_s nsfb_t; - -/** representation of a colour. - * - * The colour value comprises of four components arranged in the order ABGR: - * bits 24-31 are the alpha value and represent the opacity. 0 is - * transparent i.e. there would be no change in the target surface if - * this colour were to be used and 0xFF is opaque. - * - * bits 16-23 are the Blue component of the colour. - * - * bits 8-15 are the Green component of the colour. - * - * bits 0-7 are the Red component of the colour. - */ -typedef uint32_t nsfb_colour_t; typedef struct nsfb_event_s nsfb_event_t; /** co-ordinate for plotting operations */ diff --git a/include/libnsfb_legacy_plot.h b/include/libnsfb_legacy_plot.h deleted file mode 100644 index 276acea..0000000 --- a/include/libnsfb_legacy_plot.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2009 Vincent Sanders - * - * This file is part of libnsfb, http://www.netsurf-browser.org/ - * Licenced under the MIT License, - * http://www.opensource.org/licenses/mit-license.php - * - * This is the exported legacy plotter interface for the libnsfb graphics - * library. This interface should *not* be used for new projects. It is not - * thread safe as the framebuffer context is held as a global and not passed. - */ - -#ifndef _LIBNSFB_LEGACY_PLOT_H -#define _LIBNSFB_LEGACY_PLOT_H 1 - -/** Set the framebuffer context for all legacy plot operations. - */ -bool nsfb_lplot_ctx(nsfb_t *nsfb); - -/** Sets a clip rectangle for subsequent plots. - * - * Sets a clipping area which constrains all subsequent plotting operations. - * The clipping area must lie within the framebuffer visible screen or false - * will be returned and the new clipping area not set. - */ -bool nsfb_lplot_clip(int x0, int y0, int x1, int y1); - -/** Clears plotting area to a flat colour. - */ -bool nsfb_lplot_clg(nsfb_colour_t c); - -/** Plots a rectangle outline. - * - * The line can be solid, dotted or dashed. Top left corner at (x0,y0) and - * rectangle has given width and height. - */ -bool nsfb_lplot_rectangle(int x0, int y0, int width, int height, int line_width, nsfb_colour_t c, bool dotted, bool dashed); - -/** Plots a filled rectangle. - * - * Top left corner at (x0,y0), bottom right corner at (x1,y1). Note: (x0,y0) is - * inside filled area, but (x1,y1) is below and to the right. - */ -bool nsfb_lplot_fill(int x0, int y0, int x1, int y1, nsfb_colour_t c); - -/** Plots a line. - * - * Draw a line from (x0,y0) to (x1,y1). Coordinates are at centre of line - * width/thickness. - */ -bool nsfb_lplot_line(int x0, int y0, int x1, int y1, int line_width, nsfb_colour_t c, bool dotted, bool dashed); - - -/** Plots a filled 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 a - * non-zero winding rule. - * - */ -bool nsfb_lplot_polygon(const int *p, unsigned int n, nsfb_colour_t fillc); - -/** Plots a circle. - */ -bool nsfb_lplot_disc(int x, int y, int radius, nsfb_colour_t c, bool filled); - -/** Plots an arc. - * - * around (x,y), from anticlockwise from angle1 to angle2. Angles are measured - * anticlockwise from horizontal, in degrees. - */ -bool nsfb_lplot_arc(int x, int y, int radius, int angle1, int angle2, nsfb_colour_t c); - -#endif /* _LIBNSFB_LEGACY_PLOT_H */ diff --git a/include/libnsfb_plot.h b/include/libnsfb_plot.h index 1d420b0..ef53934 100644 --- a/include/libnsfb_plot.h +++ b/include/libnsfb_plot.h @@ -11,6 +11,40 @@ #ifndef _LIBNSFB_PLOT_H #define _LIBNSFB_PLOT_H 1 +/** representation of a colour. + * + * The colour value comprises of four components arranged in the order ABGR: + * bits 24-31 are the alpha value and represent the opacity. 0 is + * transparent i.e. there would be no change in the target surface if + * this colour were to be used and 0xFF is opaque. + * + * bits 16-23 are the Blue component of the colour. + * + * bits 8-15 are the Green component of the colour. + * + * bits 0-7 are the Red component of the colour. + */ +typedef uint32_t nsfb_colour_t; + +/** + * Type of plot operation + */ +typedef enum nsfb_plot_optype_e { + NFSB_PLOT_OPTYPE_NONE = 0, /**< No operation */ + NFSB_PLOT_OPTYPE_SOLID, /**< Solid colour */ + NFSB_PLOT_OPTYPE_PATTERN, /**< Pattern plot */ +} nsfb_plot_optype_t; + +/** pen colour and raster operation for plotting primatives. */ +typedef struct nsfb_plot_pen_s { + nsfb_plot_optype_t stroke_type; /**< Stroke plot type */ + int stroke_width; /**< Width of stroke, in pixels */ + nsfb_colour_t stroke_colour; /**< Colour of stroke */ + uint32_t stroke_pattern; + nsfb_plot_optype_t fill_type; /**< Fill plot type */ + nsfb_colour_t fill_colour; /**< Colour of fill */ +} nsfb_plot_pen_t; + /** Sets a clip rectangle for subsequent plots. * * Sets a clipping area which constrains all subsequent plotting operations. @@ -45,7 +79,13 @@ bool nsfb_plot_rectangle_fill(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c); * Draw a line from (x0,y0) to (x1,y1). Coordinates are at centre of line * width/thickness. */ -bool nsfb_plot_line(nsfb_t *nsfb, nsfb_bbox_t *line, int line_width, nsfb_colour_t c, bool dotted, bool dashed); +bool nsfb_plot_line(nsfb_t *nsfb, nsfb_bbox_t *line, nsfb_plot_pen_t *pen); + +/** Plots a number of lines. + * + * Draw a series of lines. + */ +bool nsfb_plot_lines(nsfb_t *nsfb, int linec, nsfb_bbox_t *line, nsfb_plot_pen_t *pen); /** Plots a filled polygon. * diff --git a/include/nsfb_plot.h b/include/nsfb_plot.h index 52af7cd..8b39cc5 100644 --- a/include/nsfb_plot.h +++ b/include/nsfb_plot.h @@ -10,10 +10,9 @@ typedef bool (nsfb_plotfn_clg_t)(nsfb_t *nsfb, nsfb_colour_t c); */ typedef bool (nsfb_plotfn_rectangle_t)(nsfb_t *nsfb, nsfb_bbox_t *rect, int line_width, nsfb_colour_t c, bool dotted, bool dashed); -/** Plots a line from (x0,y0) to (x1,y1). Coordinates are at - * centre of line width/thickness. +/** Plots a line using a given pen. */ -typedef bool (nsfb_plotfn_line_t)(nsfb_t *nsfb, nsfb_bbox_t *line, int line_width, nsfb_colour_t c, bool dotted, bool dashed); +typedef bool (nsfb_plotfn_line_t)(nsfb_t *nsfb, int linec, nsfb_bbox_t *line, nsfb_plot_pen_t *pen); /** Plots a filled polygon with straight lines between points. * The lines around the edge of the ploygon are not plotted. The -- cgit v1.2.3