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 /include/mupdf/fitz/document.h | |
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 'include/mupdf/fitz/document.h')
-rw-r--r-- | include/mupdf/fitz/document.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h index 95e59632..9920a054 100644 --- a/include/mupdf/fitz/document.h +++ b/include/mupdf/fitz/document.h @@ -127,7 +127,7 @@ typedef void (fz_page_drop_page_fn)(fz_context *ctx, fz_page *page); bounding box of a page. See fz_bound_page for more information. */ -typedef fz_rect *(fz_page_bound_page_fn)(fz_context *ctx, fz_page *page, fz_rect *); +typedef fz_rect (fz_page_bound_page_fn)(fz_context *ctx, fz_page *page); /* fz_page_run_page_contents_fn: Type for a function to run the @@ -186,7 +186,7 @@ typedef int (fz_page_uses_overprint_fn)(fz_context *ctx, fz_page *page); typedef void (fz_annot_drop_fn)(fz_context *ctx, fz_annot *annot); typedef fz_annot *(fz_annot_next_fn)(fz_context *ctx, fz_annot *annot); -typedef fz_rect *(fz_annot_bound_fn)(fz_context *ctx, fz_annot *annot, fz_rect *rect); +typedef fz_rect (fz_annot_bound_fn)(fz_context *ctx, fz_annot *annot); typedef void (fz_annot_run_fn)(fz_context *ctx, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie); /* @@ -469,7 +469,7 @@ fz_page *fz_new_page_of_size(fz_context *ctx, int size); fz_bound_page: Determine the size of a page at 72 dpi. */ -fz_rect *fz_bound_page(fz_context *ctx, fz_page *page, fz_rect *rect); +fz_rect fz_bound_page(fz_context *ctx, fz_page *page); /* fz_run_page: Run a page through a device. |