summaryrefslogtreecommitdiff
path: root/base/gdevprn.h
blob: 8562dd3f0b8ae36d74e48e987c71bdd286a3332a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
/* Copyright (C) 2001-2023 Artifex Software, Inc.
   All Rights Reserved.

   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied,
   modified or distributed except as expressly authorized under the terms
   of the license contained in the file LICENSE in this distribution.

   Refer to licensing information at http://www.artifex.com or contact
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
   CA 94129, USA, for further information.
*/


/* Common header file for memory-buffered printers */

#ifndef gdevprn_INCLUDED
#  define gdevprn_INCLUDED

#include "memory_.h"
#include "string_.h"
#include "gx.h"
#include "gp.h"			/* for gp_file_name_sizeof */
#include "gserrors.h"
#include "gsmatrix.h"		/* for gxdevice.h */
#include "gsutil.h"		/* for memflip8x8 */
#include "gxdevice.h"
#include "gxdevmem.h"
#include "gxclist.h"
#include "gxclthrd.h"		/* for background printing */
#include "gxclpage.h"		/* for saved_pages */
#include "gxrplane.h"
#include "gsparam.h"

/*
 * Define the parameters for the printer rendering method.
 * If the entire bitmap fits in MAX_BITMAP, and there is at least
 * PRN_MIN_MEMORY_LEFT memory left after allocating it, render in RAM,
 * otherwise use a command list with a size of PRN_BUFFER_SPACE.
 * (These are parameters that can be changed by a client program.)
 */
#define PRN_MAX_BITMAP MAX_BITMAP	/* see gxdevice.h */
#define PRN_BUFFER_SPACE BUFFER_SPACE	/* see gxdevice.h */
#define PRN_MIN_MEMORY_LEFT MIN_MEMORY_LEFT	/* see gxdevice.h */
#define PRN_MIN_BUFFER_SPACE MIN_BUFFER_SPACE	/* see gxdevice.h */

/* Define the abstract type for parameters describing buffer space. */
typedef struct gdev_space_params_s gdev_prn_space_params;

/* Define the abstract type for parameters describing buffer space. */
typedef struct gdev_banding_type gdev_prn_banding_type;

/* Define the abstract type for some band device procedures' arguments. */
typedef struct gdev_prn_start_render_params_s gdev_prn_start_render_params;

/*
 * Define the special procedures for band devices.
 */
typedef struct gx_printer_device_procs_s {

    /*
     * Print the page on the output file.  Required only for devices
     * where output_page is gdev_prn_output_page or gdev_prn_bg_output_page
     * ignored for other devices (unless their output_page calls those).
     */

#define prn_dev_proc_print_page(proc)\
  int proc(gx_device_printer *, gp_file *)
    prn_dev_proc_print_page((*print_page));
/* BACKWARD COMPATIBILITY */
#define dev_proc_print_page(proc) prn_dev_proc_print_page(proc)

    /* Print the page on the output file, with a given # of copies. */

#define prn_dev_proc_print_page_copies(proc)\
  int proc(gx_device_printer *, gp_file *, int)
    prn_dev_proc_print_page_copies((*print_page_copies));
/* BACKWARD COMPATIBILITY */
#define dev_proc_print_page_copies(proc) prn_dev_proc_print_page_copies(proc)

    /*
     * Define buffer device management procedures.
     * See gxdevcli.h for the definitions.
     */

    gx_device_buf_procs_t buf_procs;

    /*
     * Compute effective space params. These results effectively override
     * the space_params in the device, but does not replace them; that is to
     * say that computed space params are temps used for computation.
     * Procedure must fill in only those space_params that it wishes to
     * override, using curr width, height, margins, etc.
     *
     * Caller is gdevprn.open & gdevprn.put_params, calls driver or
     * default.
     */

#define prn_dev_proc_get_space_params(proc)\
  void proc(const gx_device_printer *, gdev_space_params *)
    prn_dev_proc_get_space_params((*get_space_params));

} gx_printer_device_procs;

/* ------ Printer device definition ------ */

/* Structure for generic printer devices. */
/* This must be preceded by gx_device_common. */
/* Printer devices are actually a union of a memory device */
/* and a clist device, plus some additional state. */

#define prn_fname_sizeof gp_file_name_sizeof

typedef struct bg_print_s {
    gx_semaphore_t *sema;		/* used by foreground to wait */
    gx_device *device;			/* printer/clist device for bg printing */
    gp_thread_id thread_id;
    int num_copies;
    int return_code;			/* result from background print thread */
    char *ocfname;	                /* command file name */
    clist_file_ptr ocfile;	        /* command file, normally 0 */
    char *obfname;	                /* block file name */
    clist_file_ptr obfile;	/* block file, normally 0 */
    const clist_io_procs_t *oio_procs;
} bg_print_t;

#define gx_prn_device_common\
        gx_device_clist_mutatable_common;\
        gx_printer_device_procs printer_procs;\
                /* ------ Device parameters that must be set ------ */\
                /* ------ before calling the device open routine. ------ */\
        char fname[prn_fname_sizeof];	/* OutputFile */\
                /* ------ Other device parameters ------ */\
        bool OpenOutputFile;\
        bool ReopenPerPage;\
        bool Duplex;\
        int Duplex_set;		        /* -1 = not supported */\
                /* ------ End of parameters ------ */\
        bool file_is_new;		/* true iff file just opened */\
        gp_file *file;  		/* output file */\
        bool bg_print_requested;	/* request background printing of page from clist */\
        bg_print_t *bg_print;           /* background printing data shared with thread */\
        int num_render_threads_requested;	/* for multiple band rendering threads */\
        gx_saved_pages_list *saved_pages_list;	/* list when we are saving pages instead of printing */\
        gx_device_procs save_procs_while_delaying_erasepage	/* save device procs while delaying erasepage. */

/* The device descriptor */
struct gx_device_printer_s {
    gx_device_common;
    gx_prn_device_common;
};

/* A useful check to determine if the page is being rendered as a clist */
#define PRINTER_IS_CLIST(pdev) (((gx_device_printer *)(pdev))->buffer_space != 0)

extern_st(st_device_printer);
#define public_st_device_printer()	/* in gdevprn.c */\
  gs_public_st_complex_only(st_device_printer, gx_device_printer,\
    "gx_device_printer", 0, device_printer_enum_ptrs,\
    device_printer_reloc_ptrs, gx_device_finalize)

/* Define a typedef for the sake of ansi2knr. */
typedef dev_proc_print_page((*dev_proc_print_page_t));

/* Standard device procedures for printers */
dev_proc_open_device(gdev_prn_open);
dev_proc_output_page(gdev_prn_output_page);
dev_proc_output_page(gdev_prn_output_page_seekable);
dev_proc_output_page(gdev_prn_bg_output_page);
dev_proc_output_page(gdev_prn_bg_output_page_seekable);
dev_proc_close_device(gdev_prn_close);
#define gdev_prn_map_rgb_color gx_default_b_w_map_rgb_color
#define gdev_prn_map_color_rgb gx_default_b_w_map_color_rgb
dev_proc_get_params(gdev_prn_get_params);
dev_proc_put_params(gdev_prn_put_params);
dev_proc_dev_spec_op(gdev_prn_forwarding_dev_spec_op);
dev_proc_dev_spec_op(gdev_prn_dev_spec_op);

void gdev_prn_finalize(gx_device *dev);		/* cleanup when device is freed */
int gdev_prn_get_param(gx_device *dev, char *Param, void *list);

/* Default printer-specific procedures */
/* VMS limits procedure names to 31 characters. */
prn_dev_proc_get_space_params(gx_default_get_space_params);
/* BACKWARD COMPATIBILITY */
#define gdev_prn_default_get_space_params gx_default_get_space_params

/*
 * Define macros for generating the device structure,
 * analogous to the std_device_body macros in gxdevice.h
 * Note that the macros are broken up so as to be usable for devices that
 * add further initialized state to the printer device.
 *
 * The 'margin' values provided here specify the unimageable region
 * around the edges of the page (in inches), and the left and top margins
 * also specify the displacement of the device (0,0) point from the
 * upper left corner.  We should provide macros that allow specifying
 * all 6 values independently, but we don't yet.
 *
 * Note that print_page and print_page_copies must not both be defaulted.
 */
#define prn_device_body_rest2_(print_page, print_page_copies, duplex_set)\
         { 0 },		/* std_procs */\
         GX_CLIST_MUTATABLE_DEVICE_DEFAULTS,\
         { print_page,\
           print_page_copies,\
           { gx_default_create_buf_device,\
             gx_default_size_buf_device,\
             gx_default_setup_buf_device,\
             gx_default_destroy_buf_device\
           },\
           gdev_prn_default_get_space_params\
         },\
         { 0 },		/* fname */\
        0/*false*/,	/* OpenOutputFile */\
        0/*false*/,	/* ReopenPerPage */\
        0/*false*/, duplex_set,	/* Duplex[_set] */\
        0/*false*/,	/* file_is_new */\
        0,	        /* *file */\
        0/*false*/,	/* bg_print_requested */\
        0,              /* *bg_print */\
        0, 		/* num_render_threads_requested */\
        0,              /* saved_pages_list */\
        { 0 }           /* save_procs_while_delaying_erasepage */
#define prn_device_body_rest_(print_page)\
  prn_device_body_rest2_(print_page, gx_default_print_page_copies, -1)
#define prn_device_body_copies_rest_(print_page_copies)\
  prn_device_body_rest2_(gx_print_page_single_copy, print_page_copies, -1)

/* The Sun cc compiler won't allow \ within a macro argument list. */
/* This accounts for the short parameter names here and below. */
#define prn_device_margins_body(dtype, init, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
        std_device_full_body_type(dtype, init, dname, &st_device_printer,\
          (int)((float)(w10) * (xdpi) / 10 + 0.5),\
          (int)((float)(h10) * (ydpi) / 10 + 0.5),\
          xdpi, ydpi,\
          ncomp, depth, mg, mc, dg, dc,\
          (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
          (float)((lm) * 72.0), (float)((bm) * 72.0),\
          (float)((rm) * 72.0), (float)((tm) * 72.0)\
        ),\
        prn_device_body_rest_(print_page)
#define prn_device_margins_body_duplex(dtype, init, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
        std_device_full_body_type(dtype, init, dname, &st_device_printer,\
          (int)((float)(w10) * (xdpi) / 10 + 0.5),\
          (int)((float)(h10) * (ydpi) / 10 + 0.5),\
          xdpi, ydpi,\
          ncomp, depth, mg, mc, dg, dc,\
          (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
          (float)((lm) * 72.0), (float)((bm) * 72.0),\
          (float)((rm) * 72.0), (float)((tm) * 72.0)\
        ),\
        prn_device_body_rest2_(print_page, gx_default_print_page_copies, 0)
#define prn_device_margins_stype_body(dtype, init, dname, stype, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
        std_device_full_body_type(dtype, init, dname, stype,\
          (int)((float)(w10) * (xdpi) / 10 + 0.5),\
          (int)((float)(h10) * (ydpi) / 10 + 0.5),\
          xdpi, ydpi,\
          ncomp, depth, mg, mc, dg, dc,\
          (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
          (float)((lm) * 72.0), (float)((bm) * 72.0),\
          (float)((rm) * 72.0), (float)((tm) * 72.0)\
        ),\
        prn_device_body_rest_(print_page)

#define prn_device_body(dtype, init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
  prn_device_margins_body(dtype, init, dname, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)
#define prn_device_body_duplex(dtype, init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
  prn_device_margins_body_duplex(dtype, init, dname, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)
#define prn_device_stype_body(dtype, init, dname, stype, w10, h10, xdpi, ydpi, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)\
  prn_device_margins_stype_body(dtype, init, dname, stype, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, ncomp, depth, mg, mc, dg, dc, print_page)

#define prn_device_margins_body_extended(dtype, init, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn, print_page)\
        std_device_full_body_type_extended(dtype, init, dname, &st_device_printer,\
          (int)((long)(w10) * (xdpi) / 10),\
          (int)((long)(h10) * (ydpi) / 10),\
          xdpi, ydpi,\
          mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn,\
          -(lo) * (xdpi), -(to) * (ydpi),\
          (lm) * 72.0, (bm) * 72.0,\
          (rm) * 72.0, (tm) * 72.0\
        ),\
        prn_device_body_rest_(print_page)

#define prn_device_body_extended(dtype, init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn, print_page)\
  prn_device_margins_body_extended(dtype, init, dname, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, mcomp, ncomp, pol, depth, gi, mg, mc, dg, dc, ef, cn, print_page)

#define prn_device_std_margins_body(dtype, init, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page)\
        std_device_std_color_full_body_type(dtype,init, dname, &st_device_printer,\
          (int)((float)(w10) * (xdpi) / 10 + 0.5),\
          (int)((float)(h10) * (ydpi) / 10 + 0.5),\
          xdpi, ydpi, color_bits,\
          (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
          (float)((lm) * 72.0), (float)((bm) * 72.0),\
          (float)((rm) * 72.0), (float)((tm) * 72.0)\
        ),\
        prn_device_body_rest_(print_page)

#define prn_device_std_body(dtype, init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page)\
  prn_device_std_margins_body(dtype, init, dname, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, color_bits, print_page)

#define prn_device_std_margins_body_copies(dtype, init, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page_copies)\
        std_device_std_color_full_body_type(dtype, init, dname, &st_device_printer,\
          (int)((float)(w10) * (xdpi) / 10 + 0.5),\
          (int)((float)(h10) * (ydpi) / 10 + 0.5),\
          xdpi, ydpi, color_bits,\
          (float)(-(lo) * (xdpi)), (float)(-(to) * (ydpi)),\
          (float)((lm) * 72.0), (float)((bm) * 72.0),\
          (float)((rm) * 72.0), (float)((tm) * 72.0)\
        ),\
        prn_device_body_copies_rest_(print_page_copies)

#define prn_device_std_body_copies(dtype, init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page_copies)\
  prn_device_std_margins_body_copies(dtype, init, dname, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, color_bits, print_page_copies)

     /* Note that the following macros add { } around the data. */

#define prn_device_margins(init, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page)\
{ prn_device_std_margins_body(gx_device_printer, init, dname,\
    w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page)\
}

#define prn_device(init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page)\
  prn_device_margins(init, dname, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, color_bits, print_page)

#define prn_device_margins_copies(init, dname, w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page_copies)\
{ prn_device_std_margins_body_copies(gx_device_printer, init, dname,\
    w10, h10, xdpi, ydpi, lo, to, lm, bm, rm, tm, color_bits, print_page_copies)\
}

#define prn_device_copies(init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page_copies)\
  prn_device_margins_copies(init, dname, w10, h10, xdpi, ydpi,\
    lm, tm, lm, bm, rm, tm, color_bits, print_page_copies)

/* ------ Utilities ------ */
/* These are defined in gdevprn.c. */

/*
 * Open the printer's output file if necessary.
 */
/* VMS limits procedure names to 31 characters. */
int gdev_prn_open_printer_seekable(gx_device *dev, bool binary_mode,
                                   bool seekable);
/* BACKWARD COMPATIBILITY */
#define gdev_prn_open_printer_positionable gdev_prn_open_printer_seekable
/* open_printer defaults positionable = false */
int gdev_prn_open_printer(gx_device * dev, bool binary_mode);
/*
 * Test whether the printer's output file was just opened, i.e., whether
 * this is the first page being written to this file.  This is only valid
 * at the entry to a driver's print_page procedure.
 */
bool gdev_prn_file_is_new(const gx_device_printer *pdev);

/*
 * Determine the number of bytes required for one scan line of output to
 * a printer device, without any padding.
 */
#define gdev_prn_raster(pdev) gx_device_raster((gx_device *)(pdev), 0)

#define gdev_prn_raster_chunky(pdev) gx_device_raster_chunky((gx_device *)(pdev), 0)

/*
 * Determine (conservatively) what colors are used in a given range of scan
 * lines, and return the actual range of scan lines to which the result
 * applies.  (Currently, the result will always actually apply to one or
 * more full bands.)  In the non-banded case, this information is currently
 * not available, so we return all-1s (i.e., any color may appear) as the
 * 'or', and the entire page as the range; we may improve this someday.
 *
 * On return the first Y value of the actual range is stored in
 * *range_start, and the height of the range is returned.
 * If the parameters are invalid, the procedure returns -1.
 */
int gdev_prn_color_usage(gx_device *dev, int y, int height,
                         gx_color_usage_t *color_usage,
                         int *range_start);
/*
 * Determine the colors used in a saved page.  We still need the device
 * in order to know the total page height. Saved pages are always
 * clist, so we will get this using clist_read_color_usage_array.
 */
int gx_page_info_color_usage(const gx_device *dev,
                             const gx_band_page_info_t *page_info,
                             int y, int height,
                             gx_color_usage_t *color_usage,
                             int *range_start);

/*
 * Render a subrectangle of the page into a target device provided by the
 * caller, optionally clearing the device before rendering.  The rectangle
 * need not coincide exactly with band boundaries, but it will be most
 * efficient if they do, since it is necessary to render every band that
 * even partly falls within the rectangle.  This is the lowest-level
 * rendering procedure: the other procedures for reading rasterized lines,
 * defined below, ultimately call this one.
 *
 * render_plane is used only for internal cache bookkeeping: it doesn't
 * affect what is passed to the buffer device.  It is the client's
 * responsibility to set up a plane extraction device, if required, to
 * select an individual plane for rendering.
 *
 * Note that it may be necessary to render more than one plane even if the
 * caller only requests a single plane.  Currently this only occurs for
 * non-trivial RasterOps on CMYK devices.  If this is the case, it is the
 * client's responsibility to provide a target device that accumulates full
 * pixels rather than a single plane: if the plane extraction device is
 * asked to execute an operation that requires full pixels, it will return
 * an error.
 */
int gdev_prn_render_rectangle(gx_device_printer *pdev,
                              const gs_int_rect *prect,
                              gx_device *target,
                              const gx_render_plane_t *render_plane,
                              bool clear);

/*
 * Read one or more rasterized scan lines for printing.
 * The procedure either copies the scan lines into the buffer and
 * sets *actual_buffer = buffer and *actual_bytes_per_line = bytes_per_line,
 * or sets *actual_buffer and *actual_bytes_per_line to reference
 * already-rasterized scan lines.
 *
 * For non-banded devices, copying is never necessary.  For banded devices,
 * if the client's buffer is at least as large as the single preallocated
 * one (if any), the band will be rasterized directly into the client's
 * buffer, again avoiding copying.  Alternatively, if there is a
 * preallocated buffer and the call asks for no more data than will fit
 * in that buffer, buffer may be NULL: any necessary rasterizing will
 * occur in the preallocated buffer, and a pointer into the buffer will be
 * returned.
 */
int gdev_prn_get_lines(gx_device_printer *pdev, int y, int height,
                       byte *buffer, uint bytes_per_line,
                       byte **actual_buffer, uint *actual_bytes_per_line,
                       const gx_render_plane_t *render_plane);

/*
 * Read a rasterized scan line for sending to the printer.
 * This is essentially a simplified form of gdev_prn_get_lines,
 * except that it also calls gdev_prn_clear_trailing_bits.
 */
int gdev_prn_get_bits(gx_device_printer *pdev, int y, byte *buffer,
                      byte **actual_buffer);

/*
 * Copy scan lines to send to the printer.  This is now DEPRECATED,
 * because it copies the data even if the data are already available in
 * the right form in the rasterizer buffer.  Use gdev_prn_get_bits
 * instead.  For documentation, see the implementation in gdevprn.c.
 */
int gdev_prn_copy_scan_lines(gx_device_printer *, int, byte *, uint);

/*
 * Clear any trailing bits in the last byte of one or more scan lines
 * returned from the calls for reading out rasterized data.  Note that
 * the device is only used to get the width and depth, and need not be
 * a printer device.
 */
void gdev_prn_clear_trailing_bits(byte *data, uint raster, int height,
                                  const gx_device *dev);

/*
 * Close the printer's output file.
 */
int gdev_prn_close_printer(gx_device *);

/* Print a single copy of a page by calling print_page_copies. */
prn_dev_proc_print_page(gx_print_page_single_copy);

/*
 * Define a default print_page_copies procedure just calls print_page
 * the given number of times.
 */
prn_dev_proc_print_page_copies(gx_default_print_page_copies);

/*
 * Determine the number of scan lines that should actually be passed
 * to the device.
 */
int gdev_prn_print_scan_lines(gx_device *);

/* Allocate / reallocate / free printer memory. */
int gdev_prn_allocate_memory(gx_device *pdev,
                             gdev_space_params *space,
                             int new_width, int new_height);
int gdev_prn_reallocate_memory(gx_device *pdev,
                               gdev_space_params *space,
                               int new_width, int new_height);
int gdev_prn_free_memory(gx_device *pdev);

/*
 * Create the buffer device for a printer device.  Clients should always
 * call this, and never call the device procedure directly.  The actual
 * create_buf_device procedure is passed as an argument because the banding
 * code needs this: normally it is dev_proc(some_dev, create_buf_device).
 */
typedef dev_proc_create_buf_device((*create_buf_device_proc_t));
int gdev_create_buf_device(create_buf_device_proc_t cbd_proc,
                           gx_device **pbdev, gx_device *target, int y,
                           const gx_render_plane_t *render_plane,
                           gs_memory_t *mem, gx_color_usage_t *color_usage);

/* BACKWARD COMPATIBILITY */
#define dev_print_scan_lines(dev)\
  gdev_prn_print_scan_lines((gx_device *)(dev))
#define gdev_mem_bytes_per_scan_line(dev)\
  gdev_prn_raster((gx_device_printer *)(dev))
#define gdev_prn_transpose_8x8(inp,ils,outp,ols)\
  memflip8x8(inp,ils,outp,ols)

void gdev_prn_initialize_device_procs(gx_device *dev);
void gdev_prn_initialize_device_procs_bg(gx_device *dev);
void gdev_prn_initialize_device_procs_mono(gx_device *dev);
void gdev_prn_initialize_device_procs_mono_bg(gx_device *dev);
void gdev_prn_initialize_device_procs_rgb(gx_device *dev);
void gdev_prn_initialize_device_procs_rgb_bg(gx_device *dev);
void gdev_prn_initialize_device_procs_gray(gx_device *dev);
void gdev_prn_initialize_device_procs_gray_bg(gx_device *dev);
void gdev_prn_initialize_device_procs_gray8(gx_device *dev);
void gdev_prn_initialize_device_procs_gray8_bg(gx_device *dev);
void gdev_prn_initialize_device_procs_cmyk1(gx_device *dev);
void gdev_prn_initialize_device_procs_cmyk1_bg(gx_device *dev);
void gdev_prn_initialize_device_procs_cmyk8(gx_device *dev);
void gdev_prn_initialize_device_procs_cmyk8_bg(gx_device *dev);
void gdev_prn_initialize_device_procs_cmyk16(gx_device *dev);
void gdev_prn_initialize_device_procs_cmyk16_bg(gx_device *dev);

#endif /* gdevprn_INCLUDED */