From 4a99615a609eec2b84bb2341d74fac46a5998137 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 25 Jun 2018 13:15:50 +0200 Subject: 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. --- source/pdf/pdf-link.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/pdf/pdf-link.c') diff --git a/source/pdf/pdf-link.c b/source/pdf/pdf-link.c index e9f1c36f..6fe6f334 100644 --- a/source/pdf/pdf-link.c +++ b/source/pdf/pdf-link.c @@ -255,8 +255,8 @@ pdf_load_link(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int pagenum, co if (!obj) return NULL; - pdf_to_rect(ctx, obj, &bbox); - fz_transform_rect(&bbox, page_ctm); + bbox = pdf_to_rect(ctx, obj); + bbox = fz_transform_rect(bbox, *page_ctm); obj = pdf_dict_get(ctx, dict, PDF_NAME(Dest)); if (obj) @@ -274,7 +274,7 @@ pdf_load_link(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int pagenum, co return NULL; fz_try(ctx) - link = fz_new_link(ctx, &bbox, doc, uri); + link = fz_new_link(ctx, bbox, doc, uri); fz_always(ctx) fz_free(ctx, uri); fz_catch(ctx) @@ -343,7 +343,7 @@ pdf_resolve_link(fz_context *ctx, pdf_document *doc, const char *uri, float *xp, p.y = y ? fz_atoi(y + 1) : 0; obj = pdf_lookup_page_obj(ctx, doc, page); pdf_page_obj_transform(ctx, obj, NULL, &ctm); - fz_transform_point(&p, &ctm); + p = fz_transform_point(p, ctm); if (xp) *xp = p.x; if (yp) *yp = p.y; -- cgit v1.2.3