1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
/* Copyright (C) 2001-2012 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution.
Refer to licensing information at http://www.artifex.com or contact
Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
CA 94903, U.S.A., +1(415)492-9861, for further information.
*/
/* Definitions for device specific operations */
#ifndef gxdevsop_INCLUDED
# define gxdevsop_INCLUDED
/* This file enumerates a series of device specific operations, that can be
* performed using the 'dev_spec_op' procedure in the gs_device structure.
*
* This scheme, as its name suggests, allows clients to make device specific
* calls to any given device in a safe way. This is to gs_devices what an
* ioctl is to unix file handles.
*
* Design features of this scheme ensure that:
* * Devices that support a given call call efficiently implement both
* input and output.
* * Devices that do not support a given call can efficiently refuse it
* (without having to know all the possible calls).
* * Devices that are built upon lower level devices can trivially either:
* + forward (possibly unknown) calls onto those sub devices
* + override known calls locally without passing them on
* + pass on known calls, and then modify their returned values.
* * New devices can add new device specific operations without requiring
* any changes to existing devices using the scheme.
*
* Traditionally, when developing Ghostscript, to add new device operations
* we'd have extended the list of device procedures to include one (or more)
* new entrypoint(s). With the dev_spec_op entrypoint in place, we have the
* choice whether to do this or not.
*
* Calls which need to be supported by all (or most) devices may well result
* in the extension of the device proc table as usual. Calls which only need
* affect a relatively small number of devices may well result in the use
* of a dev_spec_op call. The two schemes are complementary and which one is
* most appropriate for any given extension will vary according to the
* judgement of the programmer.
*
* All device_specific_operations are identified by a unique dev_spec_op
* key, listed in the enumeration below. To add a new one, simply extend the
* enumeration.
*
* The generic call to a dev_spec_op function is as follows:
*
* int dev_spec_op(gx_device *dev, int dev_spec_op, void *data, int size);
*
* As is common with most of ghostscript, a return value < 0 indicates an
* error. In particular a return value of gs_error_undefined will be taken
* to mean that a device did not support the given dev_spec_op. A return
* value >= 0 indicates that the device operation completed successfully.
* In general devices should use 0 to indicate successful completion, but
* for some calls values > 0 may be used to indicate dev_spec_op specific
* completion values.
*
* While this scheme is designed to be general and extensible, there are
* some common use cases. Where possible, for consistency, implementers
* should follow the example set by these existing 'families' of calls.
*
* Querying device characteristics (or 'Does this device support an
* operation?')
*
* Called with: data = NULL, size = 0.
* Returns: < 0 for 'does not support', > 0 for supports.
* Examples:
* gxdso_pattern_can_accum (Does the device support pattern
* accumulation?)
* gxdso_planar_native (Is the device natively planar?)
*
* Generic device function call:
*
* Called with data -> structure full of arguments, size = sizeof that
* structure.
* Returns: usual gs_error conventions
* Examples:
* gxdso_foo (An example)
* data -> struct { int x;
* y_t *y;
* z_t *z; }
* size = sizeof(*data);
* gxdso_bar (An example)
* data -> variable sized buffer of bytes to process
* size = sizeof(*data); (number of bytes in the buffer)
*
* Generic device function call (short form):
*
* Where we have a limited number of arguments, we can avoid the overhead
* of creating a structure on the stack just to pass them.
* Returns: usual gs_error conventions
* Examples:
* gxdso_pattern_start_accum (Start pattern accumulation)
* data = (void *)(gs_pattern1_instance_t *)pinst;
* size = (int)(gx_bitmap_is)id;
* gxdso_pattern_load (Load a pattern)
* data = NULL;
* size = (int)(gx_bitmap_id)id;
*/
/* Request data block for gxdso_device_child */
typedef struct gxdso_device_child_request_s
{
gx_device *target;
int n;
} gxdso_device_child_request;
enum {
/* All gxdso_ keys must be defined in this structure.
* Do NOT rely on your particular gxdso_ having a particular value.
* (i.e. do not use: gxdso_foo = 256, or similar below). The individual
* values may change on any compile.)
*/
/* gxdso_pattern_can_accum:
* data = UNUSED
* size = UNUSED
* Returns 1 if device supports start_accum/finish_accum calls, returns 0
* if it does not.
* (Replaces the pattern_manage__can_accum pattern_manage call)
*/
gxdso_pattern_can_accum,
/* gxdso_pattern_start_accum:
* data = gs_pattern1_instance_t * pattern to accumulate
* size = gs_id the id of the pattern
* Called to start pattern accumulation. Returns >= 0 for success.
* This call is only valid if gxdso_pattern_can_accum returns > 0.
*/
gxdso_pattern_start_accum,
/* gxdso_pattern_finish_accum:
* data = gs_pattern1_instance_t * pattern to accumulate
* size = gs_id the id of the pattern
* Called to finish pattern accumulation. Returns >= 0 for success.
* This call is only valid if gxdso_pattern_can_accum returns > 0.
*/
gxdso_pattern_finish_accum,
/* gxdso_pattern_load:
* data = NULL
* size = gs_id pattern id to load
* Called to add a specified pattern to the PDF resources table.
* Returns >= 0 for success.
* This call is only valid if gxdso_pattern_can_accum returns > 0.
*/
gxdso_pattern_load,
/* gxdso_pattern_shading_area:
* data = NULL
* size = 0
* Returns 1 if the device needs the shading area to be calculated.
*/
gxdso_pattern_shading_area,
/* gxdso_pattern_is_cpath_accum:
* data = NULL
* size = 0
* Returns 1 if the device is a clipping path accumulator (used for
* converting imagemasks to clipping paths).
*/
gxdso_pattern_is_cpath_accum,
/* gxdso_pattern_doesnt_need_path:
* data = NULL
* size = 0
* Returns 1 if the device can perform a gx_fill_path without the
* clipping path being converted to a path.
*/
gxdso_pattern_shfill_doesnt_need_path,
/* gxdso_pattern_handles_clip_path:
* data = NULL
* size = 0
* Returns 1 if the device supports an optimisation for plotting clipped
* patterns.
*/
gxdso_pattern_handles_clip_path,
/* gxdso_is_std_cmyk_1bit:
* data = NULL
* size = 0
* Returns 1 if the device is a 'standard' 1bit per component cmyk device.
* (standard means, 'maps colors equivalently to cmyk_1bit_map_cmyk_color')
*/
gxdso_is_std_cmyk_1bit,
/* gxdso_is_pdf14_device:
* data = NULL
* size = 0
* Returns 1 if the device is a pdf14 device .
*/
gxdso_is_pdf14_device,
/* gxdso_is_native_planar:
* data = NULL
* size = 0
* Returns 1 if the device's native format is planar
*/
gxdso_is_native_planar,
/* gxdso_device_child:
* data = pointer to gxdso_device_child_request struct
* size = sizeof(gxdso_device_child_request)
* Returns 1 if found.
* Call with target = device, n = 0 initially, or value returned from
* previous call.
* If a device X is called with data->target == X:
* If data->n == 0: fills in data->target with the address of the
* first device child target. Fill in data->n with 0
* if no more children, or a continuation value.
* If data->n != 0: data->n is a continuation value previously
* returned. Set data->target to the next device
* child target. Set data->n to 0 if no more, or
* another continuation value.
* Else:
* call each child device in turn until one returns a non zero result.
* Or return 0 if none do.
*/
gxdso_device_child,
/* gxdso_supports_devn:
* data = NULL
* size = 0
* Returns 1 if the device supports devicen colors. example tiffsep.
*/
gxdso_supports_devn,
/* gxdso_supports_hlcolor:
* for devices that can handle pattern and other high level structures
directly. */
gxdso_supports_hlcolor,
/* Add new gxdso_ keys above this. */
gxdso_pattern__LAST
};
#endif /* gxdevsop_INCLUDED */
|