From c040fbc4cca119ba4dcaac866e0eb4c23b76c4c7 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 11 Nov 2012 20:02:45 +0000 Subject: Allow reformats to different size. --- image/svg.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'image') diff --git a/image/svg.c b/image/svg.c index 971ab764e..54a48083b 100644 --- a/image/svg.c +++ b/image/svg.c @@ -21,6 +21,7 @@ */ #include +#include #include #include @@ -36,7 +37,9 @@ typedef struct svg_content { struct content base; struct svgtiny_diagram *diagram; - bool done_parse; + + int current_width; + int current_height; } svg_content; @@ -49,7 +52,8 @@ static nserror svg_create_svg_data(svg_content *c) if (c->diagram == NULL) goto no_memory; - c->done_parse = false; + c->current_width = INT_MAX; + c->current_height = INT_MAX; return NSERROR_OK; @@ -127,14 +131,13 @@ static void svg_reformat(struct content *c, int width, int height) assert(svg->diagram); - if (svg->done_parse == false) { + /* Avoid reformats to same width/height as we already reformatted to */ + if (width != svg->current_width || height != svg->current_height) { source_data = content__get_source_data(c, &source_size); svgtiny_parse(svg->diagram, source_data, source_size, nsurl_access(content_get_url(c)), width, height); - - svg->done_parse = true; } c->width = svg->diagram->width; -- cgit v1.2.3