summaryrefslogtreecommitdiff
path: root/pdf
AgeCommit message (Collapse)Author
2011-12-16Add fz_malloc_struct, and make code use it.Robin Watts
The new fz_malloc_struct(A,B) macro allocates sizeof(B) bytes using fz_malloc, and then passes the resultant pointer to Memento_label to label it with "B". This costs nothing in non-memento builds, but gives much nicer listings of leaked blocks when memento is enabled.
2011-12-15More Memsqueezing fixes.Robin Watts
2011-12-15Another memsqueezing bug.Robin Watts
2011-12-15Another Memsqueezing bug.Robin Watts
2011-12-15Various Memsqueezing fixes.Robin Watts
Fixes for leaks (and SEGVs, division by zeros etc) seen when Memsqueezing.
2011-12-15Fix warnings/errors on unix builds.Robin Watts
Fix warnings/errors thrown up by the last few commits (which were only tested on windows).
2011-12-15Don't count ROM data in size of fontdescs.Robin Watts
The substitute fonts used in a fontdesc are held in ROM, and as such should not count towards the size of a fontdesc. Simple fix; remove the lines that adds that in.
2011-12-15Remove stray whitespace.Tor Andersson
2011-12-15Remove 'soft limit' on pixmaps in favour of fz_store.Robin Watts
Change the fz_store to be limited to 256 Megs. Remove the soft limit for pixmaps; the store will automatically throw old resources away to stay below the limit.
2011-12-15Rework pdf_store to fz_store, a part of fz_context.Robin Watts
Firstly, we rename pdf_store to fz_store, reflecting the fact that there are no pdf specific dependencies on it. Next, we rework it so that all the objects that can be stored in the store start with an fz_storable structure. This consists of a reference count, and a function used to free the object when the reference count reaches zero. All the keep/drop functions are then reimplemented by calling fz_keep_sharable/fz_drop_sharable. The 'drop' functions as supplied by the callers are thus now 'free' functions, only called if the reference count drops to 0. The store changes to keep all the items in the store in the linked list (which becomes a doubly linked one). We still make use of the hashtable to index into this list quickly, but we now have the objects in an LRU ordering within the list. Every object is put into the store, with a size record; this is an estimate of how much memory would be freed by freeing that object. The store is moved into the context and given a maximum size; when new things are inserted into the store, care is taken to ensure that we do not expand beyond this size. We evict any stored items (that are not in use) starting from the least recently used. Finding an object in the store now takes a reference to it already. LOCK and UNLOCK comments are used to indicate where locks need to be taken and released to ensure thread safety.
2011-12-09Reinstate some missing fz_vars.Robin Watts
2011-12-09Fix pdfdraw "repairing" every document.Robin Watts
When adding the exception handling in, I'd mis-indented some code. This caused all the file to be read.
2011-12-09Squash 2 warnings (fz_obj * != int).Robin Watts
2011-12-08Stylistic changes when testing pointer values for NULL.Tor Andersson
Also: use 'cannot' instead of 'failed to' in error messages.
2011-12-08Remove deprecated error handling code.Tor Andersson
2011-12-08Remove remaining fz_error_note calls in the pdf code.Tor Andersson
2011-12-08Throw exceptions for read errors.Tor Andersson
2011-12-08Move from volatile to fz_var.Robin Watts
When using exceptions (which are implemented using setjmp/longjmp), we need to be careful to ensure that variable values get written back before any exception happens. Previously we've done that using volatile, but that produces nasty warnings (and unduly limits the compilers freedom to optimise). Here we introduce a new macro fz_var that passes the address of the variable out of scope. This means that the compiler has to ensure that any changes to its value are written back to memory before calling any out of scope function.
2011-12-08Fix regression from main; no "invalid password" errorRobin Watts
In converting from error return to exception throwing I was over enthusiatic and removed more than I should. Add missing code back in. Problem was seen with "0 - password password (crypt level 5).pdf"
2011-12-08Fix SEGV with "1439 - color softmask fails to draw jpx image.pdf"Robin Watts
Another missed fz_rethrow. Also, ensure that fz_drop_buffer copes with NULL input.
2011-12-08Fix lack of output with "719 - EOF incorrectly detected.pdf"Robin Watts
When converting to exception handling I'd messed up an error handling case; when failing to pdf_lex in pdf_repair_xref I had allowed the error to just carry on being thrown rather than catching it and cleaning up. This was resulting in not getting any output for the above file, rather than outputting as much as we could. Simple fix.
2011-12-08Fix possible NULL dereference in pdf_resolve_indirectRobin Watts
The code was dereferencing xref to get ctx before checking whether it was NULL or not. Simple fix to move the test up a bit.
2011-12-08Fix SEGV seen when repairing SumatraPDF1.1DOS.pdfRobin Watts
An error while parsing pdf_parse_array could result in double dropping of an object. Simple fix.
2011-12-08Merge branch 'master' into contextRobin Watts
2011-12-08Ignore invalid color key Masks that contain non-integer values.Tor Andersson
2011-12-07Fix tile coverage calculations.Robin Watts
The code attempts to spot cases where a pattern tile is so large that only 1 repeat is visible. Due to rounding errors, this test could sometimes fail, and (on badly formed files) we'd attempt to allocate huge pixmaps. The fix is to allow for rounding errors.
2011-12-07Fix tile coverage calculations.Robin Watts
The code attempts to spot cases where a pattern tile is so large that only 1 repeat is visible. Due to rounding errors, this test could sometimes fail, and (on badly formed files) we'd attempt to allocate huge pixmaps. The fix is to allow for rounding errors.
2011-12-06Remove dead (duplicated) code from pdf_fontfile.cRobin Watts
2 if clauses were (harmlessly) duplicated in pdf_find_builtin_font, probably due to an automated code merge (or other cut/paste error).
2011-12-06Remove dead (duplicated) code from pdf_fontfile.cRobin Watts
2 if clauses were (harmlessly) duplicated in pdf_find_builtin_font, probably due to an automated code merge (or other cut/paste error).
2011-11-25Merge branch 'master' into contextRobin Watts
2011-11-25First cut at support for OCGs in mupdf (bug 692314)Robin Watts
When opening a file, create a pdf_ocg_descriptor that lists the OCGs in a file. Add a new function to allow us to set the configuration in use (currently just the default one). This sets the states of the OCGs as appropriate. When decoding the file respect the states of the OCGs. This results in Invite.pdf rendering correctly. There is more to be done in this area (with automatic setting of OCGs by language/zoom level etc), but this is a good start.
2011-11-24Fix *STUPID* error in recent clipping changes.Robin Watts
Once we've applied the clipping path, don't clip again on every subsequent path.
2011-11-24Bug 692506: Improve repairing by accepting broken dictionaries.Robin Watts
Adopt Zenikos patch from bug 692506; if a dict fails to parse, then create an empty one and continue. The repaired document will be incomplete, but we may well get something useful out of it.
2011-11-17Bug 692424: make repair cope better with missing endobjRobin Watts
Previously when parsing an object with a missing endobj, the code would consume the header of the following object. Here we amend the code to give up searching for an endobj if it finds an integer (presumed to be the start of the next object). We backtrack over that integer and carry on.
2011-11-17Bug 692478: Honour decode arrays for jpx imagesRobin Watts
Add simple code to read decode array and apply it to a jpx image after loading. Solves bug.
2011-11-17AES encryption tweak; strings can be 0 bytes longRobin Watts
Do not emit a warning if AES strings are 0 bytes long.
2011-11-15Fix clipping error.Robin Watts
When reverting the clip path handling, I made a mistake. We need to set up the clip before starting any local group to ensure correct nesting.
2011-11-15Fix clipping error.Robin Watts
When reverting the clip path handling, I made a mistake. We need to set up the clip before starting any local group to ensure correct nesting.
2011-11-15Merge branch 'master' into contextRobin Watts
Mostly redoing the xps_context to xps_document change and adding contexts to newly written code. Conflicts: apps/pdfapp.c apps/pdfapp.h apps/x11_main.c apps/xpsdraw.c draw/draw_device.c draw/draw_scale.c fitz/base_object.c fitz/fitz.h pdf/mupdf.h pdf/pdf_interpret.c pdf/pdf_outline.c pdf/pdf_page.c xps/muxps.h xps/xps_doc.c xps/xps_xml.c
2011-11-14mupdf clip path handling; revert commit 2f8acb0Robin Watts
In commit 2f8acb0, we tweaked mupdf's clip path handling so that clip paths were resolved as soon as the operator for them was called; this protected against subsequent changes to the path happening before something else was drawn ready for clipping. Unfortunately, various PDF files out there seem to rely on the fact that they can call the 'W' operator before fully defining the path, and that the region that will be clipped is given by the final path, not the one that was in place when the operator was called. We therefore revert back to the old behaviour.
2011-11-10Add XPS outline parsing and move outline data struct to fz_outline.Tor Andersson
2011-11-01Don't round the mediabox when loading the pdf_page object.Tor Andersson
2011-10-25Treat garbage in PDFDocEncoding low code points as spaces.Tor Andersson
2011-10-04Establish 'break scope' within fz_try macroRobin Watts
It is vital that no one returns from within fz_try. As such it's often necessary to jump out of an fz_try. This can mean using a label at the end of the fz_try section to goto. By introducing a "do { } while (0)" around the contents of the fz_try we allow people to 'break' (or 'continue') to get out neatly.
2011-10-04Move to exception handling rather than error passing throughout.Robin Watts
This frees us from passing errors back everywhere, and hence enables us to pass results back as return values. Rather than having to explicitly check for errors everywhere and bubble them, we now allow exception handling to do the work for us; the downside to this is that we no longer emit as much debugging information as we did before (though this could be put back in). For now, the debugging information we have lost has been retained in comments with 'RJW:' at the start. This code needs fuller testing, but is being committed as a work in progress.
2011-09-21Add warning context.Tor Andersson
2011-09-21Rename malloc functions for arrays (fz_calloc and fz_realloc).Tor Andersson
2011-09-21Don't thread ctx through safe fz_obj functions.Tor Andersson
2011-09-20Reshuffle exception context code to fit Tor's aesthetic sense.Tor Andersson
2011-09-15Add context to mupdf.Robin Watts
Huge pervasive change to lots of files, adding a context for exception handling and allocation. In time we'll move more statics into there. Also fix some for(i = 0; i < function(...); i++) calls.