xref: /plan9/sys/src/cmd/gs/src/gxband.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1997, 1998 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: gxband.h,v 1.5 2005/03/14 18:08:36 dan Exp $ */
18 /* Band-processing parameters for Ghostscript */
19 
20 #ifndef gxband_INCLUDED
21 #  define gxband_INCLUDED
22 
23 #include "gxclio.h"
24 
25 /*
26  * Define the parameters controlling banding.
27  */
28 typedef struct gx_band_params_s {
29     bool page_uses_transparency; /* PDF 1.4 transparency is used on the page */
30     int BandWidth;		/* (optional) band width in pixels */
31     int BandHeight;		/* (optional) */
32     long BandBufferSpace;	/* (optional) */
33 } gx_band_params_t;
34 
35 #define BAND_PARAMS_INITIAL_VALUES 0, 0, 0
36 
37 /*
38  * Define information about the colors used on a page.
39  */
40 typedef struct gx_colors_used_s {
41     gx_color_index or;		/* the "or" of all the used colors */
42     bool slow_rop;		/* true if any RasterOps that can't be */
43 				/* executed plane-by-plane on CMYK devices */
44 } gx_colors_used_t;
45 
46 /*
47  * We want to store color usage information for each band in the page_info
48  * structure, but we also want this structure to be of a fixed (and
49  * reasonable) size.  We do this by allocating a fixed number of colors_used
50  * structures in the page_info structure, and if there are more bands than
51  * we have allocated, we simply reduce the precision of the information by
52  * letting each colors_used structure cover multiple bands.
53  *
54  * 30 entries would be large enough to cover A4 paper (11.3") at 600 dpi
55  * with 256-scan-line bands.  We pick 50 somewhat arbitrarily.
56  */
57 #define PAGE_INFO_NUM_COLORS_USED 50
58 
59 /*
60  * Define the information for a saved page.
61  */
62 typedef struct gx_band_page_info_s {
63     char cfname[gp_file_name_sizeof];	/* command file name */
64     clist_file_ptr cfile;	/* command file, normally 0 */
65     char bfname[gp_file_name_sizeof];	/* block file name */
66     clist_file_ptr bfile;	/* block file, normally 0 */
67     uint tile_cache_size;	/* size of tile cache */
68     long bfile_end_pos;		/* ftell at end of bfile */
69     gx_band_params_t band_params;  /* parameters used when writing band list */
70 				/* (actual values, no 0s) */
71     int scan_lines_per_colors_used; /* number of scan lines per colors_used */
72 				/* entry (a multiple of the band height) */
73     gx_colors_used_t band_colors_used[PAGE_INFO_NUM_COLORS_USED];  /* colors used on the page */
74 } gx_band_page_info_t;
75 #define PAGE_INFO_NULL_VALUES\
76   { 0 }, 0, { 0 }, 0, 0, 0, { BAND_PARAMS_INITIAL_VALUES },\
77   0x3fffffff, { { 0 } }
78 
79 /*
80  * By convention, the structure member containing the above is called
81  * page_info.  Define shorthand accessors for its members.
82  */
83 #define page_cfile page_info.cfile
84 #define page_cfname page_info.cfname
85 #define page_bfile page_info.bfile
86 #define page_bfname page_info.bfname
87 #define page_tile_cache_size page_info.tile_cache_size
88 #define page_bfile_end_pos page_info.bfile_end_pos
89 #define page_band_height page_info.band_params.BandHeight
90 
91 #endif /* ndef gxband_INCLUDED */
92