summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* GPDL: Run the pdfwrite setup each time we start a PS/PDF job.gpdl-shared-deviceRobin Watts2019-03-252-10/+26
| | | | | | | | | | | Re-run the "scheduled inits" procs after installing the device into the gstate - for the benefit of pdfwrite. For neatness, move the scheduled inits list dictionary, and the proc to run them into internaldict, so the don't contaminate the "normal" name space in systemdict. (Whatever git might say, the cleverness here is due to Chris).
* GPDL: Separate gs init file running into "post_args_init" phase.Robin Watts2019-03-258-16/+55
|
* GPDL: Simplify device creation.Robin Watts2019-03-251-8/+11
| | | | | | Just create the device once, rather than creating once, and then calling the creation function again to see if we need to create a default.
* Fix gs_main_set_device passthru of PageSize.Robin Watts2019-03-251-1/+9
| | | | | | | | | | | | | | | | /GetDeviceParam .special_op does not work in the way you might expect. <key> /GetDeviceParam .special_op will either return: <key> <value> true or false Update the code to cope.
* GPDL: Avoid dnitting twice if dnit gives error.Robin Watts2019-03-251-3/+6
| | | | Also, avoid memory leak in failure case.
* gpdl: Tidy up the device management between jobsChris Liddell2019-03-252-14/+15
| | | | | | Instead of explicitly uninstalling the page device at the end of the job (and installing the null device), use gsave/grestore so we can back up to a gstate with the nullpage device installed at the end of the job.
* Workaround for QL jobs that use %stdinChris Liddell2019-03-251-0/+47
|
* GPDL: Better error reporting in case of missing files.Robin Watts2019-03-252-2/+4
|
* gs_interp_reset() leaves the op stack one below the bottomChris Liddell2019-03-251-1/+7
| | | | So after reset, push a null, then the integer we need.
* Update language detection mechanism to be score based.Robin Watts2019-03-257-18/+246
| | | | | | | | | Rather than just saying "yes" or "no", each language auto sensor routine returns a score between 0 (not a match) and 100 (definite match) inclusive. In particular we update the PS detector with some hairy logic to guess whether it's a PS file or not.
* GPDL: Fix GS papersize initialisation.Robin Watts2019-03-252-19/+33
| | | | | | | | | | | The GS init code sets the device paper size on startup. Sadly now, this happens to the null device rather than our intended target device, so the configuration is lost. Accordingly, make the gs language code that sets the target device carry the page size forwards. This does not affect normal postscript language operations, just the way the PS language implementation in gpdl builds calls it.
* GPDL: Fix handling of languages returning InterpreterExitRobin Watts2019-03-252-3/+8
| | | | | If the languages exit with InterpreterExit, don't treat this as an error.
* GPDL: Tweak gs_main_set_deviceRobin Watts2019-03-253-13/+31
| | | | | | | | | | Do the actual device setting directly using C rather than entirely in PS. This sidesteps the 'SAFER' checks and avoids problems in the language switching where we try to insert a device under 'SAFER' conditions. This is not a security risk as we'll always be putting the same device back in each time.
* GPDL: Improve argument handlingRobin Watts2019-03-2510-91/+268
| | | | | | | | | | | | | | | | | | | | | We add a pl_interp_implementation function for setting a parameter in the language. Only the PS implementation implements this currently, and that sets the given parameters in systemdict. While we parse arguments, we both write them into a parameter list (which we feed to the device at the end of argument processing), and we use the new call to pass them into the languages. It would arguably be preferably for things to be written to the device parameter list only if the device understood it, and the rest could go to systemdict. This is impossible (or at least very complicated) with the current implementation of param lists. As it is, we end up doing pretty much the same as gs, which is probably a good thing. Also in this commit, we tidy up some of the arg handling; better checks on radix numbers (both base and value), better arg checking ("BATCHPLEASE" no longer matches for "BATCH" etc)
* GPDL: Do not uninitialise a NULL implementation.Robin Watts2019-03-251-3/+5
|
* GPDL: Fix ps_impl_init_job error handling.Robin Watts2019-03-251-1/+5
| | | | | | | If the set_device fails, unset the device to avoid us leaving the device hooked into the PS interpreter. This causes errors during shutdown when the reclaim tries to remove an already freed device.
* Update postscript initialisation to allow for -g and -r.Robin Watts2019-03-259-33/+189
| | | | | | | | | | | | | | | Using the the -g and -r flags, we need to set FIXEDMEDIA and FIXEDRESOLUTION etc in the internals of the PS interpreter. For this to work properly , it needs to be done during the init phase (i.e. before gs_main_init2 is called). Accordingly, we split the psapi init call in two. We also add some plumbing to allow us to recover the resolutions/dimensions of the pages from the top level, and to pass that down into the internals of the interpreter. For neatness, we make the standard gs init calls use these too.
* Chameleon device.Robin Watts2019-03-256-23/+922
| | | | | | | | | | | | | | Simple ppm like device that responds to LanguageUsesROPs device parameter to reconfigure itself between rendering direct to the required output space, or rendering to RGB contone, and then converting in a post process step. User settable parameters: DstBitDepth = Number of bits per component in the final output DstComponents = Number of components in the final output OutputAsPXM = 0 or 1 (Raw or with an approriate PxM header where possible)
* Make PCL and PXL set LanguageUsesROPs device parameter.Robin Watts2019-03-252-4/+67
|
* Print language switch selection with -Z:Robin Watts2019-03-251-3/+3
|
* GPDL: Cope with Postscript jobs that exit the server loopChris Liddell2019-03-251-10/+19
| | | | | | | | | | | | | | | | | In order to cope with jobs exit the server loop, we have to ensure that the change from the nulldevice (used during gpdl initialization) and the 'real' device being set prior to running the job, happens outside the server loop. Otherwise the job's exiting of the server loop results in restoring to the original state (with the nulldevice), and creating a new server loop context from that base. As things stand, the code will also exit the server loop to 'unset' the device (i.e. revert back to the nulldevice) at the end of the job. If we have to cope with a workflow that relies on making changes that really persist between jobs, we'll have to rejig this to only unset the device before shutting down.
* Rejig gs_lib_ctx_t to allow sharing of core details.Robin Watts2019-03-2517-120/+177
| | | | | | | | | | | | | | | | | | | gs_lib_ctx_t's now have a 'core' structure that contains things like stdio and gs_id records. When we try to make a gs_lib_ctx_t from a memory pointer that doesn't contain a gs_lib_ctx_t, we do the same as now, and create a completely new gs_lib_ctx, but put some of the contents in a "core" structure within it. When we try to make a gs_lib_ctx_t from a memory pointer that DOES contain a gs_lib_ctx_t, we share the core structure with the original. This enables us to have 'families' of gs_lib_ctx_t's that share the important things like stdin/stderr and gs_id records, while keeping other things private (such as the io device tables which are specific to individual languages).
* Avoid xps language instance leaking on closedown.Robin Watts2019-03-251-1/+8
|
* Change graphics state initialisation for gs.Robin Watts2019-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | When we set the device for gs, trigger the graphics state to initialise. This fix (credit to Chris) should hopefully solve the differences we were seeing between gs and gpdl in the graphics state setup. Calling gpdl and gs with: -sDEVICE=ppmraw -r300 -dMaxBitmap=800000000 and a simple file that does a stroke was causing the stroking code to be called with stroke_adjust = 1 in the gpdl case, and stroke_adjust = 0 in the gs case. After this fix, both are called with stroke_adjust = 0. It is possible that this will resolve the differences in halftone output we were seeing before.
* Rename plapi with gsapi.Robin Watts2019-03-254-58/+58
| | | | | Now our gpdl library lives under the same API as our gs one always has.
* Arrange so that gsapi is not linked into gpdl.Robin Watts2019-03-253-5/+22
| | | | | | | | | First we separate iapi.obj from the bulk of the PSI objs, then we arrange for a list of objects to be made without including that object file as well as the usual list with it. We use that reduced list to link with gpdl.
* Create psapi from the guts of gsapi.Robin Watts2019-03-258-340/+642
| | | | | | | The ps_implementation for gpdl can now call psapi rather than gsapi. This frees us up to replace plapi with a new implementation of gsapi later.
* Expand plapi to include everything that gsapi does.Robin Watts2019-03-254-13/+359
|
* LangSwitch: pl_process_file stub implementation.Robin Watts2019-03-252-2/+40
| | | | | | Previously pl_process_file would crash if called for an interpreter that didn't provide a proc_process_file function pointer. Now we fall back to processing using strings.
* LangSwitch: Simplify pl_main_instance.Robin Watts2019-03-251-14/+16
| | | | | We don't need to hold the "desired_implementation" globally as it's effectively local to one routine.
* LangSwitch: Simplify language API.Robin Watts2019-03-258-216/+81
| | | | | | | | | Rather than having separate "init_job", "set_device" and "remove_device", "dnit_job" entry points, roll each pair into one. We never want to init a job without setting the device, neither do we want to remove a device without dniting the job.
* Improve language switch debug messages.Robin Watts2019-03-251-4/+8
|
* Implement pl_main_run_string_... functions.Robin Watts2019-03-252-104/+150
|
* Update realmain.c to accept InterpreterExit.Robin Watts2019-03-252-13/+17
| | | | | | | | | | | | | | Non-windows builds of PCL use realmain.c as their top level function. After running the command line using plapi_init_with_args this feeds a PJL_UEL in using plapi_run_string_XXXX (for no particularly good reason other than exercising our API). Until now this hasn't done anything. Now we are implementing plapi_run_string_XXXX, this is falling on its face due to the code not accepting the (expected) return code of gs_error_InterpreterExit.
* Rejig handling of gsapi_run_file.Robin Watts2019-03-253-17/+51
| | | | | | | | | | | | | | When asked to gsapi_run_file, we call gs_main_run_file, which opens a file from the PS lib path, and runs it directly. This precludes it working with PDF files. The usual route with ghostscript is for things to get called via "argproc" which calls "<filename> .runfile" using run_string. We introduce gs_main_run_file2 to do the same, and make gsapi_run_file call that instead. Possibly at some point we may want to remove gs_main_run_file.
* Whitespace fixes.Robin Watts2019-03-251-31/+20
|
* Return position of UEL while parsing postscript.Robin Watts2019-03-258-39/+98
| | | | | | | Use this offset rather than searching for UEL. This has required us to tidy up the allocation/deallocation of the postscript interpreter instance.
* Whitespace tidying.Robin Watts2019-03-251-5/+5
|
* Move from systemdict flag to internal operator flag for UEL handling.Robin Watts2019-03-257-20/+49
| | | | | | | | | | | | Rather than relying on "PS_INTERP_ACT_ON_UEL" being in the systemdict, put a flag in the gs_lib_ctx. This flag is 0 by default, and we provide a gsapi_act_on_uel() call to set it to 1. We have a new .actonuel operator to get the value, and we modify .forceinterp_exit and the PS setup code to use this instead.
* Add gpdl target to the Unix and Windows default listChris Liddell2019-03-252-4/+4
|
* A little tidy up: add some comments.Chris Liddell2019-03-251-3/+18
|
* Allow the PS interp to coexist with the PJL interpreter.Chris Liddell2019-03-254-14/+103
|
* Add a process_end API call.Chris Liddell2019-03-258-3/+57
| | | | | | | | Ghostscript's API needs run_string_begin, run_string and run_string_end calls. Originally I use the existing pl_dnit_job() call, but as that is called for running by file as well as by buffer, it's less than ideal - calling run_string_end with the _begin didn't *currently* cause an issue, but it wasn't nice.
* Add API to pass data to Ghostscript by buffer.Chris Liddell2018-12-078-6/+88
| | | | | | | | | This meant adding a new API call, process_begin(). Fix ps_impl_flush_to_eoj() so it actually does flush to EOJ. Also also use ps_impl_process_eof() - that might need to change in favour of a new process_end() call (as a match for _begin).
* "Free" global device before shutting down interpreters.Chris Liddell2018-12-071-9/+9
| | | | | | The shared device can now belong to one of the interpreter's memory allocators, so if the interpreters are shut down first, the free may fail.
* More in this commit than planned!Chris Liddell2018-12-0721-14/+117
| | | | | | | | | | | | | | | | | | | 1) Adds gs_main_set_device() and gsapi_set_device() calls so the Ghostscript device can be set via the C API. Not as trivial as for the other languages since it requires the Postscript world to be properly synced with the internals. 2) Adds a proc_get_device_memory() API into the language switching interpreter implementation structure. 3) Tweak how Ghostscript is initialized from the language switching code, so the garbage collecting allocator is available when we want to create a new device. 4) Add the code in ps_impl_set_device() to call the new API calls added in 1). 5) Have a debug build throw an assert should more than one interpreter supply an allocator from the proc_get_device_memory() call.
* Add a gsapi_get_device_memory() call.Chris Liddell2018-12-0712-0/+41
| | | | | This retrieves the allocator with which Ghostscript wants the device allocated.
* Tweak the gs_register_root APIChris Liddell2018-12-0715-29/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing gs_register_root() API allows for two ways to call the function. The first is for the client to pass in a pointer to a garbager root structure to use, allowing the client to hold onto that root so it can, later, unregister the root. The second, the client passed in a NULL pointer for the garbager root structure, and the allocator will allocate its root internally. Roots such as these are not visible/accessible outside the allocator. The problem with the former is that it requires the full definition of the gs_gc_root_t type to be available to the caller: that is a dependency nightmare (due to assumptions in the original design). The problem with the second is that the caller has no record with which to unregister the root. This commit changes the API so it takes a pointer to a pointer to gs_gc_root_t. If the gs_gc_root_t ** parameter is NULL, the behaviour is the same as the existing code (the root is allocated and only visible inside the allocator). If the gs_gc_root_t ** points to a "real" gs_gc_root_t *, that is the client supplied root. The new part is if gs_gc_root_t ** points to a NULL gs_gc_root_t *, the allocator will allocate a new root, and return it to the client via the pointer-pointer parameter. Importantly, this allows gs_gc_root_t to be opaque for client code.
* txtwrite - allow some slop in zero-width detectionKen Sharp2018-12-071-2/+5
| | | | | | | | | | | | | | Bug #700322 " Endless loop when converting pdf to text " While trying to fit text (text format 2 or 3) we do some heuristic juggling to decide whether or not to use a calculated minimum size. During this we check to see whether the width is zero, and if it is we don't try to use it because it would result in an infinite loop. We actually need to allow a little 'slop' around zero, in case floating point errors result in a very small, but not quite zero, width. The loop resuling in the bug isn't endless, but it is very lengthy.
* Improve gx_get_bits_copy determination of depth.Ray Johnston2018-12-071-1/+4
| | | | | | | For devices that are separable, (GX_CINFO_SEP_LIN), it is better to use the comp_bits to determine the depth of a plane. Seen with the display device in spot color mode where dest_depth calculation from the depth divided by num_components is not correct.