From eddae6af0663243a2677674d501f9a87d55798f5 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 30 Jun 2011 15:48:07 +0000 Subject: Remove plotter table global. Pass a redraw context around redraw functions. Knockout could be handled better. Note: untested on most front ends. svn path=/trunk/netsurf/; revision=12543 --- riscos/content-handlers/artworks.c | 6 +++--- riscos/content-handlers/draw.c | 6 +++--- riscos/content-handlers/sprite.c | 6 +++--- riscos/gui/url_bar.c | 6 +++++- riscos/history.c | 8 +++++--- riscos/print.c | 16 +++++++++++----- riscos/save_draw.c | 7 +++++-- riscos/thumbnail.c | 7 +++++-- riscos/treeview.c | 11 +++++++---- riscos/window.c | 14 ++++++++++---- 10 files changed, 57 insertions(+), 30 deletions(-) (limited to 'riscos') diff --git a/riscos/content-handlers/artworks.c b/riscos/content-handlers/artworks.c index 0747a3de0..ffbd7835e 100644 --- a/riscos/content-handlers/artworks.c +++ b/riscos/content-handlers/artworks.c @@ -111,7 +111,7 @@ static nserror artworks_create(const content_handler *handler, static bool artworks_convert(struct content *c); static void artworks_destroy(struct content *c); static bool artworks_redraw(struct content *c, struct content_redraw_data *data, - const struct rect *clip); + const struct rect *clip, const struct redraw_context *ctx); static nserror artworks_clone(const struct content *old, struct content **newc); static content_type artworks_content_type(lwc_string *mime_type); @@ -330,7 +330,7 @@ void artworks_destroy(struct content *c) */ bool artworks_redraw(struct content *c, struct content_redraw_data *data, - const struct rect *clip) + const struct rect *clip, const struct redraw_context *ctx) { static const ns_os_vdu_var_list vars = { os_MODEVAR_XEIG_FACTOR, @@ -353,7 +353,7 @@ bool artworks_redraw(struct content *c, struct content_redraw_data *data, int clip_x1 = clip->x1; int clip_y1 = clip->y1; - if (plot.flush && !plot.flush()) + if (ctx->plot->flush && !ctx->plot->flush()) return false; /* pick up render addresses again in case they've changed diff --git a/riscos/content-handlers/draw.c b/riscos/content-handlers/draw.c index e8a9d654a..5f3865921 100644 --- a/riscos/content-handlers/draw.c +++ b/riscos/content-handlers/draw.c @@ -51,7 +51,7 @@ static nserror draw_create(const content_handler *handler, static bool draw_convert(struct content *c); static void draw_destroy(struct content *c); static bool draw_redraw(struct content *c, struct content_redraw_data *data, - const struct rect *clip); + const struct rect *clip, const struct redraw_context *ctx); static nserror draw_clone(const struct content *old, struct content **newc); static content_type draw_content_type(lwc_string *mime_type); @@ -207,7 +207,7 @@ void draw_destroy(struct content *c) */ bool draw_redraw(struct content *c, struct content_redraw_data *data, - const struct rect *clip) + const struct rect *clip, const struct redraw_context *ctx) { draw_content *draw = (draw_content *) c; os_trfm matrix; @@ -216,7 +216,7 @@ bool draw_redraw(struct content *c, struct content_redraw_data *data, const void *src_data; os_error *error; - if (plot.flush && !plot.flush()) + if (ctx->plot->flush && !ctx->plot->flush()) return false; if (!c->width || !c->height) diff --git a/riscos/content-handlers/sprite.c b/riscos/content-handlers/sprite.c index f10c0166f..9260703f4 100644 --- a/riscos/content-handlers/sprite.c +++ b/riscos/content-handlers/sprite.c @@ -53,7 +53,7 @@ static nserror sprite_create(const content_handler *handler, static bool sprite_convert(struct content *c); static void sprite_destroy(struct content *c); static bool sprite_redraw(struct content *c, struct content_redraw_data *data, - const struct rect *clip); + const struct rect *clip, const struct redraw_context *ctx); static nserror sprite_clone(const struct content *old, struct content **newc); static content_type sprite_content_type(lwc_string *mime_type); @@ -207,11 +207,11 @@ void sprite_destroy(struct content *c) */ bool sprite_redraw(struct content *c, struct content_redraw_data *data, - const struct rect *clip) + const struct rect *clip, const struct redraw_context *ctx) { sprite_content *sprite = (sprite_content *) c; - if (plot.flush && !plot.flush()) + if (ctx->plot->flush && !ctx->plot->flush()) return false; return image_redraw(sprite->data, diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c index d92e8fc8d..6614a8ac5 100644 --- a/riscos/gui/url_bar.c +++ b/riscos/gui/url_bar.c @@ -582,6 +582,10 @@ void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw) xwimp_plot_icon(&icon); } else { struct content_redraw_data data; + struct redraw_context ctx = { + .interactive = true, + .plot = &ro_plotters + }; xwimp_set_colour(wimp_COLOUR_WHITE); xos_plot(os_MOVE_TO, @@ -611,7 +615,7 @@ void ro_gui_url_bar_redraw(struct url_bar *url_bar, wimp_draw *redraw) data.repeat_x = false; data.repeat_y = false; - content_redraw(url_bar->favicon_content, &data, &clip); + content_redraw(url_bar->favicon_content, &data, &clip, &ctx); } } diff --git a/riscos/history.c b/riscos/history.c index 93cd65ab7..09770f90f 100644 --- a/riscos/history.c +++ b/riscos/history.c @@ -139,8 +139,10 @@ void ro_gui_history_redraw(wimp_draw *redraw) { osbool more; os_error *error; - - plot = ro_plotters; + struct redraw_context ctx = { + .interactive = true, + .plot = &ro_plotters + }; error = xwimp_redraw_window(redraw, &more); if (error) { @@ -152,7 +154,7 @@ void ro_gui_history_redraw(wimp_draw *redraw) while (more) { ro_plot_origin_x = redraw->box.x0 - redraw->xscroll; ro_plot_origin_y = redraw->box.y1 - redraw->yscroll; - history_redraw(history_current); + history_redraw(history_current, &ctx); error = xwimp_get_rectangle(redraw, &more); if (error) { LOG(("xwimp_get_rectangle: 0x%x: %s", diff --git a/riscos/print.c b/riscos/print.c index 18c6db9cd..639fa5be0 100644 --- a/riscos/print.c +++ b/riscos/print.c @@ -618,8 +618,6 @@ bool print_document(struct gui_window *g, const char *filename) goto error; } - plot = ro_plotters; - plot.option_knockout = false; ro_gui_current_redraw_gui = g; current_redraw_browser = NULL; /* we don't want to print the selection */ @@ -689,6 +687,11 @@ bool print_document(struct gui_window *g, const char *filename) while (more) { struct content_redraw_data data; + /* TODO: turn knockout off for print */ + struct redraw_context ctx = { + .interactive = false, + .plot = &ro_plotters + }; LOG(("redrawing area: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1)); @@ -706,7 +709,7 @@ bool print_document(struct gui_window *g, const char *filename) data.repeat_x = false; data.repeat_y = false; - if (!content_redraw(h, &data, &clip)) { + if (!content_redraw(h, &data, &clip, &ctx)) { error_message = "redraw error"; goto error; } @@ -805,6 +808,10 @@ const char *print_declare_fonts(hlcache_handle *h) struct content_redraw_data data; const char *error_message = 0; os_error *error; + struct redraw_context ctx = { + .interactive = false, + .plot = &print_fonts_plotters + }; free(print_fonts_list); print_fonts_list = 0; @@ -823,8 +830,7 @@ const char *print_declare_fonts(hlcache_handle *h) data.repeat_x = false; data.repeat_y = false; - plot = print_fonts_plotters; - if (!content_redraw(h, &data, &clip)) { + if (!content_redraw(h, &data, &clip, &ctx)) { if (print_fonts_error) return print_fonts_error; return "Declaring fonts failed."; diff --git a/riscos/save_draw.c b/riscos/save_draw.c index 5c8f61a3d..76fcca4d9 100644 --- a/riscos/save_draw.c +++ b/riscos/save_draw.c @@ -93,6 +93,10 @@ bool save_as_draw(hlcache_handle *h, const char *path) struct content_redraw_data data; size_t drawfile_size; os_error *error; + struct redraw_context ctx = { + .interactive = true, + .plot = &ro_plotters + }; ro_save_draw_diagram = pencil_create(); if (!ro_save_draw_diagram) { @@ -115,8 +119,7 @@ bool save_as_draw(hlcache_handle *h, const char *path) data.repeat_x = false; data.repeat_y = false; - plot = ro_save_draw_plotters; - if (!content_redraw(h, &data, &clip)) { + if (!content_redraw(h, &data, &clip, &ctx)) { pencil_free(ro_save_draw_diagram); return false; } diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c index 92fa0cdb2..c6e2b0d8e 100644 --- a/riscos/thumbnail.c +++ b/riscos/thumbnail.c @@ -86,6 +86,10 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, osspriteop_area *sprite_area = NULL; osspriteop_header *sprite_header = NULL; _kernel_oserror *error; + struct redraw_context ctx = { + .interactive = false, + .plot = &ro_plotters + }; assert(content); assert(bitmap); @@ -110,7 +114,6 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, } /* set up the plotters */ - plot = ro_plotters; ro_plot_origin_x = 0; ro_plot_origin_y = bitmap->height * 2; @@ -125,7 +128,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, colourtrans_set_gcol(os_COLOUR_WHITE, colourtrans_SET_BG_GCOL, os_ACTION_OVERWRITE, 0); - thumbnail_redraw(content, bitmap->width, bitmap->height); + thumbnail_redraw(content, bitmap->width, bitmap->height, &ctx); thumbnail_restore_output(save_area); rufl_invalidate_cache(); diff --git a/riscos/treeview.c b/riscos/treeview.c index 0206a7c29..c5f1cd526 100644 --- a/riscos/treeview.c +++ b/riscos/treeview.c @@ -357,8 +357,6 @@ void ro_treeview_redraw(wimp_draw *redraw) */ } - plot = ro_plotters; - error = xwimp_redraw_window(redraw, &more); if (error) { LOG(("xwimp_redraw_window: 0x%x: %s", @@ -380,7 +378,11 @@ void ro_treeview_redraw(wimp_draw *redraw) void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more) { - os_error *error; + os_error *error; + struct redraw_context ctx = { + .interactive = true, + .plot = &ro_plotters + }; while (more) { ro_plot_origin_x = redraw->box.x0 - redraw->xscroll; @@ -394,7 +396,8 @@ void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more) ((ro_plot_origin_y+tv->origin.y) -redraw->clip.y1)/2, (redraw->clip.x1 - redraw->clip.x0)/2, - (redraw->clip.y1 - redraw->clip.y0)/2); + (redraw->clip.y1 - redraw->clip.y0)/2, + &ctx); /* Put the graphcis window back how the Wimp set it. */ clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2; diff --git a/riscos/window.c b/riscos/window.c index 2a727643e..3caf12cd3 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -1665,6 +1665,10 @@ void ro_gui_window_redraw(wimp_draw *redraw) osbool more; struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w); os_error *error; + struct redraw_context ctx = { + .interactive = true, + .plot = &ro_plotters + }; /* We can't render locked contents. If the browser window is not * ready for redraw, do nothing. Else, in the case of buffered @@ -1672,7 +1676,6 @@ void ro_gui_window_redraw(wimp_draw *redraw) if (!browser_window_redraw_ready(g->bw)) return; - plot = ro_plotters; ro_gui_current_redraw_gui = g; current_redraw_browser = g->bw; @@ -1705,7 +1708,7 @@ void ro_gui_window_redraw(wimp_draw *redraw) if (ro_gui_current_redraw_gui->option.buffer_everything) ro_gui_buffer_open(redraw); - browser_window_redraw(g->bw, 0, 0, &clip); + browser_window_redraw(g->bw, 0, 0, &clip, &ctx); if (ro_gui_current_redraw_gui->option.buffer_everything) ro_gui_buffer_close(); @@ -4317,6 +4320,10 @@ void ro_gui_window_update_boxes(void) struct update_box *cur; struct gui_window *g; const union content_msg_data *data; + struct redraw_context ctx = { + .interactive = true, + .plot = &ro_plotters + }; for (cur = pending_updates; cur != NULL; cur = cur->next) { g = cur->g; @@ -4344,7 +4351,6 @@ void ro_gui_window_update_boxes(void) ro_gui_current_redraw_gui = g; current_redraw_browser = g->bw; - plot = ro_plotters; ro_plot_origin_x = update.box.x0 - update.xscroll; ro_plot_origin_y = update.box.y1 - update.yscroll; @@ -4357,7 +4363,7 @@ void ro_gui_window_update_boxes(void) if (use_buffer) ro_gui_buffer_open(&update); - browser_window_redraw(g->bw, 0, 0, &clip); + browser_window_redraw(g->bw, 0, 0, &clip, &ctx); if (use_buffer) ro_gui_buffer_close(); -- cgit v1.2.3