summaryrefslogtreecommitdiff
path: root/fitz/res_pixmap.c
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-06Catch errors with impossibly wide images.Robin Watts
Thanks to Zeniko for pointing this out.
2011-12-21Fix whitespace.Tor Andersson
2011-12-19More Memory squeezing fixesRobin Watts
2011-12-17More Memory Squeezing fixes.Robin Watts
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-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-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-08Merge branch 'master' into contextRobin Watts
2011-12-08Undo pre-multiplied alpha when saving PNG with alpha channels.Tor Andersson
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-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.
2011-09-14Initial import of exception handling codeRobin Watts
Import exception handling code from WSS, modified to fit into the fitz world. With this code we have 'real' fz_try/fz_catch/fz_rethrow functions, handling a fz_except type. We therefore rename the existing fz_throw/ fz_catch/fz_rethrow to be fz_error_make/fz_error_handle/fz_error_note. We don't actually use fz_try/fz_catch/fz_rethrow yet...
2011-08-17pdfdraw: Add command line option to gamma correct and invert images.Tor Andersson
2011-08-06Cosmetic style fixes.Tor Andersson
2011-08-02Squash some compiler type warnings.Robin Watts
unsigned char * is not the same as char *.
2011-07-13Non-isolated group support, and fix Bug 692336.Robin Watts
Firstly, this takes on some of Zenikos patch to correct the clip stack handling that was broken by the fix to bug 692287 (in commit 2c3bbbf). This bug should now be solved. We add a new 'shape' field to the draw device structure (and clip stack). When we are inside non-isolated groups, this is set to be a pixmap where we accumulate the 'shape' of the objects drawn. When we come to blend back, if we are blending a non-isolated group back, we have to use a different blending function that takes account of the shape. Various internal groups (the page group, and groups used to force blending) are set to be isolated to avoid carrying shape planes around when this is not required. All our rendering code now has to know how to maintain the shape plane as well as doing the basic rendering.
2011-06-01Fix android build; bug 692222.Robin Watts
Bring the MuPDF android build up to date with the latest source changes. Many thanks to Dominic Battre for his helpful report in bug 692222.
2011-04-08Add soft limit to pixmap allocation.Tor Andersson
All image loading functions call the new fz_new_pixmap_with_limit allocation function, which will return NULL if the total amount of pixmap memory would exceed a set limit. Other vital pixmap allocations which are not as easily recoverable (such as font rendering, and the various buffers in the draw device) ignore the limit.
2011-04-08Simplify arguments to fz_new_pixmap.Tor Andersson
2011-04-04Le Roi est mort, vive le Roi!Tor Andersson
The run-together words are dead! Long live the underscores! The postscript inspired naming convention of using all run-together words has served us well, but it is now time for more readable code. In this commit I have also added the sed script, rename.sed, that I used to convert the source. Use it on your patches and application code.
2011-04-04xps: Convert CMYK with alpha to RGB early to avoid premul alpha headaches.Tor Andersson
2011-04-03xps: Use fz_pixmap directly instead of wrapping it in xps_image.Tor Andersson
2011-03-31xps: Fix bugs in TIFF reader.Tor Andersson
WhiteIsBlack was flipped for fax images. re-multiplying alpha with CMYK images needs special care because of subtractive colors.
2011-03-31xps: Clean up image loading code, and handle images with alpha.Tor Andersson
2011-02-08Only interpolate upscaled images when the interpolate flag is set in the ↵Tor Andersson
image dictionary.
2011-02-03Use calloc to allocate pixmap data. Limit size of PDF images to 65k x 65k.Tor Andersson
2011-01-06Remove unused functions.Sebastian Rasmussen
2010-12-30Adhere to nil idiom.Sebastian Rasmussen
2010-11-28Support luminosity softmask background colors.Tor Andersson
2010-11-16Add a function fz_newpixmapwithdata that lets clients create pixmaps with a ↵Tor Andersson
custom backing store.
2010-08-12Remove pdf_image struct -- load images directly into fz_pixmaps instead.Tor Andersson
2010-07-17Support SMasks for general graphics (incomplete).Tor Andersson
2010-07-16Clarify function names for opening a PDF file.Tor Andersson
2010-07-15Refactored xref opening functions, command line tools, and rewrote pdfdraw ↵Tor Andersson
to be more illustrative.
2010-07-15Implement correct blend mode functions and blending.Tor Andersson
2010-07-15Add pixmap writing functions for PNM, PAM and PNG (without libpng) formats.Tor Andersson
2010-07-14Adapt debug pixmap saving to new alpha component order in pixmap samples.Sebastian Rasmussen
2010-06-19Floats everywhere!Tor Andersson
2010-04-11Rename fz_irect to fz_bbox.Tor Andersson
2010-04-08Move fz_pixmap from draw directory to fitz.Tor Andersson