From a3097232844a20ea918d63722dbe6a7c71493bab Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 11 Jan 2010 23:39:54 +0000 Subject: simplify internal headers svn path=/trunk/libnsfb/; revision=9801 --- include/libnsfb_plot.h | 16 +++++++ include/nsfb_plot.h | 115 ---------------------------------------------- include/plot.h | 121 +++++++++++++++++++++++++++++++++++++++++++++++++ include/plotters.h | 1 - 4 files changed, 137 insertions(+), 116 deletions(-) delete mode 100644 include/nsfb_plot.h create mode 100644 include/plot.h delete mode 100644 include/plotters.h (limited to 'include') diff --git a/include/libnsfb_plot.h b/include/libnsfb_plot.h index ef53934..af1768e 100644 --- a/include/libnsfb_plot.h +++ b/include/libnsfb_plot.h @@ -45,6 +45,20 @@ typedef struct nsfb_plot_pen_s { nsfb_colour_t fill_colour; /**< Colour of fill */ } nsfb_plot_pen_t; +/** path operation type. */ +typedef enum nsfb_plot_pathop_type_e { + NFSB_PLOT_PATHOP_MOVE, + NFSB_PLOT_PATHOP_LINE, + NFSB_PLOT_PATHOP_QUAD, + NFSB_PLOT_PATHOP_CUBIC, +} nsfb_plot_pathop_type_t; + +/** path element */ +typedef struct nsfb_plot_pathop_s { + nsfb_plot_pathop_type_t operation; + nsfb_point_t point; +} nsfb_plot_pathop_t; + /** Sets a clip rectangle for subsequent plots. * * Sets a clipping area which constrains all subsequent plotting operations. @@ -122,6 +136,8 @@ bool nsfb_plot_cubic_bezier(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrl bool nsfb_plot_quadratic_bezier(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrla, nsfb_colour_t cl); +bool nsfb_plot_path(nsfb_t *nsfb, int pathc, nsfb_plot_pathop_t *pathop, nsfb_plot_pen_t *pen); + /** copy an area of screen * * Copy an area of the display. diff --git a/include/nsfb_plot.h b/include/nsfb_plot.h deleted file mode 100644 index 8b39cc5..0000000 --- a/include/nsfb_plot.h +++ /dev/null @@ -1,115 +0,0 @@ - - -/** Clears plotting area to a flat colour (if needed) - */ -typedef bool (nsfb_plotfn_clg_t)(nsfb_t *nsfb, 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. - */ -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 using a given pen. - */ -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 - * polygon is filled with the non-zero winding rule. - */ -typedef bool (nsfb_plotfn_polygon_t)(nsfb_t *nsfb, const int *p, unsigned int n, nsfb_colour_t fill); - -/** 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. See diagram below. - */ -typedef bool (nsfb_plotfn_fill_t)(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c); - -/** Clipping operations. - */ -typedef bool (nsfb_plotfn_clip_t)(nsfb_t *nsfb, nsfb_bbox_t *clip); - -/** Plots an arc, around (x,y), from anticlockwise from angle1 to - * angle2. Angles are measured anticlockwise from horizontal, in - * degrees. - */ -typedef bool (nsfb_plotfn_arc_t)(nsfb_t *nsfb, int x, int y, int radius, int angle1, int angle2, nsfb_colour_t c); - -/** Plots a point. - * - * Plot a single alpha blended pixel. - */ -typedef bool (nsfb_plotfn_point_t)(nsfb_t *nsfb, int x, int y, nsfb_colour_t c); - -/** Plot an ellipse. - * - * plot an ellipse outline, note if teh bounding box is square this will plot a - * circle. - */ -typedef bool (nsfb_plotfn_ellipse_t)(nsfb_t *nsfb, nsfb_bbox_t *ellipse, nsfb_colour_t c); - -/** Plot a filled ellipse. - * - * plot a filled ellipse, note if the bounding box is square this will plot a - * circle. - */ -typedef bool (nsfb_plotfn_ellipse_fill_t)(nsfb_t *nsfb, nsfb_bbox_t *ellipse, nsfb_colour_t c); - - -/** Plot bitmap - */ -typedef bool (nsfb_plotfn_bitmap_t)(nsfb_t *nsfb, const nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha); - - -/** Copy an area of screen - * - * Copy an area of the display. - */ -typedef bool (nsfb_plotfn_copy_t)(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox); - - -/** Plot an 8 bit per pixel glyph. - */ -typedef bool (nsfb_plotfn_glyph8_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c); - - -/** Plot an 1 bit per pixel glyph. - */ -typedef bool (nsfb_plotfn_glyph1_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c); - -/** Read rectangle of screen into buffer - */ -typedef bool (nsfb_plotfn_readrect_t)(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t *buffer); - -/** Plot quadratic bezier spline - */ -typedef bool (nsfb_plotfn_quadratic_bezier_t)(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrla, nsfb_colour_t c); - -/** Plot cubic bezier spline - */ -typedef bool (nsfb_plotfn_cubic_bezier_t)(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrla, nsfb_point_t *ctrlb, nsfb_colour_t c); - -/** plotter function table. */ -typedef struct nsfb_plotter_fns_s { - nsfb_plotfn_clg_t *clg; - nsfb_plotfn_rectangle_t *rectangle; - nsfb_plotfn_line_t *line; - nsfb_plotfn_polygon_t *polygon; - nsfb_plotfn_fill_t *fill; - nsfb_plotfn_clip_t *get_clip; - nsfb_plotfn_clip_t *set_clip; - nsfb_plotfn_ellipse_t *ellipse; - nsfb_plotfn_ellipse_fill_t *ellipse_fill; - nsfb_plotfn_arc_t *arc; - nsfb_plotfn_bitmap_t *bitmap; - nsfb_plotfn_point_t *point; - nsfb_plotfn_copy_t *copy; - nsfb_plotfn_glyph8_t *glyph8; - nsfb_plotfn_glyph1_t *glyph1; - nsfb_plotfn_readrect_t *readrect; - nsfb_plotfn_quadratic_bezier_t *quadratic; - nsfb_plotfn_cubic_bezier_t *cubic; -} nsfb_plotter_fns_t; - - diff --git a/include/plot.h b/include/plot.h new file mode 100644 index 0000000..8894c7a --- /dev/null +++ b/include/plot.h @@ -0,0 +1,121 @@ + + +/** Clears plotting area to a flat colour (if needed) + */ +typedef bool (nsfb_plotfn_clg_t)(nsfb_t *nsfb, 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. + */ +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 using a given pen. + */ +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 + * polygon is filled with the non-zero winding rule. + */ +typedef bool (nsfb_plotfn_polygon_t)(nsfb_t *nsfb, const int *p, unsigned int n, nsfb_colour_t fill); + +/** 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. See diagram below. + */ +typedef bool (nsfb_plotfn_fill_t)(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c); + +/** Clipping operations. + */ +typedef bool (nsfb_plotfn_clip_t)(nsfb_t *nsfb, nsfb_bbox_t *clip); + +/** Plots an arc, around (x,y), from anticlockwise from angle1 to + * angle2. Angles are measured anticlockwise from horizontal, in + * degrees. + */ +typedef bool (nsfb_plotfn_arc_t)(nsfb_t *nsfb, int x, int y, int radius, int angle1, int angle2, nsfb_colour_t c); + +/** Plots a point. + * + * Plot a single alpha blended pixel. + */ +typedef bool (nsfb_plotfn_point_t)(nsfb_t *nsfb, int x, int y, nsfb_colour_t c); + +/** Plot an ellipse. + * + * plot an ellipse outline, note if teh bounding box is square this will plot a + * circle. + */ +typedef bool (nsfb_plotfn_ellipse_t)(nsfb_t *nsfb, nsfb_bbox_t *ellipse, nsfb_colour_t c); + +/** Plot a filled ellipse. + * + * plot a filled ellipse, note if the bounding box is square this will plot a + * circle. + */ +typedef bool (nsfb_plotfn_ellipse_fill_t)(nsfb_t *nsfb, nsfb_bbox_t *ellipse, nsfb_colour_t c); + + +/** Plot bitmap + */ +typedef bool (nsfb_plotfn_bitmap_t)(nsfb_t *nsfb, const nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha); + + +/** Copy an area of screen + * + * Copy an area of the display. + */ +typedef bool (nsfb_plotfn_copy_t)(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox); + + +/** Plot an 8 bit per pixel glyph. + */ +typedef bool (nsfb_plotfn_glyph8_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c); + + +/** Plot an 1 bit per pixel glyph. + */ +typedef bool (nsfb_plotfn_glyph1_t)(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c); + +/** Read rectangle of screen into buffer + */ +typedef bool (nsfb_plotfn_readrect_t)(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t *buffer); + +/** Plot quadratic bezier spline + */ +typedef bool (nsfb_plotfn_quadratic_bezier_t)(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrla, nsfb_colour_t c); + +/** Plot cubic bezier spline + */ +typedef bool (nsfb_plotfn_cubic_bezier_t)(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrla, nsfb_point_t *ctrlb, nsfb_colour_t c); + +/** plot path */ +typedef bool (nsfb_plotfn_path_t)(nsfb_t *nsfb, int pathc, nsfb_plot_pathop_t *pathop, nsfb_plot_pen_t *pen); + +/** plotter function table. */ +typedef struct nsfb_plotter_fns_s { + nsfb_plotfn_clg_t *clg; + nsfb_plotfn_rectangle_t *rectangle; + nsfb_plotfn_line_t *line; + nsfb_plotfn_polygon_t *polygon; + nsfb_plotfn_fill_t *fill; + nsfb_plotfn_clip_t *get_clip; + nsfb_plotfn_clip_t *set_clip; + nsfb_plotfn_ellipse_t *ellipse; + nsfb_plotfn_ellipse_fill_t *ellipse_fill; + nsfb_plotfn_arc_t *arc; + nsfb_plotfn_bitmap_t *bitmap; + nsfb_plotfn_point_t *point; + nsfb_plotfn_copy_t *copy; + nsfb_plotfn_glyph8_t *glyph8; + nsfb_plotfn_glyph1_t *glyph1; + nsfb_plotfn_readrect_t *readrect; + nsfb_plotfn_quadratic_bezier_t *quadratic; + nsfb_plotfn_cubic_bezier_t *cubic; + nsfb_plotfn_path_t *path; +} nsfb_plotter_fns_t; + + +bool select_plotters(nsfb_t *nsfb); + diff --git a/include/plotters.h b/include/plotters.h deleted file mode 100644 index dc4648b..0000000 --- a/include/plotters.h +++ /dev/null @@ -1 +0,0 @@ -bool select_plotters(nsfb_t *nsfb); -- cgit v1.2.3