1 /*
2  * OpenPrinting Vector Printer Driver API Definitions [opvp.h]
3  *
4  * Copyright (c) 2006 Free Standards Group
5  * Copyright (c) 2006 Fuji Xerox Printing Systems Co., Ltd.
6  * Copyright (c) 2006 Canon Inc.
7  * Copyright (c) 2003-2006 AXE Inc.
8  *
9  * All Rights Reserverd.
10  *
11  * Permission to use, copy, modify, distribute, and sell this software
12  * and its documentation for any purpose is hereby granted without
13  * fee, provided that the above copyright notice appear in all copies
14  * and that both that copyright notice and this permission notice
15  * appear in supporting documentation.
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT.  IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR
24  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28  /*
29   2007 Modified  for OPVP 1.0 by BBR Inc.
30  */
31 
32 #ifndef _OPVP_H_
33 #define _OPVP_H_
34 
35 /* Return Values and Error Codes */
36 #define OPVP_OK			0	/* -1 for errors */
37 #define OPVP_FATALERROR		-1	/* error: cannot be recovered */
38 #define OPVP_BADREQUEST		-2	/* error: called where it should
39                                                   not be called */
40 #define OPVP_BADCONTEXT		-3	/* error: invalid printer context */
41 #define OPVP_NOTSUPPORTED	-4	/* error: combination of
42                                                   parameters are set
43                                                   which cannot be handled
44                                                   by driver or printer */
45 #define OPVP_JOBCANCELED	-5	/* error: job has been canceled
46                                                   by some cause */
47 #define OPVP_PARAMERROR		-6	/* error: invalid parameter */
48 #define OPVP_VERSIONERROR	-7	/* error: invalid API version */
49 
50 /* Basic Types */
51 typedef int opvp_dc_t;			/* driver/device context */
52 typedef int opvp_result_t;		/* return value */
53 typedef unsigned char opvp_byte_t;	/* BYTE */
54 typedef unsigned char opvp_char_t;	/* character (string) */
55 typedef int opvp_int_t;			/* integer */
56 typedef int opvp_fix_t;			/* fixed integer */
57 typedef float opvp_float_t;		/* float */
58 typedef unsigned int opvp_flag_t;	/* flags */
59 typedef unsigned int opvp_rop_t;	/* raster operation */
60 
61 /* for opvp_fix_t */
62 #define OPVP_FIX_FRACT_WIDTH    8
63 #define OPVP_FIX_FRACT_DENOM    (1<<OPVP_FIX_FRACT_WIDTH)
64 #define OPVP_FIX_FLOOR_WIDTH    (sizeof(int)*8-OPVP_FIX_FRACT_WIDTH)
65 
66 /* convert macro */
67 #define	OPVP_I2FIX(i,fix)	(fix=i<<OPVP_FIX_FRACT_WIDTH)
68 #define	OPVP_F2FIX(f,fix)	(fix=((int)floor(f)<<OPVP_FIX_FRACT_WIDTH)\
69                                     |((int)((f-floor(f))*OPVP_FIX_FRACT_DENOM)\
70                                       &(OPVP_FIX_FRACT_DENOM-1)))
71 
72 /* graphic elements */
73 typedef struct _opvp_point {
74         opvp_fix_t x, y;
75 } opvp_point_t;
76 
77 typedef struct _opvp_rectangle {
78         opvp_point_t p0;			/* start point */
79         opvp_point_t p1;			/* diagonal point */
80 } opvp_rectangle_t;
81 
82 typedef struct _opvp_roundrectangle {
83         opvp_point_t p0;			/* start point */
84         opvp_point_t p1;			/* diagonal point */
85         opvp_fix_t xellipse, yellipse;
86 } opvp_roundrectangle_t;
87 
88 /* Image Formats */
89 typedef enum _opvp_imageformat {
90         OPVP_IFORMAT_RAW		= 0,
91         OPVP_IFORMAT_MASK		= 1,
92         OPVP_IFORMAT_RLE		= 2,
93         OPVP_IFORMAT_JPEG		= 3,
94         OPVP_IFORMAT_PNG		= 4
95 } opvp_imageformat_t;
96 
97 /* Color Presentation */
98 typedef enum _opvp_colormapping {
99         OPVP_CMAP_DIRECT		= 0,
100         OPVP_CMAP_INDEXED		= 1
101 } opvp_colormapping_t;
102 
103 typedef enum _opvp_cspace {
104         OPVP_CSPACE_BW			= 0,
105         OPVP_CSPACE_DEVICEGRAY		= 1,
106         OPVP_CSPACE_DEVICECMY		= 2,
107         OPVP_CSPACE_DEVICECMYK		= 3,
108         OPVP_CSPACE_DEVICERGB		= 4,
109         OPVP_CSPACE_DEVICEKRGB		= 5,
110         OPVP_CSPACE_STANDARDRGB		= 6,
111         OPVP_CSPACE_STANDARDRGB64	= 7
112 } opvp_cspace_t;
113 
114 /* Fill, Paint, Clip */
115 typedef enum _opvp_fillmode {
116         OPVP_FILLMODE_EVENODD		= 0,
117         OPVP_FILLMODE_WINDING		= 1
118 } opvp_fillmode_t;
119 
120 typedef enum _opvp_paintmode {
121         OPVP_PAINTMODE_OPAQUE		= 0,
122         OPVP_PAINTMODE_TRANSPARENT	= 1
123 } opvp_paintmode_t;
124 
125 typedef enum _opvp_cliprule {
126         OPVP_CLIPRULE_EVENODD		= 0,
127         OPVP_CLIPRULE_WINDING		= 1
128 } opvp_cliprule_t;
129 
130 /* Line */
131 typedef enum _opvp_linestyle {
132         OPVP_LINESTYLE_SOLID		= 0,
133         OPVP_LINESTYLE_DASH		= 1
134 } opvp_linestyle_t;
135 
136 typedef enum _opvp_linecap {
137         OPVP_LINECAP_BUTT		= 0,
138         OPVP_LINECAP_ROUND		= 1,
139         OPVP_LINECAP_SQUARE		= 2
140 } opvp_linecap_t;
141 
142 typedef enum _opvp_linejoin {
143         OPVP_LINEJOIN_MITER		= 0,
144         OPVP_LINEJOIN_ROUND		= 1,
145         OPVP_LINEJOIN_BEVEL		= 2
146 } opvp_linejoin_t;
147 
148 /* Brush */
149 typedef enum _opvp_bdtype {
150         OPVP_BDTYPE_NORMAL		= 0
151 } opvp_bdtype_t;
152 
153 typedef struct _opvp_brushdata {
154         opvp_bdtype_t type;
155         opvp_int_t width, height, pitch;
156 #if defined(__GNUC__) && __GNUC__ <= 2
157         opvp_byte_t data[1];
158 #elif defined(__SUNPRO_C)
159         opvp_byte_t data[1];
160 #elif defined(__HP_cc)
161         opvp_byte_t data[1];
162 #else
163         opvp_byte_t data[];
164 #endif
165 
166 } opvp_brushdata_t;
167 
168 typedef struct _opvp_brush {
169         opvp_cspace_t colorSpace;
170         opvp_int_t color[4];		/* aRGB quadruplet */
171         opvp_int_t xorg, yorg;		/* brush origin */
172                                         /* ignored for opvpSetBgColor */
173         opvp_brushdata_t *pbrush;	/* pointer to brush data */
174                                         /* solid brush used, if NULL */
175 } opvp_brush_t;
176 
177 /* Misc. Flags */
178 typedef enum _opvp_arcmode {
179         OPVP_ARC			= 0,
180         OPVP_CHORD			= 1,
181         OPVP_PIE			= 2
182 } opvp_arcmode_t;
183 
184 typedef enum _opvp_arcdir {
185         OPVP_CLOCKWISE			= 0,
186         OPVP_COUNTERCLOCKWISE		= 1
187 } opvp_arcdir_t;
188 
189 typedef enum _opvp_pathmode {
190         OPVP_PATHCLOSE			= 0,
191         OPVP_PATHOPEN			= 1
192 } opvp_pathmode_t;
193 
194 /* CTM */
195 typedef struct _opvp_ctm {
196         opvp_float_t a, b, c, d, e, f;
197 } opvp_ctm_t;
198 
199 /* Device Information and Capabilites */
200 typedef enum _opvp_queryinfoflags {
201   OPVP_QF_DEVICERESOLUTION	= 0x00000001,
202   OPVP_QF_MEDIASIZE		= 0x00000002,
203   OPVP_QF_PAGEROTATION		= 0x00000004,
204   OPVP_QF_MEDIANUP		= 0x00000008,
205   OPVP_QF_MEDIADUPLEX		= 0x00000010,
206   OPVP_QF_MEDIASOURCE		= 0x00000020,
207   OPVP_QF_MEDIADESTINATION	= 0x00000040,
208   OPVP_QF_MEDIATYPE		= 0x00000080,
209   OPVP_QF_MEDIACOPY		= 0x00000100, /* Maximum copy number
210                                                  supported */
211   OPVP_QF_PRINTREGION		= 0x00010000  /* only for opvpQueryDeviceInfo */
212 } opvp_queryinfoflags_t;
213 
214 /* API Procedure Entries */
215 typedef	struct _opvp_api_procs {
216         opvp_dc_t     (*opvpOpenPrinter)(opvp_int_t,const opvp_char_t*,const opvp_int_t[2],struct _opvp_api_procs**);
217         opvp_result_t (*opvpClosePrinter)(opvp_dc_t);
218         opvp_result_t (*opvpStartJob)(opvp_dc_t,const opvp_char_t*);
219         opvp_result_t (*opvpEndJob)(opvp_dc_t);
220         opvp_result_t (*opvpAbortJob)(opvp_dc_t);
221         opvp_result_t (*opvpStartDoc)(opvp_dc_t,const opvp_char_t*);
222         opvp_result_t (*opvpEndDoc)(opvp_dc_t);
223         opvp_result_t (*opvpStartPage)(opvp_dc_t,const opvp_char_t*);
224         opvp_result_t (*opvpEndPage)(opvp_dc_t);
225         opvp_result_t (*opvpQueryDeviceCapability)(opvp_dc_t,opvp_flag_t,opvp_int_t*,opvp_byte_t*);
226         opvp_result_t (*opvpQueryDeviceInfo)(opvp_dc_t,opvp_flag_t,opvp_int_t*,opvp_char_t*);
227         opvp_result_t (*opvpResetCTM)(opvp_dc_t);
228         opvp_result_t (*opvpSetCTM)(opvp_dc_t,const opvp_ctm_t*);
229         opvp_result_t (*opvpGetCTM)(opvp_dc_t,opvp_ctm_t*);
230         opvp_result_t (*opvpInitGS)(opvp_dc_t);
231         opvp_result_t (*opvpSaveGS)(opvp_dc_t);
232         opvp_result_t (*opvpRestoreGS)(opvp_dc_t);
233         opvp_result_t (*opvpQueryColorSpace)(opvp_dc_t,opvp_int_t*,opvp_cspace_t*);
234         opvp_result_t (*opvpSetColorSpace)(opvp_dc_t,opvp_cspace_t);
235         opvp_result_t (*opvpGetColorSpace)(opvp_dc_t,opvp_cspace_t*);
236         opvp_result_t (*opvpSetFillMode)(opvp_dc_t,opvp_fillmode_t);
237         opvp_result_t (*opvpGetFillMode)(opvp_dc_t,opvp_fillmode_t*);
238         opvp_result_t (*opvpSetAlphaConstant)(opvp_dc_t,opvp_float_t);
239         opvp_result_t (*opvpGetAlphaConstant)(opvp_dc_t,opvp_float_t*);
240         opvp_result_t (*opvpSetLineWidth)(opvp_dc_t,opvp_fix_t);
241         opvp_result_t (*opvpGetLineWidth)(opvp_dc_t,opvp_fix_t*);
242         opvp_result_t (*opvpSetLineDash)(opvp_dc_t,opvp_int_t,const opvp_fix_t*);
243         opvp_result_t (*opvpGetLineDash)(opvp_dc_t,opvp_int_t*,opvp_fix_t*);
244         opvp_result_t (*opvpSetLineDashOffset)(opvp_dc_t,opvp_fix_t);
245         opvp_result_t (*opvpGetLineDashOffset)(opvp_dc_t,opvp_fix_t*);
246         opvp_result_t (*opvpSetLineStyle)(opvp_dc_t,opvp_linestyle_t);
247         opvp_result_t (*opvpGetLineStyle)(opvp_dc_t,opvp_linestyle_t*);
248         opvp_result_t (*opvpSetLineCap)(opvp_dc_t,opvp_linecap_t);
249         opvp_result_t (*opvpGetLineCap)(opvp_dc_t,opvp_linecap_t*);
250         opvp_result_t (*opvpSetLineJoin)(opvp_dc_t,opvp_linejoin_t);
251         opvp_result_t (*opvpGetLineJoin)(opvp_dc_t,opvp_linejoin_t*);
252         opvp_result_t (*opvpSetMiterLimit)(opvp_dc_t,opvp_fix_t);
253         opvp_result_t (*opvpGetMiterLimit)(opvp_dc_t,opvp_fix_t*);
254         opvp_result_t (*opvpSetPaintMode)(opvp_dc_t,opvp_paintmode_t);
255         opvp_result_t (*opvpGetPaintMode)(opvp_dc_t,opvp_paintmode_t*);
256         opvp_result_t (*opvpSetStrokeColor)(opvp_dc_t,const opvp_brush_t*);
257         opvp_result_t (*opvpSetFillColor)(opvp_dc_t,const opvp_brush_t*);
258         opvp_result_t (*opvpSetBgColor)(opvp_dc_t,const opvp_brush_t*);
259         opvp_result_t (*opvpNewPath)(opvp_dc_t);
260         opvp_result_t (*opvpEndPath)(opvp_dc_t);
261         opvp_result_t (*opvpStrokePath)(opvp_dc_t);
262         opvp_result_t (*opvpFillPath)(opvp_dc_t);
263         opvp_result_t (*opvpStrokeFillPath)(opvp_dc_t);
264         opvp_result_t (*opvpSetClipPath)(opvp_dc_t,opvp_cliprule_t);
265         opvp_result_t (*opvpResetClipPath)(opvp_dc_t);
266         opvp_result_t (*opvpSetCurrentPoint)(opvp_dc_t,opvp_fix_t,opvp_fix_t);
267         opvp_result_t (*opvpLinePath)(opvp_dc_t,opvp_pathmode_t,opvp_int_t,const opvp_point_t*);
268         opvp_result_t (*opvpPolygonPath)(opvp_dc_t,opvp_int_t,const opvp_int_t*,const opvp_point_t*);
269         opvp_result_t (*opvpRectanglePath)(opvp_dc_t,opvp_int_t,const opvp_rectangle_t*);
270         opvp_result_t (*opvpRoundRectanglePath)(opvp_dc_t,opvp_int_t,const opvp_roundrectangle_t*);
271         opvp_result_t (*opvpBezierPath)(opvp_dc_t,opvp_int_t,const opvp_point_t*);
272         opvp_result_t (*opvpArcPath)(opvp_dc_t,opvp_arcmode_t,opvp_arcdir_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t);
273         opvp_result_t (*opvpDrawImage)(opvp_dc_t,opvp_int_t,opvp_int_t,opvp_int_t,opvp_imageformat_t,opvp_int_t, opvp_int_t ,const void*);
274         opvp_result_t (*opvpStartDrawImage)(opvp_dc_t,opvp_int_t,opvp_int_t,opvp_int_t,opvp_imageformat_t,opvp_int_t, opvp_int_t);
275         opvp_result_t (*opvpTransferDrawImage)(opvp_dc_t,opvp_int_t,const void*);
276         opvp_result_t (*opvpEndDrawImage)(opvp_dc_t);
277         opvp_result_t (*opvpStartScanline)(opvp_dc_t,opvp_int_t);
278         opvp_result_t (*opvpScanline)(opvp_dc_t,opvp_int_t,const opvp_int_t*);
279         opvp_result_t (*opvpEndScanline)(opvp_dc_t);
280         opvp_result_t (*opvpStartRaster)(opvp_dc_t,opvp_int_t);
281         opvp_result_t (*opvpTransferRasterData)(opvp_dc_t,opvp_int_t,const opvp_byte_t*);
282         opvp_result_t (*opvpSkipRaster)(opvp_dc_t,opvp_int_t);
283         opvp_result_t (*opvpEndRaster)(opvp_dc_t);
284         opvp_result_t (*opvpStartStream)(opvp_dc_t);
285         opvp_result_t (*opvpTransferStreamData)(opvp_dc_t,opvp_int_t,const void*);
286         opvp_result_t (*opvpEndStream)(opvp_dc_t);
287 } opvp_api_procs_t;
288 
289 /* Function prototype */
290 opvp_dc_t opvpOpenPrinter(
291         opvp_int_t outputFD,
292         const opvp_char_t *printerModel,
293         const opvp_int_t apiVersion[2],
294         opvp_api_procs_t **apiProcs);
295 
296 /* error no */
297 extern opvp_int_t	opvpErrorNo;
298 
299 #endif /* _OPVP_H_ */
300