xref: /plan9/sys/src/cmd/gs/src/gxiclass.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1999 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: gxiclass.h,v 1.5 2002/06/16 08:45:43 lpd Exp $ */
18 /* Define image rendering algorithm classes */
19 
20 #ifndef gxiclass_INCLUDED
21 #  define gxiclass_INCLUDED
22 
23 /* Define the abstract type for the image enumerator state. */
24 typedef struct gx_image_enum_s gx_image_enum;
25 
26 #ifndef gx_device_DEFINED
27 #  define gx_device_DEFINED
28 typedef struct gx_device_s gx_device;
29 #endif
30 
31 /*
32  * Define the interface for routines used to render a (source) scan line.
33  * If the buffer is the original client's input data, it may be unaligned;
34  * otherwise, it will always be aligned.
35  *
36  * The image_render procedures work on fully expanded, complete rows.  These
37  * take a height argument, which is an integer >= 0; they return a negative
38  * code, or the number of rows actually processed (which may be less than
39  * the height).  height = 0 is a special call to indicate that there is no
40  * more input data; this is necessary because the last scan lines of the
41  * source data may not produce any output.
42  *
43  * Note that the 'w' argument of the image_render procedure is the number
44  * of samples, i.e., the number of pixels * the number of samples per pixel.
45  * This is neither the width in pixels nor the width in bytes (in the case
46  * of 12-bit samples, which expand to 2 bytes apiece).
47  */
48 #define irender_proc(proc)\
49   int proc(gx_image_enum *penum, const byte *buffer, int data_x,\
50 	   uint w, int h, gx_device *dev)
51 typedef irender_proc((*irender_proc_t));
52 
53 /*
54  * Define procedures for selecting imaging methods according to the class of
55  * the image.  Image class procedures are called in alphabetical order, so
56  * their names begin with a digit that indicates their priority
57  * (0_interpolate, etc.): each one may assume that all the previous ones
58  * failed.  If a class procedure succeeds, it may update the enumerator
59  * structure as well as returning the rendering procedure.
60  */
61 #define iclass_proc(proc)\
62   irender_proc_t proc(gx_image_enum *penum)
63 typedef iclass_proc((*gx_image_class_t));
64 
65 #endif /* gxiclass_INCLUDED */
66