From 2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 21 Nov 2011 08:44:10 +0000 Subject: Improve API to allow for RAM surfaces instead of direct blitting Improve and update tests Fix RAM surface Fix VNC surface svn path=/trunk/libnsfb/; revision=13158 --- include/libnsfb.h | 94 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 33 deletions(-) (limited to 'include/libnsfb.h') diff --git a/include/libnsfb.h b/include/libnsfb.h index 3f4a4e7..330c476 100644 --- a/include/libnsfb.h +++ b/include/libnsfb.h @@ -31,46 +31,60 @@ typedef struct nsfb_bbox_s { int y1; } nsfb_bbox_t; -/** The type of frontend for a framebuffer context. */ -enum nsfb_frontend_e { - NSFB_FRONTEND_NONE = 0, /**< Empty frontend. */ - NSFB_FRONTEND_SDL, /**< SDL frontend */ - NSFB_FRONTEND_LINUX, /**< Linux frontend */ - NSFB_FRONTEND_VNC, /**< VNC frontend */ - NSFB_FRONTEND_ABLE, /**< ABLE frontend */ - NSFB_FRONTEND_RAM, /**< RAM frontend */ - NSFB_FRONTEND_X /**< X windows frontend */ +/** The type of framebuffer surface. */ +enum nsfb_type_e { + NSFB_SURFACE_NONE = 0, /**< No surface */ + NSFB_SURFACE_RAM, /**< RAM surface */ + NSFB_SURFACE_SDL, /**< SDL surface */ + NSFB_SURFACE_LINUX, /**< Linux framebuffer surface */ + NSFB_SURFACE_VNC, /**< VNC surface */ + NSFB_SURFACE_ABLE, /**< ABLE framebuffer surface */ + NSFB_SURFACE_X /**< X windows surface */ }; -/** Initialise nsfb context. - * - * This initialises a framebuffer context. - * - * @param frontend The type of frontend to create a context for. +enum nsfb_format_e { + NSFB_FMT_ANY = 0, /* No specific format - use surface default */ + NSFB_FMT_XBGR8888, /* 32bpp Blue Green Red */ + NSFB_FMT_XRGB8888, /* 32bpp Red Green Blue */ + NSFB_FMT_ABGR8888, /* 32bpp Alpga Blue Green Red */ + NSFB_FMT_ARGB8888, /* 32bpp Alpga Red Green Blue */ + NSFB_FMT_RGB888, /* 24 bpp Alpga Red Green Blue */ + NSFB_FMT_ARGB1555, /* 16 bpp 555 */ + NSFB_FMT_RGB565, /* 16 bpp 565 */ + NSFB_FMT_I8, /* 8bpp indexed */ + NSFB_FMT_I4, /* 4bpp indexed */ + NSFB_FMT_I1, /* black and white */ +}; + +/** Select frontend type from a name. + * + * @param name The name to select a frontend. + * @return The surface type or NSFB_SURFACE_NONE if frontend with specified + * name was not available */ -nsfb_t *nsfb_init(enum nsfb_frontend_e frontend); +enum nsfb_type_e nsfb_type_from_name(const char *name); -/** Finalise nsfb. +/** Create a nsfb context. * - * This shuts down and releases all resources associated with an nsfb context. + * This creates a framebuffer surface context. * - * @param nsfb The context returned from ::nsfb_init tofinalise + * @param surface_type The type of surface to create a context for. */ -int nsfb_finalise(nsfb_t *nsfb); +nsfb_t *nsfb_new(const enum nsfb_type_e surface_type); -/** Initialise selected frontend. +/** Initialise selected surface context. * * @param nsfb The context returned from ::nsfb_init */ -int nsfb_init_frontend(nsfb_t *nsfb); +int nsfb_init(nsfb_t *nsfb); -/** Select frontend type from a name. - * - * @param name The name to select a frontend. - * @return The frontend type or NSFB_FRONTEND_NONE if frontend with specified - * name was not available +/** Free nsfb context. + * + * This shuts down and releases all resources associated with an nsfb context. + * + * @param nsfb The context returned from ::nsfb_new to free */ -enum nsfb_frontend_e nsfb_frontend_from_name(const char *name); +int nsfb_free(nsfb_t *nsfb); /** Claim an area of screen to be redrawn. * @@ -86,7 +100,7 @@ int nsfb_claim(nsfb_t *nsfb, nsfb_bbox_t *box); /** Update an area of screen which has been redrawn. * * Informs the nsfb library that an area of screen has been directly - * updated by the user program. Some frontends only show the update on + * updated by the user program. Some surfaces only show the update on * notification. The area updated does not neccisarrily have to * corelate with a previous ::nsfb_claim bounding box, however if the * redrawn area is larger than the claimed area pointer plotting @@ -100,9 +114,9 @@ int nsfb_update(nsfb_t *nsfb, nsfb_bbox_t *box); * * @param width a variable to store the framebuffer width in or NULL * @param height a variable to store the framebuffer height in or NULL - * @param bpp a variable to store the framebuffer bpp in or NULL + * @param format a variable to store the framebuffer format in or NULL */ -int nsfb_get_geometry(nsfb_t *nsfb, int *width, int *height, int *bpp); +int nsfb_get_geometry(nsfb_t *nsfb, int *width, int *height, enum nsfb_format_e *format); /** Alter the geometry of a framebuffer context * @@ -111,10 +125,24 @@ int nsfb_get_geometry(nsfb_t *nsfb, int *width, int *height, int *bpp); * @param height The new display height. * @param bpp The new display depth. */ -int nsfb_set_geometry(nsfb_t *nsfb, int width, int height, int bpp); +int nsfb_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format); -/** Obtain the framebuffer memory base and stride. +/** Obtain the buffer memory base and stride. + * + * @param nsfb The context to read. */ -int nsfb_get_framebuffer(nsfb_t *nsfb, uint8_t **ptr, int *linelen); +int nsfb_get_buffer(nsfb_t *nsfb, uint8_t **ptr, int *linelen); + +/** Dump the surface to fd in PPM format + */ +bool nsfb_dump(nsfb_t *nsfb, int fd); + #endif + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ -- cgit v1.2.3