11
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/*$Id: gxcldev.h 11926 2010-12-01 05:16:55Z mvrhel $ */
15
15
/* Internal definitions for Ghostscript command lists. */
17
17
#ifndef gxcldev_INCLUDED
40
42
void clist_rld_init(stream_RLD_state *ss);
41
43
void clist_cfe_init(stream_CFE_state *ss, int width, gs_memory_t *mem);
42
44
void clist_cfd_init(stream_CFD_state *ss, int width, int height,
46
48
* A command always consists of an operation followed by operands;
59
61
cmd_op_misc = 0x00, /* (see below) */
60
62
cmd_opv_end_run = 0x00, /* (nothing) */
61
63
cmd_opv_set_tile_size = 0x01, /* rs?(1)nry?(1)nrx?(1)depth(5, encoded), */
62
/* rep_width#, rep_height#, */
63
/* [, nreps_x#][, nreps_y #] */
64
/* rep_width#, rep_height#, */
65
/* [, nreps_x#][, nreps_y #] */
65
67
cmd_opv_set_tile_phase = 0x02, /* x#, y# */
66
68
cmd_opv_set_tile_bits = 0x03, /* index#, offset#, <bits> */
67
69
cmd_opv_set_bits = 0x04, /* depth*4+compress, width#, height#, */
68
/* index#, offset#, <bits> */
70
/* index#, offset#, <bits> */
69
71
cmd_opv_set_tile_color = 0x05, /* (nothing; next set/delta_color */
71
73
cmd_opv_set_misc = 0x06,
72
74
#define cmd_set_misc_lop (0 << 6) /* 00: lop_lsb(6), lop_msb# */
73
75
#define cmd_set_misc_data_x (1 << 6) /* 01: more(1)dx_lsb(5)[, dx_msb#] */
76
78
#define cmd_set_misc_halftone (3 << 6) /* 11: type(6), num_comp# */
77
79
cmd_opv_enable_lop = 0x07, /* (nothing) */
78
80
cmd_opv_disable_lop = 0x08, /* (nothing) */
80
/* cmd_opv_set_ht_order = 0x09, */ /* component+1#[, cname#], */
81
/* width#, height#, raster#, */
82
/* shift#, num_levels#, num_bits#, */
83
/* order_procs_index */
85
/* cmd_opv_set_ht_data = 0x0a, */ /* n, n x (uint|gx_ht_bit|ushort) */
86
81
cmd_opv_end_page = 0x0b, /* (nothing) */
87
82
cmd_opv_delta_color0 = 0x0c, /* See cmd_put_color in gxclutil.c */
88
83
cmd_opv_delta_color1 = 0x0d, /* <<same as color0>> */
97
92
cmd_op_tile_rect = 0x60, /* +dy2dh2, x#, w# | +0, rect# */
98
93
cmd_op_tile_rect_short = 0x70, /* +dh, dx, dw | +0, rect_short */
99
94
cmd_op_tile_rect_tiny = 0x80, /* +dw+0, rect_tiny | +dw+8 */
100
cmd_op_copy_mono = 0x90, /* +compress, x#, y#, (w+data_x)#, */
95
cmd_op_copy_mono_plane = 0x90, /* +compress, plane, x#, y#, (w+data_x)#, */
102
97
#define cmd_copy_ht_color 4
103
/* +4+compress, x#, y#, (w+data_x)#, */
98
/* +4+compress, x#, y#, (w+data_x)#, */
105
100
#define cmd_copy_use_tile 8
106
/* +8 (use tile), x#, y# | */
107
/* +12 (use tile), x#, y# */
101
/* +8 (use tile), x#, y# | */
102
/* +12 (use tile), x#, y# */
108
103
cmd_op_copy_color_alpha = 0xa0, /* (same as copy_mono, except: */
109
/* if color, ignore ht_color; */
110
/* if alpha & !use_tile, depth is */
104
/* if color, ignore ht_color; */
105
/* if alpha & !use_tile, depth is */
112
107
cmd_op_delta_tile_index = 0xb0, /* +delta+8 */
113
108
cmd_op_set_tile_index = 0xc0 /* +index[11:8], index[7:0] */
116
111
#define cmd_op_name_strings\
117
112
"(misc)", "set_color[0]", "set_color[1]", "fill_rect",\
118
113
"fill_rect_short", "fill_rect_tiny", "tile_rect", "tile_rect_short",\
119
"tile_rect_tiny", "copy_mono", "copy_color_alpha", "delta_tile_index",\
114
"tile_rect_tiny", "copy_mono_plane", "copy_color_alpha", "delta_tile_index",\
120
115
"set_tile_index", "(misc2)", "(segment)", "(path)"
122
117
#define cmd_misc_op_name_strings\
123
118
"end_run", "set_tile_size", "set_tile_phase", "set_tile_bits",\
124
119
"set_bits", "set_tile_color", "set_misc", "enable_lop",\
125
"disable_lop", "set_ht_order", "set_ht_data", "end_page",\
120
"disable_lop", "invalid", "invalid", "end_page",\
126
121
"delta2_color0", "delta2_color1", "set_copy_color", "set_copy_alpha",
200
195
* Return the total size of the bitmap.
202
197
uint clist_bitmap_bytes(uint width_bits, uint height,
203
int compression_mask,
204
uint * width_bytes, uint * raster);
198
int compression_mask,
199
uint * width_bytes, uint * raster);
207
202
* For halftone cells, we always write an unreplicated bitmap, but we
216
211
int band_min, band_max;
217
212
#define cmd_band_end (-1) /* end of band file */
218
213
int64_t pos; /* starting position in cfile */
219
gx_band_complexity_t band_complexity;
214
gx_band_complexity_t band_complexity;
223
218
/* ---------------- Band state ---------------- */
241
236
gx_cmd_rect rect; /* most recent rectangle */
242
237
gs_logical_operation_t lop; /* most recent logical op */
243
238
short lop_enabled; /* 0 = don't use lop, 1 = use lop, */
244
/* -1 is used internally */
239
/* -1 is used internally */
245
240
short clip_enabled; /* 0 = don't clip, 1 = do clip, */
246
/* -1 is used internally */
241
/* -1 is used internally */
247
242
bool color_is_alpha; /* for copy_color_alpha */
248
243
uint known; /* flags for whether this band */
249
/* knows various misc. parameters */
244
/* knows various misc. parameters */
250
245
/* We assign 'known' flags here from the high end; */
251
246
/* gxclpath.h assigns them from the low end. */
252
247
#define tile_params_known (1<<15)
255
250
/* Following are only used when writing */
256
251
cmd_list list; /* list of commands for band */
257
252
/* Following are set when writing, read when reading */
258
gx_band_complexity_t band_complexity;
253
gx_band_complexity_t band_complexity;
259
254
gx_colors_used_t colors_used;
262
257
/* The initial values for a band state */
263
258
/*static const gx_clist_state cls_initial */
264
259
#define cls_initial_values\
265
{ gx_no_color_index, gx_no_color_index },\
266
{ gx_dc_type_none },\
267
0, gx_no_bitmap_id, gs_no_id,\
268
{ 0, 0 }, { gx_no_color_index, gx_no_color_index },\
269
{ 0, 0, 0, 0 }, lop_default, 0, 0, 0, initial_known,\
270
{ 0, 0 }, { 0, 0 }, { 0, 0 }
260
{ gx_no_color_index, gx_no_color_index },\
261
{ gx_dc_type_none },\
262
0, gx_no_bitmap_id, gs_no_id,\
263
{ 0, 0 }, { gx_no_color_index, gx_no_color_index },\
264
{ 0, 0, 0, 0 }, lop_default, 0, 0, 0, initial_known,\
265
{ 0, 0 }, { 0, 0 }, { 0, 0 }
272
267
/* Define the size of the command buffer used for reading. */
273
268
/* This is needed to split up operations with a large amount of data, */
287
282
dev_proc_fill_trapezoid(clist_fill_trapezoid);
288
283
dev_proc_fill_linear_color_trapezoid(clist_fill_linear_color_trapezoid);
289
284
dev_proc_fill_linear_color_triangle(clist_fill_linear_color_triangle);
290
dev_proc_pattern_manage(clist_pattern_manage);
285
dev_proc_dev_spec_op(clist_dev_spec_op);
286
dev_proc_copy_plane(clist_copy_plane);
292
288
/* In gxclimag.c */
293
289
dev_proc_fill_mask(clist_fill_mask);
380
376
/* and allocate space for its data. */
381
377
byte *cmd_put_list_op(gx_device_clist_writer * cldev, cmd_list * pcl, uint size);
383
/* Request a space in the buffer.
379
/* Request a space in the buffer.
384
380
Writes out the buffer if necessary.
385
381
Returns the size of available space. */
386
382
int cmd_get_buffer_space(gx_device_clist_writer * cldev, gx_clist_state * pcls, uint size);
400
396
/* Add a command for all bands or a range of bands. */
401
397
byte *cmd_put_range_op(gx_device_clist_writer * cldev, int band_min,
402
int band_max, uint size);
398
int band_max, uint size);
404
400
#define cmd_put_all_op(cldev, size)\
405
401
cmd_put_range_op(cldev, 0, (cldev)->nbands - 1, size)
481
477
/* Put out a command to set the tile colors. */
482
478
int cmd_set_tile_colors(gx_device_clist_writer *cldev, gx_clist_state * pcls,
483
gx_color_index color0, gx_color_index color1);
479
gx_color_index color0, gx_color_index color1);
485
481
/* Put out a command to set the tile phase. */
487
483
cmd_set_tile_phase_generic(gx_device_clist_writer * cldev, gx_clist_state * pcls,
488
int px, int py, bool all_bands);
484
int px, int py, bool all_bands);
489
485
int cmd_set_tile_phase(gx_device_clist_writer *cldev, gx_clist_state * pcls,
492
488
/* Enable or disable the logical operation. */
493
489
int cmd_put_enable_lop(gx_device_clist_writer *, gx_clist_state *, int);
515
511
/* Write a command to set the logical operation. */
516
512
int cmd_set_lop(gx_device_clist_writer *, gx_clist_state *,
517
gs_logical_operation_t);
513
gs_logical_operation_t);
519
515
/* Disable (if default) or enable the logical operation, setting it if */
521
517
int cmd_update_lop(gx_device_clist_writer *, gx_clist_state *,
522
gs_logical_operation_t);
518
gs_logical_operation_t);
525
521
* For dividing up an operation into bands, use the control pattern :
527
523
* cmd_rects_enum_t re;
528
524
* RECT_ENUM_INIT(re, ry, rheight);
572
568
* VMerror recovery. In such cases, the recursive call must not attempt
573
569
* second-stage VMerror recovery, since the caller would have no way of
574
570
* knowing that the writer state had been reset. Such recursive calls
575
* should be wrapped in
571
* should be wrapped in
577
573
* ++cdev->driver_call_nesting; { ... } --cdev->driver_call_nesting;
591
587
typedef struct cmd_rects_enum_s {
598
gx_clist_state *pcls;
594
gx_clist_state *pcls;
601
597
} cmd_rects_enum_t;
603
599
#define RECT_ENUM_INIT(re, yvar, heightvar)\
605
re.height = heightvar;\
606
re.yend = re.y + re.height;\
607
re.band_height = cdev->page_band_height;\
608
re.nbands = (re.yend - re.y + re.band_height - 1) / re.band_height;
601
re.height = heightvar;\
602
re.yend = re.y + re.height;\
603
re.band_height = cdev->page_band_height;\
604
re.nbands = (re.yend - re.y + re.band_height - 1) / re.band_height;
610
606
#define RECT_STEP_INIT(re)\
611
re.band = re.y / re.band_height;\
612
re.pcls = cdev->states + re.band;\
613
re.band_end = (re.band + 1) * re.band_height;\
614
re.height = min(re.band_end, re.yend) - re.y;
607
re.band = re.y / re.band_height;\
608
re.pcls = cdev->states + re.band;\
609
re.band_end = (re.band + 1) * re.band_height;\
610
re.height = min(re.band_end, re.yend) - re.y;
617
612
#define RECT_RECOVER(codevar) (codevar < 0 && (codevar = clist_VMerror_recover(cdev, codevar)) >= 0)
618
613
#define SET_BAND_CODE(codevar) (re.band_code = codevar)
620
615
/* Read a transformation matrix. */
621
616
const byte *cmd_read_matrix(gs_matrix * pmat, const byte * cbp);
624
618
/* ------ Exported by gxclrect.c ------ */
626
620
/* Put out a fill or tile rectangle command. */
627
621
int cmd_write_rect_cmd(gx_device_clist_writer * cldev, gx_clist_state * pcls,
628
int op, int x, int y, int width, int height);
622
int op, int x, int y, int width, int height);
630
624
/* Put out a fill or tile rectangle command for fillpage. */
631
625
int cmd_write_page_rect_cmd(gx_device_clist_writer * cldev, int op);
655
649
#define decompress_spread 0x200
657
651
int cmd_put_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
658
const byte * data, uint width_bits, uint height,
659
uint raster, int op_size, int compression_mask,
660
byte ** pdp, uint * psize);
652
const byte * data, uint width_bits, uint height,
653
uint raster, int op_size, int compression_mask,
654
byte ** pdp, uint * psize);
663
657
* Put out commands for a color map (transfer function, black generation, or
687
681
* procedure primarily for readability.)
689
683
int clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
690
const gx_strip_bitmap * tiles, int depth);
684
const gx_strip_bitmap * tiles, int depth);
693
687
* Change "tile" for clist_copy_*. Only uses tiles->{data, id, raster,
694
688
* rep_width, rep_height}. tiles->[rep_]shift must be zero.
696
690
int clist_change_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
697
const gx_strip_bitmap * tiles, int depth);
691
const gx_strip_bitmap * tiles, int depth);
699
693
/* ------ Exported by gxclimag.c ------ */
702
696
* Write out any necessary color mapping data.
704
698
int cmd_put_color_mapping(gx_device_clist_writer * cldev,
705
const gs_imager_state * pis);
699
const gs_imager_state * pis);
707
701
* Add commands to represent a full (device) halftone.
708
702
* (This routine should probably be in some other module.)
710
704
int cmd_put_halftone(gx_device_clist_writer * cldev,
711
const gx_device_halftone * pdht);
705
const gx_device_halftone * pdht);
713
707
/* ------ Exported by gxclrast.c for gxclread.c ------ */
724
718
/* Play back and rasterize one band. */
725
719
int clist_playback_band(clist_playback_action action,
726
gx_device_clist_reader *cdev,
727
stream *s, gx_device *target,
728
int x0, int y0, gs_memory_t *mem);
720
gx_device_clist_reader *cdev,
721
stream *s, gx_device *target,
722
int x0, int y0, gs_memory_t *mem);
730
724
/* Playback the band file, taking the indicated action w/ its contents. */
731
int clist_playback_file_bands(clist_playback_action action,
732
gx_device_clist_reader *crdev,
733
gx_band_page_info_t *page_info, gx_device *target,
734
int band_first, int band_last, int x0, int y0);
725
int clist_playback_file_bands(clist_playback_action action,
726
gx_device_clist_reader *crdev,
727
gx_band_page_info_t *page_info, gx_device *target,
728
int band_first, int band_last, int x0, int y0);
736
730
int64_t clist_file_offset(const stream_state *st, uint buffer_offset);
737
731
int top_up_offset_map(stream_state * st, const byte *buf, const byte *ptr, const byte *end);