diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-06-25 13:15:50 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-07-05 15:32:34 +0200 |
commit | 4a99615a609eec2b84bb2341d74fac46a5998137 (patch) | |
tree | 486eacff07448e4c655df1fa1bcb20df709dd8df /source/html/html-doc.c | |
parent | 2aa62902447760764e7a763dea322145d9c4808c (diff) | |
download | mupdf-4a99615a609eec2b84bb2341d74fac46a5998137.tar.xz |
Pass rect and matrix by value in geometry functions.
Several things irk me about passing values as const pointers:
* They can be NULL, which is not a valid value.
* They require explicit temporary variables for storage.
* They don't compose easily in a legible manner, requiring
weird pointer passing semantics where the variable being assigned
is hidden as an argument in the innermost function call.
* We can't change the value through the pointer, requiring yet more
local variables to hold copies of the input value.
In the device interface where we pass a matrix to a function, we often
find ourselves making a local copy of the matrix so we can concatenate
other transforms to it. This copying is a lot of unnecessary busywork
that I hope to eventually avoid by laying the groundwork with this
commit.
This is a rather large API change, so I apologize for the inconvenience,
but I hope the end result and gain in legibility will be worth the pain.
Diffstat (limited to 'source/html/html-doc.c')
-rw-r--r-- | source/html/html-doc.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/html/html-doc.c b/source/html/html-doc.c index 98bb082a..45fbd8f9 100644 --- a/source/html/html-doc.c +++ b/source/html/html-doc.c @@ -74,15 +74,16 @@ htdoc_drop_page(fz_context *ctx, fz_page *page_) { } -static fz_rect * -htdoc_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox) +static fz_rect +htdoc_bound_page(fz_context *ctx, fz_page *page_) { html_page *page = (html_page*)page_; html_document *doc = page->doc; - bbox->x0 = 0; - bbox->y0 = 0; - bbox->x1 = doc->html->page_w + doc->html->page_margin[L] + doc->html->page_margin[R]; - bbox->y1 = doc->html->page_h + doc->html->page_margin[T] + doc->html->page_margin[B]; + fz_rect bbox; + bbox.x0 = 0; + bbox.y0 = 0; + bbox.x1 = doc->html->page_w + doc->html->page_margin[L] + doc->html->page_margin[R]; + bbox.y1 = doc->html->page_h + doc->html->page_margin[T] + doc->html->page_margin[B]; return bbox; } @@ -91,7 +92,7 @@ htdoc_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix { html_page *page = (html_page*)page_; html_document *doc = page->doc; - fz_draw_html(ctx, dev, ctm, doc->html, page->number); + fz_draw_html(ctx, dev, *ctm, doc->html, page->number); } static fz_link * |