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 /* Interface for get_bits_rectangle driver procedure */
18 
19 #ifndef gxgetbit_INCLUDED
20 #  define gxgetbit_INCLUDED
21 
22 #include "gxbitfmt.h"
23 #include "gxdevcli.h"
24 
25 /*
26  * We define the options for get_bits_rectangle here in a separate file
27  * so that the great majority of driver implementors and clients, which
28  * don't care about the details, don't need to be recompiled if the set
29  * of options changes.
30  */
31 typedef gx_bitmap_format_t gs_get_bits_options_t;
32 
33 /*
34  * Define the parameter record passed to get_bits_rectangle.
35  * get_bits_rectangle may update members of this structure if
36  * the options allow it to choose their values, and always updates options
37  * to indicate what options were actually used (1 option per group).
38  */
39 struct gs_get_bits_params_s {
40     gs_get_bits_options_t options;
41     byte *data[GS_CLIENT_COLOR_MAX_COMPONENTS];
42     int x_offset;		/* in returned data */
43     int original_y;
44     uint raster;
45 };
46 
47 /*
48  * gx_bitmap_format_t defines the options passed to get_bits_rectangle,
49  * which indicate which formats are acceptable for the returned data.  If
50  * successful, get_bits_rectangle sets the options member of the parameter
51  * record to indicate what options were chosen -- 1 per group, and never the
52  * _ANY option.  Note that the chosen option is not necessarily one that
53  * appeared in the original options: for example, if GB_RASTER_ANY is the
54  * only raster option originally set, the chosen option will be
55  * GB_RASTER_STANDARD or GB_RASTER_SPECIFIED.
56  *
57  * If the options mask is 0, get_bits_rectangle must set it to the
58  * complete set of supported options and return an error.  This allows
59  * clients to determine what options are supported without actually doing
60  * a transfer.
61  *
62  * All devices must support at least one option in each group, and must
63  * support GB_COLORS_NATIVE.
64  *
65  * NOTE: the current default implementation supports only the following
66  * options in their respective groups (i.e., any other options must be
67  * supported directly by the device):
68  *      GB_DEPTH_8
69  *      GB_PACKING_CHUNKY
70  *      GB_RETURN_COPY
71  * The current default implementation also requires that all devices
72  * support GB_PACKING_CHUNKY.  */
73 
74 /* ---------------- Procedures ---------------- */
75 
76 /* Try to implement get_bits_rectangle by returning a pointer. */
77 int gx_get_bits_return_pointer(gx_device * dev, int x, int h,
78                                gs_get_bits_params_t * params,
79                                const gs_get_bits_params_t *stored,
80                                byte ** stored_base);
81 
82 /* Implement get_bits_rectangle by copying. */
83 int gx_get_bits_copy(gx_device * dev, int x, int w, int h,
84                      gs_get_bits_params_t * params,
85                      const gs_get_bits_params_t *stored,
86                      const byte * src_base, uint dev_raster);
87 
88 #endif /* gxgetbit_INCLUDED */
89