2 |
- |
1 |
/* Copyright (C) 1989, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: gdevprn.h,v 1.15 2005/05/27 05:43:24 dan Exp $ */
|
|
|
18 |
/* Common header file for memory-buffered printers */
|
|
|
19 |
|
|
|
20 |
#ifndef gdevprn_INCLUDED
|
|
|
21 |
# define gdevprn_INCLUDED
|
|
|
22 |
|
|
|
23 |
#include "memory_.h"
|
|
|
24 |
#include "string_.h"
|
|
|
25 |
#include "gx.h"
|
|
|
26 |
#include "gp.h" /* for gp_file_name_sizeof */
|
|
|
27 |
#include "gserrors.h"
|
|
|
28 |
#include "gsmatrix.h" /* for gxdevice.h */
|
|
|
29 |
#include "gsutil.h" /* for memflip8x8 */
|
|
|
30 |
#include "gxdevice.h"
|
|
|
31 |
#include "gxdevmem.h"
|
|
|
32 |
#include "gxclist.h"
|
|
|
33 |
#include "gxrplane.h"
|
|
|
34 |
#include "gsparam.h"
|
|
|
35 |
|
|
|
36 |
/*
|
|
|
37 |
* Define the parameters for the printer rendering method.
|
|
|
38 |
* If the entire bitmap fits in PRN_MAX_BITMAP, and there is at least
|
|
|
39 |
* PRN_MIN_MEMORY_LEFT memory left after allocating it, render in RAM,
|
|
|
40 |
* otherwise use a command list with a size of PRN_BUFFER_SPACE.
|
|
|
41 |
* (These are parameters that can be changed by a client program.)
|
|
|
42 |
*/
|
|
|
43 |
/* Define parameters for machines with little dinky RAMs.... */
|
|
|
44 |
#define PRN_MAX_BITMAP_SMALL 32000
|
|
|
45 |
#define PRN_BUFFER_SPACE_SMALL 25000
|
|
|
46 |
#define PRN_MIN_MEMORY_LEFT_SMALL 32000
|
|
|
47 |
/* Define parameters for machines with great big hulking RAMs.... */
|
|
|
48 |
#define PRN_MAX_BITMAP_LARGE 10000000L
|
|
|
49 |
#define PRN_BUFFER_SPACE_LARGE 4000000L
|
|
|
50 |
#define PRN_MIN_MEMORY_LEFT_LARGE 500000L
|
|
|
51 |
/* Define parameters valid on all machines. */
|
|
|
52 |
#define PRN_MIN_BUFFER_SPACE 10000 /* give up if less than this */
|
|
|
53 |
/* Now define conditional parameters. */
|
|
|
54 |
#if arch_small_memory
|
|
|
55 |
# define PRN_MAX_BITMAP PRN_MAX_BITMAP_SMALL
|
|
|
56 |
# define PRN_BUFFER_SPACE PRN_BUFFER_SPACE_SMALL
|
|
|
57 |
# define PRN_MIN_MEMORY_LEFT PRN_MIN_MEMORY_LEFT_SMALL
|
|
|
58 |
#else
|
|
|
59 |
/****** These should really be conditional on gs_debug_c('.') if
|
|
|
60 |
****** DEBUG is defined, but they're used in static initializers,
|
|
|
61 |
****** so we can't do it.
|
|
|
62 |
******/
|
|
|
63 |
# if 0 /****** # ifdef DEBUG ***** */
|
|
|
64 |
# define PRN_MAX_BITMAP\
|
|
|
65 |
(gs_debug_c('.') ? PRN_MAX_BITMAP_SMALL : PRN_MAX_BITMAP_LARGE)
|
|
|
66 |
# define PRN_BUFFER_SPACE\
|
|
|
67 |
(gs_debug_c('.') ? PRN_BUFFER_SPACE_SMALL : PRN_BUFFER_SPACE_LARGE)
|
|
|
68 |
# define PRN_MIN_MEMORY_LEFT\
|
|
|
69 |
(gs_debug_c('.') ? PRN_MIN_MEMORY_LEFT_SMALL : PRN_MIN_MEMORY_LEFT_LARGE)
|
|
|
70 |
# else
|
|
|
71 |
# define PRN_MAX_BITMAP PRN_MAX_BITMAP_LARGE
|
|
|
72 |
# define PRN_BUFFER_SPACE PRN_BUFFER_SPACE_LARGE
|
|
|
73 |
# define PRN_MIN_MEMORY_LEFT PRN_MIN_MEMORY_LEFT_LARGE
|
|
|
74 |
# endif
|
|
|
75 |
#endif
|
|
|
76 |
|
|
|
77 |
/* Define the abstract type for a printer device. */
|
|
|
78 |
#ifndef gx_device_printer_DEFINED
|
|
|
79 |
# define gx_device_printer_DEFINED
|
|
|
80 |
typedef struct gx_device_printer_s gx_device_printer;
|
|
|
81 |
#endif
|
|
|
82 |
|
|
|
83 |
/* Define the abstract type for some band device procedures' arguments. */
|
|
|
84 |
typedef struct gdev_prn_start_render_params_s gdev_prn_start_render_params;
|
|
|
85 |
|
|
|
86 |
/* Define the abstract type for a page queue for async rendering. */
|
|
|
87 |
#ifndef gx_page_queue_DEFINED
|
|
|
88 |
# define gx_page_queue_DEFINED
|
|
|
89 |
typedef struct gx_page_queue_s gx_page_queue_t;
|
|
|
90 |
#endif
|
|
|
91 |
|
|
|
92 |
/* Define the abstract type for parameters describing buffer space. */
|
|
|
93 |
#ifndef gdev_prn_space_params_DEFINED
|
|
|
94 |
# define gdev_prn_space_params_DEFINED
|
|
|
95 |
typedef struct gdev_prn_space_params_s gdev_prn_space_params;
|
|
|
96 |
#endif
|
|
|
97 |
|
|
|
98 |
/*
|
|
|
99 |
* Define the special procedures for band devices.
|
|
|
100 |
*/
|
|
|
101 |
typedef struct gx_printer_device_procs_s {
|
|
|
102 |
|
|
|
103 |
/*
|
|
|
104 |
* Print the page on the output file. Required only for devices
|
|
|
105 |
* where output_page is gdev_prn_output_page; ignored for other
|
|
|
106 |
* devices.
|
|
|
107 |
*/
|
|
|
108 |
|
|
|
109 |
#define prn_dev_proc_print_page(proc)\
|
|
|
110 |
int proc(gx_device_printer *, FILE *)
|
|
|
111 |
prn_dev_proc_print_page((*print_page));
|
|
|
112 |
/* BACKWARD COMPATIBILITY */
|
|
|
113 |
#define dev_proc_print_page(proc) prn_dev_proc_print_page(proc)
|
|
|
114 |
|
|
|
115 |
/* Print the page on the output file, with a given # of copies. */
|
|
|
116 |
|
|
|
117 |
#define prn_dev_proc_print_page_copies(proc)\
|
|
|
118 |
int proc(gx_device_printer *, FILE *, int)
|
|
|
119 |
prn_dev_proc_print_page_copies((*print_page_copies));
|
|
|
120 |
/* BACKWARD COMPATIBILITY */
|
|
|
121 |
#define dev_proc_print_page_copies(proc) prn_dev_proc_print_page_copies(proc)
|
|
|
122 |
|
|
|
123 |
/*
|
|
|
124 |
* Define buffer device management procedures.
|
|
|
125 |
* See gxdevcli.h for the definitions.
|
|
|
126 |
*/
|
|
|
127 |
|
|
|
128 |
gx_device_buf_procs_t buf_procs;
|
|
|
129 |
|
|
|
130 |
/*
|
|
|
131 |
* Compute effective space params. These results effectively override
|
|
|
132 |
* the space_params in the device, but does not replace them; that is to
|
|
|
133 |
* say that computed space params are temps used for computation.
|
|
|
134 |
* Procedure must fill in only those space_params that it wishes to
|
|
|
135 |
* override, using curr width, height, margins, etc.
|
|
|
136 |
*
|
|
|
137 |
* Caller is gdevprn.open & gdevprn.put_params, calls driver or
|
|
|
138 |
* default.
|
|
|
139 |
*/
|
|
|
140 |
|
|
|
141 |
#define prn_dev_proc_get_space_params(proc)\
|
|
|
142 |
void proc(const gx_device_printer *, gdev_prn_space_params *)
|
|
|
143 |
prn_dev_proc_get_space_params((*get_space_params));
|
|
|
144 |
|
|
|
145 |
/*
|
|
|
146 |
* Only for gx_device_printer devices that overlap interpreting and
|
|
|
147 |
* rasterizing. Since there are 2 instances of the device (1 for writing
|
|
|
148 |
* the cmd list & 1 for rasterizing it), and each device is associated
|
|
|
149 |
* with an different thread, this function is called to start the
|
|
|
150 |
* rasterizer's thread. Once started, the rasterizer thread must call
|
|
|
151 |
* down to gdev_prn_asnyc_render_thread, which will only return after
|
|
|
152 |
* device closes.
|
|
|
153 |
*
|
|
|
154 |
* Caller is gdevprna.open, calls driver implementation or default.
|
|
|
155 |
*/
|
|
|
156 |
|
|
|
157 |
#define prn_dev_proc_start_render_thread(proc)\
|
|
|
158 |
int proc(gdev_prn_start_render_params *)
|
|
|
159 |
prn_dev_proc_start_render_thread((*start_render_thread));
|
|
|
160 |
|
|
|
161 |
/*
|
|
|
162 |
* Only for gx_device_printer devices that overlap interpreting and
|
|
|
163 |
* rasterizing. Since there are 2 instances of the device (1 for writing
|
|
|
164 |
* the cmd list & 1 for rasterizing it), these fns are called to
|
|
|
165 |
* open/close the rasterizer's instance, once the writer's instance has
|
|
|
166 |
* been created & init'd. These procs must cascade down to
|
|
|
167 |
* gdev_prn_async_render_open/close.
|
|
|
168 |
*
|
|
|
169 |
* Caller is gdevprna, calls driver implementation or default.
|
|
|
170 |
*/
|
|
|
171 |
|
|
|
172 |
#define prn_dev_proc_open_render_device(proc)\
|
|
|
173 |
int proc(gx_device_printer *)
|
|
|
174 |
prn_dev_proc_open_render_device((*open_render_device));
|
|
|
175 |
|
|
|
176 |
#define prn_dev_proc_close_render_device(proc)\
|
|
|
177 |
int proc(gx_device_printer *)
|
|
|
178 |
prn_dev_proc_close_render_device((*close_render_device));
|
|
|
179 |
|
|
|
180 |
/*
|
|
|
181 |
* Buffer a page on the output device. A page may or may not have been
|
|
|
182 |
* fully rendered, but the rasterizer needs to realize the page to free
|
|
|
183 |
* up resources or support copypage. Printing a page may involve zero or
|
|
|
184 |
* more buffer_pages. All buffer_page output is overlaid in the buffer
|
|
|
185 |
* until a terminating print_page or print_page_copies clears the
|
|
|
186 |
* buffer. Note that, after the first buffer_page, the driver must call
|
|
|
187 |
* the lower-level gdev_prn_render_lines procedure instead of
|
|
|
188 |
* get_bits. The difference is that gdev_prn_render_lines requires the
|
|
|
189 |
* caller to supply the same buffered bitmap that was computed as a
|
|
|
190 |
* result of a previous buffer_page, so that gdev_prn_render_lines can
|
|
|
191 |
* add further marks to the existing buffered image. NB that output must
|
|
|
192 |
* be accumulated in buffer even if num_copies == 0.
|
|
|
193 |
*
|
|
|
194 |
* Caller is expected to be gdevprn, calls driver implementation or
|
|
|
195 |
* default. */
|
|
|
196 |
|
|
|
197 |
#define prn_dev_proc_buffer_page(proc)\
|
|
|
198 |
int proc(gx_device_printer *, FILE *, int)
|
|
|
199 |
prn_dev_proc_buffer_page((*buffer_page));
|
|
|
200 |
|
|
|
201 |
} gx_printer_device_procs;
|
|
|
202 |
|
|
|
203 |
/* ------ Printer device definition ------ */
|
|
|
204 |
|
|
|
205 |
/* Structure for generic printer devices. */
|
|
|
206 |
/* This must be preceded by gx_device_common. */
|
|
|
207 |
/* Printer devices are actually a union of a memory device */
|
|
|
208 |
/* and a clist device, plus some additional state. */
|
|
|
209 |
#define prn_fname_sizeof gp_file_name_sizeof
|
|
|
210 |
typedef enum {
|
|
|
211 |
BandingAuto = 0,
|
|
|
212 |
BandingAlways,
|
|
|
213 |
BandingNever
|
|
|
214 |
} gdev_prn_banding_type;
|
|
|
215 |
struct gdev_prn_space_params_s {
|
|
|
216 |
long MaxBitmap; /* max size of non-buffered bitmap */
|
|
|
217 |
long BufferSpace; /* space to use for buffer */
|
|
|
218 |
gx_band_params_t band; /* see gxclist.h */
|
|
|
219 |
bool params_are_read_only; /* true if put_params may not modify this struct */
|
|
|
220 |
gdev_prn_banding_type banding_type; /* used to force banding or bitmap */
|
|
|
221 |
};
|
|
|
222 |
|
|
|
223 |
#define gx_prn_device_common\
|
|
|
224 |
byte skip[max(sizeof(gx_device_memory), sizeof(gx_device_clist)) -\
|
|
|
225 |
sizeof(gx_device) + sizeof(double) /* padding */];\
|
|
|
226 |
gx_printer_device_procs printer_procs;\
|
|
|
227 |
/* ------ Device parameters that must be set ------ */\
|
|
|
228 |
/* ------ before calling the device open routine. ------ */\
|
|
|
229 |
gdev_prn_space_params space_params;\
|
|
|
230 |
char fname[prn_fname_sizeof]; /* OutputFile */\
|
|
|
231 |
/* ------ Other device parameters ------ */\
|
|
|
232 |
bool OpenOutputFile;\
|
|
|
233 |
bool ReopenPerPage;\
|
|
|
234 |
bool page_uses_transparency; /* PDF 1.4 transparency is used on page */\
|
|
|
235 |
bool Duplex;\
|
|
|
236 |
int Duplex_set; /* -1 = not supported */\
|
|
|
237 |
/* ------ End of parameters ------ */\
|
|
|
238 |
bool file_is_new; /* true iff file just opened */\
|
|
|
239 |
FILE *file; /* output file */\
|
|
|
240 |
long buffer_space; /* amount of space for clist buffer, */\
|
|
|
241 |
/* 0 means not using clist */\
|
|
|
242 |
byte *buf; /* buffer for rendering */\
|
|
|
243 |
/* ---- Begin async rendering support --- */\
|
|
|
244 |
gs_memory_t *buffer_memory; /* allocator for command list */\
|
|
|
245 |
gs_memory_t *bandlist_memory; /* allocator for bandlist files */\
|
|
|
246 |
proc_free_up_bandlist_memory((*free_up_bandlist_memory)); /* if nz, proc to free some bandlist memory */\
|
|
|
247 |
gx_page_queue_t *page_queue; /* if <> 0,page queue for gdevprna NOT GC'd */\
|
|
|
248 |
bool is_async_renderer; /* device is only the rendering part of async device */\
|
|
|
249 |
gx_device_printer *async_renderer; /* in async writer, pointer to async renderer */\
|
|
|
250 |
uint clist_disable_mask; /* mask of clist options to disable */\
|
|
|
251 |
/* ---- End async rendering support --- */\
|
|
|
252 |
gx_device_procs orig_procs /* original (std_)procs */
|
|
|
253 |
|
|
|
254 |
/* The device descriptor */
|
|
|
255 |
struct gx_device_printer_s {
|
|
|
256 |
gx_device_common;
|
|
|
257 |
gx_prn_device_common;
|
|
|
258 |
};
|
|
|
259 |
|
|
|
260 |
extern_st(st_device_printer);
|
|
|
261 |
#define public_st_device_printer() /* in gdevprn.c */\
|
|
|
262 |
gs_public_st_complex_only(st_device_printer, gx_device_printer,\
|
|
|
263 |
"gx_device_printer", 0, device_printer_enum_ptrs,\
|
|
|
264 |
device_printer_reloc_ptrs, gx_device_finalize)
|
|
|
265 |
|
|
|
266 |
/* Define a typedef for the sake of ansi2knr. */
|
|
|
267 |
typedef dev_proc_print_page((*dev_proc_print_page_t));
|
|
|
268 |
|
|
|
269 |
/* Standard device procedures for printers */
|
|
|
270 |
dev_proc_open_device(gdev_prn_open);
|
|
|
271 |
dev_proc_output_page(gdev_prn_output_page);
|
|
|
272 |
dev_proc_close_device(gdev_prn_close);
|
|
|
273 |
#define gdev_prn_map_rgb_color gx_default_b_w_map_rgb_color
|
|
|
274 |
#define gdev_prn_map_color_rgb gx_default_b_w_map_color_rgb
|
|
|
275 |
dev_proc_get_params(gdev_prn_get_params);
|
|
|
276 |
dev_proc_put_params(gdev_prn_put_params);
|
|
|
277 |
|
|
|
278 |
/* Default printer-specific procedures */
|
|
|
279 |
/* VMS limits procedure names to 31 characters. */
|
|
|
280 |
prn_dev_proc_get_space_params(gx_default_get_space_params);
|
|
|
281 |
/* BACKWARD COMPATIBILITY */
|
|
|
282 |
#define gdev_prn_default_get_space_params gx_default_get_space_params
|
|
|
283 |
prn_dev_proc_start_render_thread(gx_default_start_render_thread); /* for async rendering only, see gdevprna.c */
|
|
|
284 |
prn_dev_proc_open_render_device(gx_default_open_render_device);
|
|
|
285 |
prn_dev_proc_close_render_device(gx_default_close_render_device);
|
|
|
286 |
prn_dev_proc_buffer_page(gx_default_buffer_page); /* returns an error */
|
|
|
287 |
|
|
|
288 |
/* Macro for generating procedure table */
|
|
|
289 |
#define prn_procs(p_open, p_output_page, p_close)\
|
|
|
290 |
prn_color_procs(p_open, p_output_page, p_close, gdev_prn_map_rgb_color, gdev_prn_map_color_rgb)
|
|
|
291 |
#define prn_params_procs(p_open, p_output_page, p_close, p_get_params, p_put_params)\
|
|
|
292 |
prn_color_params_procs(p_open, p_output_page, p_close, gdev_prn_map_rgb_color, gdev_prn_map_color_rgb, p_get_params, p_put_params)
|
|
|
293 |
#define prn_color_procs(p_open, p_output_page, p_close, p_map_rgb_color, p_map_color_rgb)\
|
|
|
294 |
prn_color_params_procs(p_open, p_output_page, p_close, p_map_rgb_color, p_map_color_rgb, gdev_prn_get_params, gdev_prn_put_params)
|
|
|
295 |
/* See gdev_prn_open for explanation of the NULLs below. */
|
|
|
296 |
#define prn_color_params_procs(p_open, p_output_page, p_close, p_map_rgb_color, p_map_color_rgb, p_get_params, p_put_params) {\
|
|
|
297 |
p_open,\
|
|
|
298 |
NULL, /* get_initial_matrix */\
|
|
|
299 |
NULL, /* sync_output */\
|
|
|
300 |
p_output_page,\
|
|
|
301 |
p_close,\
|
|
|
302 |
p_map_rgb_color,\
|
|
|
303 |
p_map_color_rgb,\
|
|
|
304 |
NULL, /* fill_rectangle */\
|
|
|
305 |
NULL, /* tile_rectangle */\
|
|
|
306 |
NULL, /* copy_mono */\
|
|
|
307 |
NULL, /* copy_color */\
|
|
|
308 |
NULL, /* draw_line */\
|
|
|
309 |
NULL, /* get_bits */\
|
|
|
310 |
p_get_params,\
|
|
|
311 |
p_put_params,\
|
|
|
312 |
NULL, /* map_cmyk_color */\
|
|
|
313 |
NULL, /* get_xfont_procs */\
|
|
|
314 |
NULL, /* get_xfont_device */\
|
|
|
315 |
NULL, /* map_rgb_alpha_color */\
|
|
|
316 |
gx_page_device_get_page_device,\
|
|
|
317 |
NULL, /* get_alpha_bits */\
|
|
|
318 |
NULL, /* copy_alpha */\
|
|
|
319 |
NULL, /* get_band */\
|
|
|
320 |
NULL, /* copy_rop */\
|
|
|
321 |
NULL, /* fill_path */\
|
|
|
322 |
NULL, /* stroke_path */\
|
|
|
323 |
NULL, /* fill_mask */\
|
|
|
324 |
NULL, /* fill_trapezoid */\
|
|
|
325 |
NULL, /* fill_parallelogram */\
|
|
|
326 |
NULL, /* fill_triangle */\
|
|
|
327 |
NULL, /* draw_thin_line */\
|
|
|
328 |
NULL, /* begin_image */\
|
|
|
329 |
NULL, /* image_data */\
|
|
|
330 |
NULL, /* end_image */\
|
|
|
331 |
NULL, /* strip_tile_rectangle */\
|
|
|
332 |
NULL, /* strip_copy_rop, */\
|
|
|
333 |
NULL, /* get_clipping_box */\
|
|
|
334 |
NULL, /* begin_typed_image */\
|
|
|
335 |
NULL, /* get_bits_rectangle */\
|
|
|
336 |
NULL, /* map_color_rgb_alpha */\
|
|
|
337 |
NULL, /* create_compositor */\
|
|
|
338 |
NULL, /* get_hardware_params */\
|
|
|
339 |
NULL, /* text_begin */\
|
|
|
340 |
NULL /* finish_copydevice */\
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
/* The standard printer device procedures */
|
|
|
344 |
/* (using gdev_prn_open/output_page/close). */
|
|
|
345 |
extern const gx_device_procs prn_std_procs;
|
|
|
346 |
|
|
|
347 |
/*
|
|
|
348 |
* Define macros for generating the device structure,
|
|
|
349 |
* analogous to the std_device_body macros in gxdevice.h
|
|
|
350 |
* Note that the macros are broken up so as to be usable for devices that
|
|
|
351 |
* add further initialized state to the printer device.
|
|
|
352 |
*
|
|
|
353 |
* The 'margin' values provided here specify the unimageable region
|
|
|
354 |
* around the edges of the page (in inches), and the left and top margins
|
|
|
355 |
* also specify the displacement of the device (0,0) point from the
|
|
|
356 |
* upper left corner. We should provide macros that allow specifying
|
|
|
357 |
* all 6 values independently, but we don't yet.
|
|
|
358 |
*
|
|
|
359 |
* Note that print_page and print_page_copies must not both be defaulted.
|
|
|
360 |
*/
|
|
|
361 |
#define prn_device_body_rest2_(print_page, print_page_copies)\
|
|
|
362 |
{ 0 }, /* std_procs */\
|
|
|
363 |
{ 0 }, /* skip */\
|
|
|
364 |
{ print_page,\
|
|
|
365 |
print_page_copies,\
|
|
|
366 |
{ gx_default_create_buf_device,\
|
|
|
367 |
gx_default_size_buf_device,\
|
|
|
368 |
gx_default_setup_buf_device,\
|
|
|
369 |
gx_default_destroy_buf_device\
|
|
|
370 |
},\
|
|
|
371 |
gdev_prn_default_get_space_params,\
|
|
|
372 |
gx_default_start_render_thread,\
|
|
|
373 |
gx_default_open_render_device,\
|
|
|
374 |
gx_default_close_render_device,\
|
|
|
375 |
gx_default_buffer_page\
|
|
|
376 |
},\
|
|
|
377 |
{ PRN_MAX_BITMAP, PRN_BUFFER_SPACE,\
|
|
|
378 |
{ BAND_PARAMS_INITIAL_VALUES },\
|
|
|
379 |
0/*false*/, /* params_are_read_only */\
|
|
|
380 |
BandingAuto /* banding_type */\
|
|
|
381 |
},\
|
|
|
382 |
{ 0 }, /* fname */\
|
|
|
383 |
0/*false*/, /* OpenOutputFile */\
|
|
|
384 |
0/*false*/, /* ReopenPerPage */\
|
|
|
385 |
0/*false*/, /* page_uses_transparency */\
|
|
|
386 |
0/*false*/, -1, /* Duplex[_set] */\
|
|
|
387 |
0/*false*/, 0, 0, 0, /* file_is_new ... buf */\
|
|
|
388 |
0, 0, 0, 0, 0/*false*/, 0, 0, /* buffer_memory ... clist_dis'_mask */\
|
|
|
389 |
{ 0 } /* ... orig_procs */
|
|
|
390 |
#define prn_device_body_rest_(print_page)\
|
|
|
391 |
prn_device_body_rest2_(print_page, gx_default_print_page_copies)
|
|
|
392 |
#define prn_device_body_copies_rest_(print_page_copies)\
|
|
|
393 |
prn_device_body_rest2_(gx_print_page_single_copy, print_page_copies)
|
|
|
394 |
|
|
|
395 |
/* The Sun cc compiler won't allow \ within a macro argument list. */
|
|
|
396 |
/* This accounts for the short parameter names here and below. */
|
|
|
397 |
#define prn_device_margins_body(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
|
|
|
398 |
std_device_full_body_type(dtype, &procs, dname, &st_device_printer,\
|
|
|
399 |
(int)((float)(w10) * (xdpi) / 10 + 0.5),\
|
|
|
400 |
(int)((float)(h10) * (ydpi) / 10 + 0.5),\
|
|
|
401 |
xdpi, ydpi,\
|
|
|
402 |
ncomp, depth, mg, mc, dg, dc,\
|
|
|
403 |
(float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
|
|
|
404 |
(float)((lm) * 72.0), (float)((bm) * 72.0),\
|
|
|
405 |
(float)((rm) * 72.0), (float)((tm) * 72.0)\
|
|
|
406 |
),\
|
|
|
407 |
prn_device_body_rest_(print_page)
|
|
|
408 |
|
|
|
409 |
#define prn_device_body(dtype, procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
|
|
|
410 |
prn_device_margins_body(dtype, procs, dname, w10, h10, xdpi, ydpi,\
|
|
|
411 |
lm, tm, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)
|
|
|
412 |
|
|
|
413 |
#define prn_device_margins_body_extended(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn, print_page)\
|
|
|
414 |
std_device_full_body_type_extended(dtype, &procs, dname, &st_device_printer,\
|
|
|
415 |
(int)((long)(w10) * (xdpi) / 10),\
|
|
|
416 |
(int)((long)(h10) * (ydpi) / 10),\
|
|
|
417 |
xdpi, ydpi,\
|
|
|
418 |
mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn,\
|
|
|
419 |
-(lo) * (xdpi), -(to) * (ydpi),\
|
|
|
420 |
(lm) * 72.0, (bm) * 72.0,\
|
|
|
421 |
(rm) * 72.0, (tm) * 72.0\
|
|
|
422 |
),\
|
|
|
423 |
prn_device_body_rest_(print_page)
|
|
|
424 |
|
|
|
425 |
#define prn_device_body_extended(dtype, procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn, print_page)\
|
|
|
426 |
prn_device_margins_body_extended(dtype, procs, dname, w10, h10, xdpi, ydpi,\
|
|
|
427 |
lm, tm, lm, bm, rm, tm, mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn, print_page)
|
|
|
428 |
|
|
|
429 |
#define prn_device_std_margins_body(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page)\
|
|
|
430 |
std_device_std_color_full_body_type(dtype, &procs, dname, &st_device_printer,\
|
|
|
431 |
(int)((float)(w10) * (xdpi) / 10 + 0.5),\
|
|
|
432 |
(int)((float)(h10) * (ydpi) / 10 + 0.5),\
|
|
|
433 |
xdpi, ydpi, color_bits,\
|
|
|
434 |
(float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
|
|
|
435 |
(float)((lm) * 72.0), (float)((bm) * 72.0),\
|
|
|
436 |
(float)((rm) * 72.0), (float)((tm) * 72.0)\
|
|
|
437 |
),\
|
|
|
438 |
prn_device_body_rest_(print_page)
|
|
|
439 |
|
|
|
440 |
#define prn_device_std_body(dtype, procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page)\
|
|
|
441 |
prn_device_std_margins_body(dtype, procs, dname, w10, h10, xdpi, ydpi,\
|
|
|
442 |
lm, tm, lm, bm, rm, tm, color_bits, print_page)
|
|
|
443 |
|
|
|
444 |
#define prn_device_std_margins_body_copies(dtype, procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page_copies)\
|
|
|
445 |
std_device_std_color_full_body_type(dtype, &procs, dname, &st_device_printer,\
|
|
|
446 |
(int)((float)(w10) * (xdpi) / 10 + 0.5),\
|
|
|
447 |
(int)((float)(h10) * (ydpi) / 10 + 0.5),\
|
|
|
448 |
xdpi, ydpi, color_bits,\
|
|
|
449 |
(float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
|
|
|
450 |
(float)((lm) * 72.0), (float)((bm) * 72.0),\
|
|
|
451 |
(float)((rm) * 72.0), (float)((tm) * 72.0)\
|
|
|
452 |
),\
|
|
|
453 |
prn_device_body_copies_rest_(print_page_copies)
|
|
|
454 |
|
|
|
455 |
#define prn_device_std_body_copies(dtype, procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page_copies)\
|
|
|
456 |
prn_device_std_margins_body_copies(dtype, procs, dname, w10, h10, xdpi, ydpi,\
|
|
|
457 |
lm, tm, lm, bm, rm, tm, color_bits, print_page_copies)
|
|
|
458 |
|
|
|
459 |
/* Note that the following macros add { } around the data. */
|
|
|
460 |
|
|
|
461 |
#define prn_device_margins(procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page)\
|
|
|
462 |
{ prn_device_std_margins_body(gx_device_printer, procs, dname,\
|
|
|
463 |
w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page)\
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
#define prn_device(procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page)\
|
|
|
467 |
prn_device_margins(procs, dname, w10, h10, xdpi, ydpi,\
|
|
|
468 |
lm, tm, lm, bm, rm, tm, color_bits, print_page)
|
|
|
469 |
|
|
|
470 |
#define prn_device_margins_copies(procs, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page_copies)\
|
|
|
471 |
{ prn_device_std_margins_body_copies(gx_device_printer, procs, dname,\
|
|
|
472 |
w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page_copies)\
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
#define prn_device_copies(procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page_copies)\
|
|
|
476 |
prn_device_margins_copies(procs, dname, w10, h10, xdpi, ydpi,\
|
|
|
477 |
lm, tm, lm, bm, rm, tm, color_bits, print_page_copies)
|
|
|
478 |
|
|
|
479 |
/* ------ Utilities ------ */
|
|
|
480 |
/* These are defined in gdevprn.c. */
|
|
|
481 |
|
|
|
482 |
/*
|
|
|
483 |
* Open the printer's output file if necessary.
|
|
|
484 |
*/
|
|
|
485 |
/* VMS limits procedure names to 31 characters. */
|
|
|
486 |
int gdev_prn_open_printer_seekable(gx_device *dev, bool binary_mode,
|
|
|
487 |
bool seekable);
|
|
|
488 |
/* BACKWARD COMPATIBILITY */
|
|
|
489 |
#define gdev_prn_open_printer_positionable gdev_prn_open_printer_seekable
|
|
|
490 |
/* open_printer defaults positionable = false */
|
|
|
491 |
int gdev_prn_open_printer(gx_device * dev, bool binary_mode);
|
|
|
492 |
/*
|
|
|
493 |
* Test whether the printer's output file was just opened, i.e., whether
|
|
|
494 |
* this is the first page being written to this file. This is only valid
|
|
|
495 |
* at the entry to a driver's print_page procedure.
|
|
|
496 |
*/
|
|
|
497 |
bool gdev_prn_file_is_new(const gx_device_printer *pdev);
|
|
|
498 |
|
|
|
499 |
/*
|
|
|
500 |
* Determine the number of bytes required for one scan line of output to
|
|
|
501 |
* a printer device, without any padding.
|
|
|
502 |
*/
|
|
|
503 |
#define gdev_prn_raster(pdev) gx_device_raster((gx_device *)(pdev), 0)
|
|
|
504 |
|
|
|
505 |
/*
|
|
|
506 |
* Determine (conservatively) what colors are used in a given range of scan
|
|
|
507 |
* lines, and return the actual range of scan lines to which the result
|
|
|
508 |
* applies. (Currently, the result will always actually apply to one or
|
|
|
509 |
* more full bands.) In the non-banded case, this information is currently
|
|
|
510 |
* not available, so we return all-1s (i.e., any color may appear) as the
|
|
|
511 |
* 'or', and the entire page as the range; we may improve this someday.
|
|
|
512 |
*
|
|
|
513 |
* The return value is like get_band: the first Y value of the actual range
|
|
|
514 |
* is stored in *range_start, and the height of the range is returned.
|
|
|
515 |
* If the parameters are invalid, the procedure returns -1.
|
|
|
516 |
*/
|
|
|
517 |
int gdev_prn_colors_used(gx_device *dev, int y, int height,
|
|
|
518 |
gx_colors_used_t *colors_used,
|
|
|
519 |
int *range_start);
|
|
|
520 |
/*
|
|
|
521 |
* Determine the colors used in a saved page. We still need the device
|
|
|
522 |
* in order to know the total page height.
|
|
|
523 |
*/
|
|
|
524 |
int gx_page_info_colors_used(const gx_device *dev,
|
|
|
525 |
const gx_band_page_info_t *page_info,
|
|
|
526 |
int y, int height,
|
|
|
527 |
gx_colors_used_t *colors_used,
|
|
|
528 |
int *range_start);
|
|
|
529 |
|
|
|
530 |
/*
|
|
|
531 |
* Render a subrectangle of the page into a target device provided by the
|
|
|
532 |
* caller, optionally clearing the device before rendering. The rectangle
|
|
|
533 |
* need not coincide exactly with band boundaries, but it will be most
|
|
|
534 |
* efficient if they do, since it is necessary to render every band that
|
|
|
535 |
* even partly falls within the rectangle. This is the lowest-level
|
|
|
536 |
* rendering procedure: the other procedures for reading rasterized lines,
|
|
|
537 |
* defined below, ultimately call this one.
|
|
|
538 |
*
|
|
|
539 |
* render_plane is used only for internal cache bookkeeping: it doesn't
|
|
|
540 |
* affect what is passed to the buffer device. It is the client's
|
|
|
541 |
* responsibility to set up a plane extraction device, if required, to
|
|
|
542 |
* select an individual plane for rendering.
|
|
|
543 |
*
|
|
|
544 |
* Note that it may be necessary to render more than one plane even if the
|
|
|
545 |
* caller only requests a single plane. Currently this only occurs for
|
|
|
546 |
* non-trivial RasterOps on CMYK devices. If this is the case, it is the
|
|
|
547 |
* client's responsibility to provide a target device that accumulates full
|
|
|
548 |
* pixels rather than a single plane: if the plane extraction device is
|
|
|
549 |
* asked to execute an operation that requires full pixels, it will return
|
|
|
550 |
* an error.
|
|
|
551 |
*/
|
|
|
552 |
int gdev_prn_render_rectangle(gx_device_printer *pdev,
|
|
|
553 |
const gs_int_rect *prect,
|
|
|
554 |
gx_device *target,
|
|
|
555 |
const gx_render_plane_t *render_plane,
|
|
|
556 |
bool clear);
|
|
|
557 |
|
|
|
558 |
/*
|
|
|
559 |
* Read one or more rasterized scan lines for printing.
|
|
|
560 |
* The procedure either copies the scan lines into the buffer and
|
|
|
561 |
* sets *actual_buffer = buffer and *actual_bytes_per_line = bytes_per_line,
|
|
|
562 |
* or sets *actual_buffer and *actual_bytes_per_line to reference
|
|
|
563 |
* already-rasterized scan lines.
|
|
|
564 |
*
|
|
|
565 |
* For non-banded devices, copying is never necessary. For banded devices,
|
|
|
566 |
* if the client's buffer is at least as large as the single preallocated
|
|
|
567 |
* one (if any), the band will be rasterized directly into the client's
|
|
|
568 |
* buffer, again avoiding copying. Alternatively, if there is a
|
|
|
569 |
* preallocated buffer and the call asks for no more data than will fit
|
|
|
570 |
* in that buffer, buffer may be NULL: any necessary rasterizing will
|
|
|
571 |
* occur in the preallocated buffer, and a pointer into the buffer will be
|
|
|
572 |
* returned.
|
|
|
573 |
*/
|
|
|
574 |
int gdev_prn_get_lines(gx_device_printer *pdev, int y, int height,
|
|
|
575 |
byte *buffer, uint bytes_per_line,
|
|
|
576 |
byte **actual_buffer, uint *actual_bytes_per_line,
|
|
|
577 |
const gx_render_plane_t *render_plane);
|
|
|
578 |
|
|
|
579 |
/*
|
|
|
580 |
* Read a rasterized scan line for sending to the printer.
|
|
|
581 |
* This is essentially a simplified form of gdev_prn_get_lines,
|
|
|
582 |
* except that it also calls gdev_prn_clear_trailing_bits.
|
|
|
583 |
*/
|
|
|
584 |
int gdev_prn_get_bits(gx_device_printer *pdev, int y, byte *buffer,
|
|
|
585 |
byte **actual_buffer);
|
|
|
586 |
|
|
|
587 |
/*
|
|
|
588 |
* Copy scan lines to send to the printer. This is now DEPRECATED,
|
|
|
589 |
* because it copies the data even if the data are already available in
|
|
|
590 |
* the right form in the rasterizer buffer. Use gdev_prn_get_bits
|
|
|
591 |
* instead. For documentation, see the implementation in gdevprn.c.
|
|
|
592 |
*/
|
|
|
593 |
int gdev_prn_copy_scan_lines(gx_device_printer *, int, byte *, uint);
|
|
|
594 |
|
|
|
595 |
/*
|
|
|
596 |
* Clear any trailing bits in the last byte of one or more scan lines
|
|
|
597 |
* returned from the calls for reading out rasterized data. Note that
|
|
|
598 |
* the device is only used to get the width and depth, and need not be
|
|
|
599 |
* a printer device.
|
|
|
600 |
*/
|
|
|
601 |
void gdev_prn_clear_trailing_bits(byte *data, uint raster, int height,
|
|
|
602 |
const gx_device *dev);
|
|
|
603 |
|
|
|
604 |
/*
|
|
|
605 |
* Close the printer's output file.
|
|
|
606 |
*/
|
|
|
607 |
int gdev_prn_close_printer(gx_device *);
|
|
|
608 |
|
|
|
609 |
/* Print a single copy of a page by calling print_page_copies. */
|
|
|
610 |
prn_dev_proc_print_page(gx_print_page_single_copy);
|
|
|
611 |
|
|
|
612 |
/*
|
|
|
613 |
* Define a default print_page_copies procedure just calls print_page
|
|
|
614 |
* the given number of times.
|
|
|
615 |
*/
|
|
|
616 |
prn_dev_proc_print_page_copies(gx_default_print_page_copies);
|
|
|
617 |
|
|
|
618 |
/*
|
|
|
619 |
* Determine the number of scan lines that should actually be passed
|
|
|
620 |
* to the device.
|
|
|
621 |
*/
|
|
|
622 |
int gdev_prn_print_scan_lines(gx_device *);
|
|
|
623 |
|
|
|
624 |
/* Allocate / reallocate / free printer memory. */
|
|
|
625 |
int gdev_prn_allocate_memory(gx_device *pdev,
|
|
|
626 |
gdev_prn_space_params *space,
|
|
|
627 |
int new_width, int new_height);
|
|
|
628 |
int gdev_prn_reallocate_memory(gx_device *pdev,
|
|
|
629 |
gdev_prn_space_params *space,
|
|
|
630 |
int new_width, int new_height);
|
|
|
631 |
int gdev_prn_free_memory(gx_device *pdev);
|
|
|
632 |
|
|
|
633 |
/*
|
|
|
634 |
* Create the buffer device for a printer device. Clients should always
|
|
|
635 |
* call this, and never call the device procedure directly. The actual
|
|
|
636 |
* create_buf_device procedure is passed as an argument because the banding
|
|
|
637 |
* code needs this: normally it is dev_proc(some_dev, create_buf_device).
|
|
|
638 |
*/
|
|
|
639 |
typedef dev_proc_create_buf_device((*create_buf_device_proc_t));
|
|
|
640 |
int gdev_create_buf_device(create_buf_device_proc_t cbd_proc,
|
|
|
641 |
gx_device **pbdev, gx_device *target,
|
|
|
642 |
const gx_render_plane_t *render_plane,
|
|
|
643 |
gs_memory_t *mem, bool for_band);
|
|
|
644 |
|
|
|
645 |
/* BACKWARD COMPATIBILITY */
|
|
|
646 |
#define dev_print_scan_lines(dev)\
|
|
|
647 |
gdev_prn_print_scan_lines((gx_device *)(dev))
|
|
|
648 |
#define gdev_mem_bytes_per_scan_line(dev)\
|
|
|
649 |
gdev_prn_raster((gx_device_printer *)(dev))
|
|
|
650 |
#define gdev_prn_transpose_8x8(inp,ils,outp,ols)\
|
|
|
651 |
memflip8x8(inp,ils,outp,ols)
|
|
|
652 |
|
|
|
653 |
/* ------ Printer device types ------ */
|
|
|
654 |
/**************** THE FOLLOWING CODE IS NOT USED YET. ****************/
|
|
|
655 |
|
|
|
656 |
#if 0 /**************** VMS linker gets upset *************** */
|
|
|
657 |
#endif
|
|
|
658 |
int gdev_prn_initialize(gx_device *, const char *, dev_proc_print_page((*)));
|
|
|
659 |
void gdev_prn_init_color(gx_device *, int, dev_proc_map_rgb_color((*)), dev_proc_map_color_rgb((*)));
|
|
|
660 |
|
|
|
661 |
#define prn_device_type(dtname, initproc, pageproc)\
|
|
|
662 |
private dev_proc_print_page(pageproc);\
|
|
|
663 |
device_type(dtname, st_prn_device, initproc)
|
|
|
664 |
|
|
|
665 |
#define prn_device_type_mono(dtname, dname, initproc, pageproc)\
|
|
|
666 |
private dev_proc_print_page(pageproc);\
|
|
|
667 |
private int \
|
|
|
668 |
initproc(gx_device *dev)\
|
|
|
669 |
{ return gdev_prn_initialize(dev, dname, pageproc);\
|
|
|
670 |
}\
|
|
|
671 |
device_type(dtname, st_prn_device, initproc)
|
|
|
672 |
|
|
|
673 |
#define prn_device_type_color(dtname, dname, depth, initproc, pageproc, rcproc, crproc)\
|
|
|
674 |
private dev_proc_print_page(pageproc);\
|
|
|
675 |
private int \
|
|
|
676 |
initproc(gx_device *dev)\
|
|
|
677 |
{ int code = gdev_prn_initialize(dev, dname, pageproc);\
|
|
|
678 |
gdev_prn_init_color(dev, depth, rcproc, crproc);\
|
|
|
679 |
return code;\
|
|
|
680 |
}\
|
|
|
681 |
device_type(dtname, st_prn_device, initproc)
|
|
|
682 |
|
|
|
683 |
#endif /* gdevprn_INCLUDED */
|