summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2012-01-19Multi-threading support for MuPDFRobin Watts
When we moved over to a context based system, we laid the foundation for a thread-safe mupdf. This commit should complete that process. Firstly, fz_clone_context is properly implemented so that it makes a new context, but shares certain sections (currently just the allocator, and the store). Secondly, we add locking (to parts of the code that have previously just had placeholder LOCK/UNLOCK comments). Functions to lock and unlock a mutex are added to the allocator structure; omit these (as is the case today) and no multithreading is (safely) possible. The context will refuse to clone if these are not provided. Finally we flesh out the LOCK/UNLOCK comments to be real calls of the functions - unfortunately this requires us to plumb fz_context into the fz_keep_storable function (and all the fz_keep_xxx functions that call it). This is the largest section of the patch. No changes expected to any test files.
2012-01-18Better handling of 'uncacheable' Type3 glyphs. Bug 692745.Robin Watts
Some Type 3 fonts contain glyphs that rely on inheriting various aspects of the graphics state from their calling code. (i.e. a glyph might use d0, then fill an area without setting a color first). While the spec is vague on this point, we believe that technically it is invalid. Previously mupdf defaulted all elements of the graphic state back when beginning to draw the glyph. This does not match what Acrobat does though, so we change the approach taken. We now watch (by use of bits in the device flags word) for the use of parts of the graphics state before it is set. If such use is detected, then we note that the glyph is 'uncacheable' and render it direct. This seems to match Acrobats behaviour.
2012-01-18Add fullscreen mode to mupdf viewer.Tor Andersson
Toggle with 'f'. Fullscreen turns off shrinkwrap, and shrinkwrap turns off fullscreen.
2012-01-14Smarter path construction (avoid needless segments).Robin Watts
Automatically skip segments in a path that serve no purpose at construction time. * MOVE then MOVE -> the original MOVE is ignored. * LINETO the currentpoint -> ignored if previous segment was not a moveto. * CURVETO the currentpoint (with coincident coords) -> ignored if previous segment was not a moveto. * CLOSE then CLOSE -> second close ignored. It's worth noting here that in pdf a closepath leaves the current point at the point which it closes to - any new segments will begin a new subpath, but the current point is defined.
2012-01-13Rework pdf_resolve_indirect to make it idempotent.Robin Watts
pdf_resolve_indirect(x) = pdf_resolve_indirect(pdf_resolve_indirect(x)) now - as long as it doesn't throw an exception. Update the rest of the code to minimise unnecessary function calls. Previously, we were calling one function to find out if an object was a dict, only for that to call a function to see if it needed to resolve the object, then calling another function to actually get the dict, only to have that call the function to check for the dict needing resolving again!
2012-01-13Avoid infinite loops with XObjects.Robin Watts
Every xobject keeps a reference to the object from whence it came. This is marked/unmarked as it is executed. Thanks to Zeniko for spotting the potential problem.
2012-01-13Allow the interpreter gstate stack to grow.Robin Watts
Copes with files with many many gstates in; such as 'tikz-gtree' documents, according to Sumatra. Thanks to Zeniko for this.
2012-01-13Avoid premature flushing of warnings.Robin Watts
Thanks to Zeniko for this.
2012-01-13Clipping stack handling tweaks in dev_list.Robin Watts
Thanks to Zeniko for spotting these problems.
2012-01-13Simple annotation fixes to avoid infinite recursions.Robin Watts
Thanks to Zeniko for spotting the problem here.
2012-01-13Scavenging fixes; overflow and division by zero.Robin Watts
Ensure we don't get a division by zero (when *phase goes to 16). Also ensure we don't overflow the bounds of an unsigned int. Thanks to Zeniko for spotting these problems.
2012-01-13Ensure that client_data pointer for jpx decodes is ctx.Robin Watts
The call to opj_set_event_mgr would overwrite client_data=ctx with client_data=stderr - not what was wanted. Thanks to Zeniko for this.
2012-01-12Support proper XPS mitering. (And stroke fixes).Robin Watts
XPS differs from PS/PDF/etc in the way it handles miters; rather than simply converting a miter that's overly long to a bevel, it truncates it at the miter limit. As such it needs to be handled correctly. For clarity, expose new enumerated types for linejoins and linecaps, and use these throughout code. When we upgrade our freetype, we can move to using proper xps mitering in that too. Add new fz_matrix_max_expansion function to return a safer expansion value that works in the case where we scale up in one direction and down in another. In the xps path drawing code, avoid generating unnecessary linetos. Thanks to Zeniko for spotting these and providing implementations.
2012-01-12Avoid possible array overrun (and SEGV).Robin Watts
Check for cid being in range before using it. Thanks to Zeniko for spotting this.
2012-01-12Calculate individual glyph bboxes for Type 3 fonts too.Tor Andersson
2012-01-12Use the FontMatrix entry to scale the FontBBox in Type3 fonts.Tor Andersson
2012-01-12Fix typo in pdf_repair.cTor Andersson
2012-01-12Update copyright notices for 2012.Tor Andersson
2012-01-12Check the abort cookie in XPS.Tor Andersson
2012-01-12Fix memory leak in font->bbox_table.Tor Andersson
2012-01-12Use the same coordinate system for pdf and xps pages in the interface.Tor Andersson
Move coordinate space tweaks into pdf_ and xps_run_page, and provide neutral pdf_ and xps_bound_page functions to return the page size as a zero-origined bounding box.
2012-01-12Fix android for previous glyph cache changes.Tor Andersson
2012-01-11Add xps_run_page function.Tor Andersson
2012-01-11Flush warnings before printing an error message in fz_throw.Tor Andersson
2012-01-11Use enum for FZ_STORE_DEFAULT default size.Tor Andersson
2012-01-11Hide glyph cache in context.Tor Andersson
2012-01-11Set default values for alloc context and max store size if none are given.Sebastian Rasmussen
2012-01-11Do not unnecessarily use O_BINARY in X11 viewer.Sebastian Rasmussen
2012-01-11Stylistic comment and whitespace fixes.Tor Andersson
2012-01-11Add glyph bbox cache.Tor Andersson
2012-01-11Calculate accurate per-glyph bounding boxes for fz_bound_text.Tor Andersson
2012-01-11Remove fuzzing from fz_round_rect.Tor Andersson
I don't remember exactly why I added it; but there are several progressions when I remove it.
2012-01-10Make debian package files work.Sebastian Rasmussen
2012-01-10Automatically load page tree when accessing a page/page count.Sebastian Rasmussen
2012-01-10Move fuzz from fz_execute_display_list into fz_bound_text.Robin Watts
Keep the fuzz in just one place. Hopefully will be rendered unnecessary by changes to make fz_bound_text accurate.
2012-01-10Add fz_blend_pixel_function.Robin Watts
Inspired by Sumatras gdi devices need for such a function expose the blending functions. Note that we produce unsigned char's where Zenikos original produces ints, but it's otherwise identical. This requires us to make various knockon changes throughout the code from int to unsigned char, none of which should make any difference at all - I hope! We reserve the right to change/amend this function in future to operate on blocks of pixels (or pixels in different colorspaces) (or anything else we think of) in future.
2012-01-10Fix many spelling errors.Sebastian Rasmussen
2012-01-09Update fz_try/fz_catch to be fz_try/{fz_always}/fz_catch.Robin Watts
Add explanations of how to use the macros in fitz.h. Also included are 2 different formulations, with different strengths/ weaknesses for reference. Will remove these shortly, but I want a reference to them in git. Workaround bug in Mac OS Lion gcc (clang works fine).
2012-01-09Fix Android logging bug; cut and paste error.Robin Watts
Thanks to Zeniko for pointing this out.
2012-01-09Fix Bug 692356 (comment #2)Robin Watts
Take on a modified version of Zenikos patch; only take the quick exit if the whole dash length is small, or if the dash_length scaled up by the maximum possible scale in the ctm is less than 1/2 a pixel.
2012-01-09Add fz_try/fz_catch to xpsdrawRobin Watts
Avoid unhandled exceptions. Thanks to Zeniko for this.
2012-01-09Fix bug where pdf function was used after being dropped.Sebastian Rasmussen
2012-01-07Empty object store when freeing xref.Sebastian Rasmussen
Fixes a bug where objects remained in the store and would keep stable pointers to the freed xref, later on those objects could lead to false positive hits.
2012-01-07Fix compilation warningsSebastian Rasmussen
Add missing newline and remove excessive arguments.
2012-01-06Android tweaks.Robin Watts
Include android headers in fitz.h so we can debug. Arrange for error throwing to output to android error stream as well as stderr. Change jpeg library to not use backing store. Solves bug 692473.
2012-01-06XPS tweaks/fixes.Robin Watts
xps_parse_resource_dictionary can now warn and return NULL when reading an empty dictionary, rather than throwing an error. Various bits of code are therefore updated to check for a NULL return value. We should cope better with multiple Resource dictionaries. Tweak to the zip file handling when looking for parts. Again, all from (or inspired by) Zenikos patch.
2012-01-06PDF fixes/tweaks.Robin Watts
Fix 2 places where we were filling a stroked pattern rather than stroking it. Cope with being asked to run a NULL buffer. If running a stream fails, warn and return what we have, rather than giving up entirely. Should really set a return code for each render. Only look at the Print flag bit for Print renders. Only look at the View flag bit for view renders. If we find an unexpected ) or > during object parsing, warn and continue rather than giving up entirely. If optional content groups are broken, render the rest of the page anyway. Previously indirect objects that point to another indirection would cause a failure; now attempt to resolve these. We set an arbitrary limit of 10 such redirections to avoid infinite loops.
2012-01-06Various fixes to avoid arithmetic problems.Robin Watts
Various fixes to avoid overflow problems, division by zeros, use of uninitialised variables etc. All from/suggested by Zenikos patch.
2012-01-06pdf_repair tweaks; fail in fewer cases.Robin Watts
When repairing, if we hit a problem after having found a root object live with that root object rather than giving up completely. Also fix a memory leak, and cope better with trailing crap. Thanks to Zeniko for these.
2012-01-06Catch errors with impossibly wide images.Robin Watts
Thanks to Zeniko for pointing this out.