11
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gxclist.h 8369 2007-11-15 07:22:43Z leonardo $ */
14
/* $Id: gxclist.h 8862 2008-07-22 06:24:14Z leonardo $ */
15
15
/* Command list definitions for Ghostscript. */
16
16
/* Requires gxdevice.h and gxdevmem.h */
184
184
gx_band_page_info_t page_info; /* page information */\
185
185
int nbands /* # of bands */
188
* Chech whether a clist is used for storing a pattern command stream.
189
* Useful for both reader and writer.
191
#define IS_CLIST_FOR_PATTERN(cdev) (cdev->procs.open_device == pattern_clist_open_device)
187
193
typedef struct gx_device_clist_common_s {
188
194
gx_device_clist_common_members;
189
195
} gx_device_clist_common;
198
204
/* (Strokes with longer patterns are converted to fills.) */
199
205
#define cmd_max_dash 11
207
/* Define a clist cropping buffer,
208
which represents a cropping stack element while clist writing. */
209
typedef struct clist_writer_cropping_buffer_s clist_writer_cropping_buffer_t;
211
struct clist_writer_cropping_buffer_s {
212
int cropping_min, cropping_max;
213
uint mask_id, temp_mask_id;
214
clist_writer_cropping_buffer_t *next;
217
#define private_st_clist_writer_cropping_buffer()\
218
gs_private_st_ptrs1(st_clist_writer_cropping_buffer,\
219
clist_writer_cropping_buffer_t, "clist_writer_transparency_buffer",\
220
clist_writer_cropping_buffer_enum_ptrs, clist_writer_cropping_buffer_reloc_ptrs, next)
201
223
/* Define the state of a band list when writing. */
202
224
typedef struct clist_color_space_s {
203
225
byte byte1; /* see cmd_opv_set_color_space in gxclpath.h */
204
226
gs_id id; /* space->id for comparisons */
205
227
const gs_color_space *space;
206
228
} clist_color_space_t;
207
typedef struct gx_device_clist_writer_s {
229
struct gx_device_clist_writer_s {
208
230
gx_device_clist_common_members; /* (must be first) */
209
231
int error_code; /* error returned by cmd_put_op */
210
232
gx_clist_state *states; /* current state of each band */
249
271
proc_free_up_bandlist_memory((*free_up_bandlist_memory)); /* if nz, proc to free some bandlist memory */
250
272
int disable_mask; /* mask of routines to disable clist_disable_xxx */
251
273
gs_pattern1_instance_t *pinst; /* Used when it is a pattern clist. */
252
bool cropping_by_path;
253
274
int cropping_min, cropping_max;
275
int save_cropping_min, save_cropping_max;
277
clist_writer_cropping_buffer_t *cropping_stack;
255
} gx_device_clist_writer;
281
uint temp_mask_id; /* Mask id of a mask of an image with SMask. */
283
#ifndef gx_device_clist_writer_DEFINED
284
#define gx_device_clist_writer_DEFINED
285
typedef struct gx_device_clist_writer_s gx_device_clist_writer;
257
288
/* Bits for gx_device_clist_writer.disable_mask. Bit set disables behavior */
258
289
#define clist_disable_fill_path (1 << 0)
263
294
#define clist_disable_pass_thru_params (1 << 5) /* disable EXCEPT at top of page */
264
295
#define clist_disable_copy_alpha (1 << 6) /* target does not support copy_alpha */
297
#ifndef clist_render_thread_control_t_DEFINED
298
# define clist_render_thread_control_t_DEFINED
299
typedef struct clist_render_thread_control_s clist_render_thread_control_t;
266
302
/* Define the state of a band list when reading. */
267
303
/* For normal rasterizing, pages and num_pages are both 0. */
268
304
typedef struct gx_device_clist_reader_s {
274
310
gx_band_complexity_t *band_complexity_array; /* num_bands elements */
275
311
void *offset_map; /* Just against collecting the map as garbage. */
312
int num_render_threads; /* number of threads being used */
313
clist_render_thread_control_t *render_threads; /* array of threads */
314
byte *main_thread_data; /* saved data pointer of main thread */
315
int curr_render_thread; /* index into array */
316
int thread_lookahead_direction; /* +1 or -1 */
276
317
} gx_device_clist_reader;
278
319
union gx_device_clist_s {
292
333
"gx_device_clist", 0, device_clist_enum_ptrs, device_clist_reloc_ptrs,\
293
334
gx_device_finalize)
294
335
#define st_device_clist_max_ptrs\
295
(st_device_forward_max_ptrs + st_imager_state_num_ptrs + 3)
336
(st_device_forward_max_ptrs + st_imager_state_num_ptrs + 4)
297
338
#define CLIST_IS_WRITER(cdev) ((cdev)->common.ymin < 0)
384
425
clist_copy_band_complexity(gx_band_complexity_t *this, const gx_band_complexity_t *from);
427
/* Retrieve total size for cfile and bfile. */
428
int clist_data_size(const gx_device_clist *cdev, int select);
429
/* Get command list data. */
430
int clist_get_data(const gx_device_clist *cdev, int select, int offset, byte *buf, int length);
431
/* Put command list data. */
432
int clist_put_data(const gx_device_clist *cdev, int select, int offset, const byte *buf, int length);
434
/* Exports from gxclread used by the multi-threading logic */
436
/* Initialize for reading. */
437
int clist_render_init(gx_device_clist *dev);
440
clist_close_writer_and_init_reader(gx_device_clist *cldev);
443
clist_select_render_plane(gx_device *dev, int y, int height,
444
gx_render_plane_t *render_plane, int index);
446
int clist_rasterize_lines(gx_device *dev, int y, int lineCount,
448
const gx_render_plane_t *render_plane,
451
/* Enable multi threaded rendering. Returns > 0 if supported, < 0 if single threaded */
453
clist_enable_multi_thread_render(gx_device *dev);
455
/* Shutdown render threads and free up the related memory */
457
clist_teardown_render_threads(gx_device *dev);
387
460
#define clist_debug_rect clist_debug_rect_imp
388
461
void clist_debug_rect_imp(int x, int y, int width, int height);
396
469
#define clist_debug_set_ctm (void)
472
/* Cropping by Y is necessary when the shading path is smaller than shading.
473
In this case the clipping path is written into the path's bands only.
474
Thus bands outside the shading path are not clipped,
475
but the shading may paint into them, so use this macro to crop them.
477
Besides that, cropping by Y is necessary when a transparency compositor
478
is installed over clist writer. Transparency compositors change the number
479
of device color components, so transparency group's elements
480
must not paint to bands that are not covered by the transparency bbox
481
to prevent a failure when clist reader recieves a wrong number of color components.
483
#define crop_fill_y(cdev, ry, rheight)\
485
if (ry < cdev->cropping_min) {\
486
rheight = ry + rheight - cdev->cropping_min;\
487
ry = cdev->cropping_min;\
489
if (ry + rheight > cdev->cropping_max)\
490
rheight = cdev->cropping_max - ry;\
493
#define crop_fill(dev, x, y, w, h)\
497
fit_fill_w(dev, x, w);\
498
crop_fill_y(dev, y, h);\
501
#define crop_copy_y(cdev, data, data_x, raster, id, ry, rheight)\
503
if (ry < cdev->cropping_min) {\
504
rheight = ry + rheight - cdev->cropping_min;\
505
data += (cdev->cropping_min - ry) * raster;\
506
id = gx_no_bitmap_id;\
507
ry = cdev->cropping_min;\
509
if (ry + rheight > cdev->cropping_max)\
510
rheight = cdev->cropping_max - ry;\
513
#define crop_copy(dev, data, data_x, raster, id, x, y, w, h)\
516
w += x, data_x -= x, x = 0;\
517
fit_fill_w(dev, x, w);\
518
crop_copy_y(dev, data, data_x, raster, id, y, h);\
399
521
#endif /* gxclist_INCLUDED */