Update monkey frontend to use bitmap operation table.

This commit is contained in:
Vincent Sanders 2015-04-15 22:03:34 +01:00
parent cc11912da1
commit 9679561eca
5 changed files with 66 additions and 16 deletions

View File

@ -26,16 +26,15 @@
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include <cairo.h>
#include <gtk/gtk.h>
#include "utils/log.h"
#include "content/content.h"
#include "image/bitmap.h"
#include "gtk/scaffolding.h"
#include "gtk/bitmap.h"
#include "image/bitmap.h"
#include "utils/log.h"
/**

View File

@ -18,9 +18,12 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "image/bitmap.h"
#include "monkey/bitmap.h"
struct bitmap {
void *ptr;
size_t rowstride;
@ -29,7 +32,7 @@ struct bitmap {
unsigned int state;
};
void *bitmap_create(int width, int height, unsigned int state)
static void *bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)
@ -49,14 +52,14 @@ void *bitmap_create(int width, int height, unsigned int state)
return ret;
}
void bitmap_destroy(void *bitmap)
static void bitmap_destroy(void *bitmap)
{
struct bitmap *bmap = bitmap;
free(bmap->ptr);
free(bmap);
}
void bitmap_set_opaque(void *bitmap, bool opaque)
static void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bmap = bitmap;
@ -66,56 +69,73 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
bmap->state &= ~(BITMAP_OPAQUE);
}
bool bitmap_test_opaque(void *bitmap)
static bool bitmap_test_opaque(void *bitmap)
{
return false;
}
bool bitmap_get_opaque(void *bitmap)
static bool bitmap_get_opaque(void *bitmap)
{
struct bitmap *bmap = bitmap;
return (bmap->state & BITMAP_OPAQUE) == BITMAP_OPAQUE;
}
unsigned char *bitmap_get_buffer(void *bitmap)
static unsigned char *bitmap_get_buffer(void *bitmap)
{
struct bitmap *bmap = bitmap;
return (unsigned char *)(bmap->ptr);
}
size_t bitmap_get_rowstride(void *bitmap)
static size_t bitmap_get_rowstride(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->width * 4;
}
size_t bitmap_get_bpp(void *bitmap)
static size_t bitmap_get_bpp(void *bitmap)
{
/* OMG?! */
return 4;
}
bool bitmap_save(void *bitmap, const char *path, unsigned flags)
static bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
return true;
}
void bitmap_modified(void *bitmap)
static void bitmap_modified(void *bitmap)
{
struct bitmap *bmap = bitmap;
bmap->state |= BITMAP_MODIFIED;
}
int bitmap_get_width(void *bitmap)
static int bitmap_get_width(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->width;
}
int bitmap_get_height(void *bitmap)
static int bitmap_get_height(void *bitmap)
{
struct bitmap *bmap = bitmap;
return bmap->height;
}
static struct gui_bitmap_table bitmap_table = {
.create = bitmap_create,
.destroy = bitmap_destroy,
.set_opaque = bitmap_set_opaque,
.get_opaque = 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 *monkey_bitmap_table = &bitmap_table;

24
monkey/bitmap.h Normal file
View File

@ -0,0 +1,24 @@
/*
* Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
*
* 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_MONKEY_BITMAP_H
#define NS_MONKEY_BITMAP_H
extern struct gui_bitmap_table *monkey_bitmap_table;
#endif /* NS_MONKEY_BITMAP_H */

View File

@ -16,4 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NS_MONKEY_FETCH_H
#define NS_MONKEY_FETCH_H
struct gui_fetch_table *monkey_fetch_table;
#endif /* NS_MONKEY_FETCH_H */

View File

@ -37,6 +37,7 @@
#include "monkey/filetype.h"
#include "monkey/fetch.h"
#include "monkey/schedule.h"
#include "monkey/bitmap.h"
char **respaths; /** resource search path vector */
@ -140,6 +141,7 @@ main(int argc, char **argv)
.window = monkey_window_table,
.download = monkey_download_table,
.fetch = monkey_fetch_table,
.bitmap = monkey_bitmap_table,
};
ret = netsurf_register(&monkey_table);