1 /* Copyright (C) 2001-2012 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,
8    modified or distributed except as expressly authorized under the terms
9    of the license contained in the file LICENSE in this distribution.
10 
11    Refer to licensing information at http://www.artifex.com or contact
12    Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
13    CA  94903, U.S.A., +1(415)492-9861, for further information.
14 */
15 
16 
17 /* Definitions for device buffer management */
18 
19 #ifndef gxdevbuf_INCLUDED
20 #  define gxdevbuf_INCLUDED
21 
22 #include "gxrplane.h"		/* for _buf_device procedures */
23 
24 /*
25  * Define the procedures for managing rendering buffers.  These are
26  * currently associated with printer and/or banded devices, but they
27  * might have broader applicability in the future.
28  *
29  * For "async" devices, size_buf_device may be called by either the
30  * writer or the reader thread; the other procedures may be called only
31  * by the reader thread.
32  */
33 
34 #ifndef gx_device_DEFINED
35 #  define gx_device_DEFINED
36 typedef struct gx_device_s gx_device;
37 #endif
38 
39 /* Define the structure for returning buffer space requirements. */
40 typedef struct gx_device_buf_space_s {
41     ulong bits;
42     ulong line_ptrs;
43     uint raster;
44 } gx_device_buf_space_t;
45 
46 /* clist contents analysis per band */
47 typedef struct gx_band_complexity_s {
48     /* use null or contents to denote non banding case: */
49 
50     bool uses_color;
51     bool nontrivial_rops;
52 
53 #if 0
54     /* halftone phase */
55     int x0;
56     int y0;
57 #endif
58 } gx_band_complexity_t;
59 
60 typedef struct gx_device_buf_procs_s {
61 
62     /*
63      * Create the buffer device(s) for the pixels or a plane of a page
64      * or band.  We use 'buf' instead of buffer because VMS limits
65      * procedure names to 31 characters.  Note that the client must
66      * fully initialize the render_plane using gx_render_plane_init.
67      *
68      * If mem is NULL, *pbdev must already point to a gx_device_memory,
69      * and this procedure must initialize it.  If this isn't possible
70      * (e.g., if render_plane calls for a single plane),
71      * create_buf_device must return an error.
72      */
73 
74 #define dev_proc_create_buf_device(proc)\
75   int proc(gx_device **pbdev, gx_device *target, int y,\
76            const gx_render_plane_t *render_plane, gs_memory_t *mem,\
77            gx_band_complexity_t *band_complexity)
78 
79     dev_proc_create_buf_device((*create_buf_device));
80 
81     /*
82      * Return the amount of buffer space needed by setup_buf_device.
83      */
84 
85 #define dev_proc_size_buf_device(proc)\
86   int proc(gx_device_buf_space_t *space, gx_device *target,\
87            const gx_render_plane_t *render_plane,\
88            int height, bool for_band)
89 
90     dev_proc_size_buf_device((*size_buf_device));
91 
92     /*
93      * Set up the buffer device with a specific buffer.
94      * If line_ptrs is not NULL, it points to an allocated area for
95      * the scan line pointers of an eventual memory device.
96      *
97      * Note that this procedure is used for two different purposes:
98      * setting up a full band buffer for rendering, and setting up a
99      * partial-band buffer device for reading out selected scan lines.
100      * The latter case requires that we also pass the full height of the
101      * buffer, for multi-planar memory devices; in the former case,
102      * y = 0 and setup_height = full_height.
103      */
104 
105 #define dev_proc_setup_buf_device(proc)\
106   int proc(gx_device *bdev, byte *buffer, int bytes_per_line,\
107            byte **line_ptrs /*[height]*/, int y, int setup_height,\
108            int full_height)
109 
110     dev_proc_setup_buf_device((*setup_buf_device));
111 
112     /*
113      * Destroy the buffer device and all associated structures.
114      * Note that this does *not* destroy the buffered data.
115      */
116 
117 #define dev_proc_destroy_buf_device(proc)\
118   void proc(gx_device *bdev)
119 
120     dev_proc_destroy_buf_device((*destroy_buf_device));
121 
122 } gx_device_buf_procs_t;
123 
124 /* Define default buffer device management procedures. */
125 dev_proc_create_buf_device(gx_default_create_buf_device);
126 dev_proc_size_buf_device(gx_default_size_buf_device);
127 dev_proc_setup_buf_device(gx_default_setup_buf_device);
128 dev_proc_destroy_buf_device(gx_default_destroy_buf_device);
129 
130 #endif /* gxdevbuf_INCLUDED */
131