Convert framebuffer frontend to bitmap operations table.
This commit is contained in:
parent
c02f552e87
commit
cc11912da1
|
@ -2518,7 +2518,7 @@ void browser_window_reformat(struct browser_window *bw, bool background,
|
|||
}
|
||||
|
||||
/**
|
||||
* Set bowser window scale.
|
||||
* Set browser window scale.
|
||||
*
|
||||
* \param bw Browser window.
|
||||
* \param scale value.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2015 Vincent Sanders <vince@netsurf-browser.h>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_FB_BITMAP_H
|
||||
#define NS_FB_BITMAP_H
|
||||
|
||||
extern struct gui_bitmap_table *framebuffer_bitmap_table;
|
||||
|
||||
bool framebuffer_bitmap_get_opaque(void *bitmap);
|
||||
|
||||
#endif /* NS_FB_BITMAP_H */
|
|
@ -37,6 +37,7 @@
|
|||
#include "framebuffer/fbtk.h"
|
||||
#include "framebuffer/framebuffer.h"
|
||||
#include "framebuffer/font.h"
|
||||
#include "framebuffer/bitmap.h"
|
||||
|
||||
/* netsurf framebuffer library handle */
|
||||
static nsfb_t *nsfb;
|
||||
|
@ -215,7 +216,7 @@ framebuffer_plot_bitmap(int x, int y,
|
|||
* a flat fill of the area. Can only be done when image is fully
|
||||
* opaque. */
|
||||
if ((width == 1) && (height == 1)) {
|
||||
if (bitmap_get_opaque(bm)) {
|
||||
if (framebuffer_bitmap_get_opaque(bm)) {
|
||||
/** TODO: Currently using top left pixel. Maybe centre
|
||||
* pixel or average value would be better. */
|
||||
return nsfb_plot_rectangle_fill(nsfb, &clipbox,
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "framebuffer/font.h"
|
||||
#include "framebuffer/clipboard.h"
|
||||
#include "framebuffer/fetch.h"
|
||||
#include "framebuffer/bitmap.h"
|
||||
|
||||
#include "content/urldb.h"
|
||||
#include "content/fetch.h"
|
||||
|
@ -106,7 +107,7 @@ static struct gui_drag {
|
|||
*/
|
||||
static void die(const char *error)
|
||||
{
|
||||
LOG(("%s", error));
|
||||
fprintf(stderr, "%s\n", error);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -2081,6 +2082,7 @@ main(int argc, char** argv)
|
|||
.clipboard = framebuffer_clipboard_table,
|
||||
.fetch = framebuffer_fetch_table,
|
||||
.utf8 = framebuffer_utf8_table,
|
||||
.bitmap = framebuffer_bitmap_table,
|
||||
};
|
||||
|
||||
ret = netsurf_register(&framebuffer_table);
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
/**
|
||||
* \file
|
||||
* Generic bitmap handling (GDK / GTK+ implementation).
|
||||
*
|
||||
* This implements the interface given by desktop/bitmap.h using GdkPixbufs.
|
||||
|
|
Loading…
Reference in New Issue