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/pdf/pdf-pattern.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/pdf/pdf-pattern.c')
-rw-r--r-- | source/pdf/pdf-pattern.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c index f1f94352..5574a565 100644 --- a/source/pdf/pdf-pattern.c +++ b/source/pdf/pdf-pattern.c @@ -58,13 +58,10 @@ pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *dict) pat->ystep = pdf_dict_get_real(ctx, dict, PDF_NAME(YStep)); obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox)); - pdf_to_rect(ctx, obj, &pat->bbox); + pat->bbox = pdf_to_rect(ctx, obj); obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix)); - if (obj) - pdf_to_matrix(ctx, obj, &pat->matrix); - else - pat->matrix = fz_identity; + pat->matrix = pdf_to_matrix(ctx, obj); pat->resources = pdf_dict_get(ctx, dict, PDF_NAME(Resources)); if (pat->resources) |