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/fitz/image.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/fitz/image.c')
-rw-r--r-- | source/fitz/image.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/source/fitz/image.c b/source/fitz/image.c index 51699772..8cda9687 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -590,7 +590,7 @@ update_ctm_for_subarea(fz_matrix *ctm, const fz_irect *subarea, int w, int h) m.d = (float) (subarea->y1 - subarea->y0) / h; m.e = (float) subarea->x0 / w; m.f = (float) subarea->y0 / h; - fz_concat(ctm, &m, ctm); + *ctm = fz_concat(m, *ctm); } void fz_default_image_decode(void *arg, int w, int h, int l2factor, fz_irect *subarea) @@ -1139,8 +1139,7 @@ display_list_image_get_pixmap(fz_context *ctx, fz_image *image_, fz_irect *subar /* If we render the display list into pix with the image matrix, we'll get a unit * square result. Therefore scale by w, h. */ - ctm = image->transform; - fz_pre_scale(&ctm, w, h); + ctm = fz_pre_scale(image->transform, w, h); fz_clear_pixmap(ctx, pix); /* clear to transparent */ dev = fz_new_draw_device(ctx, &ctm, pix); @@ -1196,7 +1195,7 @@ fz_image *fz_new_image_from_display_list(fz_context *ctx, float w, float h, fz_d display_list_image_get_size, drop_display_list_image); image->super.scalable = 1; - fz_scale(&image->transform, 1 / w, 1 / h); + image->transform = fz_scale(1 / w, 1 / h); image->list = fz_keep_display_list(ctx, list); return &image->super; |