Fix the BeOS build:

- hack to work around stdbool.h issue with R5 devkit
- fix prototypes
- fix bitmap code
- fix copy-paste on forward button
- remove unused gif throbber loading code
- R5 rgb_color doesn't have != operator, use memcmp()
- switch back to file based [beos]default.css for the time being
- realpath() hack for R5
Regressions:
- asserts on haiku-os.org
- no libns* yet, so less image support
- text field input doesn't work anymore.

svn path=/trunk/netsurf/; revision=5109
This commit is contained in:
François Revel 2008-08-13 19:35:41 +00:00
parent 80c98b8694
commit 44856d86d4
16 changed files with 83 additions and 139 deletions

View File

@ -23,7 +23,8 @@
* This implements the interface given by desktop/bitmap.h using BBitmap.
*/
#include <stdbool.h>
#define __STDBOOL_H__ 1
//#include <stdbool.h>
#include <assert.h>
#include <string.h>
#include <Bitmap.h>
@ -118,7 +119,7 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
* \return an opaque struct bitmap, or NULL on memory exhaustion
*/
struct bitmap *bitmap_create(int width, int height, unsigned int state)
void *bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
if (bmp == NULL)
@ -153,8 +154,9 @@ struct bitmap *bitmap_create(int width, int height, unsigned int state)
* \param bitmap a bitmap, as returned by bitmap_create()
* \param opaque whether the bitmap should be plotted opaque
*/
void bitmap_set_opaque(struct bitmap *bitmap, bool opaque)
void bitmap_set_opaque(void *vbitmap, bool opaque)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
/* todo: set bitmap as opaque */
bitmap->opaque = true;
@ -167,8 +169,9 @@ void bitmap_set_opaque(struct bitmap *bitmap, bool opaque)
* \param bitmap a bitmap, as returned by bitmap_create()
* \return whether the bitmap is opaque
*/
bool bitmap_test_opaque(struct bitmap *bitmap)
bool bitmap_test_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
/* todo: test if bitmap as opaque */
return false;//bitmap->opaque;
@ -180,8 +183,9 @@ bool bitmap_test_opaque(struct bitmap *bitmap)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
bool bitmap_get_opaque(struct bitmap *bitmap)
bool bitmap_get_opaque(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
/* todo: get whether bitmap is opaque */
return false;//bitmap->opaque;
@ -198,10 +202,11 @@ bool bitmap_get_opaque(struct bitmap *bitmap)
* of rows. The width of a row in bytes is given by bitmap_get_rowstride().
*/
char *bitmap_get_buffer(struct bitmap *bitmap)
unsigned char *bitmap_get_buffer(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
return (char *)(bitmap->shadow->Bits());
return (unsigned char *)(bitmap->shadow->Bits());
}
@ -212,13 +217,29 @@ char *bitmap_get_buffer(struct bitmap *bitmap)
* \return width of a pixel row in the bitmap
*/
size_t bitmap_get_rowstride(struct bitmap *bitmap)
size_t bitmap_get_rowstride(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
return (bitmap->primary->BytesPerRow());
}
/**
* Find the bytes per pixels of a bitmap.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \return bytes per pixels of the bitmap
*/
size_t bitmap_get_bpp(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
return 4;
}
static void
nsbeos_bitmap_free_pretiles(struct bitmap *bitmap)
{
@ -235,8 +256,9 @@ nsbeos_bitmap_free_pretiles(struct bitmap *bitmap)
* \param bitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_destroy(struct bitmap *bitmap)
void bitmap_destroy(void *vbitmap)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
nsbeos_bitmap_free_pretiles(bitmap);
delete bitmap->primary;
@ -254,8 +276,9 @@ void bitmap_destroy(struct bitmap *bitmap)
* \return true on success, false on error and error reported
*/
bool bitmap_save(struct bitmap *bitmap, const char *path, unsigned flags)
bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
#warning WRITEME
#if 0 /* GTK */
GError *err = NULL;
@ -276,7 +299,8 @@ bool bitmap_save(struct bitmap *bitmap, const char *path, unsigned flags)
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
void bitmap_modified(struct bitmap *bitmap) {
void bitmap_modified(void *vbitmap) {
struct bitmap *bitmap = (struct bitmap *)vbitmap;
// convert the shadow (ABGR) to into the primary bitmap
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
bitmap->primary->Bounds().Width() + 1,
@ -294,8 +318,9 @@ void bitmap_modified(struct bitmap *bitmap) {
* \param suspend the function to be called upon suspension
* \param resume the function to be called when resuming
*/
void bitmap_set_suspendable(struct bitmap *bitmap, void *private_word,
void bitmap_set_suspendable(void *vbitmap, void *private_word,
void (*invalidate)(struct bitmap *bitmap, void *private_word)) {
struct bitmap *bitmap = (struct bitmap *)vbitmap;
}
static BBitmap *
@ -370,7 +395,7 @@ nsbeos_bitmap_generate_pretile(BBitmap *primary, int repeat_x, int repeat_y)
BBitmap *
nsbeos_bitmap_get_primary(struct bitmap* bitmap)
{
return bitmap->primary;
return bitmap->primary;
}
/**

View File

@ -21,6 +21,7 @@
#define _GNU_SOURCE
#define __STDBOOL_H__ 1
#include <assert.h>
#include <errno.h>
#include <stdbool.h>

View File

@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDBOOL_H__ 1
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

View File

@ -24,6 +24,7 @@
*/
#define __STDBOOL_H__ 1
#include <stdbool.h>
#include <assert.h>
#include <stdio.h>
@ -353,7 +354,7 @@ bool nsfont_paint(const struct css_style *style,
view->DrawString(line.String(), where);
view->SetDrawingMode(oldmode);
if (oldbg != background)
if (memcmp(&oldbg, &background, sizeof(rgb_color)))
view->SetLowColor(oldbg);
//nsbeos_current_gc_unlock();

View File

@ -18,6 +18,7 @@
*/
#define _GNU_SOURCE /* for strndup */
#define __STDBOOL_H__ 1
#include <assert.h>
#include <ctype.h>
#include <stdbool.h>
@ -33,7 +34,9 @@
#include <Alert.h>
#include <Application.h>
#include <BeBuild.h>
#include <Mime.h>
#include <Path.h>
#include <Roster.h>
#include <String.h>
@ -226,6 +229,20 @@ static char *generate_default_css()
return strdup(url);
}
/* realpath fallback on R5 */
#if !defined(__HAIKU__) && !defined(B_BEOS_VERSION_DANO)
char *realpath(const char *f, char *buf)
{
BPath path(f, NULL, true);
if (path.InitCheck() < 0) {
strncpy(buf, f, MAXPATHLEN);
return NULL;
}
strncpy(buf, path.Path(), MAXPATHLEN);
return buf;
}
#endif
/**
* Locate a shared resource file by searching known places in order.
*
@ -447,13 +464,15 @@ void gui_init(int argc, char** argv)
beos_fetch_filetype_init(buf);
/* set up stylesheet urls */
/*find_resource(buf, "beosdefault.css", "./beos/res/beosdefault.css");*/
default_stylesheet_url = strdup("rsrc:/beosdefault.css,text/css");
find_resource(buf, "beosdefault.css", "./beos/res/beosdefault.css");
default_stylesheet_url = path_to_url(buf);
//default_stylesheet_url = strdup("rsrc:/beosdefault.css,text/css");
//default_stylesheet_url = generate_default_css();
LOG(("Using '%s' as Default CSS URL", default_stylesheet_url));
/*find_resource(buf, "adblock.css", "./beos/res/adblock.css");*/
adblock_stylesheet_url = strdup("rsrc:/adblock.css,text/css");
find_resource(buf, "adblock.css", "./beos/res/adblock.css");
adblock_stylesheet_url = path_to_url(buf);
//adblock_stylesheet_url = strdup("rsrc:/adblock.css,text/css");
LOG(("Using '%s' as AdBlock CSS URL", adblock_stylesheet_url));
urldb_load(option_url_file);
@ -768,7 +787,7 @@ void gui_quit(void)
struct gui_download_window *gui_download_window_create(const char *url,
const char *mime_type, struct fetch *fetch,
unsigned int total_size)
unsigned int total_size, struct gui_window *gui)
{
return 0;
}

View File

@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDBOOL_H__ 1
extern "C" {
#include "utils/log.h"
#include "content/urldb.h"

View File

@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDBOOL_H__ 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDBOOL_H__ 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -22,6 +22,7 @@
* Target independent plotting (BeOS/Haiku implementation).
*/
#define __STDBOOL_H__ 1
#include <math.h>
#include <BeBuild.h>
#include <Bitmap.h>
@ -72,10 +73,10 @@ static bool nsbeos_plot_disc(int x, int y, int radius, colour c, bool filled);
static bool nsbeos_plot_arc(int x, int y, int radius, int angle1, int angle2,
colour c);
static bool nsbeos_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg);
struct bitmap *bitmap, colour bg, struct content *content);
static bool nsbeos_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y);
bool repeat_x, bool repeat_y, struct content *content);
#if 0 /* GTK */
static GdkRectangle cliprect;
@ -563,7 +564,7 @@ static bool nsbeos_plot_bbitmap(int x, int y, int width, int height,
}
bool nsbeos_plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg)
struct bitmap *bitmap, colour bg, struct content *content)
{
BBitmap *b = nsbeos_bitmap_get_primary(bitmap);
return nsbeos_plot_bbitmap(x, y, width, height, b, bg);
@ -575,7 +576,7 @@ bool nsbeos_plot_bitmap(int x, int y, int width, int height,
bool nsbeos_plot_bitmap_tile(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bool repeat_x, bool repeat_y)
bool repeat_x, bool repeat_y, struct content *content)
{
int doneheight = 0, donewidth = 0;
BBitmap *primary;
@ -583,7 +584,7 @@ bool nsbeos_plot_bitmap_tile(int x, int y, int width, int height,
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
return nsbeos_plot_bitmap(x,y,width,height,bitmap,bg);
return nsbeos_plot_bitmap(x,y,width,height,bitmap,bg,content);
}
if (repeat_x && !repeat_y)

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#define __STDBOOL_H__ 1
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@ -539,7 +539,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
nsbeos_window_update_back_forward(scaffold);
break;
case 'forw':
if (!history_back_available(bw->history))
if (!history_forward_available(bw->history))
break;
history_forward(bw, bw->history);
nsbeos_window_update_back_forward(scaffold);

View File

@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDBOOL_H__ 1
#include <stdlib.h>
#include <stdbool.h>
#include <OS.h>

View File

@ -17,12 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDBOOL_H__ 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
#include "utils/log.h"
#include "image/gifread.h"
}
#include "beos/beos_throbber.h"
#include "beos/beos_bitmap.h"
@ -106,117 +106,6 @@ bool nsbeos_throbber_initialise_from_png(const int frames, ...)
return true;
}
/**
* Creates the throbber using a single GIF, using the first frame as the
* inactive throbber, and the others for the active animation. The GIF must
* therefor have at least two frames.
*
* \param fn Filename of GIF to use. It must have at least two frames.
* \return true on success.
*/
bool nsbeos_throbber_initialise_from_gif(const char *fn)
{
/* disect the GIF provided by filename in *fn into a series of
* BBitmap for use later.
*/
struct gif_animation *gif; /**< structure for gifread.c */
struct nsbeos_throbber *throb; /**< structure we generate */
int i;
FILE *fh = fopen(fn, "rb");
if (fh == NULL) {
LOG(("Unable to open throbber image '%s' for reading!", fn));
return false;
}
gif = (struct gif_animation *)malloc(sizeof(struct gif_animation));
throb = (struct nsbeos_throbber *)malloc(sizeof(struct nsbeos_throbber));
/* discover the size of the data file. */
fseek(fh, 0, SEEK_END);
gif->buffer_size = ftell(fh);
fseek(fh, 0, SEEK_SET);
/* allocate a block of sufficient size, and load the data in. */
gif->gif_data = (unsigned char *)malloc(gif->buffer_size);
fread(gif->gif_data, gif->buffer_size, 1, fh);
fclose(fh);
/* set current position within GIF file to beginning, in order to
* signal to gifread that we're brand new.
*/
gif->buffer_position = 0;
/* initialise the gif_animation structure. */
switch (gif_initialise(gif))
{
case GIF_INSUFFICIENT_FRAME_DATA:
case GIF_FRAME_DATA_ERROR:
case GIF_INSUFFICIENT_DATA:
case GIF_DATA_ERROR:
LOG(("GIF image '%s' appears invalid!", fn));
free(gif->gif_data);
free(gif);
free(throb);
return false;
break;
case GIF_INSUFFICIENT_MEMORY:
LOG(("Ran out of memory decoding GIF image '%s'!", fn));
free(gif->gif_data);
free(gif);
free(throb);
return false;
break;
}
throb->nframes = gif->frame_count;
if (throb->nframes < 2)
{
/* we need at least two frames - one for idle, one for active */
LOG(("Insufficent number of frames in throbber image '%s'!",
fn));
LOG(("(GIF contains %d frames, where 2 is a minimum.)",
throb->nframes));
free(gif->gif_data);
free(gif);
free(throb);
return false;
}
throb->framedata = (BBitmap **)malloc(sizeof(BBitmap *)
* throb->nframes);
/* decode each frame in turn, extracting the struct bitmap * for each,
* and put that in our array of frames.
*/
for (i = 0; i < throb->nframes; i++)
{
gif_decode_frame(gif, i);
throb->framedata[i] = new BBitmap(
nsbeos_bitmap_get_primary(gif->frame_image));
}
gif_finalise(gif);
free(gif->gif_data);
free(gif);
/* debug code: save out each frame as a PNG to make sure decoding is
* working correctly.
for (i = 0; i < throb->nframes; i++) {
char fname[20];
sprintf(fname, "frame%d.png", i);
gdk_pixbuf_save(throb->framedata[i], fname, "png", NULL, NULL);
}
*/
nsbeos_throbber = throb;
return true;
}
void nsbeos_throbber_finalise(void)
{
int i;

View File

@ -25,6 +25,7 @@
* scale.
*/
#define __STDBOOL_H__ 1
#include <assert.h>
#include <Bitmap.h>
#include <View.h>

View File

@ -22,6 +22,7 @@
*/
#define __STDBOOL_H__ 1
extern "C" {
#include "utils/config.h"
#include "desktop/tree.h"

View File

@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __STDBOOL_H__ 1
#include <assert.h>
extern "C" {
#include "desktop/browser.h"

View File

@ -4,7 +4,7 @@
/* Load base stylesheet. */
@import "rsrc:/default.css,text/css";
@import "default.css";
/* Apply GTK specific rules. */