Harlequin RIP SDK
Raster backend output API

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...
 
RasterDescriptionRasterDescriptionUnpack (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_SHEETRasterSheetFromDescription (const RasterDescription *pRD)
 Get the raster sheet currently being rendered in an (unpacked) raster description. More...
 

Detailed Description

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:

Note
The core RIP does not call implementations of these callback functions directly. The raster backend API is selected using SwLeSetRasterAPI() from the page buffer device's PageBufferType parameter. Calls to the raster backend API are proxied through the page buffer device.
There is currently no function in this API to indicate when a backend is selected or deselected. If your raster backend requires event handlers, perhaps to track job numbers or for integrating eHVD with libHVD, you need to register your event handlers before selecting the raster backend API. Global Graphics intends to rectify this omission in a future release, to add methods that are called when the raster backend is selected and deselected and can be used to register and deregister event handlers.

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 Documentation

◆ RASTER_FINISH_EX

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.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
handlepA 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.
pRasterDescriptionThe raster description for the page
resultRASTER_noErr if the page was output succesfully, otherwise an error value
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error.

◆ RASTER_JOB_END_EX

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.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
handlepA pointer to the raster handle obtained from RASTER_START_EX
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error.
Note
This function is called in the Farm RIPs, at the end of some sets of chunks for a job. These calls will not necessarily be at the end of all chunks for a job. You should not rely on this call being at the end of a job when using the Scalable RIP, but it can still be used to clean up any state allocated by raster start and finish functions.

◆ 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.

◆ RASTER_START_EX

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.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
pRasterDescriptionThe raster description for the page
handlepIf successful, set by the callback to the raster handle for this page
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error.

◆ RASTER_WRITE_DATA_EX

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.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
handleThe raster handle obtained from RASTER_START_EX
pRasterDescriptionThe raster description for the page
dataThe raster data. This may be NULL if the entire separation was trimmed out.
toplineThe index of the first line of raster data being provided to this call
nlinesThe number of lines of raster data being provided
bytesperlineThe number of bytes of unpadded data in each line of raster.
planeThe 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.
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error.

◆ SwLeBLANKPAGECALLBACK

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.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
handlepA 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.
pBlankThe RASTER_BLANK structure shared by RIP and skin.
pRasterDescriptionA pointer to a RasterDescription structure describing the size, job, and number of the omitted page.
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error; or RASTER_notReady to indicate that the RIP should call the skin again.

◆ SwLeRASTERBANDSIZE

typedef RASTER_result() SwLeRASTERBANDSIZE(void *pJobContext, RASTER_BANDSIZE *pBandSize)

Type of a callback function which allows the skin to affect band size computations.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
[in,out]pBandSizeStructure 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.
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error; or RASTER_notReady indicate that the RIP should call the skin again.

◆ SwLeRASTERDESTINATION

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.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
pRasterDestinationThe RASTER_DESTINATION structure shared by RIP and skin.
separationIndexThe index of the current separation.
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error; or RASTER_notReady to indicate that the RIP should call the skin again.
Note
This function does not have a failure return code. This function is used to set the raster destination address associated with a pre-allocated framebuffer, discovered through the raster requirements callback (see the SwLeRASTERREQUIREMENTS callback type). If the framebuffer allocation can fail, the raster requirements call should return the failure code.

◆ SwLeRASTERREQUIREMENTS

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.

Parameters
pJobContextAn opaque pointer to caller-managed data, as originally provided by inputq_print_job() or SwLeJobStart().
pRasterRequirementsA pointer to the RASTER_REQUIREMENTS structure shared by RIP and skin.
pRasterDescriptionA 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.
Returns
This function should return RASTER_noErr (0) for success; one of the negative RASTER_RESULT codes or a sw_mon_type error code greater than MON_CLASS_ERROR with a valid subclass, PS error type, and UID for an error; or RASTER_notReady to indicate that the RIP should call the skin again.
Note
It may be that the best approach is for the skin to allocate raster memory during the earlier calls to this type of function, i.e., with pRasterDescription is 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:

  • RASTER_REQUIREMENTS::have_framebuffer is a flag which the callee can set to indicate that it has will allocate the memory for all of the band buffers (a framebuffer). This can lead to extra efficiencies, by avoiding data copying. For any particular value of the RASTER_REQUIREMENTS::eraseno field, the skin must not change its mind about the setting of RASTER_REQUIREMENTS::have_framebuffer between the interpreter and renderer calls to this function.
  • RASTER_REQUIREMENTS::scratch_size may be set in the interpretation calls to request a scratch buffer from the core. The buffer will be provided to the renderer calls in the RASTER_REQUIREMENTS::scratch_band field.
  • RASTER_REQUIREMENTS::band_order may be modified by the raster backend to indicate the order in which it can handle bands. This may be changed in the first render call, but not in the per-sheet calls.
  • RASTER_REQUIREMENTS::bands_handled_by_caller may be modified by the raster backend to indicate that it takes responsibility for issuing SWEVT_BANDS_HANDLED events. This allows the raster backend to process data in bands asynchronously, returning to the RIP immediately. If DynamicBands are configured, this allows the RIP to render the next band while the backend is processing data.
  • RASTER_REQUIREMENTS::store_partial may be modified by the raster backend to indicate how partial paints and transparency compositing passes should be stored.
  • RASTER_REQUIREMENTS::copies_handled_by_output may be modified by the raster backend to indicate that it can handle transmitting multiple copies of the same page to the output, rather than have the RIP re-output the page multiple times.
  • RASTER_REQUIREMENTS::write_empty_bands may be modified by the raster backend to indicate if it can handle empty bands being skipped either at the start and end of a page, anywhere in a page, or not at all.
  • RASTER_REQUIREMENTS::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. Note that the maximum such delay should be around 100 milliseconds.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Values of RasterDescription::interleavingStyle.

Enumerator
interleavingStyle_monochrome 

Monochrome interleaving style.

Monochrome indicates a single channel, but note that more than one colorant may be mapped onto that one channel if separations are imposed. Simple separations are separate sheets each of which is interleavingStyle_monochrome, but separations may also be made to color devices so this is not the only case to account for.

interleavingStyle_pixel 

Pixel interleaving style.

Pixel interleaved means all colors of one pixel appear in raster memory before any colors of the next. This is similar to TIFF PlanarConfiguration = 1, Chunky.

interleavingStyle_band 

Band interleaving style.

Band interleaved means that all the colors of pixels in a band of consecutive scan lines appear in a contiguous chunk of memory, but in that memory each color is presented in turn

interleavingStyle_frame 

Frame interleaving style.

Frame interleaved means that all pixels for one color of the raster appear before any pixels of the next color. This is similar to TIFF PlanarConfiguration = 2, Planar.

◆ RASTER_RESULT

Raster handler result codes.

Enumerator
RASTER_noErr 

Success.

RASTER_fileOutputErr 

I/O error in raster output.

RASTER_requestErr 

Error in the raster output request.

RASTER_fileSeekErr 

Error seeking position in output file.

RASTER_compressionErr 

Error in output compression.

RASTER_memoryErr 

Allocation error in raster handler.

RASTER_otherErr 

Other unspecified error in raster handler.

RASTER_notReady 

Call this function again (if documented for function)

Function Documentation

◆ RasterDescriptionFreeUnpacked()

void RasterDescriptionFreeUnpacked ( RasterDescription **  ppRD)

Free the memory allocated for a RasterDescription previously created by RasterDescriptionUnpack().

Parameters
[in,out]ppRDA 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.

◆ RasterDescriptionPack()

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.

Parameters
[in]rdThe RasterDescription to pack.
[in]addrAn 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.
Returns
The size in bytes of the memory used by the packed RasterDescription.

◆ RasterDescriptionUnpack()

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.

Note
The raster params pointer will not be preserved across packing and unpacking.
Parameters
[in]addrA memory address where a packed RasterDescription was stored.
Returns
An unpacked RasterDescription, or NULL if memory could not be allocated for the RasterDescription. The caller must dispose of this using RasterDescriptionFreeUnpacked() when it is done with the structure.

◆ RasterSheetFromDescription()

RASTER_SHEET* RasterSheetFromDescription ( const RasterDescription pRD)

Get the raster sheet currently being rendered in an (unpacked) raster description.

Parameters
[in]pRDA raster description.
Returns
The raster sheet currently being rendered in the raster description, or NULL if there is no sheet.

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.

◆ SwLeSetRasterAPI()

void SwLeSetRasterAPI ( sw_raster_api_20230105 api)

Sets the API structure that the RIP will call back to present raster data to the skin.

Parameters
[in]apiA pointer to a raster API structure. The API structure must remain valid and unchanged for the duration that it is selected by the RIP.