From 3722ff8d867db506c68e5467bbcdb6012e384fc8 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 11 Feb 2017 13:54:08 +0000 Subject: Update all core use of plotters to new API --- content/content.c | 8 +++--- content/handlers/image/bmp.c | 8 ++++-- content/handlers/image/image.c | 14 +++++++---- content/handlers/image/nssprite.c | 27 ++++++++++++++------- content/handlers/image/rsvg.c | 13 +++++++--- content/handlers/image/svg.c | 51 ++++++++++++++++++++++++--------------- 6 files changed, 78 insertions(+), 43 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index 2eb035cdf..2719db851 100644 --- a/content/content.c +++ b/content/content.c @@ -600,12 +600,12 @@ bool content_scaled_redraw(struct hlcache_handle *h, clip.x1 = width; clip.y1 = height; - new_ctx.plot->clip(&clip); + new_ctx.plot->clip(&new_ctx, &clip); /* Plot white background */ - plot_ok &= new_ctx.plot->rectangle(clip.x0, clip.y0, clip.x1, clip.y1, - plot_style_fill_white); - + plot_ok &= (new_ctx.plot->rectangle(&new_ctx, + plot_style_fill_white, + &clip) == NSERROR_OK); /* Set up content redraw data */ data.x = 0; diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c index 5970f8b16..271787449 100644 --- a/content/handlers/image/bmp.c +++ b/content/handlers/image/bmp.c @@ -199,8 +199,12 @@ static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data, if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return ctx->plot->bitmap(data->x, data->y, data->width, data->height, - bmp->bitmap, data->background_colour, flags); + return (ctx->plot->bitmap(ctx, + bmp->bitmap, + data->x, data->y, + data->width, data->height, + data->background_colour, + flags) == NSERROR_OK); } diff --git a/content/handlers/image/image.c b/content/handlers/image/image.c index e7cc9218f..675fdd691 100644 --- a/content/handlers/image/image.c +++ b/content/handlers/image/image.c @@ -137,9 +137,9 @@ bool image_bitmap_plot(struct bitmap *bitmap, fill_style.stroke_type = PLOT_OP_TYPE_NONE; fill_style.fill_type = PLOT_OP_TYPE_SOLID; - return ctx->plot->rectangle(area.x0, area.y0, - area.x1, area.y1, - &fill_style); + return (ctx->plot->rectangle(ctx, + &fill_style, + &area) == NSERROR_OK); } else if ((fill_style.fill_colour & 0xff000000) == 0) { /* transparent pixel used as spacer, skip it */ @@ -154,6 +154,10 @@ bool image_bitmap_plot(struct bitmap *bitmap, if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return ctx->plot->bitmap(data->x, data->y, data->width, data->height, - bitmap, data->background_colour, flags); + return (ctx->plot->bitmap(ctx, + bitmap, + data->x, data->y, + data->width, data->height, + data->background_colour, + flags) == NSERROR_OK); } diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c index c902fc3e2..247574aa4 100644 --- a/content/handlers/image/nssprite.c +++ b/content/handlers/image/nssprite.c @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -/** \file - * Content for image/x-riscos-sprite (librosprite implementation). - * +/** + * \file + * librosprite implementation for content image/x-riscos-sprite */ #include @@ -185,19 +185,28 @@ static void nssprite_destroy(struct content *c) * Redraw a CONTENT_SPRITE. */ -static bool nssprite_redraw(struct content *c, struct content_redraw_data *data, - const struct rect *clip, const struct redraw_context *ctx) +static bool +nssprite_redraw(struct content *c, + struct content_redraw_data *data, + const struct rect *clip, + const struct redraw_context *ctx) { nssprite_content *nssprite = (nssprite_content *) c; bitmap_flags_t flags = BITMAPF_NONE; - if (data->repeat_x) + if (data->repeat_x) { flags |= BITMAPF_REPEAT_X; - if (data->repeat_y) + } + if (data->repeat_y) { flags |= BITMAPF_REPEAT_Y; + } - return ctx->plot->bitmap(data->x, data->y, data->width, data->height, - nssprite->bitmap, data->background_colour, flags); + return (ctx->plot->bitmap(ctx, + nssprite->bitmap, + data->x, data->y, + data->width, data->height, + data->background_colour, + flags) == NSERROR_OK); } diff --git a/content/handlers/image/rsvg.c b/content/handlers/image/rsvg.c index 1bf4b4403..0665f217f 100644 --- a/content/handlers/image/rsvg.c +++ b/content/handlers/image/rsvg.c @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -/** \file - * Content handler for image/svg using librsvg (implementation). +/** + * \file + * implementation of content handler for image/svg using librsvg. * * SVG files are rendered to a NetSurf bitmap by creating a Cairo rendering * surface (content_rsvg_data.cs) over the bitmap's data, creating a Cairo @@ -234,8 +235,12 @@ static bool rsvg_redraw(struct content *c, struct content_redraw_data *data, if (data->repeat_y) flags |= BITMAPF_REPEAT_Y; - return ctx->plot->bitmap(data->x, data->y, data->width, data->height, - rsvgcontent->bitmap, data->background_colour, flags); + return (ctx->plot->bitmap(ctx, + rsvgcontent->bitmap, + data->x, data->y, + data->width, data->height, + data->background_colour, + flags) == NSERROR_OK); } static void rsvg_destroy(struct content *c) diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c index 94c485822..b34c6b7bb 100644 --- a/content/handlers/image/svg.c +++ b/content/handlers/image/svg.c @@ -16,8 +16,9 @@ * along with this program. If not, see . */ -/** \file - * Content for image/svg (implementation). +/** + * \file + * implementation of content for image/svg using libsvgtiny. */ #include @@ -154,18 +155,25 @@ static void svg_reformat(struct content *c, int width, int height) * Redraw a CONTENT_SVG. */ -static bool svg_redraw_internal(struct content *c, int x, int y, - int width, int height, const struct rect *clip, - const struct redraw_context *ctx, float scale, - colour background_colour) +static bool +svg_redraw_internal(struct content *c, + int x, + int y, + int width, + int height, + const struct rect *clip, + const struct redraw_context *ctx, + float scale, + colour background_colour) { svg_content *svg = (svg_content *) c; float transform[6]; struct svgtiny_diagram *diagram = svg->diagram; - bool ok; int px, py; unsigned int i; plot_font_style_t fstyle = *plot_style_font; + plot_style_t pstyle; + nserror res; assert(diagram); @@ -183,14 +191,17 @@ static bool svg_redraw_internal(struct content *c, int x, int y, for (i = 0; i != diagram->shape_count; i++) { if (diagram->shape[i].path) { - ok = ctx->plot->path(diagram->shape[i].path, - diagram->shape[i].path_length, - BGR(diagram->shape[i].fill), - diagram->shape[i].stroke_width, - BGR(diagram->shape[i].stroke), - transform); - if (!ok) + pstyle.stroke_colour = BGR(diagram->shape[i].stroke); + pstyle.fill_colour = BGR(diagram->shape[i].fill); + res = ctx->plot->path(ctx, + &pstyle, + diagram->shape[i].path, + diagram->shape[i].path_length, + diagram->shape[i].stroke_width, + transform); + if (res != NSERROR_OK) { return false; + } } else if (diagram->shape[i].text) { px = transform[0] * diagram->shape[i].text_x + @@ -204,12 +215,14 @@ static bool svg_redraw_internal(struct content *c, int x, int y, fstyle.foreground = 0x000000; fstyle.size = (8 * FONT_SIZE_SCALE) * scale; - ok = ctx->plot->text(px, py, - diagram->shape[i].text, - strlen(diagram->shape[i].text), - &fstyle); - if (!ok) + res = ctx->plot->text(ctx, + &fstyle, + px, py, + diagram->shape[i].text, + strlen(diagram->shape[i].text)); + if (res != NSERROR_OK) { return false; + } } } -- cgit v1.2.3