This API defines the callback function types that output backends must implement in order to receive raster data from the Harlequin RIP. Example implementations of raster handling backends are given in libtiffrast.c, rawrast.c, nonerast.c and others. More...
Files | |
file | rasthand.h |
Raster output backend API. | |
file | skinras.h |
Raster description for the raster output backend API. | |
file | rdutils.c |
Utilities for RasterDescription manipulation. | |
Data Structures | |
struct | sw_raster_api_20230105 |
A structure collecting the raster backend API functions. More... | |
struct | ScreenData |
ScreenData is only used in conjunction with RLE output format. More... | |
struct | RasterDescription |
The main structure describing the raster produced by the RIP. More... | |
Macros | |
#define | MAX_PGB_TYPE_LENGTH 32 |
The maximum string length for the /PageBufferType parameter in the page device. | |
#define | MAX_OUTPUT_TARGET_LENGTH 32 |
The maximum string length for the /OutputTarget parameter in the page device. | |
#define | PDF_ID_LENGTH 33 |
The maximum string length permitted for a PDF Optimized ID. This should be RR_ELEMENT_ID_LENGTH * 2 + 1 for a hexadecimal representation of the element ID plus a zero terminator byte. | |
#define | MAX_COLOR_NAME_LENGTH 1024 |
The maximum string length permitted for a colorant name. | |
Typedefs | |
typedef void * | RASTER_handle |
All the raster callback functions receive an opaque value of this type. The output backend implementation can use it to ensure any necessary state is available to the callback implementations. | |
typedef HqnResult | RASTER_result |
Type for return values from raster functions. More... | |
typedef RASTER_result() | SwLeRASTERBANDSIZE(void *pJobContext, RASTER_BANDSIZE *pBandSize) |
Type of a callback function which allows the skin to affect band size computations. More... | |
typedef RASTER_result() | SwLeRASTERREQUIREMENTS(void *pJobContext, RASTER_REQUIREMENTS *pRasterRequirements, RasterDescription *pRasterDescription) |
Type of a callback function which gives the skin the details of the raster that's about to be handed, and allows the skin to allocate memory to contain it. More... | |
typedef RASTER_result() | SwLeRASTERDESTINATION(void *pJobContext, RASTER_DESTINATION *pRasterDestination, int32 separationIndex) |
Type of a callback function which asks the skin to provide a memory address range into which to render. More... | |
typedef RASTER_result() | SwLeBLANKPAGECALLBACK(void *pJobContext, RASTER_handle *handlep, RASTER_BLANK *pBlank, RasterDescription *pRasterDescription) |
Type of a callback function used to indicate that a page is blank, and may be entirely omitted if desired. More... | |
typedef RASTER_result() | RASTER_START_EX(void *pJobContext, RasterDescription *pRasterDescription, RASTER_handle *handlep) |
Type of a function called once at the start of each output separation, giving preparatory information for handling the separation. More... | |
typedef RASTER_result() | RASTER_WRITE_DATA_EX(void *pJobContext, RASTER_handle handle, RasterDescription *pRasterDescription, void *data, int32 topline, int32 nlines, int32 bytesperline, int32 plane) |
Type of a function called multiple times per output separation, with each call containing a band of raster data for the page. More... | |
typedef RASTER_result() | RASTER_FINISH_EX(void *pJobContext, RASTER_handle *handlep, RasterDescription *pRasterDescription, RASTER_result result) |
Type of a function called once at the end of each output separation. More... | |
typedef RASTER_result() | RASTER_JOB_END_EX(void *pJobContext, RASTER_handle *handlep) |
Type of a function called once at the end of a job. More... | |
typedef struct sw_raster_api_20230105 | sw_raster_api_20230105 |
A structure collecting the raster backend API functions. | |
typedef struct ScreenData | ScreenData |
ScreenData is only used in conjunction with RLE output format. | |
typedef struct RasterDescription | RasterDescription |
The main structure describing the raster produced by the RIP. | |
Enumerations | |
enum | RASTER_RESULT { RASTER_noErr = HQN_RESULT_SUCCESS , RASTER_fileOutputErr = -1 , RASTER_requestErr = -2 , RASTER_fileSeekErr = -3 , RASTER_compressionErr = -4 , RASTER_memoryErr = -5 , RASTER_otherErr = -6 , RASTER_notReady = 1 } |
Raster handler result codes. More... | |
enum | { interleavingStyle_monochrome = 1 , interleavingStyle_pixel = 2 , interleavingStyle_band = 3 , interleavingStyle_frame = 4 } |
Values of RasterDescription::interleavingStyle. More... | |
Functions | |
void | SwLeSetRasterAPI (sw_raster_api_20230105 *api) |
Sets the API structure that the RIP will call back to present raster data to the skin. More... | |
size_t | RasterDescriptionPack (RasterDescription *rd, void *addr) |
Pack a raster description into a contiguous block of memory. More... | |
RasterDescription * | RasterDescriptionUnpack (const void *addr) |
Unpack a raster description from a contiguous block of memory into allocated memory. More... | |
void | RasterDescriptionFreeUnpacked (RasterDescription **ppRD) |
Free the memory allocated for a RasterDescription previously created by RasterDescriptionUnpack(). More... | |
RASTER_SHEET * | RasterSheetFromDescription (const RasterDescription *pRD) |
Get the raster sheet currently being rendered in an (unpacked) raster description. More... | |
This API defines the callback function types that output backends must implement in order to receive raster data from the Harlequin RIP. Example implementations of raster handling backends are given in libtiffrast.c, rawrast.c, nonerast.c and others.
Most of the functions in the raster backend output API are optional. The expected call sequence of these functions is:
NULL
value for the RASTER_REQUIREMENTS parameter to this function. Note that when using Harlequin Parallel Pages, there may be calls from the interpreter interleaved with calls from the renderer. Also, the page being interpreted may be cancelled before rendering, so the client should be careful about retaining memory or objects during the interpreter calls.NULL
, and its RASTER_REQUIREMENTS::raster_sheet_index field will be -1. This call is made at a point that allows some aspects of band memory and ordering to be changed. Note that there may be multiple render passes for each page.NULL
, and its RASTER_REQUIREMENTS::raster_sheet_index field will be a non-negative index into a raster layout structure. At this point, the band memory and ordering are fixed and cannot be changed.NULL
.NULL
raster handle (an opaque type defined by the raster backend) if it succeeds. If this function returns an error, the RASTER_WRITE_DATA_EX and RASTER_FINISH_EX functions will not be called for this render pass.RasterDescriptionPack(), RasterDescriptionUnpack(), and RasterDescriptionFreeUnpacked() allow serialisation of raster descriptions, storing them into a single contiguous chunk of memory.
RasterSheetFromDescription() extracts the raster sheet currently being rendered from and unpacked raster description.
typedef RASTER_result() RASTER_FINISH_EX(void *pJobContext, RASTER_handle *handlep, RasterDescription *pRasterDescription, RASTER_result result) |
Type of a function called once at the end of each output separation.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). |
handlep | A pointer to the raster handle obtained from RASTER_START_EX. This function may destroy the handle and reset the value to NULL if operating separation-by-separation, or it may leave the handle intact and rely on the RASTER_JOB_END_EX function to destroy the handle if maintaining data across separations or pages. |
pRasterDescription | The raster description for the page |
result | RASTER_noErr if the page was output succesfully, otherwise an error value |
typedef RASTER_result() RASTER_JOB_END_EX(void *pJobContext, RASTER_handle *handlep) |
Type of a function called once at the end of a job.
Implementations can use this call to perform tasks at job scope, such as closing disk files and releasing other platform resources.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). |
handlep | A pointer to the raster handle obtained from RASTER_START_EX |
typedef HqnResult RASTER_result |
Type for return values from raster functions.
RASTER_result is a subclass of HqnResult that also supports some specific extra error codes generated by the raster backend functions (declared as the RASTER_RESULT enumeration), and for some functions. Before assigning to values of HqnResult type or any of its other subclasses, RASTER_result values must be converted to change the raster specific values to HQN_RESULT_SUCCESS or a monitor UID error code greater than MON_CLASS_ERROR.
typedef RASTER_result() RASTER_START_EX(void *pJobContext, RasterDescription *pRasterDescription, RASTER_handle *handlep) |
Type of a function called once at the start of each output separation, giving preparatory information for handling the separation.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). |
pRasterDescription | The raster description for the page |
handlep | If successful, set by the callback to the raster handle for this page |
typedef RASTER_result() RASTER_WRITE_DATA_EX(void *pJobContext, RASTER_handle handle, RasterDescription *pRasterDescription, void *data, int32 topline, int32 nlines, int32 bytesperline, int32 plane) |
Type of a function called multiple times per output separation, with each call containing a band of raster data for the page.
This function will be called with successive bands of data until all frames of the separation have been delivered.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). |
handle | The raster handle obtained from RASTER_START_EX |
pRasterDescription | The raster description for the page |
data | The raster data. This may be NULL if the entire separation was trimmed out. |
topline | The index of the first line of raster data being provided to this call |
nlines | The number of lines of raster data being provided |
bytesperline | The number of bytes of unpadded data in each line of raster. |
plane | The raster plane index, counted across all planes of all frames in the separation, after separation omission. For a normal RIP configuration, this will be zero for monochrome and pixel interleaved output; the band index after separation omission for band interleaved output; or the frame index after separation omission for frame interleaved output. The RasterPlaneFromDescription() function can be used to retrieve the plane structure in callback functions. |
typedef RASTER_result() SwLeBLANKPAGECALLBACK(void *pJobContext, RASTER_handle *handlep, RASTER_BLANK *pBlank, RasterDescription *pRasterDescription) |
Type of a callback function used to indicate that a page is blank, and may be entirely omitted if desired.
The pRasterDescription pointer has as much information about the omitted page as is known, including the page width and height, but the colorant and channel information is not available.
RASTER_BLANK::handled is a flag which the callee sets when it has decisively dealt with the call. Not setting the flag before returning indicates to the RIP that the callee would like to be called again with the same parameters. This is used when the skin needs to delay to allow some output or other work to progress before the RIP continues, or to split the production of a blank page into multiple passes in order to better suit the rest of the workflow.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). |
handlep | A pointer to a raster handle. This will normally point to a NULL handle, but for raster backends that maintain data across pages, this may point to an existing handle created by a previous blank page, or by RASTER_START_EX. The blank page function may create, destroy, or update the raster handle. |
pBlank | The RASTER_BLANK structure shared by RIP and skin. |
pRasterDescription | A pointer to a RasterDescription structure describing the size, job, and number of the omitted page. |
typedef RASTER_result() SwLeRASTERBANDSIZE(void *pJobContext, RASTER_BANDSIZE *pBandSize) |
Type of a callback function which allows the skin to affect band size computations.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). | |
[in,out] | pBandSize | Structure providing details of the raster stride (byte offset between the start address of successive raster lines), and some parameters for the skin to indicate to the RIP whether to limit band size and whether to allocate dynamic bands for asynchronous processing. |
typedef RASTER_result() SwLeRASTERDESTINATION(void *pJobContext, RASTER_DESTINATION *pRasterDestination, int32 separationIndex) |
Type of a callback function which asks the skin to provide a memory address range into which to render.
The use of this callback is optional. Together with SwLeRASTERREQUIREMENTS, it gives a mechanism for the skin to provide all of the memory into which the RIP should render, which in turn eliminates memory copying operations and so improves performance.
For the given frame and band number, the skin should calculate the correct destination range and return it in RASTER_DESTINATION::memory_base and RASTER_DESTINATION::memory_ceiling. This range is exclusive, i.e., RASTER_DESTINATION::memory_ceiling is the address of the first byte that the RIP is not allowed to write into.
RASTER_DESTINATION::handled is a flag which the callee sets when it has decisively dealt with the call. Not setting the flag before returning indicates to the RIP that the callee would like to be called again with the same parameters. This is used when the skin needs to delay to allow some output or other work to progress before the RIP continues, or to split the rendering of a single RIP band into multiple passes in order to better suit the rest of the workflow.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). |
pRasterDestination | The RASTER_DESTINATION structure shared by RIP and skin. |
separationIndex | The index of the current separation. |
typedef RASTER_result() SwLeRASTERREQUIREMENTS(void *pJobContext, RASTER_REQUIREMENTS *pRasterRequirements, RasterDescription *pRasterDescription) |
Type of a callback function which gives the skin the details of the raster that's about to be handed, and allows the skin to allocate memory to contain it.
The use of this callback is optional. Together with SwLeRASTERDESTINATION, it gives a mechanism for the skin to provide all of the memory into which the RIP should render, which in turn can eliminate memory copying operations and so improve performance.
pJobContext | An opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart(). |
pRasterRequirements | A pointer to the RASTER_REQUIREMENTS structure shared by RIP and skin. |
pRasterDescription | A pointer to a description of the raster data. There are several points in the sequence of processing a job at which the RIP will call this type of function. There will be a set of calls while a page is being interpreted: the first is when the page device has just changed, there are also calls if dynamic separations are added which may affect the raster layout, and also just before the page is handed over for rendering. There will also be a set of calls while the page is being rendered; the first when about to render a pass of a page (i.e., a partial paint, composite, or final render), and secondly before each sheet is rendered. For the calls from interpretation and the render pass call, pRasterDescription will be NULL , and the RASTER_REQUIREMENTS::raster_sheet_index field will be -1. The calls before each sheet will have the pRasterDescription pointer non-NULL and it will contain the finalised description of the raster data, and the RASTER_REQUIREMENTS::raster_sheet_index field will be non-negative. |
NULL
, to ensure that the raster memory is always available. Depending on configuration, it's possible that if raster memory allocation happens later that the RIP uses all available memory and there's not enough left for raster memory when needed. However, if the skin is in a position to guarantee that a later allocation when pRasterDescription is non-NULL
will succeed, that approach is preferable - not least because the page device changes quite often - perhaps a dozen or more times per job. When Harlequin Parallel Pages is enabled, calls to this function may be made from both interpreter (pRasterDescription NULL
) and renderer threads (pRasterDescription non-NULL
) simultaneously. The skin must not assume that a renderer call is related to the most recent interpreter call. The RASTER_REQUIREMENTS::eraseno field can be used to correlate calls from the interpreter with subsequent renderer calls. Not every interpreter call will have an associated call from a renderer. The RASTER_REQUIREMENTS::eraseno field increases monotonically for each raster description, so when a renderer call is received, all buffers allocated for raster descriptions with lower values of RASTER_REQUIREMENTS::eraseno can be discarded.The RIP will set all fields in the RASTER_REQUIREMENTS argument.
The following fields are used to communicate information back from the raster backend to the RIP:
anonymous enum |
Values of RasterDescription::interleavingStyle.
enum RASTER_RESULT |
Raster handler result codes.
void RasterDescriptionFreeUnpacked | ( | RasterDescription ** | ppRD | ) |
Free the memory allocated for a RasterDescription previously created by RasterDescriptionUnpack().
[in,out] | ppRD | A location where the unpacked RasterDescription handle is stored. This will be set to NULL on exit. This function is safe to call with this location pointing at a NULL RasterDescription. |
size_t RasterDescriptionPack | ( | RasterDescription * | rd, |
void * | addr | ||
) |
Pack a raster description into a contiguous block of memory.
Packed RasterDescriptions must not have internal pointers dereferenced.
[in] | rd | The RasterDescription to pack. |
[in] | addr | An address to pack the RasterDescription into. If this is NULL, this function will return the size of the memory required to pack the RasterDescription, but without packing it. |
RasterDescription* RasterDescriptionUnpack | ( | const void * | addr | ) |
Unpack a raster description from a contiguous block of memory into allocated memory.
Unpacking a packed RasterDescriptions re-creates a valid structure, and allows internal pointers to be dereferenced. Unpacked RasterDescriptions should not have their internal pointer structure modified.
[in] | addr | A memory address where a packed RasterDescription was stored. |
RASTER_SHEET* RasterSheetFromDescription | ( | const RasterDescription * | pRD | ) |
Get the raster sheet currently being rendered in an (unpacked) raster description.
[in] | pRD | A raster description. |
This function does not take a reference on the raster description's raster layout. It is the caller's responsibility to ensure that it remains valid while the raster sheet pointer returned is being accessed.
void SwLeSetRasterAPI | ( | sw_raster_api_20230105 * | api | ) |
Sets the API structure that the RIP will call back to present raster data to the skin.
[in] | api | A pointer to a raster API structure. The API structure must remain valid and unchanged for the duration that it is selected by the RIP. |