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. --- platform/java/src/com/artifex/mupdf/fitz/DisplayList.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'platform/java/src/com/artifex/mupdf/fitz') diff --git a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java index c6c33f20..5b64583f 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java +++ b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java @@ -15,10 +15,10 @@ public class DisplayList pointer = 0; } - private native long newNative(); + private native long newNative(Rect mediabox); - public DisplayList() { - pointer = newNative(); + public DisplayList(Rect mediabox) { + pointer = newNative(mediabox); } private DisplayList(long p) { -- cgit v1.2.3