From e5863b17d091895b199240ff970eb663a7aaaa8d Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Sun, 9 May 2004 21:05:24 +0000 Subject: [project @ 2004-05-09 21:05:24 by rjw] Local options are now adhered to (dither, filter, animate). svn path=/import/netsurf/; revision=847 --- riscos/gif.c | 39 +++++++++++++++++++++++++++------------ riscos/gui.h | 1 + riscos/jpeg.c | 21 +++++++++++++++++++-- riscos/png.c | 15 ++++++++++++++- riscos/window.c | 27 ++++++++++++++++++++++++--- 5 files changed, 85 insertions(+), 18 deletions(-) (limited to 'riscos') diff --git a/riscos/gif.c b/riscos/gif.c index 9bf5b0586..942ef49e0 100644 --- a/riscos/gif.c +++ b/riscos/gif.c @@ -91,20 +91,40 @@ void nsgif_redraw(struct content *c, long x, long y, float scale) { int previous_frame; - unsigned int frame; + unsigned int frame, current_frame; + unsigned int tinct_options; /* Reject no images (paranoia) */ if (c->data.gif.gif->frame_count_partial < 1) return; + /* If we have a gui_window then we work from there, if not we use the global + settings. We default to the first image if we don't have a GUI as we are + drawing a thumbnail unless something has gone very wrong somewhere else. + */ + if (ro_gui_current_redraw_gui) { + tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?(1<<1):0) | + (ro_gui_current_redraw_gui->option_dither_sprites?(1<<2):0); + if (ro_gui_current_redraw_gui->option_animate_images) { + current_frame = c->data.gif.current_frame; + } else { + current_frame = 0; + } + } else { + current_frame = 0; + tinct_options = (option_filter_sprites?(1<<1):0) | + (option_dither_sprites?(1<<2):0); + } + /* Decode from the last frame to the current frame */ - if (c->data.gif.current_frame < c->data.gif.gif->decoded_frame) + if (current_frame < c->data.gif.gif->decoded_frame) { previous_frame = 0; - else + } else { previous_frame = c->data.gif.gif->decoded_frame + 1; - for (frame = previous_frame; frame <= c->data.gif.current_frame; frame++) { + } + for (frame = previous_frame; frame <= current_frame; frame++) { gif_decode_frame(c->data.gif.gif, frame); } @@ -116,7 +136,7 @@ void nsgif_redraw(struct content *c, long x, long y, (char *)c->data.gif.gif->frame_image, x, (int)(y - height), width, height, - (option_filter_sprites?(1<<1):0) | (option_dither_sprites?(1<<2):0)); + tinct_options); } @@ -145,18 +165,13 @@ void nsgif_animate(void *p) /* at the moment just advance by one frame */ c->data.gif.current_frame++; if (c->data.gif.current_frame == c->data.gif.gif->frame_count) { -/* if (!c->data.gif.loop_gif) { - c->data.gif.current_frame--; - c->data.gif.animate_gif = false; - return; - } else -*/ c->data.gif.current_frame = 0; + c->data.gif.current_frame = 0; } schedule(c->data.gif.gif->frames[c->data.gif.current_frame].frame_delay, nsgif_animate, c); - /* area within gif to redraw (currently whole gif) */ + /* area within gif to redraw */ data.redraw.x = c->data.gif.gif->frames[c->data.gif.current_frame].redraw_x; data.redraw.y = c->data.gif.gif->frames[c->data.gif.current_frame].redraw_y; data.redraw.width = c->data.gif.gif->frames[c->data.gif.current_frame].redraw_width; diff --git a/riscos/gui.h b/riscos/gui.h index fb9dcb307..e6656b3c1 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -32,6 +32,7 @@ extern gui_window *window_list; extern bool gui_reformat_pending; extern bool gui_redraw_debug; extern gui_window *current_gui; +extern gui_window *ro_gui_current_redraw_gui; extern osspriteop_area *gui_pointers; typedef enum { GUI_BROWSER_WINDOW, GUI_DOWNLOAD_WINDOW } gui_window_type; diff --git a/riscos/jpeg.c b/riscos/jpeg.c index 2319c15cd..971c7cfbc 100644 --- a/riscos/jpeg.c +++ b/riscos/jpeg.c @@ -25,6 +25,7 @@ #include "netsurf/utils/config.h" #include "netsurf/content/content.h" #include "netsurf/desktop/gui.h" +#include "netsurf/riscos/gui.h" #include "netsurf/riscos/jpeg.h" #include "netsurf/riscos/options.h" #include "netsurf/riscos/tinct.h" @@ -234,12 +235,28 @@ void nsjpeg_redraw(struct content *c, long x, long y, long clip_x0, long clip_y0, long clip_x1, long clip_y1, float scale) { + unsigned int tinct_options; + + /* If we have a gui_window then we work from there, if not we use the global + settings as we are drawing a thumbnail. + */ + if (ro_gui_current_redraw_gui) { + tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?(1<<1):0) | + (ro_gui_current_redraw_gui->option_dither_sprites?(1<<2):0); + } else { + tinct_options = (option_filter_sprites?(1<<1):0) | + (option_dither_sprites?(1<<2):0); + } + + /* Tinct currently only handles 32bpp sprites that have an embedded alpha mask. Any + sprites not matching the required specifications are ignored. See the Tinct + documentation for further information. + */ _swix(Tinct_PlotScaled, _IN(2) | _IN(3) | _IN(4) | _IN(5) | _IN(6) | _IN(7), (char *) c->data.jpeg.sprite_area + c->data.jpeg.sprite_area->first, x, (int) (y - height), width, height, - (option_filter_sprites ? (1<<1) : 0) | - (option_dither_sprites ? (1<<2) : 0)); + tinct_options); } diff --git a/riscos/png.c b/riscos/png.c index c8fe028b4..7bbc9827f 100644 --- a/riscos/png.c +++ b/riscos/png.c @@ -15,6 +15,7 @@ #include "oslib/osspriteop.h" #include "netsurf/utils/config.h" #include "netsurf/content/content.h" +#include "netsurf/riscos/gui.h" #include "netsurf/riscos/options.h" #include "netsurf/riscos/png.h" #include "netsurf/riscos/tinct.h" @@ -249,6 +250,18 @@ void nspng_redraw(struct content *c, long x, long y, long clip_x0, long clip_y0, long clip_x1, long clip_y1, float scale) { + unsigned int tinct_options; + + /* If we have a gui_window then we work from there, if not we use the global + settings as we are drawing a thumbnail. + */ + if (ro_gui_current_redraw_gui) { + tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?(1<<1):0) | + (ro_gui_current_redraw_gui->option_dither_sprites?(1<<2):0); + } else { + tinct_options = (option_filter_sprites?(1<<1):0) | + (option_dither_sprites?(1<<2):0); + } /* Tinct currently only handles 32bpp sprites that have an embedded alpha mask. Any sprites not matching the required specifications are ignored. See the Tinct @@ -258,6 +271,6 @@ void nspng_redraw(struct content *c, long x, long y, ((char *) c->data.png.sprite_area + c->data.png.sprite_area->first), x, (int)(y - height), width, height, - (option_filter_sprites?(1<<1):0) | (option_dither_sprites?(1<<2):0)); + tinct_options); } #endif diff --git a/riscos/window.c b/riscos/window.c index ea8942038..81732d381 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -35,6 +35,7 @@ #include "netsurf/utils/url.h" #include "netsurf/utils/utils.h" +gui_window *ro_gui_current_redraw_gui; gui_window *window_list = 0; static int window_count = 0; @@ -200,10 +201,16 @@ void gui_window_redraw_window(gui_window* g) void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw) { osbool more; - osbool clear_background = false; + bool clear_background = false; struct content *c = g->data.browser.bw->current_content; unsigned long background_colour = 0xffffff; + /* Set the current redraw gui_window to get options from + */ + ro_gui_current_redraw_gui = g; + + /* Perform the update + */ if (g->type == GUI_BROWSER_WINDOW && c != NULL) { /* We should clear the background for GIFs and PNGs @@ -244,6 +251,11 @@ void ro_gui_window_redraw(gui_window* g, wimp_draw* redraw) { more = wimp_get_rectangle(redraw); } } + + /* Reset the current redraw gui_window to prevent thumbnails from + retaining options + */ + ro_gui_current_redraw_gui = NULL; } @@ -258,7 +270,7 @@ void gui_window_update_box(gui_window *g, const union content_msg_data *data) { struct content *c = g->data.browser.bw->current_content; osbool more; - osbool clear_background = false; + bool clear_background = false; unsigned long background_colour = 0xffffff; os_error *error; wimp_draw update; @@ -275,6 +287,10 @@ void gui_window_update_box(gui_window *g, const union content_msg_data *data) return; } + /* Set the current redraw gui_window to get options from + */ + ro_gui_current_redraw_gui = g; + /* We should clear the background for content that isn't HTML or plain text */ if ((c->type != CONTENT_HTML) && @@ -316,9 +332,14 @@ void gui_window_update_box(gui_window *g, const union content_msg_data *data) if (error) { LOG(("xwimp_get_rectangle: 0x%x: %s", error->errnum, error->errmess)); - return; +// return; } } + + /* Reset the current redraw gui_window to prevent thumbnails from + retaining options + */ + ro_gui_current_redraw_gui = NULL; } void gui_window_set_scroll(gui_window* g, unsigned long sx, unsigned long sy) -- cgit v1.2.3