From cc11912da1e2881803828330f85b0fe177b570b6 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 14 Apr 2015 23:08:02 +0100 Subject: Convert framebuffer frontend to bitmap operations table. --- framebuffer/bitmap.c | 55 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 18 deletions(-) (limited to 'framebuffer/bitmap.c') diff --git a/framebuffer/bitmap.c b/framebuffer/bitmap.c index fb45d6e95..713cf840a 100644 --- a/framebuffer/bitmap.c +++ b/framebuffer/bitmap.c @@ -16,16 +16,22 @@ * along with this program. If not, see . */ +/** + * \file + * Framebuffer implementation of generic bitmap interface. + */ + #include #include #include #include - #include #include "image/bitmap.h" #include "utils/log.h" +#include "framebuffer/bitmap.h" + /** * Create a bitmap. * @@ -34,8 +40,7 @@ * \param state a flag word indicating the initial state * \return an opaque struct bitmap, or NULL on memory exhaustion */ - -void *bitmap_create(int width, int height, unsigned int state) +static void *bitmap_create(int width, int height, unsigned int state) { nsfb_t *bm; @@ -72,8 +77,7 @@ void *bitmap_create(int width, int height, unsigned int state) * The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end * of rows. The width of a row in bytes is given by bitmap_get_rowstride(). */ - -unsigned char *bitmap_get_buffer(void *bitmap) +static unsigned char *bitmap_get_buffer(void *bitmap) { nsfb_t *bm = bitmap; unsigned char *bmpptr; @@ -92,8 +96,7 @@ unsigned char *bitmap_get_buffer(void *bitmap) * \param bitmap a bitmap, as returned by bitmap_create() * \return width of a pixel row in the bitmap */ - -size_t bitmap_get_rowstride(void *bitmap) +static size_t bitmap_get_rowstride(void *bitmap) { nsfb_t *bm = bitmap; int bmpstride; @@ -111,8 +114,7 @@ size_t bitmap_get_rowstride(void *bitmap) * * \param bitmap a bitmap, as returned by bitmap_create() */ - -void bitmap_destroy(void *bitmap) +static void bitmap_destroy(void *bitmap) { nsfb_t *bm = bitmap; @@ -130,8 +132,7 @@ void bitmap_destroy(void *bitmap) * \param flags flags controlling how the bitmap is saved. * \return true on success, false on error and error reported */ - -bool bitmap_save(void *bitmap, const char *path, unsigned flags) +static bool bitmap_save(void *bitmap, const char *path, unsigned flags) { return true; } @@ -142,7 +143,7 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags) * * \param bitmap a bitmap, as returned by bitmap_create() */ -void bitmap_modified(void *bitmap) { +static void bitmap_modified(void *bitmap) { } /** @@ -151,7 +152,7 @@ void bitmap_modified(void *bitmap) { * \param bitmap a bitmap, as returned by bitmap_create() * \param opaque whether the bitmap should be plotted opaque */ -void bitmap_set_opaque(void *bitmap, bool opaque) +static void bitmap_set_opaque(void *bitmap, bool opaque) { nsfb_t *bm = bitmap; @@ -171,7 +172,7 @@ void bitmap_set_opaque(void *bitmap, bool opaque) * \param bitmap a bitmap, as returned by bitmap_create() * \return whether the bitmap is opaque */ -bool bitmap_test_opaque(void *bitmap) +static bool bitmap_test_opaque(void *bitmap) { int tst; nsfb_t *bm = bitmap; @@ -203,7 +204,7 @@ bool bitmap_test_opaque(void *bitmap) * * \param bitmap a bitmap, as returned by bitmap_create() */ -bool bitmap_get_opaque(void *bitmap) +bool framebuffer_bitmap_get_opaque(void *bitmap) { nsfb_t *bm = bitmap; enum nsfb_format_e format; @@ -218,7 +219,7 @@ bool bitmap_get_opaque(void *bitmap) return true; } -int bitmap_get_width(void *bitmap) +static int bitmap_get_width(void *bitmap) { nsfb_t *bm = bitmap; int width; @@ -230,7 +231,7 @@ int bitmap_get_width(void *bitmap) return(width); } -int bitmap_get_height(void *bitmap) +static int bitmap_get_height(void *bitmap) { nsfb_t *bm = bitmap; int height; @@ -243,11 +244,29 @@ int bitmap_get_height(void *bitmap) } /* get bytes per pixel */ -size_t bitmap_get_bpp(void *bitmap) +static size_t bitmap_get_bpp(void *bitmap) { return 4; } +static struct gui_bitmap_table bitmap_table = { + .create = bitmap_create, + .destroy = bitmap_destroy, + .set_opaque = bitmap_set_opaque, + .get_opaque = framebuffer_bitmap_get_opaque, + .test_opaque = bitmap_test_opaque, + .get_buffer = bitmap_get_buffer, + .get_rowstride = bitmap_get_rowstride, + .get_width = bitmap_get_width, + .get_height = bitmap_get_height, + .get_bpp = bitmap_get_bpp, + .save = bitmap_save, + .modified = bitmap_modified, +}; + +struct gui_bitmap_table *framebuffer_bitmap_table = &bitmap_table; + + /* * Local Variables: * c-basic-offset:8 -- cgit v1.2.3