Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | 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 interface for the libnsfb graphics library.
  9.  */
  10.  
  11. #ifndef _LIBNSFB_H
  12. #define _LIBNSFB_H 1
  13.  
  14. #include <stdint.h>
  15.  
  16. typedef struct nsfb_palette_s nsfb_palette_t;
  17. typedef struct nsfb_cursor_s nsfb_cursor_t;
  18. typedef struct nsfb_s nsfb_t;
  19. typedef struct nsfb_event_s nsfb_event_t;
  20.  
  21. /** co-ordinate for plotting operations */
  22. typedef struct nsfb_point_s {
  23.     int x;
  24.     int y;
  25. } nsfb_point_t;
  26.  
  27. /** bounding box for plotting operations */
  28. typedef struct nsfb_bbox_s {
  29.     int x0;
  30.     int y0;
  31.     int x1;
  32.     int y1;
  33. } nsfb_bbox_t;
  34.  
  35. /** The type of framebuffer surface. */
  36. enum nsfb_type_e {
  37.     NSFB_SURFACE_NONE = 0, /**< No surface */
  38.     NSFB_SURFACE_RAM, /**< RAM surface */
  39.     NSFB_SURFACE_SDL, /**< SDL surface */
  40.     NSFB_SURFACE_LINUX, /**< Linux framebuffer surface */
  41.     NSFB_SURFACE_VNC, /**< VNC surface */
  42.     NSFB_SURFACE_ABLE, /**< ABLE framebuffer surface */
  43.     NSFB_SURFACE_X /**< X windows surface */
  44. };
  45.  
  46. enum nsfb_format_e {
  47.     NSFB_FMT_ANY = 0, /* No specific format - use surface default */
  48.     NSFB_FMT_XBGR8888, /* 32bpp Blue Green Red */
  49.     NSFB_FMT_XRGB8888, /* 32bpp Red Green Blue */
  50.     NSFB_FMT_ABGR8888, /* 32bpp Alpga Blue Green Red */
  51.     NSFB_FMT_ARGB8888, /* 32bpp Alpga Red Green Blue */
  52.     NSFB_FMT_RGB888, /* 24 bpp Alpga Red Green Blue */
  53.     NSFB_FMT_ARGB1555, /* 16 bpp 555 */
  54.     NSFB_FMT_RGB565, /* 16 bpp 565 */
  55.     NSFB_FMT_I8, /* 8bpp indexed */
  56.     NSFB_FMT_I4, /* 4bpp indexed */
  57.     NSFB_FMT_I1, /* black and white */
  58. };
  59.  
  60. /** Select frontend type from a name.
  61.  *
  62.  * @param name The name to select a frontend.
  63.  * @return The surface type or NSFB_SURFACE_NONE if frontend with specified
  64.  *         name was not available
  65.  */
  66. enum nsfb_type_e nsfb_type_from_name(const char *name);
  67.  
  68. /** Create a nsfb context.
  69.  *
  70.  * This creates a framebuffer surface context.
  71.  *
  72.  * @param surface_type The type of surface to create a context for.
  73.  */
  74. nsfb_t *nsfb_new(const enum nsfb_type_e surface_type);
  75.  
  76. /** Initialise selected surface context.
  77.  *
  78.  * @param nsfb The context returned from ::nsfb_init
  79.  */
  80. int nsfb_init(nsfb_t *nsfb);
  81.  
  82. /** Free nsfb context.
  83.  *
  84.  * This shuts down and releases all resources associated with an nsfb context.
  85.  *
  86.  * @param nsfb The context returned from ::nsfb_new to free
  87.  */
  88. int nsfb_free(nsfb_t *nsfb);
  89.  
  90. /** Claim an area of screen to be redrawn.
  91.  *
  92.  * Informs the nsfb library that an area of screen will be directly
  93.  * updated by the user program. This is neccisarry so the library can
  94.  * ensure the soft cursor plotting is correctly handled. After the
  95.  * update has been perfomed ::nsfb_update should be called.
  96.  *
  97.  * @param box The bounding box of the area which might be altered.
  98.  */
  99. int nsfb_claim(nsfb_t *nsfb, nsfb_bbox_t *box);
  100.  
  101. /** Update an area of screen which has been redrawn.
  102.  *
  103.  * Informs the nsfb library that an area of screen has been directly
  104.  * updated by the user program. Some surfaces only show the update on
  105.  * notification. The area updated does not neccisarrily have to
  106.  * corelate with a previous ::nsfb_claim bounding box, however if the
  107.  * redrawn area is larger than the claimed area pointer plotting
  108.  * artifacts may occour.
  109.  *
  110.  * @param box The bounding box of the area which has been altered.
  111.  */
  112. int nsfb_update(nsfb_t *nsfb, nsfb_bbox_t *box);
  113.  
  114. /** Obtain the geometry of a nsfb context.
  115.  *
  116.  * @param width a variable to store the framebuffer width in or NULL
  117.  * @param height a variable to store the framebuffer height in or NULL
  118.  * @param format a variable to store the framebuffer format in or NULL
  119.  */
  120. int nsfb_get_geometry(nsfb_t *nsfb, int *width, int *height, enum nsfb_format_e *format);
  121.  
  122. /** Alter the geometry of a surface
  123.  *
  124.  * @param nsfb The context to alter.
  125.  * @param width The new display width.
  126.  * @param height The new display height.
  127.  * @param format The desired surface format.
  128.  */
  129. int nsfb_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format);
  130.  
  131. /** Set parameters a surface
  132.  *
  133.  * Some surface types can take additional parameters for
  134.  * attributes. For example the linux surface uses this to allow the
  135.  * setting of a different output device
  136.  *
  137.  * @param nsfb The surface to alter.
  138.  * @param parameters The parameters for the surface.
  139.  */
  140. int nsfb_set_parameters(nsfb_t *nsfb, const char *parameters);
  141.  
  142. /** Obtain the buffer memory base and stride.
  143.  *
  144.  * @param nsfb The context to read.
  145.  */
  146. int nsfb_get_buffer(nsfb_t *nsfb, uint8_t **ptr, int *linelen);
  147.  
  148. /** Dump the surface to fd in PPM format  
  149.  */
  150. bool nsfb_dump(nsfb_t *nsfb, int fd);
  151.  
  152.  
  153. #endif
  154.  
  155. /*
  156.  * Local variables:
  157.  *  c-basic-offset: 4
  158.  *  tab-width: 8
  159.  * End:
  160.  */
  161.