1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gxcomp.h 8585 2008-03-03 16:01:12Z leonardo $ */
15
/* Definitions for implementing compositing functions */
17
#ifndef gxcomp_INCLUDED
18
# define gxcomp_INCLUDED
25
* Because compositor information is passed through the command list,
26
* individual compositors must be identified by some means that is
27
* independent of address space. The address of the compositor method
28
* array, gs_composite_type_t (see below), cannot be used, as it is
29
* meaningful only within a single address space.
31
* In addition, it is desirable the keep the compositor identifier
32
* size as small as possible, as this identifier must be passed through
33
* the command list for all bands whenever the compositor is invoked.
34
* Fortunately, compositor invocation is not so frequent as to warrant
35
* byte-sharing techniques, which most likely would store the identifier
36
* in some unused bits of a command code byte. Hence, the smallest
37
* reasonable size for the identifier is one byte. This allows for up
38
* to 255 compositors, which should be ample (as of this writing, there
39
* are only two compositors, only one of which can be passed through
42
* The following list is intended to enumerate all compositors. We
43
* use definitions rather than an encoding to ensure a one-byte size.
45
#define GX_COMPOSITOR_ALPHA 0x01 /* DPS/Next alpha compositor */
46
#define GX_COMPOSITOR_OVERPRINT 0x02 /* overprint/overprintmode compositor */
47
#define GX_COMPOSITOR_PDF14_TRANS 0x03 /* PDF 1.4 transparency compositor */
51
* Define the abstract superclass for all compositing function types.
53
/*typedef struct gs_composite_s gs_composite_t; *//* in gscompt.h */
55
#ifndef gs_imager_state_DEFINED
56
# define gs_imager_state_DEFINED
57
typedef struct gs_imager_state_s gs_imager_state;
60
#ifndef gx_device_DEFINED
61
# define gx_device_DEFINED
62
typedef struct gx_device_s gx_device;
65
#ifndef gx_device_clist_writer_DEFINED
66
#define gx_device_clist_writer_DEFINED
67
typedef struct gx_device_clist_writer_s gx_device_clist_writer;
70
typedef struct gs_composite_type_procs_s {
73
* Create the default compositor for a compositing function.
75
#define composite_create_default_compositor_proc(proc)\
76
int proc(const gs_composite_t *pcte, gx_device **pcdev,\
77
gx_device *dev, gs_imager_state *pis, gs_memory_t *mem)
78
composite_create_default_compositor_proc((*create_default_compositor));
81
* Test whether this function is equal to another one.
83
#define composite_equal_proc(proc)\
84
bool proc(const gs_composite_t *pcte, const gs_composite_t *pcte2)
85
composite_equal_proc((*equal));
88
* Convert the representation of this function to a string
89
* for writing in a command list. *psize is the amount of space
90
* available. If it is large enough, the procedure sets *psize
91
* to the amount used and returns 0; if it is not large enough,
92
* the procedure sets *psize to the amount needed and returns a
93
* rangecheck error; in the case of any other error, *psize is
96
#define composite_write_proc(proc)\
97
int proc(const gs_composite_t *pcte, byte *data, uint *psize, gx_device_clist_writer *cdev)
98
composite_write_proc((*write));
101
* Convert the string representation of a function back to
102
* a structure, allocating the structure. Return the number of
103
* bytes read, or < 0 in the event of an error.
105
#define composite_read_proc(proc)\
106
int proc(gs_composite_t **ppcte, const byte *data, uint size,\
108
composite_read_proc((*read));
111
* Adjust CTM before applying the compositor. Used with banding.
113
#define composite_adjust_ctm_proc(proc)\
114
int proc(gs_composite_t *pcte, int x0, int y0, gs_imager_state *pis)
115
composite_adjust_ctm_proc((*adjust_ctm));
118
* Checks whether a next compositor operation closes this one.
119
* Must set the 2nd argument with a pointer to the opening compositor operation.
120
* Return coides : <0 - error, 0 - not closing,
121
* 1 - closing with annihilation, 2 - execute immediately,
122
* 3 - closing and replacing, 4 - replace one, 5 - drop queue.
124
#define composite_is_closing_proc(proc)\
125
int proc(const gs_composite_t *this, gs_composite_t **pcte, gx_device *dev)
126
composite_is_closing_proc((*is_closing));
129
* Checks whether a next operation is friendly to the compositor
130
* so that it may commutate with the compositor operation.
132
#define composite_is_friendly_proc(proc)\
133
bool proc(const gs_composite_t *this, byte cmd0, byte cmd1)
134
composite_is_friendly_proc((*is_friendly));
137
* Update the clist write device when a compositor device is created.
139
#define composite_clist_write_update(proc)\
140
int proc(const gs_composite_t * pcte, gx_device * dev, gx_device ** pcdev,\
141
gs_imager_state * pis, gs_memory_t * mem)
142
composite_clist_write_update((*clist_compositor_write_update));
145
* Update the clist read device when a compositor device is created.
147
#define composite_clist_read_update(proc)\
148
int proc(gs_composite_t * pcte, gx_device * cdev, gx_device * tdev,\
149
gs_imager_state * pis, gs_memory_t * mem)
150
composite_clist_read_update((*clist_compositor_read_update));
153
* Get compositor cropping.
155
#define composite_get_cropping_proc(proc)\
156
int proc(const gs_composite_t * pcte, int *ry, int *rheight)
157
composite_get_cropping_proc((*get_cropping));
159
} gs_composite_type_procs_t;
161
typedef struct gs_composite_type_s {
162
byte comp_id; /* to identify compositor passed through command list */
163
gs_composite_type_procs_t procs;
164
} gs_composite_type_t;
167
* Default implementation for creating a compositor for clist writing.
168
* The default does nothing.
170
composite_clist_write_update(gx_default_composite_clist_write_update);
172
/* Default handler for adjusting a compositor's CTM. */
173
composite_adjust_ctm_proc(gx_default_composite_adjust_ctm);
175
/* Default check for closing compositor. */
176
composite_is_closing_proc(gx_default_composite_is_closing);
178
/* Default check for a friendly command to a compositor. */
179
composite_is_friendly_proc(gx_default_composite_is_friendly);
182
* Default implementation for adjusting the clist reader when a compositor
183
* device is added. The default does nothing.
185
composite_clist_read_update(gx_default_composite_clist_read_update);
188
* Default implementation for get_cropping doesn't return a cropping.
190
composite_get_cropping_proc(gx_default_composite_get_cropping);
193
* Compositing objects are reference-counted, because graphics states will
194
* eventually reference them. Note that the common part has no
195
* garbage-collectible pointers and is never actually instantiated, so no
196
* structure type is needed for it.
198
#define gs_composite_common\
199
const gs_composite_type_t *type;\
200
gs_id id; /* see gscompt.h */\
201
bool idle; /* Doesn't paint anything. */\
202
struct gs_composite_s *prev, *next /* Queue links for clist_playback_band. */
204
struct gs_composite_s {
208
/* Replace a procedure with a macro. */
209
#define gs_composite_id(pcte) ((pcte)->id)
211
#endif /* gxcomp_INCLUDED */