From fe7921a387c5a71c8ecba7bb605679b7dab4b86f Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 13 Feb 2011 22:25:11 +0000 Subject: Pass clip rect as struct through content_redraw api. Update the front ends to use this. Note only RO build tested. svn path=/trunk/netsurf/; revision=11670 --- amiga/icon.c | 3 +-- amiga/icon.h | 5 +++-- amiga/thumbnail.c | 9 +++++++-- atari/browser.c | 23 +++++++++++------------ beos/beos_thumbnail.cpp | 9 +++++++-- beos/beos_window.cpp | 11 +++++++---- cocoa/thumbnail.m | 8 +++++++- content/content.c | 47 ++++++++++++++++++----------------------------- content/content.h | 7 +++---- desktop/browser.c | 3 +-- desktop/print.c | 26 +++++++++++--------------- desktop/tree.c | 2 +- gtk/thumbnail.c | 11 ++++++++--- image/bmp.c | 6 ++---- image/bmp.h | 7 +++---- image/gif.c | 6 ++---- image/gif.h | 7 +++---- image/ico.c | 6 ++---- image/ico.h | 7 +++---- image/jpeg.c | 6 ++---- image/jpeg.h | 7 +++---- image/mng.c | 6 ++---- image/mng.h | 7 +++---- image/nssprite.c | 3 +-- image/nssprite.h | 4 ++-- image/png.c | 7 +++---- image/png.h | 12 ++++++------ image/rsvg.c | 10 +++++----- image/rsvg.h | 7 +++---- image/svg.c | 3 +-- image/svg.h | 4 ++-- image/webp.c | 3 +-- image/webp.h | 4 ++-- render/favicon.c | 14 +++++++++++--- render/html.h | 3 +-- render/html_redraw.c | 33 ++++++++++----------------------- render/textplain.c | 23 +++++++---------------- render/textplain.h | 4 ++-- riscos/artworks.c | 8 ++++++-- riscos/artworks.h | 4 ++-- riscos/draw.c | 3 +-- riscos/draw.h | 4 ++-- riscos/plugin.c | 5 ++--- riscos/plugin.h | 4 ++-- riscos/print.c | 18 +++++++++++------- riscos/save_draw.c | 7 ++++++- riscos/sprite.c | 3 +-- riscos/sprite.h | 4 ++-- riscos/thumbnail.c | 7 ++++++- windows/thumbnail.c | 9 +++++++-- 50 files changed, 215 insertions(+), 224 deletions(-) diff --git a/amiga/icon.c b/amiga/icon.c index 8f230b691..711144de5 100644 --- a/amiga/icon.c +++ b/amiga/icon.c @@ -188,8 +188,7 @@ void amiga_icon_destroy(struct content *c) */ bool amiga_icon_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { return plot.bitmap(x, y, width, height, diff --git a/amiga/icon.h b/amiga/icon.h index a89cbdfb0..f7d9e6384 100644 --- a/amiga/icon.h +++ b/amiga/icon.h @@ -29,6 +29,8 @@ #include #include "content/hlcache.h" +struct rect; + struct content_amiga_icon_data { /* empty */ }; @@ -36,8 +38,7 @@ struct content_amiga_icon_data { bool amiga_icon_convert(struct content *c); void amiga_icon_destroy(struct content *c); bool amiga_icon_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool amiga_icon_clone(const struct content *old, struct content *new_content); diff --git a/amiga/thumbnail.c b/amiga/thumbnail.c index 5d10d3e0c..44bd985cb 100755 --- a/amiga/thumbnail.c +++ b/amiga/thumbnail.c @@ -36,6 +36,12 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, const char *url) { struct BitScaleArgs bsa; + struct rect clip; + + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = content_get_width(content); + clip.y1 = content_get_width(content); bitmap->nativebm = p96AllocBitMap(bitmap->width, bitmap->height, 32, BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED, @@ -47,8 +53,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, current_redraw_browser = curbw; plot = amiplot; content_redraw(content, 0, 0, content_get_width(content), - content_get_width(content), 0, 0, content_get_width(content), - content_get_width(content), 1.0, 0xFFFFFF); + content_get_width(content), &clip, 1.0, 0xFFFFFF); current_redraw_browser = NULL; if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1) diff --git a/atari/browser.c b/atari/browser.c index d6097d984..2c667a5d7 100755 --- a/atari/browser.c +++ b/atari/browser.c @@ -849,7 +849,7 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff ) LGRECT work; CMP_BROWSER b = gw->browser; GRECT area; - int clip_x0, clip_x1, clip_y0, clip_y1; + struct rect clip; LOG(("%s : %d,%d - %d,%d\n", b->bw->name, b->redraw.area.x0, b->redraw.area.y0, b->redraw.area.x1, b->redraw.area.y1 @@ -862,16 +862,16 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff ) current_redraw_browser = b->bw; if(content_get_type(b->bw->current_content) == CONTENT_HTML ) { - clip_x0 = b->redraw.area.x0; - clip_y0 = b->redraw.area.y0; - clip_x1 = b->redraw.area.x1; - clip_y1 = b->redraw.area.y1; + clip.x0 = b->redraw.area.x0; + clip.y0 = b->redraw.area.y0; + clip.x1 = b->redraw.area.x1; + clip.y1 = b->redraw.area.y1; } else { /* totally different coords, I don't understand why! */ - clip_x0 = b->redraw.area.x0 + b->scroll.current.x; - clip_y0 = b->redraw.area.y0 + b->scroll.current.y; - clip_x1 = b->redraw.area.x1 + b->scroll.current.x; - clip_y1 = b->redraw.area.y1 + b->scroll.current.y; + clip.x0 = b->redraw.area.x0 + b->scroll.current.x; + clip.y0 = b->redraw.area.y0 + b->scroll.current.y; + clip.x1 = b->redraw.area.x1 + b->scroll.current.x; + clip.y1 = b->redraw.area.y1 + b->scroll.current.y; /* must clear the surface: */ plot.clip( b->redraw.area.x0, b->redraw.area.y0, b->redraw.area.x1, b->redraw.area.y1 @@ -889,8 +889,7 @@ static void browser_redraw_content( struct gui_window * gw, int xoff, int yoff ) -b->scroll.current.x, -b->scroll.current.y, content_get_width( b->bw->current_content), content_get_height( b->bw->current_content), - clip_x0, clip_y0, - clip_x1, clip_y1, + &clip, b->bw->scale, 0xFFFFFF ); current_redraw_browser = NULL; @@ -1057,4 +1056,4 @@ static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * dat } return; -} \ No newline at end of file +} diff --git a/beos/beos_thumbnail.cpp b/beos/beos_thumbnail.cpp index 65c6636d3..c093d34d4 100644 --- a/beos/beos_thumbnail.cpp +++ b/beos/beos_thumbnail.cpp @@ -66,6 +66,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, float width; float height; int depth; + struct rect clip; assert(content); assert(bitmap); @@ -125,11 +126,15 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, content_get_width(content), plot_style_fill_white); + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = content_get_width(content); + clip.y1 = content_get_width(content); + /* render the content */ content_redraw(content, 0, 0, content_get_width(content), content_get_width(content), - 0, 0, - content_get_width(content), content_get_width(content), + &clip, 1.0, 0xFFFFFF); view->Sync(); diff --git a/beos/beos_window.cpp b/beos/beos_window.cpp index 795b7b7fc..98ace7e4a 100644 --- a/beos/beos_window.cpp +++ b/beos/beos_window.cpp @@ -918,6 +918,7 @@ void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message) BRect updateRect; hlcache_handle *c; float scale = g->bw->scale; + struct rect clip; assert(g); assert(g->bw); @@ -953,13 +954,15 @@ void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message) plot = nsbeos_plotters; nsbeos_plot_set_scale(g->bw->scale); current_redraw_browser = g->bw; + + clip.x0 = (int)updateRect.left; + clip.y0 = (int)updateRect.top; + clip.x1 = (int)updateRect.right + 1; + clip.y1 = (int)updateRect.bottom + 1; content_redraw(c, 0, 0, (view->Bounds().Width() + 1) * scale, (view->Bounds().Height() + 1) * scale, - (int)updateRect.left, - (int)updateRect.top, - (int)updateRect.right + 1, - (int)updateRect.bottom + 1, + &clip, g->bw->scale, 0xFFFFFF); current_redraw_browser = NULL; diff --git a/cocoa/thumbnail.m b/cocoa/thumbnail.m index 8dadf080e..70185affe 100644 --- a/cocoa/thumbnail.m +++ b/cocoa/thumbnail.m @@ -38,6 +38,12 @@ bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap, size_t width = MIN( content_get_width( content ), 1024 ); size_t height = MIN( content_get_height( content ), 768 ); + + struct rect clip; + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = content_get_width( content ); + clip.y1 = content_get_height( content ); CGContextTranslateCTM( bitmapContext, 0, bitmap_get_height( bitmap ) ); CGContextScaleCTM( bitmapContext, (CGFloat)bitmap_get_width( bitmap ) / width, -(CGFloat)bitmap_get_height( bitmap ) / height ); @@ -45,7 +51,7 @@ bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap, [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: bitmapContext flipped: YES]]; content_redraw( content, 0, 0, content_get_width( content ), content_get_height( content ), - 0, 0, content_get_width( content ), content_get_height( content ), + &clip, 1.0, 0xFFFFFFFF ); [NSGraphicsContext setCurrentContext: nil]; diff --git a/content/content.c b/content/content.c index 99102fb1c..d3fc32388 100644 --- a/content/content.c +++ b/content/content.c @@ -275,12 +275,10 @@ struct handler_entry { void (*mouse_action)(struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y); bool (*redraw)(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool (*redraw_tiled)(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); void (*open)(struct content *c, struct browser_window *bw, @@ -879,19 +877,16 @@ void content_request_redraw(struct hlcache_handle *h, * \param y coordinate for top-left of redraw * \param width render width (not used for HTML redraw) * \param height render height (not used for HTML redraw) - * \param clip_x0 clip rectangle left - * \param clip_y0 clip rectangle top - * \param clip_x1 clip rectangle right - * \param clip_y1 clip rectangle bottom + * \param clip clip rectangle * \param scale scale for redraw * \param background_colour the background colour * \return true if successful, false otherwise * - * x, y and clip_* are coordinates from the top left of the canvas area. + * x, y and clip are coordinates from the top left of the canvas area. * - * The top left corner of the clip rectangle is (clip_x0, clip_y0) and - * the bottom right corner of the clip rectangle is (clip_x1, clip_y1). - * Units for x, y and clip_* are pixels. + * The top left corner of the clip rectangle is (x0, y0) and + * the bottom right corner of the clip rectangle is (x1, y1). + * Units for x, y and clip are pixels. * * Content scaling is handled differently for contents with and without * intrinsic dimensions. @@ -906,8 +901,7 @@ void content_request_redraw(struct hlcache_handle *h, */ bool content_redraw(hlcache_handle *h, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { struct content *c = hlcache_handle_get_content(h); @@ -923,8 +917,7 @@ bool content_redraw(hlcache_handle *h, int x, int y, } return handler_map[c->type].redraw(c, x, y, width, height, - clip_x0, clip_y0, clip_x1, clip_y1, scale, - background_colour); + clip, scale, background_colour); } @@ -936,8 +929,7 @@ bool content_redraw(hlcache_handle *h, int x, int y, */ bool content_redraw_tiled(hlcache_handle *h, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { @@ -953,8 +945,8 @@ bool content_redraw_tiled(hlcache_handle *h, int x, int y, return true; if (handler_map[c->type].redraw_tiled) { return handler_map[c->type].redraw_tiled(c, x, y, width, height, - clip_x0, clip_y0, clip_x1, clip_y1, scale, - background_colour, repeat_x, repeat_y); + clip, scale, background_colour, + repeat_x, repeat_y); } else { /* ensure we have a redrawable content */ if ((!handler_map[c->type].redraw) || (width == 0) || @@ -963,20 +955,19 @@ bool content_redraw_tiled(hlcache_handle *h, int x, int y, /* simple optimisation for no repeat (common for backgrounds) */ if ((!repeat_x) && (!repeat_y)) return handler_map[c->type].redraw(c, x, y, width, - height, clip_x0, clip_y0, clip_x1, clip_y1, - scale, background_colour); + height, clip, scale, background_colour); /* find the redraw boundaries to loop within*/ x0 = x; if (repeat_x) { - for (; x0 > clip_x0; x0 -= width); - x1 = clip_x1; + for (; x0 > clip->x0; x0 -= width); + x1 = clip->x1; } else { x1 = x + 1; } y0 = y; if (repeat_y) { - for (; y0 > clip_y0; y0 -= height); - y1 = clip_y1; + for (; y0 > clip->y0; y0 -= height); + y1 = clip->y1; } else { y1 = y + 1; } @@ -984,9 +975,7 @@ bool content_redraw_tiled(hlcache_handle *h, int x, int y, for (y = y0; y < y1; y += height) for (x = x0; x < x1; x += width) if (!handler_map[c->type].redraw(c, x, y, - width, height, - clip_x0, clip_y0, - clip_x1, clip_y1, + width, height, clip, scale, background_colour)) return false; } diff --git a/content/content.h b/content/content.h index ed5bca041..1abb40be6 100644 --- a/content/content.h +++ b/content/content.h @@ -40,6 +40,7 @@ struct content; struct llcache_handle; struct hlcache_handle; struct object_params; +struct rect; /** Status of a content */ typedef enum { @@ -124,12 +125,10 @@ void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw, void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y); bool content_redraw(struct hlcache_handle *h, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool content_redraw_tiled(struct hlcache_handle *h, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); void content_open(struct hlcache_handle *h, struct browser_window *bw, diff --git a/desktop/browser.c b/desktop/browser.c index 454fbf5e9..3d5f1a9cb 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -120,8 +120,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y, } return content_redraw(bw->current_content, x, y, width, height, - clip.x0, clip.y0, clip.x1, clip.y1, - bw->scale, 0xFFFFFF); + &clip, bw->scale, 0xFFFFFF); } /* exported interface, documented in browser.h */ diff --git a/desktop/print.c b/desktop/print.c index 0099a8c69..995f1bf73 100644 --- a/desktop/print.c +++ b/desktop/print.c @@ -120,32 +120,28 @@ bool print_set_up(hlcache_handle *content, bool print_draw_next_page(const struct printer *printer, struct print_settings *settings) { - int clip_x1, clip_y1; + struct rect clip; plot = *(printer->plotter); html_redraw_printing_top_cropped = INT_MAX; - - clip_x1 = page_content_width * settings->scale; - clip_y1 = page_content_height * settings->scale; + + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = page_content_width * settings->scale; + clip.y1 = page_content_height * settings->scale; html_redraw_printing = true; - html_redraw_printing_border = clip_y1; + html_redraw_printing_border = clip.y1; printer->print_next_page(); - if (!content_redraw(printed_content, - 0, - -done_height, - 0,0, - 0, - 0, - clip_x1, - clip_y1, - settings->scale, 0xffffff)) + if (!content_redraw(printed_content, 0, -done_height, + 0, 0, + &clip, settings->scale, 0xffffff)) return false; done_height += page_content_height - (html_redraw_printing_top_cropped != INT_MAX ? - clip_y1 - html_redraw_printing_top_cropped : 0) / + clip.y1 - html_redraw_printing_top_cropped : 0) / settings->scale; return true; diff --git a/desktop/tree.c b/desktop/tree.c index ddffef698..131106b65 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -1623,7 +1623,7 @@ static void tree_draw_node_element(struct tree *tree, plot.clip(c.x0, c.y0, c.x1, c.y1); content_redraw(icon , x, y + icon_inset, TREE_ICON_SIZE, TREE_ICON_SIZE, - c.x0, c.y0, c.x1, c.y1, 1, 0); + &c, 1, 0); /* Restore previous clipping area */ plot.clip(clip.x0, clip.y0, clip.x1, clip.y1); diff --git a/gtk/thumbnail.c b/gtk/thumbnail.c index 53d62fe30..f0a25ce30 100644 --- a/gtk/thumbnail.c +++ b/gtk/thumbnail.c @@ -51,6 +51,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, { GdkPixbuf *pixbuf; int cwidth, cheight; + struct rect clip; gint width; gint height; gint depth; @@ -60,6 +61,11 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, assert(content); assert(bitmap); + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = content_get_width(content); + clip.y1 = content_get_width(content); + cwidth = min(content_get_width(content), 1024); cheight = min(content_get_height(content), 768); @@ -100,13 +106,12 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, #endif plot.rectangle(0, 0, cwidth, cwidth, plot_style_fill_white); - plot.clip(0, 0, content_get_width(content), content_get_width(content)); + plot.clip(clip.x0, clip.y0, clip.x1, clip.y1); /* render the content */ content_redraw(content, 0, 0, content_get_width(content), content_get_width(content), - 0, 0, content_get_width(content), - content_get_width(content), 1.0, 0xFFFFFF); + &clip, 1.0, 0xFFFFFF); /* resample the large plot down to the size of our thumbnail */ big = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0, diff --git a/image/bmp.c b/image/bmp.c index ac7bc300e..b5487a3b8 100644 --- a/image/bmp.c +++ b/image/bmp.c @@ -117,8 +117,7 @@ bool nsbmp_convert(struct content *c) bool nsbmp_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { @@ -132,8 +131,7 @@ bool nsbmp_redraw(struct content *c, int x, int y, bool nsbmp_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { diff --git a/image/bmp.h b/image/bmp.h index e78d52f6f..b1d689d2a 100644 --- a/image/bmp.h +++ b/image/bmp.h @@ -34,6 +34,7 @@ struct content; struct bitmap; struct http_parameter; +struct rect; struct content_bmp_data { bmp_image *bmp; /** BMP image data */ @@ -45,12 +46,10 @@ bool nsbmp_create(struct content *c, const struct http_parameter *params); bool nsbmp_convert(struct content *c); void nsbmp_destroy(struct content *c); bool nsbmp_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool nsbmp_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); bool nsbmp_clone(const struct content *old, struct content *new_content); diff --git a/image/gif.c b/image/gif.c index ce2d19a4b..8745942cd 100644 --- a/image/gif.c +++ b/image/gif.c @@ -152,8 +152,7 @@ void nsgif_invalidate(void *bitmap, void *private_word) } bool nsgif_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { if (c->data.gif.current_frame != c->data.gif.gif->decoded_frame) @@ -168,8 +167,7 @@ bool nsgif_redraw(struct content *c, int x, int y, bool nsgif_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { diff --git a/image/gif.h b/image/gif.h index 9b2eb9fd6..27b2385cf 100644 --- a/image/gif.h +++ b/image/gif.h @@ -32,6 +32,7 @@ struct content; struct http_parameter; +struct rect; struct content_gif_data { struct gif_animation *gif; /**< GIF animation data */ @@ -42,12 +43,10 @@ bool nsgif_create(struct content *c, const struct http_parameter *params); bool nsgif_convert(struct content *c); void nsgif_destroy(struct content *c); bool nsgif_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool nsgif_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); bool nsgif_clone(const struct content *old, struct content *new_content); diff --git a/image/ico.c b/image/ico.c index 190da86d2..e1e3d2939 100644 --- a/image/ico.c +++ b/image/ico.c @@ -105,8 +105,7 @@ bool nsico_convert(struct content *c) } bool nsico_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height); @@ -140,8 +139,7 @@ bool nsico_set_bitmap_from_size(hlcache_handle *h, int width, int height) } bool nsico_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { diff --git a/image/ico.h b/image/ico.h index 6ed8b59d2..16db54e94 100644 --- a/image/ico.h +++ b/image/ico.h @@ -32,6 +32,7 @@ struct content; struct hlcache_handle; struct http_parameter; +struct rect; struct content_ico_data { struct ico_collection *ico; /** ICO collection data */ @@ -41,12 +42,10 @@ bool nsico_create(struct content *c, const struct http_parameter *params); bool nsico_convert(struct content *c); void nsico_destroy(struct content *c); bool nsico_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool nsico_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); bool nsico_clone(const struct content *old, struct content *new_content); diff --git a/image/jpeg.c b/image/jpeg.c index 6e5e446dd..f247243ea 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -244,8 +244,7 @@ void nsjpeg_term_source(j_decompress_ptr cinfo) */ bool nsjpeg_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { return plot.bitmap(x, y, width, height, @@ -258,8 +257,7 @@ bool nsjpeg_redraw(struct content *c, int x, int y, */ bool nsjpeg_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { diff --git a/image/jpeg.h b/image/jpeg.h index 5f142546a..c484ec890 100644 --- a/image/jpeg.h +++ b/image/jpeg.h @@ -30,6 +30,7 @@ struct bitmap; struct content; +struct rect; struct content_jpeg_data { int dummy; /* NOT USED but to satisfy Norcroft */ @@ -38,12 +39,10 @@ struct content_jpeg_data { bool nsjpeg_convert(struct content *c); void nsjpeg_destroy(struct content *c); bool nsjpeg_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool nsjpeg_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); bool nsjpeg_clone(const struct content *old, struct content *new_content); diff --git a/image/mng.c b/image/mng.c index c97a96660..d360b4c1a 100644 --- a/image/mng.c +++ b/image/mng.c @@ -524,8 +524,7 @@ void nsmng_destroy(struct content *c) bool nsmng_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { bool ret; @@ -551,8 +550,7 @@ bool nsmng_redraw(struct content *c, int x, int y, bool nsmng_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { diff --git a/image/mng.h b/image/mng.h index 9b45852a0..eaf92968d 100644 --- a/image/mng.h +++ b/image/mng.h @@ -30,6 +30,7 @@ struct content; struct http_parameter; +struct rect; struct content_mng_data { bool opaque_test_pending; @@ -46,12 +47,10 @@ bool nsmng_process_data(struct content *c, const char *data, unsigned int size); bool nsmng_convert(struct content *c); void nsmng_destroy(struct content *c); bool nsmng_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool nsmng_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); bool nsmng_clone(const struct content *old, struct content *new_content); diff --git a/image/nssprite.c b/image/nssprite.c index 6e2778960..df1cdbe36 100644 --- a/image/nssprite.c +++ b/image/nssprite.c @@ -136,8 +136,7 @@ void nssprite_destroy(struct content *c) */ bool nssprite_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { return plot.bitmap(x, y, width, height, diff --git a/image/nssprite.h b/image/nssprite.h index 7149b1fa0..800defd42 100644 --- a/image/nssprite.h +++ b/image/nssprite.h @@ -29,6 +29,7 @@ #include struct content; +struct rect; struct content_nssprite_data { struct rosprite_area* sprite_area; @@ -37,8 +38,7 @@ struct content_nssprite_data { bool nssprite_convert(struct content *c); void nssprite_destroy(struct content *c); bool nssprite_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool nssprite_clone(const struct content *old, struct content *new_content); diff --git a/image/png.c b/image/png.c index 7be801099..246b6d4ff 100644 --- a/image/png.c +++ b/image/png.c @@ -305,8 +305,7 @@ void nspng_destroy(struct content *c) bool nspng_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { assert(c->bitmap != NULL); @@ -315,8 +314,8 @@ bool nspng_redraw(struct content *c, int x, int y, background_colour, BITMAPF_NONE); } -bool nspng_redraw_tiled(struct content *c, int x, int y, int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, +bool nspng_redraw_tiled(struct content *c, int x, int y, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { diff --git a/image/png.h b/image/png.h index 9f673d9fe..3e6e157be 100644 --- a/image/png.h +++ b/image/png.h @@ -32,6 +32,7 @@ struct content; struct bitmap; struct http_parameter; +struct rect; struct content_png_data { png_structp png; @@ -47,13 +48,12 @@ bool nspng_process_data(struct content *c, const char *data, unsigned int size); bool nspng_convert(struct content *c); void nspng_destroy(struct content *c); bool nspng_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); -bool nspng_redraw_tiled(struct content *c, int x, int y, int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, - float scale, colour background_colour, - bool repeat_x, bool repeat_y); +bool nspng_redraw_tiled(struct content *c, int x, int y, + int width, int height, struct rect *clip, + float scale, colour background_colour, + bool repeat_x, bool repeat_y); bool nspng_clone(const struct content *old, struct content *new_content); #endif diff --git a/image/rsvg.c b/image/rsvg.c index 6f6babc38..3da101aca 100644 --- a/image/rsvg.c +++ b/image/rsvg.c @@ -180,16 +180,16 @@ bool rsvg_convert(struct content *c) return true; } -bool rsvg_redraw(struct content *c, int x, int y, int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, - float scale, colour background_colour) +bool rsvg_redraw(struct content *c, int x, int y, + int width, int height, struct rect *clip, + float scale, colour background_colour) { plot.bitmap(x, y, width, height, c->bitmap, background_colour, BITMAPF_NONE); return true; } -bool rsvg_redraw_tiled(struct content *c, int x, int y, int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, +bool rsvg_redraw_tiled(struct content *c, int x, int y, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y) { diff --git a/image/rsvg.h b/image/rsvg.h index e85115dcf..78a853c89 100644 --- a/image/rsvg.h +++ b/image/rsvg.h @@ -34,6 +34,7 @@ struct content; struct http_parameter; +struct rect; struct content_rsvg_data { RsvgHandle *rsvgh; /**< Context handle for RSVG renderer */ @@ -47,12 +48,10 @@ bool rsvg_process_data(struct content *c, const char *data, unsigned int size); bool rsvg_convert(struct content *c); void rsvg_destroy(struct content *c); bool rsvg_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool rsvg_redraw_tiled(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour, bool repeat_x, bool repeat_y); bool rsvg_clone(const struct content *old, struct content *new_content); diff --git a/image/svg.c b/image/svg.c index 44f893afe..26112b13c 100644 --- a/image/svg.c +++ b/image/svg.c @@ -107,8 +107,7 @@ void svg_reformat(struct content *c, int width, int height) */ bool svg_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { float transform[6]; diff --git a/image/svg.h b/image/svg.h index 9720a3772..9ce8093e6 100644 --- a/image/svg.h +++ b/image/svg.h @@ -28,6 +28,7 @@ struct content; struct http_parameter; struct svgtiny_diagram; +struct rect; struct content_svg_data { struct svgtiny_diagram *diagram; @@ -39,8 +40,7 @@ bool svg_convert(struct content *c); void svg_destroy(struct content *c); void svg_reformat(struct content *c, int width, int height); bool svg_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool svg_clone(const struct content *old, struct content *new_content); diff --git a/image/webp.c b/image/webp.c index 56d1a5008..671ea5195 100644 --- a/image/webp.c +++ b/image/webp.c @@ -130,8 +130,7 @@ void webp_destroy(struct content *c) */ bool webp_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { return plot.bitmap(x, y, width, height, diff --git a/image/webp.h b/image/webp.h index 5ff38c900..acd449cbf 100644 --- a/image/webp.h +++ b/image/webp.h @@ -29,6 +29,7 @@ #include struct content; +struct rect; struct content_webp_data { /* empty */ @@ -37,8 +38,7 @@ struct content_webp_data { bool webp_convert(struct content *c); void webp_destroy(struct content *c); bool webp_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool webp_clone(const struct content *old, struct content *new_content); diff --git a/render/favicon.c b/render/favicon.c index 097c0c8cc..6bc654e29 100644 --- a/render/favicon.c +++ b/render/favicon.c @@ -20,6 +20,7 @@ #include #include "content/content_protected.h" #include "content/hlcache.h" +#include "desktop/shape.h" #include "render/favicon.h" #include "render/html.h" #include "utils/log.h" @@ -247,10 +248,17 @@ nserror favicon_callback(hlcache_handle *icon, } #ifdef WITH_GIF - if (consider_redraw && (c->data.html.favicon != NULL) && (content_get_type(c->data.html.favicon) == CONTENT_GIF)) { + if (consider_redraw && (c->data.html.favicon != NULL) && + (content_get_type(c->data.html.favicon) == + CONTENT_GIF)) { union content_msg_data msg_data; - /* This is needed in order to cause animated GIFs to update their bitmap */ - content_redraw(c->data.html.favicon, 0, 0, -1, -1, 0, 0, 0, 0, 1.0, 0); + struct rect clip; + /* This is needed in order to cause animated GIFs to update + * their bitmap */ + clip.x0 = clip.y0 = 0; + clip.x1 = clip.y1 = 0; + content_redraw(c->data.html.favicon, 0, 0, -1, -1, &clip, + 1.0, 0); content_broadcast(c, CONTENT_MSG_FAVICON_REFRESH, msg_data); } #endif diff --git a/render/html.h b/render/html.h index 9a82b3a03..324e795f0 100644 --- a/render/html.h +++ b/render/html.h @@ -209,8 +209,7 @@ void html_redraw_a_box(struct hlcache_handle *h, struct box *box); /* in render/html_redraw.c */ bool html_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); /* in render/html_interaction.c */ diff --git a/render/html_redraw.c b/render/html_redraw.c index 9e7e6fc6a..d36eb8d91 100644 --- a/render/html_redraw.c +++ b/render/html_redraw.c @@ -101,10 +101,7 @@ bool html_redraw_debug = false; * \param y coordinate for top-left of redraw * \param width available width (not used for HTML redraw) * \param height available height (not used for HTML redraw) - * \param clip_x0 clip rectangle - * \param clip_y0 clip rectangle - * \param clip_x1 clip rectangle - * \param clip_y1 clip rectangle + * \param clip clip rectangle * \param scale scale for redraw * \param background_colour the background colour * \return true if successful, false otherwise @@ -113,8 +110,7 @@ bool html_redraw_debug = false; */ bool html_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { struct box *box; @@ -145,26 +141,21 @@ bool html_redraw(struct content *c, int x, int y, /* check if the redraw rectangle is completely inside of the select menu */ select_only = form_clip_inside_select_menu(control, scale, - clip_x0, clip_y0, clip_x1, clip_y1); + clip->x0, clip->y0, clip->x1, clip->y1); } if (!select_only) { - struct rect clip; - clip.x0 = clip_x0; - clip.y0 = clip_y0; - clip.x1 = clip_x1; - clip.y1 = clip_y1; /* clear to background colour */ - result = plot.clip(clip_x0, clip_y0, clip_x1, clip_y1); + result = plot.clip(clip->x0, clip->y0, clip->x1, clip->y1); if (c->data.html.background_colour != NS_TRANSPARENT) pstyle_fill_bg.fill_colour = c->data.html.background_colour; - result &= plot.rectangle(clip_x0, clip_y0, clip_x1, clip_y1, + result &= plot.rectangle(clip->x0, clip->y0, clip->x1, clip->y1, &pstyle_fill_bg); - result &= html_redraw_box(box, x, y, clip, + result &= html_redraw_box(box, x, y, *clip, scale, pstyle_fill_bg.fill_colour); } @@ -180,7 +171,7 @@ bool html_redraw(struct content *c, int x, int y, current_redraw_browser->visible_select_menu, x + menu_x, y + menu_y, current_redraw_browser->scale, - clip_x0, clip_y0, clip_x1, clip_y1); + clip->x0, clip->y0, clip->x1, clip->y1); } if (want_knockout) @@ -667,7 +658,7 @@ bool html_redraw_box(struct box *box, int x_parent, int y_parent, if (!content_redraw(box->object, x_scrolled + padding_left, y_scrolled + padding_top, - width, height, r.x0, r.y0, r.x1, r.y1, scale, + width, height, &r, scale, current_background_color)) return false; @@ -2191,9 +2182,7 @@ bool html_redraw_background(int x, int y, struct box *box, float scale, if (!content_redraw_tiled( background->background, x, y, ceilf(width * scale), - ceilf(height * scale), - clip.x0, clip.y0, - clip.x1, clip.y1, + ceilf(height * scale), &clip, scale, *background_colour, repeat_x, repeat_y)) return false; @@ -2334,9 +2323,7 @@ bool html_redraw_inline_background(int x, int y, struct box *box, float scale, return false; if (!content_redraw_tiled(box->background, x, y, ceilf(width * scale), - ceilf(height * scale), - clip.x0, clip.y0, - clip.x1, clip.y1, + ceilf(height * scale), &clip, scale, *background_colour, repeat_x, repeat_y)) return false; diff --git a/render/textplain.c b/render/textplain.c index 547d6a82c..ada008f35 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -537,10 +537,7 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw, * \param y coordinate for top-left of redraw * \param width available width * \param height available height - * \param clip_x0 clip rectangle - * \param clip_y0 clip rectangle - * \param clip_x1 clip rectangle - * \param clip_y1 clip rectangle + * \param clip clip rectangle * \param scale scale for redraw * \param background_colour the background colour * \return true if successful, false otherwise @@ -549,8 +546,7 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw, */ bool textplain_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { struct browser_window *bw = current_redraw_browser; @@ -559,18 +555,12 @@ bool textplain_redraw(struct content *c, int x, int y, unsigned long line_count = c->data.textplain.physical_line_count; float line_height = textplain_line_height(); float scaled_line_height = line_height * scale; - long line0 = clip_y0 / scaled_line_height - 1; - long line1 = clip_y1 / scaled_line_height + 1; + long line0 = clip->y0 / scaled_line_height - 1; + long line1 = clip->y1 / scaled_line_height + 1; struct textplain_line *line = c->data.textplain.physical_line; - struct rect clip; size_t length; plot_style_t *plot_style_highlight; - clip.x0 = clip_x0; - clip.y0 = clip_y0; - clip.x1 = clip_x1; - clip.y1 = clip_y1; - if (line0 < 0) line0 = 0; if (line1 < 0) @@ -582,7 +572,8 @@ bool textplain_redraw(struct content *c, int x, int y, if (line1 < line0) line1 = line0; - if (!plot.rectangle(clip_x0, clip_y0, clip_x1, clip_y1, plot_style_fill_white)) + if (!plot.rectangle(clip->x0, clip->y0, clip->x1, clip->y1, + plot_style_fill_white)) return false; if (!line) @@ -623,7 +614,7 @@ bool textplain_redraw(struct content *c, int x, int y, line[lineno].start + offset, false, &textplain_style, tx, y + (lineno * scaled_line_height), - &clip, line_height, scale, false)) + clip, line_height, scale, false)) return false; if (next_offset >= length) diff --git a/render/textplain.h b/render/textplain.h index c94b18074..284585e35 100644 --- a/render/textplain.h +++ b/render/textplain.h @@ -30,6 +30,7 @@ struct content; struct hlcache_handle; struct http_parameter; +struct rect; struct textplain_line { size_t start; @@ -58,8 +59,7 @@ void textplain_mouse_action(struct content *c, struct browser_window *bw, void textplain_reformat(struct content *c, int width, int height); void textplain_destroy(struct content *c); bool textplain_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool textplain_clone(const struct content *old, struct content *new_content); diff --git a/riscos/artworks.c b/riscos/artworks.c index 385ec2b41..ecd3c3db2 100644 --- a/riscos/artworks.c +++ b/riscos/artworks.c @@ -224,8 +224,7 @@ void artworks_destroy(struct content *c) */ bool artworks_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { static const ns_os_vdu_var_list vars = { @@ -243,6 +242,11 @@ bool artworks_redraw(struct content *c, int x, int y, os_trfm matrix; int vals[24]; + int clip_x0 = clip->x0; + int clip_y0 = clip->y0; + int clip_x1 = clip->x1; + int clip_y1 = clip->y1; + if (plot.flush && !plot.flush()) return false; diff --git a/riscos/artworks.h b/riscos/artworks.h index 1f88b5007..8642f76a9 100644 --- a/riscos/artworks.h +++ b/riscos/artworks.h @@ -24,6 +24,7 @@ #define _NETSURF_RISCOS_ARTWORKS_H_ struct content; +struct rect; struct content_artworks_data { int x0, y0, x1, y1; @@ -41,8 +42,7 @@ struct content_artworks_data { bool artworks_convert(struct content *c); void artworks_destroy(struct content *c); bool artworks_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool artworks_clone(const struct content *old, struct content *new_content); diff --git a/riscos/draw.c b/riscos/draw.c index fcde5a763..4c2cfd409 100644 --- a/riscos/draw.c +++ b/riscos/draw.c @@ -105,8 +105,7 @@ void draw_destroy(struct content *c) */ bool draw_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { os_trfm matrix; diff --git a/riscos/draw.h b/riscos/draw.h index 854772e17..26c9ee08b 100644 --- a/riscos/draw.h +++ b/riscos/draw.h @@ -29,6 +29,7 @@ #include struct content; +struct rect; struct content_draw_data { int x0, y0; @@ -37,8 +38,7 @@ struct content_draw_data { bool draw_convert(struct content *c); void draw_destroy(struct content *c); bool draw_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool draw_clone(const struct content *old, struct content *new_content); diff --git a/riscos/plugin.c b/riscos/plugin.c index eae6ad0ed..71a0167a9 100644 --- a/riscos/plugin.c +++ b/riscos/plugin.c @@ -245,12 +245,11 @@ void plugin_destroy(struct content *c) * \param y Top of content box * \param width Width of content box * \param height Height of content box - * \param clip[xy][01] Clipping rectangle + * \param clip Clipping rectangle * \param scale Scale of page (1.0 = 100%) */ bool plugin_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { /* do nothing */ diff --git a/riscos/plugin.h b/riscos/plugin.h index 6f288235a..290a00da3 100644 --- a/riscos/plugin.h +++ b/riscos/plugin.h @@ -31,6 +31,7 @@ struct browser_window; struct content; struct object_params; struct plugin_stream; +struct rect; /* We have one content per instance of a plugin */ struct content_plugin_data { @@ -58,8 +59,7 @@ bool plugin_convert(struct content *c, int width, int height); void plugin_reformat(struct content *c, int width, int height); void plugin_destroy(struct content *c); bool plugin_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); void plugin_open(struct content *c, struct browser_window *bw, struct content *page, unsigned int index, struct box *box, diff --git a/riscos/print.c b/riscos/print.c index 192fe5de4..575990f27 100644 --- a/riscos/print.c +++ b/riscos/print.c @@ -635,7 +635,7 @@ bool print_document(struct gui_window *g, const char *filename) print_active = true; do { - int clip_x0, clip_y0, clip_x1, clip_y1; + struct rect clip; os_box b; os_hom_trfm t; os_coord p; @@ -697,14 +697,14 @@ bool print_document(struct gui_window *g, const char *filename) while (more) { LOG(("redrawing area: [(%d, %d), (%d, %d)]", b.x0, b.y0, b.x1, b.y1)); - clip_x0 = (b.x0 - ro_plot_origin_x) / 2; - clip_y0 = (ro_plot_origin_y - b.y1) / 2; - clip_x1 = (b.x1 - ro_plot_origin_x) / 2; - clip_y1 = (ro_plot_origin_y - b.y0) / 2; + clip.x0 = (b.x0 - ro_plot_origin_x) / 2; + clip.y0 = (ro_plot_origin_y - b.y1) / 2; + clip.x1 = (b.x1 - ro_plot_origin_x) / 2; + clip.y1 = (ro_plot_origin_y - b.y0) / 2; if (!content_redraw(h, 0, 0, content_get_width(h), content_get_height(h), - clip_x0, clip_y0, clip_x1, clip_y1, + &clip, print_scale, 0xFFFFFF)) { error_message = "redraw error"; @@ -805,6 +805,7 @@ error: const char *print_declare_fonts(hlcache_handle *h) { unsigned int i; + struct rect clip; const char *error_message = 0; os_error *error; @@ -813,10 +814,13 @@ const char *print_declare_fonts(hlcache_handle *h) print_fonts_count = 0; print_fonts_error = 0; + clip.x0 = clip.y0 = INT_MIN; + clip.x1 = clip.y1 = INT_MAX; + plot = print_fonts_plotters; if (!content_redraw(h, 0, 0, content_get_width(h), content_get_height(h), - INT_MIN, INT_MIN, INT_MAX, INT_MAX, 1, 0xffffff)) { + &clip, 1, 0xffffff)) { 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 a142c63da..5fa93e4f7 100644 --- a/riscos/save_draw.c +++ b/riscos/save_draw.c @@ -32,6 +32,7 @@ #include "content/content.h" #include "content/hlcache.h" #include "desktop/plotters.h" +#include "desktop/shape.h" #include "riscos/bitmap.h" #include "riscos/gui.h" #include "riscos/save_draw.h" @@ -89,6 +90,7 @@ bool save_as_draw(hlcache_handle *h, const char *path) { pencil_code code; char *drawfile_buffer; + struct rect clip; size_t drawfile_size; os_error *error; @@ -101,10 +103,13 @@ bool save_as_draw(hlcache_handle *h, const char *path) ro_save_draw_width = content_get_width(h); ro_save_draw_height = content_get_height(h); + clip.x0 = clip.y0 = INT_MIN; + clip.x1 = clip.y1 = INT_MAX; + plot = ro_save_draw_plotters; if (!content_redraw(h, 0, -ro_save_draw_height, ro_save_draw_width, ro_save_draw_height, - INT_MIN, INT_MIN, INT_MAX, INT_MAX, + &clip, 1, 0xFFFFFF)) { diff --git a/riscos/sprite.c b/riscos/sprite.c index ba7f78a85..cc75b54cd 100644 --- a/riscos/sprite.c +++ b/riscos/sprite.c @@ -112,8 +112,7 @@ void sprite_destroy(struct content *c) */ bool sprite_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour) { if (plot.flush && !plot.flush()) diff --git a/riscos/sprite.h b/riscos/sprite.h index 2248cd400..44cc029d8 100644 --- a/riscos/sprite.h +++ b/riscos/sprite.h @@ -29,6 +29,7 @@ #ifdef WITH_SPRITE struct content; +struct rect; struct content_sprite_data { void *data; @@ -37,8 +38,7 @@ struct content_sprite_data { bool sprite_convert(struct content *c); void sprite_destroy(struct content *c); bool sprite_redraw(struct content *c, int x, int y, - int width, int height, - int clip_x0, int clip_y0, int clip_x1, int clip_y1, + int width, int height, struct rect *clip, float scale, colour background_colour); bool sprite_clone(const struct content *old, struct content *new_content); #endif diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c index 82b885bfe..fba43f6bf 100644 --- a/riscos/thumbnail.c +++ b/riscos/thumbnail.c @@ -83,6 +83,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, { float scale = 1.0; struct thumbnail_save_area *save_area; + struct rect clip; osspriteop_area *sprite_area = NULL; osspriteop_header *sprite_header = NULL; _kernel_oserror *error; @@ -130,8 +131,12 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap, colourtrans_set_gcol(os_COLOUR_WHITE, colourtrans_SET_BG_GCOL, os_ACTION_OVERWRITE, 0); os_clg(); + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = bitmap->width; + clip.y1 = bitmap->height; content_redraw(content, 0, 0, bitmap->width, bitmap->height, - 0, 0, bitmap->width, bitmap->height, scale, 0xFFFFFF); + &clip, scale, 0xFFFFFF); thumbnail_restore_output(save_area); rufl_invalidate_cache(); diff --git a/windows/thumbnail.c b/windows/thumbnail.c index dece47253..729e642dd 100644 --- a/windows/thumbnail.c +++ b/windows/thumbnail.c @@ -39,10 +39,16 @@ thumbnail_create(hlcache_handle *content, HDC hdc, bufferdc, minidc; struct bitmap *fsbitmap; + struct rect clip; width = min(content_get_width(content), 800); height = min(content_get_height(content), 600); + clip.x0 = 0; + clip.y0 = 0; + clip.x1 = width; + clip.y1 = height; + LOG(("bitmap %p for url %s content %p width %d, height %d", bitmap, url, content, width, height)); @@ -65,8 +71,7 @@ thumbnail_create(hlcache_handle *content, hdc = plot_hdc; plot_hdc = bufferdc; - content_redraw(content, 0, 0, width, height, 0, 0, - width, height, 1.0, 0xFFFFFF); + content_redraw(content, 0, 0, width, height, &clip, 1.0, 0xFFFFFF); plot_hdc = hdc; /* scale bitmap bufferbm into minibm */ -- cgit v1.2.3