summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2016-09-22tools: Prefer fz_atof() to atof().Sebastian Rasmussen
2016-09-22GProof: When invoking gs, redirect gs stdio to local stderr.Robin Watts
For android this means it will go to our logging. This moves the code out of gs.
2016-09-22Bug 697015: Avoid object references vanishing during repair.Robin Watts
A PDF repair can be triggered 'just in time', when we encounter a problem in the file. The idea is that this can happen without the enclosing code being aware of it. Thus the enclosing code may be holding 'borrowed' references (such as those returned by pdf_dict_get()) at the time when the repair is triggered. We are therefore at pains to ensure that the repair does not replace any objects that exist already, so that the calling code will not have these references unexpectedly invalidated. The sole exception to this is when we replace the 'Length' fields in stream dictionaries with the actual lengths. Bug 697015 shows exactly this situation causing a reference to become invalid. The solution implemented here is to add an 'orphan list' to the document, where we put these (hopefully few, small) objects. These orphans are kept around until the document is closed.
2016-09-22Bug 697018: Avoid recursing infinitely on dicts in mutool info.Sebastian Rasmussen
2016-09-21fix the quotes fixfred ross-perry
2016-09-21Bug 697106: Mark 64bit constants as such.Robin Watts
Avoids gcc giving spurious warnings.
2016-09-21Gproof GS invocation: Only quote profile names if required.Robin Watts
We need to quote profile names if we use system, but not if we use the GS_API. Update the code to cope.
2016-09-21Update GPRF invocation of GSRobin Watts
Have both the GSAPI and non GSAPI invocations be identical. Remove the -rxx bit because it is not required when using -gWxH and -dFitPage. Add some simple debug code.
2016-09-20Fix Memento crashRobin Watts
When reallocing set the rawsize before attempting to write the post guard block.
2016-09-20Sync Memento with gs.Robin Watts
Including: Bug 697134: Tweak MEMENTO_GS_HACKS inclusion. Rather than rolling our own memset prototype in this case, use the one that gs provides. And, bug 697133: Fix typo in Memento. Causing a significant slowdown. Thanks to George Burgess IV for spotting this.
2016-09-20Avoid signed/unsigned warnings.Robin Watts
2016-09-20SVG: If no width/height given, then guess from viewBox.Robin Watts
2016-09-19Update SVG document handler; circles.Robin Watts
Cope with circles, rounded rects, etc. Not the worlds best approximation to a circular arc, but it's better than nothing.
2016-09-19fz_store: Reap passes.Robin Watts
A few commits back, we introduced the fz_key_storable concept to allow us to cope with objects that were used both as values within the store and as parts of keys within the store. This commit worked, but showed up performance problems; when the store has several million PDF objects in it, bulk changes (such as dropping a display list or document) could trigger many passes across the store. We therefore introduce a mechanism to ameliorate this. These passes, now known as "reap passes", can be batched together using fz_defer_reap_start and fz_defer_reap_end. We trigger this start/end around display list dropping, and around PDF content stream processing. This should be fine, as deferral will be interrupted if we ever run our of memory during mallocing.
2016-09-19Make fz_printf() handle %lu.Sebastian Rasmussen
2016-09-19jpx: Fix off by one in palettized images.Sebastian Rasmussen
2016-09-19svg: Throw on nonconforming transform attributes.Sebastian Rasmussen
2016-09-18svg: Use fz_atof() and fz_strtod().Sebastian Rasmussen
2016-09-18Make printing empty hash table entries optional.Sebastian Rasmussen
2016-09-18Fix printing of hash table.Sebastian Rasmussen
2016-09-18Make fz_printf() support %p.Sebastian Rasmussen
This is used at several places in mupdf.
2016-09-18svg: Ensure that read svg file is null-terminated.Sebastian Rasmussen
fz_parse_xml() assumes a null-terminated xml string.
2016-09-18svg: Fix typo in opacity attribute variable name.Sebastian Rasmussen
2016-09-18Free fz_tree nodes when dropping tree.Sebastian Rasmussen
2016-09-18tiff: Do not assume that images always have alpha component.Sebastian Rasmussen
2016-09-17Squash some memento warnings in MEMENTO_LEAKONLY builds.Robin Watts
2016-09-16Remove unused variable.Robin Watts
2016-09-16Correct assertion in pdf-store.Robin Watts
We can use names as keys for colorspaces. These are not bound to a particular document.
2016-09-16More tweaking of gproof device gs invocation.Robin Watts
If USE_GS_API is defined, we use the gsapi interface to call gs. The gsapi interface is defined in iapi.h, which is not included in the mupdf source code. We therefore include a potted version of this API inline. To use the original, pass HAVE_IAPI_H at compile time.
2016-09-16Bug 695988: Avoid sending image data multiple times.Robin Watts
If the same image is used repeatedly, then we currently send the data again and again. Instead, send each image as a reusable symbol and reuse it as required. This reduces the size of the output by over 50% for the example file, but unfortunately results in the example file killing both Firefox and Edge when we attempt to load it. The file seems entirely valid though, and this is a saving on sane files. There is a #define that can be made to revert to the old behaviour (SVG_SEND_REPEATED_IMAGES).
2016-09-16Silence some warnings.Robin Watts
2016-09-16Improve fz_filter_store speed.Robin Watts
Now linear time rather than n^2.
2016-09-16Tweak store handling of PDF document destroy.Robin Watts
When we destroy a PDF document, currently we bin everything from the store. Instead, drop just the objects that are specifically tied to that document. Any object tied to the document has a pdf_obj with the required document pointer in it as the key.
2016-09-16Tweak gprf-doc.c to avoid warnings.Robin Watts
2016-09-16Extend store to cope with references used in keys.Robin Watts
The store is effectively a list of items, where each item is a (key, value) pair. The design is such that we can easily get into the state where the only reference to a value is that held by the store. Subsequent references can then be generated by things being 'found' from within the store. While the only reference to an object is that held by it being a value in the store, the store is free to evict it to save memory. Images present a complication to this design; images are stored both as values within the store (by the pdf agent, so that we do not regenerate images each time we meet them in the file), and as parts of the keys within the store. For example, once an image is decoded to give a pixmap, the pixmap is cached in the store. The key to look that pixmap up again includes a reference to the image from which the pixmap was generated. This means, that for document handlers such as gproof that do not place images in the store, we can end up with images that are kept around purely by dint of being used as references in store keys. There is no chance of the value (the decoded pixmap) ever being 'found' from the store as no one other than the key is holding a reference to the image required. Thus the images/pixmaps are never freed until the store is emptied. This commit offers a fix for this situation. Standard store items are based on an fz_storable type. Here we introduce a new fz_key_storable type derived from that. As well as keeping track of the number of references a given item has to it, it keeps a separate count of the number of references a given item has to it from keys in the store. On dropping a reference, we check to see if the number of references has become the same as the number of references from keys in the store. If it has, then we know that these keys can never be 'found' again. So we filter them out of the store, which drops the items.
2016-09-16Update gproof device to invoke gs better.Robin Watts
When invoking gs, pass in -gWIDTHxHEIGHT -dFitPage. This avoids any possible mismatch betwen the page size we expect and the page size that gs returns.
2016-09-16fz_unpack_tile now skips extra input components.Sebastian Rasmussen
This is useful when a TIFF image is grayscale but supplies more than a single component per sample.
2016-09-14Redirect fprintf to android logcat in debug builds.Robin Watts
This makes debugging much simpler.
2016-09-14Don't report addRef/dropRef events to Memento twice.Robin Watts
We call Memento_addRef etc in fz_keep_impXX functions, so don't call them in the callers too.
2016-09-14Add scripts to remove/replace 'static' from functions.Robin Watts
Getting a backtrace out with missing functions makes the backtrace much less useful. Some backtrace routines (such as that used by Memento on Android) are incapable of resolving static functions. We therefore provide 2 scripts (scripts/destatic.sh and scripts/restatic.sh) that respectively remove and replace the 'static' from function definitions. The scripts do not affect "static inline" or "static const" definitions, and they are are restricted to working in the source directory (excluding source/tools), thirdparty/mujs and the platform/{java,android} directories. The transformed source should NOT be checked in. To avoid problems with clashing symbols, some functions are renamed or tweaked slightly in this patch.
2016-09-14Update android logging code within Memento.Robin Watts
Work around the problems in that androids logging only works in whole lines by buffering until we have one. Also, androids logging goes to a circular buffer that loses data when it overflows. Hack around this by adding a 1ms sleep after every line output.
2016-09-14Table should be static const.Robin Watts
2016-09-13Fix Memento Android backtrace code.Robin Watts
Thanks to Sebastian for pointing out that the demangling code wants a malloced block, cos it might realloc it. Drop back to the dumber version.
2016-09-13Update Memento for Android.Robin Watts
Add backtrace abilities, and fix missing return value from android logging.
2016-09-13Add missing include.Robin Watts
Without this we don't pick up FZ_ENABLE_GPRF from the header correctly.
2016-09-13Bug 696984: Type 3 fonts bbox fixes.Robin Watts
The upshot of debugging this is that: 1) We can't trust the FontBBox. Certainly it appears that no one else trusts it. 2) We can't trust the d1 values in all cases, as it can lead to use rendering glyphs far larger than we'd want to. So we have the compromise used here. 1) We never clip to the FontBBox. 2) If the FontBBox is invalid, then we calculate the bbox from the contents of the data streams. 3) If the FontBBox is valid, and the d1 rectangle given does not fit inside it, then we calculate the bbox from the contents of the data streams. This could theoretically produce problems with glyphs that have much more content than they actually need, and rely on the d1 rect to clip it down to sanity. If the FontBBox is invalid in such fonts, we will go wrong. It's not clear to me that this will actually work in Acrobat/ Foxit/gs etc either, so we defer handling this better until we actually have an example. Tested with bug 694952, and bug 695843 which were the last 2 in this area.
2016-09-13Fix compiler warning.Tor Andersson
2016-09-12Add UsePDFX3Profile option to gproof deviceMichael Vrhel
The gproof device should make use of the output intent if it exists.
2016-09-12Correct rounding in gproof skeleton files.Robin Watts
In the gproof pipeline MuPDF first generates a skeleton file with page sizes in. Then it gets gs to generate individual pages for that file. In one case, the pdf file has a height of 203.4 - at 300dpi that's 847.5 device pixels. MuPDF was rounding that up to 848pixels, whereas gs was rounding it down to 847, causing an error on load. Adjust MuPDFs skeleton file generation so that it matches gs.
2016-09-09Fix incorrect type usage.Robin Watts
MSVC is obviously more picky than linux in some cases.