From 3128ecf2a5c94102e0e1659f947a345d36750afe Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 28 Jun 2011 20:17:39 +0000 Subject: Unify content_redraw params in content_redraw_data struct. Core and RISC OS content handlers updated. svn path=/trunk/netsurf/; revision=12529 --- image/bmp.c | 14 ++++++-------- image/gif.c | 16 +++++++--------- image/ico.c | 15 +++++++-------- image/jpeg.c | 15 ++++++--------- image/mng.c | 21 ++++++++------------- image/nssprite.c | 20 ++++++++------------ image/png.c | 14 ++++++-------- image/rsvg.c | 14 ++++++-------- image/svg.c | 40 ++++++++++++++++++++-------------------- image/webp.c | 20 ++++++++------------ 10 files changed, 82 insertions(+), 107 deletions(-) (limited to 'image') diff --git a/image/bmp.c b/image/bmp.c index b40ab7e8c..d209621ba 100644 --- a/image/bmp.c +++ b/image/bmp.c @@ -197,10 +197,8 @@ static bool nsbmp_convert(struct content *c) return true; } -static bool nsbmp_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { nsbmp_content *bmp = (nsbmp_content *) c; bitmap_flags_t flags = BITMAPF_NONE; @@ -211,13 +209,13 @@ static bool nsbmp_redraw(struct content *c, int x, int y, c->bitmap = bmp->bmp->bitmap; - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, c->bitmap, - background_colour, flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); } diff --git a/image/gif.c b/image/gif.c index 696362205..0a3dccf31 100644 --- a/image/gif.c +++ b/image/gif.c @@ -338,10 +338,8 @@ static gif_result nsgif_get_frame(struct content *c) return res; } -static bool nsgif_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +static bool nsgif_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { nsgif_content *gif = (nsgif_content *) c; bitmap_flags_t flags = BITMAPF_NONE; @@ -352,16 +350,16 @@ static bool nsgif_redraw(struct content *c, int x, int y, c->bitmap = gif->gif->frame_image; - if ((width == -1) && (height == -1)) + if ((data->width == -1) && (data->height == -1)) return true; - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, c->bitmap, - background_colour, flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); } diff --git a/image/ico.c b/image/ico.c index e9cfc3a55..a64f76e70 100644 --- a/image/ico.c +++ b/image/ico.c @@ -157,13 +157,11 @@ static bool nsico_convert(struct content *c) } -static bool nsico_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +static bool nsico_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { nsico_content *ico = (nsico_content *) c; - struct bmp_image *bmp = ico_find(ico->ico, width, height); + struct bmp_image *bmp = ico_find(ico->ico, data->width, data->height); bitmap_flags_t flags = BITMAPF_NONE; if (!bmp->decoded) @@ -172,12 +170,13 @@ static bool nsico_redraw(struct content *c, int x, int y, c->bitmap = bmp->bitmap; - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, c->bitmap, background_colour, flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); } diff --git a/image/jpeg.c b/image/jpeg.c index 5b355f3e5..544840241 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -277,21 +277,18 @@ static void nsjpeg_destroy(struct content *c) /** * Redraw a CONTENT_JPEG with appropriate tiling. */ -static bool nsjpeg_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +static bool nsjpeg_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { bitmap_flags_t flags = BITMAPF_NONE; - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, - c->bitmap, background_colour, - flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); } diff --git a/image/mng.c b/image/mng.c index ee2b121ea..731f5f14e 100644 --- a/image/mng.c +++ b/image/mng.c @@ -67,10 +67,8 @@ static bool nsmng_process_data(struct content *c, const char *data, unsigned int size); static bool nsmng_convert(struct content *c); static void nsmng_destroy(struct content *c); -static bool nsmng_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y); +static bool nsmng_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip); static nserror nsmng_clone(const struct content *old, struct content **newc); static content_type nsmng_content_type(lwc_string *mime_type); @@ -687,10 +685,8 @@ void nsmng_destroy(struct content *c) } -bool nsmng_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +bool nsmng_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { nsmng_content *mng = (nsmng_content *) c; bool ret; @@ -704,14 +700,13 @@ bool nsmng_redraw(struct content *c, int x, int y, mng->opaque_test_pending = false; } - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - ret = plot.bitmap(x, y, width, height, - c->bitmap, background_colour, - flags); + ret = plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); /* Check if we need to restart the animation */ diff --git a/image/nssprite.c b/image/nssprite.c index 4c1e173c0..0eff2a148 100644 --- a/image/nssprite.c +++ b/image/nssprite.c @@ -50,10 +50,8 @@ static nserror nssprite_create(const content_handler *handler, bool quirks, struct content **c); static bool nssprite_convert(struct content *c); static void nssprite_destroy(struct content *c); -static bool nssprite_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y); +static bool nssprite_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip); static nserror nssprite_clone(const struct content *old, struct content **newc); static content_type nssprite_content_type(lwc_string *mime_type); @@ -240,20 +238,18 @@ void nssprite_destroy(struct content *c) * Redraw a CONTENT_SPRITE. */ -bool nssprite_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +bool nssprite_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { bitmap_flags_t flags = BITMAPF_NONE; - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, - c->bitmap, background_colour, flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); } diff --git a/image/png.c b/image/png.c index 3b4b30dc0..a0475aa2f 100644 --- a/image/png.c +++ b/image/png.c @@ -362,23 +362,21 @@ static void nspng_destroy(struct content *c) } -static bool nspng_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +static bool nspng_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { nspng_content *png_c = (nspng_content *) c; bitmap_flags_t flags = BITMAPF_NONE; assert(png_c->bitmap != NULL); - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, - png_c->bitmap, background_colour, flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + png_c->bitmap, data->background_colour, flags); } static nserror nspng_clone(const struct content *old_c, struct content **new_c) diff --git a/image/rsvg.c b/image/rsvg.c index 63c2f2b6f..39bec0190 100644 --- a/image/rsvg.c +++ b/image/rsvg.c @@ -229,22 +229,20 @@ static bool rsvg_convert(struct content *c) return true; } -static bool rsvg_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +static bool rsvg_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { bitmap_flags_t flags = BITMAPF_NONE; assert(c->bitmap != NULL); - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, - c->bitmap, background_colour, flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); } static void rsvg_destroy(struct content *c) diff --git a/image/svg.c b/image/svg.c index a447eaf54..d53013033 100644 --- a/image/svg.c +++ b/image/svg.c @@ -51,10 +51,8 @@ static nserror svg_create_svg_data(svg_content *c); static bool svg_convert(struct content *c); static void svg_destroy(struct content *c); static void svg_reformat(struct content *c, int width, int height); -static bool svg_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y); +static bool svg_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip); static nserror svg_clone(const struct content *old, struct content **newc); static content_type svg_content_type(lwc_string *mime_type); @@ -285,21 +283,22 @@ static bool svg_redraw_internal(struct content *c, int x, int y, * Redraw a CONTENT_SVG. */ -bool svg_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +bool svg_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { - if ((width <= 0) && (height <= 0)) { + int x = data->x; + int y = data->y; + + if ((data->width <= 0) && (data->height <= 0)) { /* No point trying to plot SVG if it does not occupy a valid * area */ return true; } - if ((repeat_x == false) && (repeat_y == false)) { + if ((data->repeat_x == false) && (data->repeat_y == false)) { /* Simple case: SVG is not tiled */ - return svg_redraw_internal(c, x, y, width, height, - clip, scale, background_colour); + return svg_redraw_internal(c, x, y, data->width, data->height, + clip, data->scale, data->background_colour); } else { /* Tiled redraw required. SVG repeats to extents of clip * rectangle, in x, y or both directions */ @@ -307,26 +306,27 @@ bool svg_redraw(struct content *c, int x, int y, /* Find the redraw boundaries to loop within */ x0 = x; - if (repeat_x) { - for (; x0 > clip->x0; x0 -= width); + if (data->repeat_x) { + for (; x0 > clip->x0; x0 -= data->width); x1 = clip->x1; } else { x1 = x + 1; } y0 = y; - if (repeat_y) { - for (; y0 > clip->y0; y0 -= height); + if (data->repeat_y) { + for (; y0 > clip->y0; y0 -= data->height); y1 = clip->y1; } else { y1 = y + 1; } /* Repeatedly plot the SVG across the area */ - for (y = y0; y < y1; y += height) { - for (x = x0; x < x1; x += width) { + for (y = y0; y < y1; y += data->height) { + for (x = x0; x < x1; x += data->width) { if (!svg_redraw_internal(c, x, y, - width, height, clip, scale, - background_colour)) { + data->width, data->height, + clip, data->scale, + data->background_colour)) { return false; } } diff --git a/image/webp.c b/image/webp.c index daa7f4522..8702b0a3b 100644 --- a/image/webp.c +++ b/image/webp.c @@ -47,10 +47,8 @@ static nserror webp_create(const content_handler *handler, bool quirks, struct content **c); static bool webp_convert(struct content *c); static void webp_destroy(struct content *c); -static bool webp_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y); +static bool webp_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip); static nserror webp_clone(const struct content *old, struct content **newc); static content_type webp_content_type(lwc_string *mime_type); @@ -213,20 +211,18 @@ void webp_destroy(struct content *c) * Redraw a CONTENT_WEBP. */ -bool webp_redraw(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - float scale, colour background_colour, - bool repeat_x, bool repeat_y) +bool webp_redraw(struct content *c, struct content_redraw_data *data, + const struct rect *clip) { bitmap_flags_t flags = BITMAPF_NONE; - if (repeat_x) + if (data->repeat_x) flags |= BITMAPF_REPEAT_X; - if (repeat_y) + if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return plot.bitmap(x, y, width, height, - c->bitmap, background_colour, flags); + return plot.bitmap(data->x, data->y, data->width, data->height, + c->bitmap, data->background_colour, flags); } -- cgit v1.2.3