Subversion Repositories Kolibri OS

Rev

Rev 3621 | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2009 Vincent Sanders <vince@simtec.co.uk>
  3.  *
  4.  * This file is part of libnsfb, http://www.netsurf-browser.org/
  5.  * Licenced under the MIT License,
  6.  *                http://www.opensource.org/licenses/mit-license.php
  7.  *
  8.  * This is the exported plotter interface for the libnsfb graphics library.
  9.  */
  10.  
  11. #ifndef _LIBNSFB_PLOT_H
  12. #define _LIBNSFB_PLOT_H 1
  13.  
  14. /** representation of a colour.
  15.  *
  16.  * The colour value comprises of four components arranged in the order ABGR:
  17.  * bits 24-31 are the alpha value and represent the opacity. 0 is
  18.  *   transparent i.e. there would be no change in the target surface if
  19.  *   this colour were to be used and 0xFF is opaque.
  20.  *
  21.  * bits 16-23 are the Blue component of the colour.
  22.  *
  23.  * bits 8-15 are the Green component of the colour.
  24.  *
  25.  * bits 0-7 are the Red component of the colour.
  26.  */
  27. typedef uint32_t nsfb_colour_t;
  28.  
  29. /**
  30.  * Type of plot operation
  31.  */
  32. typedef enum nsfb_plot_optype_e {
  33.         NFSB_PLOT_OPTYPE_NONE = 0, /**< No operation */
  34.         NFSB_PLOT_OPTYPE_SOLID, /**< Solid colour */
  35.         NFSB_PLOT_OPTYPE_PATTERN, /**< Pattern plot */
  36. } nsfb_plot_optype_t;
  37.  
  38. /** pen colour and raster operation for plotting primatives. */
  39. typedef struct nsfb_plot_pen_s {
  40.         nsfb_plot_optype_t stroke_type; /**< Stroke plot type */
  41.         int stroke_width; /**< Width of stroke, in pixels */
  42.         nsfb_colour_t stroke_colour; /**< Colour of stroke */
  43.         uint32_t stroke_pattern;
  44.         nsfb_plot_optype_t fill_type; /**< Fill plot type */
  45.         nsfb_colour_t fill_colour; /**< Colour of fill */
  46. } nsfb_plot_pen_t;
  47.  
  48. /** path operation type. */
  49. typedef enum nsfb_plot_pathop_type_e {
  50.         NFSB_PLOT_PATHOP_MOVE,
  51.         NFSB_PLOT_PATHOP_LINE,
  52.         NFSB_PLOT_PATHOP_QUAD,
  53.         NFSB_PLOT_PATHOP_CUBIC,
  54. } nsfb_plot_pathop_type_t;
  55.  
  56. /** path element */
  57. typedef struct nsfb_plot_pathop_s {
  58.         nsfb_plot_pathop_type_t operation;
  59.         nsfb_point_t point;
  60. } nsfb_plot_pathop_t;
  61.  
  62. /** Sets a clip rectangle for subsequent plots.
  63.  *
  64.  * Sets a clipping area which constrains all subsequent plotting operations.
  65.  * The clipping area must lie within the framebuffer visible screen or false
  66.  * will be returned and the new clipping area not set.
  67.  */
  68. bool nsfb_plot_set_clip(nsfb_t *nsfb, nsfb_bbox_t *clip);
  69.  
  70. /** Get the previously set clipping region.
  71.  */
  72. bool nsfb_plot_get_clip(nsfb_t *nsfb, nsfb_bbox_t *clip);
  73.  
  74. /** Clears plotting area to a flat colour.
  75.  */
  76. bool nsfb_plot_clg(nsfb_t *nsfb, nsfb_colour_t c);
  77.  
  78. /** Plots a rectangle outline.
  79.  *
  80.  * The line can be solid, dotted or dashed. Top left corner at (x0,y0) and
  81.  * rectangle has given width and height.
  82.  */
  83. bool nsfb_plot_rectangle(nsfb_t *nsfb, nsfb_bbox_t *rect, int line_width, nsfb_colour_t c, bool dotted, bool dashed);
  84.  
  85. /** Plots a filled rectangle. Top left corner at (x0,y0), bottom
  86.  *                right corner at (x1,y1). Note: (x0,y0) is inside filled area,
  87.  *                but (x1,y1) is below and to the right. See diagram below.
  88.  */
  89. bool nsfb_plot_rectangle_fill(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c);
  90.  
  91. /** Plots a line.
  92.  *
  93.  * Draw a line from (x0,y0) to (x1,y1). Coordinates are at centre of line
  94.  * width/thickness.
  95.  */
  96. bool nsfb_plot_line(nsfb_t *nsfb, nsfb_bbox_t *line, nsfb_plot_pen_t *pen);
  97.  
  98. /** Plots a number of lines.
  99.  *
  100.  * Draw a series of lines.
  101.  */
  102. bool nsfb_plot_lines(nsfb_t *nsfb, int linec, nsfb_bbox_t *line, nsfb_plot_pen_t *pen);
  103.  
  104. /** Plots a number of connected lines.
  105.  *
  106.  * Draw a series of connected lines.
  107.  */
  108. bool nsfb_plot_polylines(nsfb_t *nsfb, int pointc, const nsfb_point_t *points, nsfb_plot_pen_t *pen);
  109.  
  110. /** Plots a filled polygon.
  111.  *
  112.  * Plots a filled polygon with straight lines between points. The lines around
  113.  * the edge of the ploygon are not plotted. The polygon is filled with a
  114.  * non-zero winding rule.
  115.  *
  116.  *
  117.  */
  118. bool nsfb_plot_polygon(nsfb_t *nsfb, const int *p, unsigned int n, nsfb_colour_t fill);
  119.  
  120. /** Plot an ellipse.
  121.  */
  122. bool nsfb_plot_ellipse(nsfb_t *nsfb, nsfb_bbox_t *ellipse, nsfb_colour_t c);
  123.  
  124. /** Plot a filled ellipse.
  125.  */
  126. bool nsfb_plot_ellipse_fill(nsfb_t *nsfb, nsfb_bbox_t *ellipse, nsfb_colour_t c);
  127.  
  128. /** Plots an arc.
  129.  *
  130.  * around (x,y), from anticlockwise from angle1 to angle2. Angles are measured
  131.  * anticlockwise from horizontal, in degrees.
  132.  */
  133. bool nsfb_plot_arc(nsfb_t *nsfb, int x, int y, int radius, int angle1, int angle2, nsfb_colour_t c);
  134.  
  135. /** Plots an alpha blended pixel.
  136.  *
  137.  * plots an alpha blended pixel.
  138.  */
  139. bool nsfb_plot_point(nsfb_t *nsfb, int x, int y, nsfb_colour_t c);
  140.  
  141. bool nsfb_plot_cubic_bezier(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrla, nsfb_point_t *ctrlb, nsfb_plot_pen_t *pen);
  142.  
  143. bool nsfb_plot_quadratic_bezier(nsfb_t *nsfb, nsfb_bbox_t *curve, nsfb_point_t *ctrla, nsfb_plot_pen_t *pen);
  144.  
  145. bool nsfb_plot_path(nsfb_t *nsfb, int pathc, nsfb_plot_pathop_t *pathop, nsfb_plot_pen_t *pen);
  146.  
  147. /** copy an area of screen
  148.  *
  149.  * Copy an area of the display.
  150.  */
  151. bool nsfb_plot_copy(nsfb_t *srcfb, nsfb_bbox_t *srcbox, nsfb_t *dstfb, nsfb_bbox_t *dstbox);
  152.  
  153. /** Plot bitmap.
  154.  */
  155. bool nsfb_plot_bitmap(nsfb_t *nsfb, const nsfb_bbox_t *loc, const nsfb_colour_t *pixel, int bmp_width, int bmp_height, int bmp_stride, bool alpha);
  156.  
  157. /** Plot an 8 bit glyph.
  158.  */
  159. bool nsfb_plot_glyph8(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c);
  160.  
  161.  
  162. /** Plot an 1 bit glyph.
  163.  */
  164. bool nsfb_plot_glyph1(nsfb_t *nsfb, nsfb_bbox_t *loc, const uint8_t *pixel, int pitch, nsfb_colour_t c);
  165.  
  166. /* read rectangle into buffer */
  167. bool nsfb_plot_readrect(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t *buffer);
  168.  
  169. #endif /* _LIBNSFB_PLOT_H */
  170.