summaryrefslogtreecommitdiff
path: root/source/gprf/gprf-doc.c
AgeCommit message (Collapse)Author
2017-05-31Avoid double literals causing casts to float.Sebastian Rasmussen
2017-05-09Fix key_storable operations leading to leaks of fz_image.Robin Watts
key_storable objects can either be freed 'directly' by an API call (such as fz_drop_image), or 'internally' by the store realising that the sole thing holding onto a key_storable is a key. The current code frees more structure in the direct call than it does in the internal call. Clearly this is wrong and leads to leaks. The fix is to do ALL the freeing in the internal 'drop' function within the key_storable. This means we don't need (or want) either fz_drop_key_storable_key or fz_drop_key_storable to return an int to tell us whether they were actually dropped, so we make that change to simplify the code. This shifts the responsibility for freeing the extra internal structure into the innermost drop functions - fz_drop_image_imp and fz_drop_image_gprf_imp. To avoid duplicating code, we put the extra freeing logic into a fz_drop_image_base function.
2017-04-13Move extension/mimetype detection to common function.Sebastian Rasmussen
A document handler normally only exposes a list of extensions and mimetypes. Only formats that use some kind of extra detection mechnism need to supply a recognize() callback, such as xps that can handle .xps-files unpacked into a directory.
2017-03-28Return fz_document from all document handlers.Sebastian Rasmussen
To make it possible to avoid casting in most cases.
2017-03-22Update fz_new_page.Robin Watts
Move this into the same style as fz_new_document and fz_new_image.
2017-03-20Remove fz_drop_image_base.Robin Watts
2016-11-15move the definition of GSDLLCALL to a different spot, above where it'sFred Ross-Perry
first used.
2016-11-03GProof: Silence warning seen in MSVC x64 builds.Robin Watts
2016-11-03Fix DebugGProof builds on windows.Robin Watts
GSDLLCALL was not being set.
2016-10-18Internal drop functions don't need to check for NULL.Sebastian Rasmussen
2016-10-16Avoid casting when dropping super objects.Sebastian Rasmussen
2016-10-12Remove superfluous context null checks.Tor Andersson
Code MUST pass a non-null context to all functions. Checking ctx for null and failing silently is no more useful than segfaulting. fz_keep_imp and fz_drop_imp handle NULL pointers safely, so the NULL checks for this can also be dropped at the same time.
2016-10-12Always call fz_drop_document() to drop the document.Sebastian Rasmussen
2016-10-11Free document in fz_drop_document(), not in subclassing documents.Sebastian Rasmussen
2016-09-23GProof: Fix typos in gs invocationRobin Watts
2016-09-22GPROOF: Modify gs invocation.Michael Vrhel
If we get the print profile given as '<EMBEDDED>' then use the print profile (Output Intent) embedded in the file. If not, we continue to use the defaults if given the empty string, or the given file otherwise.
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-21fix the quotes fixfred ross-perry
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-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-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-13Add missing include.Robin Watts
Without this we don't pick up FZ_ENABLE_GPRF from the header correctly.
2016-09-12Add UsePDFX3Profile option to gproof deviceMichael Vrhel
The gproof device should make use of the output intent if it exists.
2016-08-16Android viewer: get experimental proofing to build again.fred ross-perry
- use FZ_ENABLE_GPRF everywhere - chasing changed fz APIs in gprf-doc.c
2016-07-08Use fz_keep_imp and fz_drop_imp for all reference counting.Tor Andersson
2016-07-06Proofing - fix a bug in the use of gswin32.exe.fredrossperry
Surround the final filename parameter in quotes ("") so file and folder names with spaces can be used.
2016-06-27Fix GProof operation.Robin Watts
Broken due to recent API changes. Also retire SUPPORT_GPROOF in favour of FZ_ENABLE_GPRF.
2016-04-28Refactor fz_image code cases.Robin Watts
Split compressed images (images based on a compressed buffer) and pixmap images (images based on a pixmap) out into separate subclasses.
2016-04-28Partial image decode.Robin Watts
Update the core fz_get_pixmap_from_image code to allow fetching a subarea of a pixmap. We pass in the required subarea, together with the transformation matrix for the whole image. On return, we have a pixmap at least as big as was requested, and the transformation matrix is updated to map the supplied area to the correct place on the screen. The draw device is updated to use this as required. Everywhere else passes NULLs in, and so gets unchanged behaviour. The standard 'get_pixmap' function has been updated to decode just the required areas of the bitmaps. This means that banded rendering of pages will decode just the image subareas that are required for each band, limiting the memory use. The downside to this is that each band will redecode the image again to extract just the section we want. The image subareas are put into the fz_store in the same way as full images. Currently image areas in the store are only matched when they match exactly; subareas are not identified as being able to use existing images.
2016-04-26Improve fz_new_documentRobin Watts
Use a macro to make fz_new_document nicer (akin to fz_malloc_struct).
2016-03-14Remove begin_page and end_page device calls.Tor Andersson
To be moved into a new document writer interface later.
2016-02-02Fix Gproof DLL calling on windows.Robin Watts
Unadorned calling works on 64bit, but on 32bit we need to ensure that the gsapi functions are declared as __stdcall.
2016-01-20Various formatting cleanups.Tor Andersson
2016-01-05Clean up trailing whitespace.Tor Andersson
2015-09-29add fz_separation_disabled_on_page() and related functionsfredrossperry
2015-09-29gproof: put the generated page file in the same directory as the gproof filefredrossperry
2015-09-29Support for proofingfredrossperry
- use core.fileFormat to decide whether a proof file is being viewed, - don't show the proofing button except for PDF files. - in a proofing activity, show the page that was being viewed when the proof was requested. - Add extra two arguments to fz_write_gproof_file in the Android build.
2015-09-02Add in support for icc profiles in gprf/gproof formatMichael Vrhel
The default profile case (sRGB and SWOP CMYK) are indicated by empty strings for those entries.
2015-08-28Update gproof document handler to cope with renamed gs device.Robin Watts
Ghostscript device has been changed from gproof to gprf for sanity. Also update the non-gsapi calling code to use the same options as the gsapi calling code.
2015-08-26Make the ICC color path the default when rendering the gproof pages with gs.Michael Vrhel
Setting the default post rendering ICC profile to sRGB will make the ghostscript code use the ICC path with a SWOP CMYK device profile followed by a conversion to sRGB for the RGB content in the gproof file.
2015-08-24GProof: Hook up fz_meta - just for 'format' currently.Robin Watts
This will be useful for identifying when we are proofing.
2015-08-19Add stdout and stderr procedures for use with gs api callsMichael Vrhel
gsview on windows does not support the use of stdout and stderr. The calls to write out to these will return 0 leading to an i/o error from gs. To avoid this we define dummy functions that simply return the length that was to be written. To avoid issues with including "iapi.h" in Android builds that do not support gproof we wrap all of gprf-doc.c in an ifdef SUPPORT_GPROOF
2015-08-17GPrf: Alter gsapi invocationRobin Watts
Michael reports that adding -I%rom%Resource/Init/ to the args solves some problems by ensuring that the ROM filing system is used.
2015-08-17Fix stupid ommission in gprf-doc.cRobin Watts
I missed a line when refactoring code.
2015-08-17gprf: Minor fixes for neatness.Robin Watts
We should use a void *instance, not a void **instance. And fz_read_string is more correct than fz_read_line.
2015-08-17GProof: Use better RGB -> CMYK conversion when working from seps.Robin Watts
When proofing an image without all the separations enabled, we reconstitute it using the equivalent cmyk colors, and then convert to rgb. The CMYK -> RGB step is important for quality, and the whole point of GProof mode is to give the best possible quality, so use the slower, but prettier code. Also, fix the blatent bugs in the slower but prettier code that I introduced when hurriedly fixpointing it.
2015-08-17GProof: Fix creating images from a selection of separationsRobin Watts
The code for this was broken; the wrong flag was being tested for selection number, and the values were being assembled per line rather than per pixel.