1 /* Copyright (C) 2001-2019 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.,  1305 Grant Avenue - Suite 200, Novato,
13    CA 94945, 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 "gxband.h"
23 #include "gxrplane.h"		/* for _buf_device procedures */
24 
25 /*
26  * Define the procedures for managing rendering buffers.  These are
27  * currently associated with printer and/or banded devices, but they
28  * might have broader applicability in the future.
29  *
30  * For "async" devices, size_buf_device may be called by either the
31  * writer or the reader thread; the other procedures may be called only
32  * by the reader thread.
33  */
34 
35 /* Define the structure for returning buffer space requirements. */
36 typedef struct gx_device_buf_space_s {
37     ulong bits;
38     ulong line_ptrs;
39     uint raster;
40 } gx_device_buf_space_t;
41 
42 typedef struct gx_device_buf_procs_s {
43 
44     /*
45      * Create the buffer device(s) for the pixels or a plane of a page
46      * or band.  We use 'buf' instead of buffer because VMS limits
47      * procedure names to 31 characters.  Note that the client must
48      * fully initialize the render_plane using gx_render_plane_init.
49      *
50      * If mem is NULL, *pbdev must already point to a gx_device_memory,
51      * and this procedure must initialize it.  If this isn't possible
52      * (e.g., if render_plane calls for a single plane),
53      * create_buf_device must return an error.
54      */
55 
56 #define dev_proc_create_buf_device(proc)\
57   int proc(gx_device **pbdev, gx_device *target, int y,\
58            const gx_render_plane_t *render_plane, gs_memory_t *mem,\
59            gx_color_usage_t *color_usage)
60 
61     dev_proc_create_buf_device((*create_buf_device));
62 
63     /*
64      * Return the amount of buffer space needed by setup_buf_device.
65      */
66 
67 #define dev_proc_size_buf_device(proc)\
68   int proc(gx_device_buf_space_t *space, gx_device *target,\
69            const gx_render_plane_t *render_plane,\
70            int height, bool for_band)
71 
72     dev_proc_size_buf_device((*size_buf_device));
73 
74     /*
75      * Set up the buffer device with a specific buffer.
76      * If line_ptrs is not NULL, it points to an allocated area for
77      * the scan line pointers of an eventual memory device.
78      *
79      * Note that this procedure is used for two different purposes:
80      * setting up a full band buffer for rendering, and setting up a
81      * partial-band buffer device for reading out selected scan lines.
82      * The latter case requires that we also pass the full height of the
83      * buffer, for multi-planar memory devices; in the former case,
84      * y = 0 and setup_height = full_height.
85      */
86 
87 #define dev_proc_setup_buf_device(proc)\
88   int proc(gx_device *bdev, byte *buffer, int bytes_per_line,\
89            byte **line_ptrs /*[height]*/, int y, int setup_height,\
90            int full_height)
91 
92     dev_proc_setup_buf_device((*setup_buf_device));
93 
94     /*
95      * Destroy the buffer device and all associated structures.
96      * Note that this does *not* destroy the buffered data.
97      */
98 
99 #define dev_proc_destroy_buf_device(proc)\
100   void proc(gx_device *bdev)
101 
102     dev_proc_destroy_buf_device((*destroy_buf_device));
103 
104 } gx_device_buf_procs_t;
105 
106 /* Define default buffer device management procedures. */
107 dev_proc_create_buf_device(gx_default_create_buf_device);
108 dev_proc_size_buf_device(gx_default_size_buf_device);
109 dev_proc_setup_buf_device(gx_default_setup_buf_device);
110 dev_proc_destroy_buf_device(gx_default_destroy_buf_device);
111 
112 #endif /* gxdevbuf_INCLUDED */
113