summaryrefslogtreecommitdiff
path: root/framebuffer/bitmap.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-04-14 23:08:02 +0100
committerVincent Sanders <vince@kyllikki.org>2015-04-14 23:08:02 +0100
commitcc11912da1e2881803828330f85b0fe177b570b6 (patch)
tree3c75b3ab3858c2a29d86ec62959a62266edf682c /framebuffer/bitmap.c
parentc02f552e8704f52e1a9ab92b21cb7d23211d98ab (diff)
downloadnetsurf-cc11912da1e2881803828330f85b0fe177b570b6.tar.gz
netsurf-cc11912da1e2881803828330f85b0fe177b570b6.tar.bz2
Convert framebuffer frontend to bitmap operations table.
Diffstat (limited to 'framebuffer/bitmap.c')
-rw-r--r--framebuffer/bitmap.c55
1 files changed, 37 insertions, 18 deletions
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 <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Framebuffer implementation of generic bitmap interface.
+ */
+
#include <inttypes.h>
#include <sys/types.h>
#include <stdbool.h>
#include <assert.h>
-
#include <libnsfb.h>
#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