~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/gxclist.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
 
   All Rights Reserved.
3
 
  
4
 
   This software is provided AS-IS with no warranty, either express or
5
 
   implied.
6
 
 
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.
12
 
*/
13
 
 
14
 
/* $Id: gxclist.h 8862 2008-07-22 06:24:14Z leonardo $ */
15
 
/* Command list definitions for Ghostscript. */
16
 
/* Requires gxdevice.h and gxdevmem.h */
17
 
 
18
 
#ifndef gxclist_INCLUDED
19
 
#  define gxclist_INCLUDED
20
 
 
21
 
#include "gscspace.h"
22
 
#include "gxband.h"
23
 
#include "gxbcache.h"
24
 
#include "gxclio.h"
25
 
#include "gxdevbuf.h"
26
 
#include "gxistate.h"
27
 
#include "gxrplane.h"
28
 
 
29
 
/*
30
 
 * A command list is essentially a compressed list of driver calls.
31
 
 * Command lists are used to record an image that must be rendered in bands
32
 
 * for high-resolution and/or limited-memory printers.
33
 
 *
34
 
 * Command lists work in two phases.  The first phase records driver calls,
35
 
 * sorting them according to the band(s) they affect.  The second phase
36
 
 * reads back the commands band-by-band to create the bitmap images.
37
 
 * When opened, a command list is in the recording state; it switches
38
 
 * automatically from recording to reading when its get_bits procedure
39
 
 * is called.  Currently, there is a hack to reopen the device after
40
 
 * each page is processed, in order to switch back to recording.
41
 
 */
42
 
 
43
 
/*
44
 
 * The command list contains both commands for particular bands (the vast
45
 
 * majority) and commands that apply to a range of bands.  In order to
46
 
 * synchronize the two, we maintain the following invariant for buffered
47
 
 * commands:
48
 
 *
49
 
 *      If there are any band-range commands in the buffer, they are the
50
 
 *      first commands in the buffer, before any specific-band commands.
51
 
 *
52
 
 * To maintain this invariant, whenever we are about to put an band-range
53
 
 * command in the buffer, we check to see if the buffer already has any
54
 
 * band-range commands in it, and if so, whether they are the last commands
55
 
 * in the buffer and are for the same range; if the answer to any of these
56
 
 * questions is negative, we flush the buffer.
57
 
 */
58
 
 
59
 
#ifndef gs_pattern1_instance_t_DEFINED
60
 
#  define gs_pattern1_instance_t_DEFINED
61
 
typedef struct gs_pattern1_instance_s gs_pattern1_instance_t;
62
 
#endif
63
 
 
64
 
/* ---------------- Public structures ---------------- */
65
 
 
66
 
/*
67
 
 * Define a saved page object.  This consists of a snapshot of the device
68
 
 * structure, information about the page per se, and the num_copies
69
 
 * parameter of output_page.
70
 
 */
71
 
typedef struct gx_saved_page_s {
72
 
    gx_device device;
73
 
    char dname[8 + 1];          /* device name for checking */
74
 
    gx_band_page_info_t info;
75
 
    int num_copies;
76
 
} gx_saved_page;
77
 
 
78
 
/*
79
 
 * Define a saved page placed at a particular (X,Y) offset for rendering.
80
 
 */
81
 
typedef struct gx_placed_page_s {
82
 
    gx_saved_page *page;
83
 
    gs_int_point offset;
84
 
} gx_placed_page;
85
 
  
86
 
/*
87
 
 * Define a procedure to cause some bandlist memory to be freed up,
88
 
 * probably by rendering current bandlist contents.
89
 
 */
90
 
#define proc_free_up_bandlist_memory(proc)\
91
 
  int proc(gx_device *dev, bool flush_current)
92
 
 
93
 
/* ---------------- Internal structures ---------------- */
94
 
 
95
 
/*
96
 
 * Currently, halftoning occurs during the first phase, producing calls
97
 
 * to tile_rectangle.  Both phases keep a cache of recently seen bitmaps
98
 
 * (halftone cells and characters), which allows writing only a short cache
99
 
 * index in the command list rather than the entire bitmap.
100
 
 *
101
 
 * We keep only a single cache for all bands, but since the second phase
102
 
 * reads the command lists for each band separately, we have to keep track
103
 
 * for each cache entry E and band B whether the definition of E has been
104
 
 * written into B's list.  We do this with a bit mask in each entry.
105
 
 *
106
 
 * Eventually, we will replace this entire arrangement with one in which
107
 
 * we pass the actual halftone screen (whitening order) to all bands
108
 
 * through the command list, and halftoning occurs on the second phase.
109
 
 * This not only will shrink the command list, but will allow us to apply
110
 
 * other rendering algorithms such as error diffusion in the second phase.
111
 
 */
112
 
typedef struct {
113
 
    ulong offset;               /* writing: offset from cdev->data, */
114
 
    /*   0 means unused */
115
 
    /* reading: offset from cdev->chunk.data */
116
 
} tile_hash;
117
 
typedef struct {
118
 
    gx_cached_bits_common;
119
 
    /* To save space, instead of storing rep_width and rep_height, */
120
 
    /* we store width / rep_width and height / rep_height. */
121
 
    byte x_reps, y_reps;
122
 
    ushort rep_shift;
123
 
    ushort index;               /* index in table (hash table when writing) */
124
 
    ushort num_bands;           /* # of 1-bits in the band mask */
125
 
    /* byte band_mask[]; */
126
 
#define ts_mask(pts) (byte *)((pts) + 1)
127
 
    /* byte bits[]; */
128
 
#define ts_bits(cldev,pts) (ts_mask(pts) + (cldev)->tile_band_mask_size)
129
 
} tile_slot;
130
 
 
131
 
/* Define the prefix on each command run in the writing buffer. */
132
 
typedef struct cmd_prefix_s cmd_prefix;
133
 
struct cmd_prefix_s {
134
 
    cmd_prefix *next;
135
 
    uint size;
136
 
    ulong id; /* Debug purpose only. */
137
 
};
138
 
 
139
 
/* Define the pointers for managing a list of command runs in the buffer. */
140
 
/* There is one of these for each band, plus one for band-range commands. */
141
 
typedef struct cmd_list_s {
142
 
    cmd_prefix *head, *tail;    /* list of commands for band */
143
 
} cmd_list;
144
 
 
145
 
/*
146
 
 * In order to keep the per-band state down to a reasonable size,
147
 
 * we store only a single set of the imager state parameters;
148
 
 * for each parameter, each band has a flag that says whether that band
149
 
 * 'knows' the current value of the parameters.
150
 
 */
151
 
extern const gs_imager_state clist_imager_state_initial;
152
 
 
153
 
/*
154
 
 * Define the main structure for holding command list state.
155
 
 * Unless otherwise noted, all elements are used in both the writing (first)
156
 
 * and reading (second) phase.
157
 
 */
158
 
typedef struct gx_clist_state_s gx_clist_state;
159
 
 
160
 
#define gx_device_clist_common_members\
161
 
        gx_device_forward_common;       /* (see gxdevice.h) */\
162
 
                /* Following must be set before writing or reading. */\
163
 
                /* See gx_device_clist_writer, below, for more that must be init'd */\
164
 
        /* gx_device *target; */        /* device for which commands */\
165
 
                                        /* are being buffered */\
166
 
        gx_device_buf_procs_t buf_procs;\
167
 
        gs_memory_t *bandlist_memory;   /* allocator for in-memory bandlist files */\
168
 
        byte *data;                     /* buffer area */\
169
 
        uint data_size;                 /* size of buffer */\
170
 
        gx_band_params_t band_params;   /* band buffering parameters */\
171
 
        bool do_not_open_or_close_bandfiles;    /* if true, do not open/close bandfiles */\
172
 
        bool page_uses_transparency;    /* if true then page uses PDF 1.4 transparency */\
173
 
                /* Following are used for both writing and reading. */\
174
 
        gx_bits_cache_chunk chunk;      /* the only chunk of bits */\
175
 
        gx_bits_cache bits;\
176
 
        uint tile_hash_mask;            /* size of tile hash table -1 */\
177
 
        uint tile_band_mask_size;       /* size of band mask preceding */\
178
 
                                        /* each tile in the cache */\
179
 
        tile_hash *tile_table;          /* table for tile cache: */\
180
 
                                        /* see tile_hash above */\
181
 
                                        /* (a hash table when writing) */\
182
 
        int ymin, ymax;                 /* current band, <0 when writing */\
183
 
                /* Following are set when writing, read when reading. */\
184
 
        gx_band_page_info_t page_info;  /* page information */\
185
 
        int nbands                      /* # of bands */
186
 
 
187
 
/*
188
 
 * Chech whether a clist is used for storing a pattern command stream.
189
 
 * Useful for both reader and writer.
190
 
 */
191
 
#define IS_CLIST_FOR_PATTERN(cdev) (cdev->procs.open_device == pattern_clist_open_device)
192
 
 
193
 
typedef struct gx_device_clist_common_s {
194
 
    gx_device_clist_common_members;
195
 
} gx_device_clist_common;
196
 
 
197
 
#define clist_band_height(cldev) ((cldev)->page_info.band_height)
198
 
#define clist_cfname(cldev) ((cldev)->page_info.cfname)
199
 
#define clist_cfile(cldev) ((cldev)->page_info.cfile)
200
 
#define clist_bfname(cldev) ((cldev)->page_info.bfname)
201
 
#define clist_bfile(cldev) ((cldev)->page_info.bfile)
202
 
 
203
 
/* Define the length of the longest dash pattern we are willing to store. */
204
 
/* (Strokes with longer patterns are converted to fills.) */
205
 
#define cmd_max_dash 11
206
 
 
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;
210
 
 
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;
215
 
};
216
 
 
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)
221
 
 
222
 
 
223
 
/* Define the state of a band list when writing. */
224
 
typedef struct clist_color_space_s {
225
 
    byte byte1;                 /* see cmd_opv_set_color_space in gxclpath.h */
226
 
    gs_id id;                   /* space->id for comparisons */
227
 
    const gs_color_space *space;
228
 
} clist_color_space_t;
229
 
struct gx_device_clist_writer_s {
230
 
    gx_device_clist_common_members;     /* (must be first) */
231
 
    int error_code;             /* error returned by cmd_put_op */
232
 
    gx_clist_state *states;     /* current state of each band */
233
 
    byte *cbuf;                 /* start of command buffer */
234
 
    byte *cnext;                /* next slot in command buffer */
235
 
    byte *cend;                 /* end of command buffer */
236
 
    cmd_list *ccl;              /* &clist_state.list of last command */
237
 
    cmd_list band_range_list;   /* list of band-range commands */
238
 
    int band_range_min, band_range_max;         /* range for list */
239
 
    uint tile_max_size;         /* max size of a single tile (bytes) */
240
 
    uint tile_max_count;        /* max # of hash table entries */
241
 
    gx_strip_bitmap tile_params;        /* current tile parameters */
242
 
    int tile_depth;             /* current tile depth */
243
 
    int tile_known_min, tile_known_max;  /* range of bands that knows the */
244
 
                                /* current tile parameters */
245
 
    /*
246
 
     * NOTE: we must not set the line_params.dash.pattern member of the
247
 
     * imager state to point to the dash_pattern member of the writer
248
 
     * state (except transiently), since this would confuse the
249
 
     * garbage collector.
250
 
     */
251
 
    gs_imager_state imager_state;       /* current values of imager params */
252
 
    float dash_pattern[cmd_max_dash];   /* current dash pattern */
253
 
    const gx_clip_path *clip_path;      /* current clip path, */
254
 
                                /* only non-transient for images */
255
 
    gs_id clip_path_id;         /* id of current clip path */
256
 
    clist_color_space_t color_space;    /* current color space, */
257
 
                                /* only used for non-mask images */
258
 
    gs_id transfer_ids[4];      /* ids of transfer maps */
259
 
    gs_id black_generation_id;  /* id of black generation map */
260
 
    gs_id undercolor_removal_id;        /* id of u.c.r. map */
261
 
    gs_id device_halftone_id;   /* id of device halftone */
262
 
    gs_id image_enum_id;        /* non-0 if we are inside an image */
263
 
                                /* that we are passing through */
264
 
    int error_is_retryable;             /* Extra status used to distinguish hard VMerrors */
265
 
                               /* from warnings upgraded to VMerrors. */
266
 
                               /* T if err ret'd by cmd_put_op et al can be retried */
267
 
    int permanent_error;                /* if < 0, error only cleared by clist_reset() */
268
 
    int driver_call_nesting;    /* nesting level of non-retryable driver calls */
269
 
    int ignore_lo_mem_warnings; /* ignore warnings from clist file/mem */
270
 
            /* Following must be set before writing */
271
 
    proc_free_up_bandlist_memory((*free_up_bandlist_memory)); /* if nz, proc to free some bandlist memory */
272
 
    int disable_mask;           /* mask of routines to disable clist_disable_xxx */
273
 
    gs_pattern1_instance_t *pinst; /* Used when it is a pattern clist. */
274
 
    int cropping_min, cropping_max;
275
 
    int save_cropping_min, save_cropping_max;
276
 
    int cropping_level;
277
 
    clist_writer_cropping_buffer_t *cropping_stack;
278
 
    ulong ins_count;
279
 
    uint mask_id_count;
280
 
    uint mask_id;
281
 
    uint temp_mask_id; /* Mask id of a mask of an image with SMask. */
282
 
};
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;
286
 
#endif
287
 
 
288
 
/* Bits for gx_device_clist_writer.disable_mask. Bit set disables behavior */
289
 
#define clist_disable_fill_path (1 << 0)
290
 
#define clist_disable_stroke_path (1 << 1)
291
 
#define clist_disable_hl_image (1 << 2)
292
 
#define clist_disable_complex_clip (1 << 3)
293
 
#define clist_disable_nonrect_hl_image (1 << 4)
294
 
#define clist_disable_pass_thru_params (1 << 5) /* disable EXCEPT at top of page */
295
 
#define clist_disable_copy_alpha (1 << 6) /* target does not support copy_alpha */
296
 
 
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;
300
 
#endif
301
 
 
302
 
/* Define the state of a band list when reading. */
303
 
/* For normal rasterizing, pages and num_pages are both 0. */
304
 
typedef struct gx_device_clist_reader_s {
305
 
    gx_device_clist_common_members;     /* (must be first) */
306
 
    gx_render_plane_t yplane;           /* current plane, index = -1 */
307
 
                                        /* means all planes */
308
 
    const gx_placed_page *pages;
309
 
    int num_pages;
310
 
    gx_band_complexity_t *band_complexity_array;  /* num_bands elements */
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 */
317
 
} gx_device_clist_reader;
318
 
 
319
 
union gx_device_clist_s {
320
 
    gx_device_clist_common common;
321
 
    gx_device_clist_reader reader;
322
 
    gx_device_clist_writer writer;
323
 
};
324
 
 
325
 
#ifndef gx_device_clist_DEFINED
326
 
#define gx_device_clist_DEFINED
327
 
typedef union gx_device_clist_s gx_device_clist;
328
 
#endif
329
 
 
330
 
extern_st(st_device_clist);
331
 
#define public_st_device_clist()        /* in gxclist.c */\
332
 
  gs_public_st_complex_only(st_device_clist, gx_device_clist,\
333
 
    "gx_device_clist", 0, device_clist_enum_ptrs, device_clist_reloc_ptrs,\
334
 
    gx_device_finalize)
335
 
#define st_device_clist_max_ptrs\
336
 
  (st_device_forward_max_ptrs + st_imager_state_num_ptrs + 4)
337
 
 
338
 
#define CLIST_IS_WRITER(cdev) ((cdev)->common.ymin < 0)
339
 
 
340
 
/* setup before opening clist device */
341
 
#define clist_init_params(xclist, xdata, xdata_size, xtarget, xbuf_procs, xband_params, xexternal, xmemory, xfree_bandlist, xdisable, pageusestransparency)\
342
 
    BEGIN\
343
 
        (xclist)->common.data = (xdata);\
344
 
        (xclist)->common.data_size = (xdata_size);\
345
 
        (xclist)->common.target = (xtarget);\
346
 
        (xclist)->common.buf_procs = (xbuf_procs);\
347
 
        (xclist)->common.band_params = (xband_params);\
348
 
        (xclist)->common.do_not_open_or_close_bandfiles = (xexternal);\
349
 
        (xclist)->common.bandlist_memory = (xmemory);\
350
 
        (xclist)->writer.free_up_bandlist_memory = (xfree_bandlist);\
351
 
        (xclist)->writer.disable_mask = (xdisable);\
352
 
        (xclist)->writer.page_uses_transparency = (pageusestransparency);\
353
 
        (xclist)->writer.pinst = NULL;\
354
 
    END
355
 
 
356
 
/* Determine whether this clist device is able to recover VMerrors */
357
 
#define clist_test_VMerror_recoverable(cldev)\
358
 
  ((cldev)->free_up_bandlist_memory != 0)
359
 
 
360
 
/* The device template itself is never used, only the procedures. */
361
 
extern const gx_device_procs gs_clist_device_procs;
362
 
 
363
 
void clist_init_io_procs(gx_device_clist *pclist_dev, bool in_memory);
364
 
 
365
 
/* Reset (or prepare to append to) the command list after printing a page. */
366
 
int clist_finish_page(gx_device * dev, bool flush);
367
 
 
368
 
/* Close the band files and delete their contents. */
369
 
int clist_close_output_file(gx_device *dev);
370
 
 
371
 
/*
372
 
 * Close and delete the contents of the band files associated with a
373
 
 * page_info structure (a page that has been separated from the device).
374
 
 */
375
 
int clist_close_page_info(gx_band_page_info_t *ppi);
376
 
 
377
 
/*
378
 
 * Compute the colors-used information in the page_info structure from the
379
 
 * information in the individual writer bands.  This is only useful at the
380
 
 * end of a page.  gdev_prn_colors_used calls this procedure if it hasn't
381
 
 * been called since the page was started.  clist_end_page also calls it.
382
 
 */
383
 
void clist_compute_colors_used(gx_device_clist_writer *cldev);
384
 
 
385
 
/* Define the abstract type for a printer device. */
386
 
#ifndef gx_device_printer_DEFINED
387
 
#  define gx_device_printer_DEFINED
388
 
typedef struct gx_device_printer_s gx_device_printer;
389
 
#endif
390
 
 
391
 
/* Do device setup from params passed in the command list. */
392
 
int clist_setup_params(gx_device *dev);
393
 
 
394
 
/*
395
 
 * Render a rectangle to a client-supplied image.  This implements
396
 
 * gdev_prn_render_rectangle for devices that are using banding.
397
 
 * 
398
 
 * Note that clist_render_rectangle only guarantees to render *at least* the
399
 
 * requested rectangle to bdev, offset by (-prect->p.x, -prect->p.y):
400
 
 * anything it does to avoid rendering regions outside the rectangle is
401
 
 * merely an optimization.  If the client really wants the output clipped to
402
 
 * some rectangle smaller than ((0, 0), (bdev->width, bdev->height)), it
403
 
 * must set up a clipping device.
404
 
 */
405
 
int clist_render_rectangle(gx_device_clist *cdev,
406
 
                           const gs_int_rect *prect, gx_device *bdev,
407
 
                           const gx_render_plane_t *render_plane,
408
 
                           bool clear);
409
 
 
410
 
/* A null pointer is used to denote not banding.  
411
 
 * Since false == NULL the old usage of for_banding = false works even if it's hackish.
412
 
 *
413
 
 * returns the complexity for a band given the y offset from top of page.
414
 
 */
415
 
gx_band_complexity_t *
416
 
clist_get_band_complexity(gx_device *dev, int y);
417
 
 
418
 
/* Free any band_complexity_array memory used by the clist reader device */
419
 
void gx_clist_reader_free_band_complexity_array(gx_device_clist *cldev);
420
 
 
421
 
/* deep copy constructor if from != NULL
422
 
 * default constructor if from == NULL
423
 
 */
424
 
void 
425
 
clist_copy_band_complexity(gx_band_complexity_t *this, const gx_band_complexity_t *from);
426
 
 
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);
433
 
 
434
 
/* Exports from gxclread used by the multi-threading logic */
435
 
 
436
 
/* Initialize for reading. */
437
 
int clist_render_init(gx_device_clist *dev);
438
 
 
439
 
int 
440
 
clist_close_writer_and_init_reader(gx_device_clist *cldev);
441
 
 
442
 
void
443
 
clist_select_render_plane(gx_device *dev, int y, int height,
444
 
                          gx_render_plane_t *render_plane, int index);
445
 
 
446
 
int clist_rasterize_lines(gx_device *dev, int y, int lineCount,
447
 
                                  gx_device *bdev,
448
 
                                  const gx_render_plane_t *render_plane,
449
 
                                  int *pmy);
450
 
 
451
 
/* Enable multi threaded rendering. Returns > 0 if supported, < 0 if single threaded */
452
 
int
453
 
clist_enable_multi_thread_render(gx_device *dev);
454
 
 
455
 
/* Shutdown render threads and free up the related memory */
456
 
void
457
 
clist_teardown_render_threads(gx_device *dev);
458
 
 
459
 
#ifdef DEBUG 
460
 
#define clist_debug_rect clist_debug_rect_imp
461
 
void clist_debug_rect_imp(int x, int y, int width, int height);
462
 
#define clist_debug_image_rect clist_debug_image_rect_imp
463
 
void clist_debug_image_rect_imp(int x, int y, int width, int height);
464
 
#define clist_debug_set_ctm clist_debug_set_ctm_imp
465
 
void clist_debug_set_ctm_imp(const gs_matrix *m);
466
 
#else
467
 
#define clist_debug_rect (void)
468
 
#define clist_debug_image_rect (void)
469
 
#define clist_debug_set_ctm (void)
470
 
#endif
471
 
 
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.
476
 
 
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.
482
 
 */
483
 
#define crop_fill_y(cdev, ry, rheight)\
484
 
    BEGIN\
485
 
        if (ry < cdev->cropping_min) {\
486
 
            rheight = ry + rheight - cdev->cropping_min;\
487
 
            ry = cdev->cropping_min;\
488
 
        }\
489
 
        if (ry + rheight > cdev->cropping_max)\
490
 
            rheight = cdev->cropping_max - ry;\
491
 
    END
492
 
 
493
 
#define crop_fill(dev, x, y, w, h)\
494
 
    BEGIN\
495
 
        if ( x < 0 )\
496
 
            w += x, x = 0;\
497
 
        fit_fill_w(dev, x, w);\
498
 
        crop_fill_y(dev, y, h);\
499
 
    END
500
 
 
501
 
#define crop_copy_y(cdev, data, data_x, raster, id, ry, rheight)\
502
 
    BEGIN\
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;\
508
 
        }\
509
 
        if (ry + rheight > cdev->cropping_max)\
510
 
            rheight = cdev->cropping_max - ry;\
511
 
    END
512
 
 
513
 
#define crop_copy(dev, data, data_x, raster, id, x, y, w, h)\
514
 
    BEGIN\
515
 
        if ( x < 0 )\
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);\
519
 
    END
520
 
 
521
 
#endif /* gxclist_INCLUDED */