summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--include/libnsfb.h24
-rw-r--r--src/plot/32bpp-xrgb8888.c6
-rw-r--r--src/plot/generic.c16
-rw-r--r--src/surface/surface.c11
5 files changed, 43 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 95cb27e..e70cffb 100644
--- a/Makefile
+++ b/Makefile
@@ -2,11 +2,11 @@
#
# Makefile for libnsfb
#
-# Copyright 2013-2015 Vincent Sanders <vince@netsurf-browser.org>
+# Copyright 2013-2020 Vincent Sanders <vince@netsurf-browser.org>
# Component settings
COMPONENT := nsfb
-COMPONENT_VERSION := 0.2.0
+COMPONENT_VERSION := 0.2.2
# Default to a static library
COMPONENT_TYPE ?= lib-static
diff --git a/include/libnsfb.h b/include/libnsfb.h
index dfb720c..674df65 100644
--- a/include/libnsfb.h
+++ b/include/libnsfb.h
@@ -35,13 +35,14 @@ typedef struct nsfb_bbox_s {
/** 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_X, /**< X windows surface */
+ NSFB_SURFACE_WL, /**< Wayland surface */
NSFB_SURFACE_VNC, /**< VNC surface */
+ NSFB_SURFACE_LINUX, /**< Linux framebuffer surface */
NSFB_SURFACE_ABLE, /**< ABLE framebuffer surface */
- NSFB_SURFACE_X, /**< X windows surface */
- NSFB_SURFACE_WL /**< Wayland surface */
+ NSFB_SURFACE_RAM, /**< RAM surface */
+ NSFB_SURFACE_COUNT, /**< The number of surface kinds */
};
enum nsfb_format_e {
@@ -58,6 +59,21 @@ enum nsfb_format_e {
NSFB_FMT_I1, /* black and white */
};
+/** Callback for surface enumeration
+ *
+ * @param The context you gave for the enumeration
+ * @param The name of a surface registered with libnsfb
+ * @param The type of that surface for use with ::nsfb_new
+ */
+typedef void (*surface_enumeration_cb)(void *, const char *, enum nsfb_type_e);
+
+/** Enumerate surface types registered with libnsfb
+ *
+ * @param cb The callback to call with each surface
+ * @param context The context to pass to the enumeration callback
+ */
+void nsfb_enumerate_surface_types(surface_enumeration_cb cb, void *context);
+
/** Select frontend type from a name.
*
* @param name The name to select a frontend.
diff --git a/src/plot/32bpp-xrgb8888.c b/src/plot/32bpp-xrgb8888.c
index 6f77f44..28e6673 100644
--- a/src/plot/32bpp-xrgb8888.c
+++ b/src/plot/32bpp-xrgb8888.c
@@ -66,9 +66,7 @@ static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
*/
static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
{
- return ((pixel & 0xFF) << 16) |
- ((pixel & 0xFF00)) |
- ((pixel & 0xFF0000) >> 16);
+ return (((pixel >> 16) | (pixel << 16)) & 0xff00ff) | (pixel & 0xff00);
}
@@ -81,7 +79,7 @@ static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
*/
static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
{
- return ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16);
+ return (((c >> 16) | (c << 16)) & 0xff00ff) | (c & 0xff00);
}
#endif
diff --git a/src/plot/generic.c b/src/plot/generic.c
index ea0bb04..e343390 100644
--- a/src/plot/generic.c
+++ b/src/plot/generic.c
@@ -267,7 +267,7 @@ static bool polygon(nsfb_t *nsfb, const int *p, unsigned int n, nsfb_colour_t c)
int poly_x0, poly_y0; /* Bounding box top left corner */
int poly_x1, poly_y1; /* Bounding box bottom right corner */
int i, j; /* indexes */
- int x0, x1; /* filled span extents */
+ int x0 = 0, x1 = 0; /* filled span extents */
int y; /* current y coordinate */
int y_max; /* bottom of plot area */
nsfb_bbox_t fline;
@@ -615,13 +615,13 @@ copy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
static bool arc(nsfb_t *nsfb, int x, int y, int radius, int angle1,
int angle2, nsfb_colour_t c)
{
- nsfb=nsfb;
- x = x;
- y = y;
- radius = radius;
- c = c;
- angle1=angle1;
- angle2=angle2;
+ (void)nsfb;
+ (void)x;
+ (void)y;
+ (void)radius;
+ (void)c;
+ (void)angle1;
+ (void)angle2;
return true;
}
diff --git a/src/surface/surface.c b/src/surface/surface.c
index f3127bd..426efa9 100644
--- a/src/surface/surface.c
+++ b/src/surface/surface.c
@@ -151,6 +151,17 @@ nsfb_type_from_name(const char *name)
return NSFB_SURFACE_NONE;
}
+/* exported interface defined in libnsfb.h */
+void
+nsfb_enumerate_surface_types(surface_enumeration_cb cb, void *context)
+{
+ int fend_loop;
+
+ for (fend_loop = 0; fend_loop < surface_count; fend_loop++) {
+ cb(context, surfaces[fend_loop].name, surfaces[fend_loop].type);
+ }
+}
+
/*
* Local variables:
* c-basic-offset: 4