From 44856d86d4efb12e08c8ef7560f39233107dfa8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revel?= Date: Wed, 13 Aug 2008 19:35:41 +0000 Subject: [PATCH] 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 --- beos/beos_bitmap.cpp | 51 ++++++++++++----- beos/beos_fetch_rsrc.cpp | 1 + beos/beos_filetype.cpp | 1 + beos/beos_font.cpp | 3 +- beos/beos_gui.cpp | 29 ++++++++-- beos/beos_history.cpp | 1 + beos/beos_login.cpp | 1 + beos/beos_options.cpp | 1 + beos/beos_plotters.cpp | 11 ++-- beos/beos_scaffolding.cpp | 4 +- beos/beos_schedule.cpp | 1 + beos/beos_throbber.cpp | 113 +------------------------------------- beos/beos_thumbnail.cpp | 1 + beos/beos_treeview.cpp | 1 + beos/beos_window.cpp | 1 + beos/res/beosdefault.css | 2 +- 16 files changed, 83 insertions(+), 139 deletions(-) diff --git a/beos/beos_bitmap.cpp b/beos/beos_bitmap.cpp index 3c8f575b0..778a2eb68 100644 --- a/beos/beos_bitmap.cpp +++ b/beos/beos_bitmap.cpp @@ -23,7 +23,8 @@ * This implements the interface given by desktop/bitmap.h using BBitmap. */ -#include +#define __STDBOOL_H__ 1 +//#include #include #include #include @@ -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; } /** diff --git a/beos/beos_fetch_rsrc.cpp b/beos/beos_fetch_rsrc.cpp index 157395c91..36bea4206 100644 --- a/beos/beos_fetch_rsrc.cpp +++ b/beos/beos_fetch_rsrc.cpp @@ -21,6 +21,7 @@ #define _GNU_SOURCE +#define __STDBOOL_H__ 1 #include #include #include diff --git a/beos/beos_filetype.cpp b/beos/beos_filetype.cpp index f06d63364..1b5b94302 100644 --- a/beos/beos_filetype.cpp +++ b/beos/beos_filetype.cpp @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +#define __STDBOOL_H__ 1 #include #include #include diff --git a/beos/beos_font.cpp b/beos/beos_font.cpp index 81c66b4bb..70c5be84f 100644 --- a/beos/beos_font.cpp +++ b/beos/beos_font.cpp @@ -24,6 +24,7 @@ */ +#define __STDBOOL_H__ 1 #include #include #include @@ -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(); diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp index f1a99e245..dba6ba75a 100644 --- a/beos/beos_gui.cpp +++ b/beos/beos_gui.cpp @@ -18,6 +18,7 @@ */ #define _GNU_SOURCE /* for strndup */ +#define __STDBOOL_H__ 1 #include #include #include @@ -33,7 +34,9 @@ #include #include +#include #include +#include #include #include @@ -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; } diff --git a/beos/beos_history.cpp b/beos/beos_history.cpp index f63660356..a13f319aa 100644 --- a/beos/beos_history.cpp +++ b/beos/beos_history.cpp @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#define __STDBOOL_H__ 1 extern "C" { #include "utils/log.h" #include "content/urldb.h" diff --git a/beos/beos_login.cpp b/beos/beos_login.cpp index 0e5280d3b..a0a0fa546 100644 --- a/beos/beos_login.cpp +++ b/beos/beos_login.cpp @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#define __STDBOOL_H__ 1 #include #include #include diff --git a/beos/beos_options.cpp b/beos/beos_options.cpp index 816aca3cb..6e492a6a4 100644 --- a/beos/beos_options.cpp +++ b/beos/beos_options.cpp @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#define __STDBOOL_H__ 1 #include #include #include diff --git a/beos/beos_plotters.cpp b/beos/beos_plotters.cpp index d26eb3e9e..8628fcb46 100644 --- a/beos/beos_plotters.cpp +++ b/beos/beos_plotters.cpp @@ -22,6 +22,7 @@ * Target independent plotting (BeOS/Haiku implementation). */ +#define __STDBOOL_H__ 1 #include #include #include @@ -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) diff --git a/beos/beos_scaffolding.cpp b/beos/beos_scaffolding.cpp index 3ef8db800..430a47e6f 100644 --- a/beos/beos_scaffolding.cpp +++ b/beos/beos_scaffolding.cpp @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include +#define __STDBOOL_H__ 1 #include #include #include @@ -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); diff --git a/beos/beos_schedule.cpp b/beos/beos_schedule.cpp index a8b1ca5d0..347cde438 100644 --- a/beos/beos_schedule.cpp +++ b/beos/beos_schedule.cpp @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#define __STDBOOL_H__ 1 #include #include #include diff --git a/beos/beos_throbber.cpp b/beos/beos_throbber.cpp index 55fce870c..8ed3663fb 100644 --- a/beos/beos_throbber.cpp +++ b/beos/beos_throbber.cpp @@ -17,12 +17,12 @@ * along with this program. If not, see . */ +#define __STDBOOL_H__ 1 #include #include #include 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; diff --git a/beos/beos_thumbnail.cpp b/beos/beos_thumbnail.cpp index 72ee5f3ce..fef540d1b 100644 --- a/beos/beos_thumbnail.cpp +++ b/beos/beos_thumbnail.cpp @@ -25,6 +25,7 @@ * scale. */ +#define __STDBOOL_H__ 1 #include #include #include diff --git a/beos/beos_treeview.cpp b/beos/beos_treeview.cpp index 60fcaa40d..1688a95fa 100644 --- a/beos/beos_treeview.cpp +++ b/beos/beos_treeview.cpp @@ -22,6 +22,7 @@ */ +#define __STDBOOL_H__ 1 extern "C" { #include "utils/config.h" #include "desktop/tree.h" diff --git a/beos/beos_window.cpp b/beos/beos_window.cpp index 796e4d6bd..b4c585b7f 100644 --- a/beos/beos_window.cpp +++ b/beos/beos_window.cpp @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +#define __STDBOOL_H__ 1 #include extern "C" { #include "desktop/browser.h" diff --git a/beos/res/beosdefault.css b/beos/res/beosdefault.css index 1101176cb..9021eedd9 100644 --- a/beos/res/beosdefault.css +++ b/beos/res/beosdefault.css @@ -4,7 +4,7 @@ /* Load base stylesheet. */ -@import "rsrc:/default.css,text/css"; +@import "default.css"; /* Apply GTK specific rules. */