pixman.h revision 81988197
1b4b94579Smrg/***********************************************************
2b4b94579Smrg
3b4b94579SmrgCopyright 1987, 1998  The Open Group
4b4b94579Smrg
5b4b94579SmrgPermission to use, copy, modify, distribute, and sell this software and its
6b4b94579Smrgdocumentation for any purpose is hereby granted without fee, provided that
7b4b94579Smrgthe above copyright notice appear in all copies and that both that
8b4b94579Smrgcopyright notice and this permission notice appear in supporting
9b4b94579Smrgdocumentation.
10b4b94579Smrg
11b4b94579SmrgThe above copyright notice and this permission notice shall be included in
12b4b94579Smrgall copies or substantial portions of the Software.
13b4b94579Smrg
14b4b94579SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15b4b94579SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16b4b94579SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17b4b94579SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18b4b94579SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19b4b94579SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20b4b94579Smrg
21b4b94579SmrgExcept as contained in this notice, the name of The Open Group shall not be
22b4b94579Smrgused in advertising or otherwise to promote the sale, use or other dealings
23b4b94579Smrgin this Software without prior written authorization from The Open Group.
24b4b94579Smrg
25b4b94579SmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
26b4b94579Smrg
27b4b94579Smrg                        All Rights Reserved
28b4b94579Smrg
29b4b94579SmrgPermission to use, copy, modify, and distribute this software and its
30b4b94579Smrgdocumentation for any purpose and without fee is hereby granted,
31b4b94579Smrgprovided that the above copyright notice appear in all copies and that
32b4b94579Smrgboth that copyright notice and this permission notice appear in
33b4b94579Smrgsupporting documentation, and that the name of Digital not be
34b4b94579Smrgused in advertising or publicity pertaining to distribution of the
35b4b94579Smrgsoftware without specific, written prior permission.
36b4b94579Smrg
37b4b94579SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38b4b94579SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39b4b94579SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40b4b94579SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41b4b94579SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42b4b94579SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43b4b94579SmrgSOFTWARE.
44b4b94579Smrg
45b4b94579Smrg******************************************************************/
46b4b94579Smrg/*
47b4b94579Smrg * Copyright © 1998, 2004 Keith Packard
48b4b94579Smrg * Copyright   2007 Red Hat, Inc.
49b4b94579Smrg *
50b4b94579Smrg * Permission to use, copy, modify, distribute, and sell this software and its
51b4b94579Smrg * documentation for any purpose is hereby granted without fee, provided that
52b4b94579Smrg * the above copyright notice appear in all copies and that both that
53b4b94579Smrg * copyright notice and this permission notice appear in supporting
54b4b94579Smrg * documentation, and that the name of Keith Packard not be used in
55b4b94579Smrg * advertising or publicity pertaining to distribution of the software without
56b4b94579Smrg * specific, written prior permission.  Keith Packard makes no
57b4b94579Smrg * representations about the suitability of this software for any purpose.  It
58b4b94579Smrg * is provided "as is" without express or implied warranty.
59b4b94579Smrg *
60b4b94579Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
61b4b94579Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
62b4b94579Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
63b4b94579Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
64b4b94579Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65b4b94579Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
66b4b94579Smrg * PERFORMANCE OF THIS SOFTWARE.
67b4b94579Smrg */
68b4b94579Smrg
69b4b94579Smrg#ifndef PIXMAN_H__
70b4b94579Smrg#define PIXMAN_H__
71b4b94579Smrg
72b4b94579Smrg#include <pixman-version.h>
73b4b94579Smrg
74952204abSmrg#ifdef  __cplusplus
75952204abSmrg#define PIXMAN_BEGIN_DECLS extern "C" {
76952204abSmrg#define PIXMAN_END_DECLS }
77952204abSmrg#else
78952204abSmrg#define PIXMAN_BEGIN_DECLS
79952204abSmrg#define PIXMAN_END_DECLS
80952204abSmrg#endif
81952204abSmrg
82952204abSmrgPIXMAN_BEGIN_DECLS
83952204abSmrg
84b4b94579Smrg/*
85b4b94579Smrg * Standard integers
86b4b94579Smrg */
87952204abSmrg
88952204abSmrg#if !defined (PIXMAN_DONT_DEFINE_STDINT)
89952204abSmrg
90952204abSmrg#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__) || defined (__HP_cc)
91b4b94579Smrg#  include <inttypes.h>
92952204abSmrg/* VS 2010 (_MSC_VER 1600) has stdint.h */
93952204abSmrg#elif defined (_MSC_VER) && _MSC_VER < 1600
94b4b94579Smrgtypedef __int8 int8_t;
95b4b94579Smrgtypedef unsigned __int8 uint8_t;
96b4b94579Smrgtypedef __int16 int16_t;
97b4b94579Smrgtypedef unsigned __int16 uint16_t;
98b4b94579Smrgtypedef __int32 int32_t;
99b4b94579Smrgtypedef unsigned __int32 uint32_t;
100b4b94579Smrgtypedef __int64 int64_t;
101b4b94579Smrgtypedef unsigned __int64 uint64_t;
10227693ee9Sveego#elif defined (_AIX)
10327693ee9Sveego#  include <sys/inttypes.h>
104b4b94579Smrg#else
105b4b94579Smrg#  include <stdint.h>
106b4b94579Smrg#endif
107b4b94579Smrg
108952204abSmrg#endif
109952204abSmrg
110b4b94579Smrg/*
111b4b94579Smrg * Boolean
112b4b94579Smrg */
113b4b94579Smrgtypedef int pixman_bool_t;
114b4b94579Smrg
115b4b94579Smrg/*
116b4b94579Smrg * Fixpoint numbers
117b4b94579Smrg */
118b4b94579Smrgtypedef int64_t			pixman_fixed_32_32_t;
119b4b94579Smrgtypedef pixman_fixed_32_32_t	pixman_fixed_48_16_t;
120b4b94579Smrgtypedef uint32_t		pixman_fixed_1_31_t;
121b4b94579Smrgtypedef uint32_t		pixman_fixed_1_16_t;
122b4b94579Smrgtypedef int32_t			pixman_fixed_16_16_t;
123b4b94579Smrgtypedef pixman_fixed_16_16_t	pixman_fixed_t;
124b4b94579Smrg
125b4b94579Smrg#define pixman_fixed_e			((pixman_fixed_t) 1)
126b4b94579Smrg#define pixman_fixed_1			(pixman_int_to_fixed(1))
127b4b94579Smrg#define pixman_fixed_1_minus_e		(pixman_fixed_1 - pixman_fixed_e)
128952204abSmrg#define pixman_fixed_minus_1		(pixman_int_to_fixed(-1))
129b4b94579Smrg#define pixman_fixed_to_int(f)		((int) ((f) >> 16))
130b4b94579Smrg#define pixman_int_to_fixed(i)		((pixman_fixed_t) ((i) << 16))
131b4b94579Smrg#define pixman_fixed_to_double(f)	(double) ((f) / (double) pixman_fixed_1)
132b4b94579Smrg#define pixman_double_to_fixed(d)	((pixman_fixed_t) ((d) * 65536.0))
133b4b94579Smrg#define pixman_fixed_frac(f)		((f) & pixman_fixed_1_minus_e)
134b4b94579Smrg#define pixman_fixed_floor(f)		((f) & ~pixman_fixed_1_minus_e)
135b4b94579Smrg#define pixman_fixed_ceil(f)		pixman_fixed_floor ((f) + pixman_fixed_1_minus_e)
136b4b94579Smrg#define pixman_fixed_fraction(f)	((f) & pixman_fixed_1_minus_e)
137b4b94579Smrg#define pixman_fixed_mod_2(f)		((f) & (pixman_fixed1 | pixman_fixed_1_minus_e))
138b4b94579Smrg#define pixman_max_fixed_48_16		((pixman_fixed_48_16_t) 0x7fffffff)
139b4b94579Smrg#define pixman_min_fixed_48_16		(-((pixman_fixed_48_16_t) 1 << 31))
140b4b94579Smrg
141b4b94579Smrg/*
142b4b94579Smrg * Misc structs
143b4b94579Smrg */
144b4b94579Smrgtypedef struct pixman_color pixman_color_t;
145b4b94579Smrgtypedef struct pixman_point_fixed pixman_point_fixed_t;
146b4b94579Smrgtypedef struct pixman_line_fixed pixman_line_fixed_t;
147b4b94579Smrgtypedef struct pixman_vector pixman_vector_t;
148b4b94579Smrgtypedef struct pixman_transform pixman_transform_t;
149b4b94579Smrg
150b4b94579Smrgstruct pixman_color
151b4b94579Smrg{
152b4b94579Smrg    uint16_t	red;
153b4b94579Smrg    uint16_t    green;
154b4b94579Smrg    uint16_t    blue;
155b4b94579Smrg    uint16_t    alpha;
156b4b94579Smrg};
157b4b94579Smrg
158b4b94579Smrgstruct pixman_point_fixed
159b4b94579Smrg{
160b4b94579Smrg    pixman_fixed_t	x;
161b4b94579Smrg    pixman_fixed_t	y;
162b4b94579Smrg};
163b4b94579Smrg
164b4b94579Smrgstruct pixman_line_fixed
165b4b94579Smrg{
166b4b94579Smrg    pixman_point_fixed_t	p1, p2;
167b4b94579Smrg};
168b4b94579Smrg
169317c648bSmrg/*
170317c648bSmrg * Fixed point matrices
171317c648bSmrg */
172317c648bSmrg
173b4b94579Smrgstruct pixman_vector
174b4b94579Smrg{
175b4b94579Smrg    pixman_fixed_t	vector[3];
176b4b94579Smrg};
177b4b94579Smrg
178b4b94579Smrgstruct pixman_transform
179b4b94579Smrg{
180b4b94579Smrg    pixman_fixed_t	matrix[3][3];
181b4b94579Smrg};
182b4b94579Smrg
183317c648bSmrg/* forward declaration (sorry) */
184317c648bSmrgstruct pixman_box16;
185952204abSmrgtypedef  union pixman_image		pixman_image_t;
186317c648bSmrg
187d0321353Smrgvoid          pixman_transform_init_identity    (struct pixman_transform       *matrix);
188d0321353Smrgpixman_bool_t pixman_transform_point_3d         (const struct pixman_transform *transform,
189d0321353Smrg						 struct pixman_vector          *vector);
190d0321353Smrgpixman_bool_t pixman_transform_point            (const struct pixman_transform *transform,
191d0321353Smrg						 struct pixman_vector          *vector);
192d0321353Smrgpixman_bool_t pixman_transform_multiply         (struct pixman_transform       *dst,
193d0321353Smrg						 const struct pixman_transform *l,
194d0321353Smrg						 const struct pixman_transform *r);
195d0321353Smrgvoid          pixman_transform_init_scale       (struct pixman_transform       *t,
196d0321353Smrg						 pixman_fixed_t                 sx,
197d0321353Smrg						 pixman_fixed_t                 sy);
198d0321353Smrgpixman_bool_t pixman_transform_scale            (struct pixman_transform       *forward,
199d0321353Smrg						 struct pixman_transform       *reverse,
200d0321353Smrg						 pixman_fixed_t                 sx,
201d0321353Smrg						 pixman_fixed_t                 sy);
202d0321353Smrgvoid          pixman_transform_init_rotate      (struct pixman_transform       *t,
203d0321353Smrg						 pixman_fixed_t                 cos,
204d0321353Smrg						 pixman_fixed_t                 sin);
205d0321353Smrgpixman_bool_t pixman_transform_rotate           (struct pixman_transform       *forward,
206d0321353Smrg						 struct pixman_transform       *reverse,
207d0321353Smrg						 pixman_fixed_t                 c,
208d0321353Smrg						 pixman_fixed_t                 s);
209d0321353Smrgvoid          pixman_transform_init_translate   (struct pixman_transform       *t,
210d0321353Smrg						 pixman_fixed_t                 tx,
211d0321353Smrg						 pixman_fixed_t                 ty);
212d0321353Smrgpixman_bool_t pixman_transform_translate        (struct pixman_transform       *forward,
213d0321353Smrg						 struct pixman_transform       *reverse,
214d0321353Smrg						 pixman_fixed_t                 tx,
215d0321353Smrg						 pixman_fixed_t                 ty);
216d0321353Smrgpixman_bool_t pixman_transform_bounds           (const struct pixman_transform *matrix,
217d0321353Smrg						 struct pixman_box16           *b);
218d0321353Smrgpixman_bool_t pixman_transform_invert           (struct pixman_transform       *dst,
219d0321353Smrg						 const struct pixman_transform *src);
220d0321353Smrgpixman_bool_t pixman_transform_is_identity      (const struct pixman_transform *t);
221d0321353Smrgpixman_bool_t pixman_transform_is_scale         (const struct pixman_transform *t);
222d0321353Smrgpixman_bool_t pixman_transform_is_int_translate (const struct pixman_transform *t);
223d0321353Smrgpixman_bool_t pixman_transform_is_inverse       (const struct pixman_transform *a,
224d0321353Smrg						 const struct pixman_transform *b);
225317c648bSmrg
226317c648bSmrg/*
227317c648bSmrg * Floating point matrices
228317c648bSmrg */
229d0321353Smrgstruct pixman_f_vector
230d0321353Smrg{
231317c648bSmrg    double  v[3];
232317c648bSmrg};
233317c648bSmrg
234d0321353Smrgstruct pixman_f_transform
235d0321353Smrg{
236317c648bSmrg    double  m[3][3];
237317c648bSmrg};
238317c648bSmrg
239d0321353Smrgpixman_bool_t pixman_transform_from_pixman_f_transform (struct pixman_transform         *t,
240d0321353Smrg							const struct pixman_f_transform *ft);
241d0321353Smrgvoid          pixman_f_transform_from_pixman_transform (struct pixman_f_transform       *ft,
242d0321353Smrg							const struct pixman_transform   *t);
243d0321353Smrgpixman_bool_t pixman_f_transform_invert                (struct pixman_f_transform       *dst,
244d0321353Smrg							const struct pixman_f_transform *src);
245d0321353Smrgpixman_bool_t pixman_f_transform_point                 (const struct pixman_f_transform *t,
246d0321353Smrg							struct pixman_f_vector          *v);
247d0321353Smrgvoid          pixman_f_transform_point_3d              (const struct pixman_f_transform *t,
248d0321353Smrg							struct pixman_f_vector          *v);
249d0321353Smrgvoid          pixman_f_transform_multiply              (struct pixman_f_transform       *dst,
250d0321353Smrg							const struct pixman_f_transform *l,
251d0321353Smrg							const struct pixman_f_transform *r);
252d0321353Smrgvoid          pixman_f_transform_init_scale            (struct pixman_f_transform       *t,
253d0321353Smrg							double                           sx,
254d0321353Smrg							double                           sy);
255d0321353Smrgpixman_bool_t pixman_f_transform_scale                 (struct pixman_f_transform       *forward,
256d0321353Smrg							struct pixman_f_transform       *reverse,
257d0321353Smrg							double                           sx,
258d0321353Smrg							double                           sy);
259d0321353Smrgvoid          pixman_f_transform_init_rotate           (struct pixman_f_transform       *t,
260d0321353Smrg							double                           cos,
261d0321353Smrg							double                           sin);
262d0321353Smrgpixman_bool_t pixman_f_transform_rotate                (struct pixman_f_transform       *forward,
263d0321353Smrg							struct pixman_f_transform       *reverse,
264d0321353Smrg							double                           c,
265d0321353Smrg							double                           s);
266d0321353Smrgvoid          pixman_f_transform_init_translate        (struct pixman_f_transform       *t,
267d0321353Smrg							double                           tx,
268d0321353Smrg							double                           ty);
269d0321353Smrgpixman_bool_t pixman_f_transform_translate             (struct pixman_f_transform       *forward,
270d0321353Smrg							struct pixman_f_transform       *reverse,
271d0321353Smrg							double                           tx,
272d0321353Smrg							double                           ty);
273d0321353Smrgpixman_bool_t pixman_f_transform_bounds                (const struct pixman_f_transform *t,
274d0321353Smrg							struct pixman_box16             *b);
275d0321353Smrgvoid          pixman_f_transform_init_identity         (struct pixman_f_transform       *t);
276317c648bSmrg
277b4b94579Smrgtypedef enum
278b4b94579Smrg{
279b4b94579Smrg    PIXMAN_REPEAT_NONE,
280b4b94579Smrg    PIXMAN_REPEAT_NORMAL,
281b4b94579Smrg    PIXMAN_REPEAT_PAD,
282b4b94579Smrg    PIXMAN_REPEAT_REFLECT
283b4b94579Smrg} pixman_repeat_t;
284b4b94579Smrg
285b4b94579Smrgtypedef enum
286b4b94579Smrg{
287b4b94579Smrg    PIXMAN_FILTER_FAST,
288b4b94579Smrg    PIXMAN_FILTER_GOOD,
289b4b94579Smrg    PIXMAN_FILTER_BEST,
290b4b94579Smrg    PIXMAN_FILTER_NEAREST,
291b4b94579Smrg    PIXMAN_FILTER_BILINEAR,
292b4b94579Smrg    PIXMAN_FILTER_CONVOLUTION
293b4b94579Smrg} pixman_filter_t;
294b4b94579Smrg
295b4b94579Smrgtypedef enum
296b4b94579Smrg{
297b4b94579Smrg    PIXMAN_OP_CLEAR			= 0x00,
298b4b94579Smrg    PIXMAN_OP_SRC			= 0x01,
299b4b94579Smrg    PIXMAN_OP_DST			= 0x02,
300b4b94579Smrg    PIXMAN_OP_OVER			= 0x03,
301b4b94579Smrg    PIXMAN_OP_OVER_REVERSE		= 0x04,
302b4b94579Smrg    PIXMAN_OP_IN			= 0x05,
303b4b94579Smrg    PIXMAN_OP_IN_REVERSE		= 0x06,
304b4b94579Smrg    PIXMAN_OP_OUT			= 0x07,
305b4b94579Smrg    PIXMAN_OP_OUT_REVERSE		= 0x08,
306b4b94579Smrg    PIXMAN_OP_ATOP			= 0x09,
307b4b94579Smrg    PIXMAN_OP_ATOP_REVERSE		= 0x0a,
308b4b94579Smrg    PIXMAN_OP_XOR			= 0x0b,
309b4b94579Smrg    PIXMAN_OP_ADD			= 0x0c,
310b4b94579Smrg    PIXMAN_OP_SATURATE			= 0x0d,
311b4b94579Smrg
312b4b94579Smrg    PIXMAN_OP_DISJOINT_CLEAR		= 0x10,
313b4b94579Smrg    PIXMAN_OP_DISJOINT_SRC		= 0x11,
314b4b94579Smrg    PIXMAN_OP_DISJOINT_DST		= 0x12,
315b4b94579Smrg    PIXMAN_OP_DISJOINT_OVER		= 0x13,
316b4b94579Smrg    PIXMAN_OP_DISJOINT_OVER_REVERSE	= 0x14,
317b4b94579Smrg    PIXMAN_OP_DISJOINT_IN		= 0x15,
318b4b94579Smrg    PIXMAN_OP_DISJOINT_IN_REVERSE	= 0x16,
319b4b94579Smrg    PIXMAN_OP_DISJOINT_OUT		= 0x17,
320b4b94579Smrg    PIXMAN_OP_DISJOINT_OUT_REVERSE	= 0x18,
321b4b94579Smrg    PIXMAN_OP_DISJOINT_ATOP		= 0x19,
322b4b94579Smrg    PIXMAN_OP_DISJOINT_ATOP_REVERSE	= 0x1a,
323b4b94579Smrg    PIXMAN_OP_DISJOINT_XOR		= 0x1b,
324b4b94579Smrg
325b4b94579Smrg    PIXMAN_OP_CONJOINT_CLEAR		= 0x20,
326b4b94579Smrg    PIXMAN_OP_CONJOINT_SRC		= 0x21,
327b4b94579Smrg    PIXMAN_OP_CONJOINT_DST		= 0x22,
328b4b94579Smrg    PIXMAN_OP_CONJOINT_OVER		= 0x23,
329b4b94579Smrg    PIXMAN_OP_CONJOINT_OVER_REVERSE	= 0x24,
330b4b94579Smrg    PIXMAN_OP_CONJOINT_IN		= 0x25,
331b4b94579Smrg    PIXMAN_OP_CONJOINT_IN_REVERSE	= 0x26,
332b4b94579Smrg    PIXMAN_OP_CONJOINT_OUT		= 0x27,
333b4b94579Smrg    PIXMAN_OP_CONJOINT_OUT_REVERSE	= 0x28,
334b4b94579Smrg    PIXMAN_OP_CONJOINT_ATOP		= 0x29,
335b4b94579Smrg    PIXMAN_OP_CONJOINT_ATOP_REVERSE	= 0x2a,
336b4b94579Smrg    PIXMAN_OP_CONJOINT_XOR		= 0x2b,
337b4b94579Smrg
338dc259aabSmrg    PIXMAN_OP_MULTIPLY                  = 0x30,
339dc259aabSmrg    PIXMAN_OP_SCREEN                    = 0x31,
340dc259aabSmrg    PIXMAN_OP_OVERLAY                   = 0x32,
341dc259aabSmrg    PIXMAN_OP_DARKEN                    = 0x33,
342dc259aabSmrg    PIXMAN_OP_LIGHTEN                   = 0x34,
343dc259aabSmrg    PIXMAN_OP_COLOR_DODGE               = 0x35,
344dc259aabSmrg    PIXMAN_OP_COLOR_BURN                = 0x36,
345dc259aabSmrg    PIXMAN_OP_HARD_LIGHT                = 0x37,
346dc259aabSmrg    PIXMAN_OP_SOFT_LIGHT                = 0x38,
347dc259aabSmrg    PIXMAN_OP_DIFFERENCE                = 0x39,
348dc259aabSmrg    PIXMAN_OP_EXCLUSION                 = 0x3a,
349dc259aabSmrg    PIXMAN_OP_HSL_HUE			= 0x3b,
350dc259aabSmrg    PIXMAN_OP_HSL_SATURATION		= 0x3c,
351dc259aabSmrg    PIXMAN_OP_HSL_COLOR			= 0x3d,
352952204abSmrg    PIXMAN_OP_HSL_LUMINOSITY		= 0x3e
353dc259aabSmrg
354952204abSmrg#ifdef PIXMAN_USE_INTERNAL_API
355952204abSmrg    ,
356952204abSmrg    PIXMAN_N_OPERATORS,
357afd9aa65Sapb    PIXMAN_OP_NONE = PIXMAN_N_OPERATORS,
358afd9aa65Sapb    PIXMAN_OP_any = PIXMAN_N_OPERATORS + 1
359952204abSmrg#endif
360b4b94579Smrg} pixman_op_t;
361b4b94579Smrg
362b4b94579Smrg/*
363b4b94579Smrg * Regions
364b4b94579Smrg */
365b4b94579Smrgtypedef struct pixman_region16_data	pixman_region16_data_t;
366b4b94579Smrgtypedef struct pixman_box16		pixman_box16_t;
367b4b94579Smrgtypedef struct pixman_rectangle16	pixman_rectangle16_t;
368b4b94579Smrgtypedef struct pixman_region16		pixman_region16_t;
369b4b94579Smrg
370b4b94579Smrgstruct pixman_region16_data {
371b4b94579Smrg    long		size;
372b4b94579Smrg    long		numRects;
373b4b94579Smrg/*  pixman_box16_t	rects[size];   in memory but not explicitly declared */
374b4b94579Smrg};
375b4b94579Smrg
376b4b94579Smrgstruct pixman_rectangle16
377b4b94579Smrg{
378d0321353Smrg    int16_t	x, y;
379d0321353Smrg    uint16_t	width, height;
380b4b94579Smrg};
381b4b94579Smrg
382b4b94579Smrgstruct pixman_box16
383b4b94579Smrg{
384b4b94579Smrg    int16_t x1, y1, x2, y2;
385b4b94579Smrg};
386b4b94579Smrg
387b4b94579Smrgstruct pixman_region16
388b4b94579Smrg{
389b4b94579Smrg    pixman_box16_t          extents;
390d0321353Smrg    pixman_region16_data_t *data;
391b4b94579Smrg};
392b4b94579Smrg
393b4b94579Smrgtypedef enum
394b4b94579Smrg{
395b4b94579Smrg    PIXMAN_REGION_OUT,
396b4b94579Smrg    PIXMAN_REGION_IN,
397b4b94579Smrg    PIXMAN_REGION_PART
398b4b94579Smrg} pixman_region_overlap_t;
399b4b94579Smrg
400d0321353Smrg/* This function exists only to make it possible to preserve
401d0321353Smrg * the X ABI - it should go away at first opportunity.
402b4b94579Smrg */
403d0321353Smrgvoid pixman_region_set_static_pointers (pixman_box16_t         *empty_box,
404d0321353Smrg					pixman_region16_data_t *empty_data,
405d0321353Smrg					pixman_region16_data_t *broken_data);
406b4b94579Smrg
407b4b94579Smrg/* creation/destruction */
408d0321353Smrgvoid                    pixman_region_init               (pixman_region16_t *region);
409d0321353Smrgvoid                    pixman_region_init_rect          (pixman_region16_t *region,
410d0321353Smrg							  int                x,
411d0321353Smrg							  int                y,
412d0321353Smrg							  unsigned int       width,
413d0321353Smrg							  unsigned int       height);
414d0321353Smrgpixman_bool_t           pixman_region_init_rects         (pixman_region16_t *region,
415952204abSmrg							  const pixman_box16_t *boxes,
416d0321353Smrg							  int                count);
417d0321353Smrgvoid                    pixman_region_init_with_extents  (pixman_region16_t *region,
418d0321353Smrg							  pixman_box16_t    *extents);
419952204abSmrgvoid                    pixman_region_init_from_image    (pixman_region16_t *region,
420952204abSmrg							  pixman_image_t    *image);
421d0321353Smrgvoid                    pixman_region_fini               (pixman_region16_t *region);
422b4b94579Smrg
423b4b94579Smrg
424d0321353Smrg/* manipulation */
425d0321353Smrgvoid                    pixman_region_translate          (pixman_region16_t *region,
426d0321353Smrg							  int                x,
427d0321353Smrg							  int                y);
428d0321353Smrgpixman_bool_t           pixman_region_copy               (pixman_region16_t *dest,
429d0321353Smrg							  pixman_region16_t *source);
430d0321353Smrgpixman_bool_t           pixman_region_intersect          (pixman_region16_t *new_reg,
431d0321353Smrg							  pixman_region16_t *reg1,
432d0321353Smrg							  pixman_region16_t *reg2);
433d0321353Smrgpixman_bool_t           pixman_region_union              (pixman_region16_t *new_reg,
434d0321353Smrg							  pixman_region16_t *reg1,
435d0321353Smrg							  pixman_region16_t *reg2);
436d0321353Smrgpixman_bool_t           pixman_region_union_rect         (pixman_region16_t *dest,
437d0321353Smrg							  pixman_region16_t *source,
438d0321353Smrg							  int                x,
439d0321353Smrg							  int                y,
440d0321353Smrg							  unsigned int       width,
441d0321353Smrg							  unsigned int       height);
4421b18d63aSmrgpixman_bool_t		pixman_region_intersect_rect     (pixman_region16_t *dest,
4431b18d63aSmrg							  pixman_region16_t *source,
4441b18d63aSmrg							  int                x,
4451b18d63aSmrg							  int                y,
4461b18d63aSmrg							  unsigned int       width,
4471b18d63aSmrg							  unsigned int       height);
448d0321353Smrgpixman_bool_t           pixman_region_subtract           (pixman_region16_t *reg_d,
449d0321353Smrg							  pixman_region16_t *reg_m,
450d0321353Smrg							  pixman_region16_t *reg_s);
451d0321353Smrgpixman_bool_t           pixman_region_inverse            (pixman_region16_t *new_reg,
452d0321353Smrg							  pixman_region16_t *reg1,
453d0321353Smrg							  pixman_box16_t    *inv_rect);
454d0321353Smrgpixman_bool_t           pixman_region_contains_point     (pixman_region16_t *region,
455d0321353Smrg							  int                x,
456d0321353Smrg							  int                y,
457d0321353Smrg							  pixman_box16_t    *box);
458952204abSmrgpixman_region_overlap_t pixman_region_contains_rectangle (pixman_region16_t *region,
459d0321353Smrg							  pixman_box16_t    *prect);
460d0321353Smrgpixman_bool_t           pixman_region_not_empty          (pixman_region16_t *region);
461d0321353Smrgpixman_box16_t *        pixman_region_extents            (pixman_region16_t *region);
462d0321353Smrgint                     pixman_region_n_rects            (pixman_region16_t *region);
463d0321353Smrgpixman_box16_t *        pixman_region_rectangles         (pixman_region16_t *region,
464d0321353Smrg							  int               *n_rects);
465d0321353Smrgpixman_bool_t           pixman_region_equal              (pixman_region16_t *region1,
466d0321353Smrg							  pixman_region16_t *region2);
467d0321353Smrgpixman_bool_t           pixman_region_selfcheck          (pixman_region16_t *region);
468d0321353Smrgvoid                    pixman_region_reset              (pixman_region16_t *region,
469d0321353Smrg							  pixman_box16_t    *box);
47081988197Sjmcneillvoid			pixman_region_clear		 (pixman_region16_t *region);
471b4b94579Smrg/*
472b4b94579Smrg * 32 bit regions
473b4b94579Smrg */
474b4b94579Smrgtypedef struct pixman_region32_data	pixman_region32_data_t;
475b4b94579Smrgtypedef struct pixman_box32		pixman_box32_t;
476b4b94579Smrgtypedef struct pixman_rectangle32	pixman_rectangle32_t;
477b4b94579Smrgtypedef struct pixman_region32		pixman_region32_t;
478b4b94579Smrg
479b4b94579Smrgstruct pixman_region32_data {
480b4b94579Smrg    long		size;
481b4b94579Smrg    long		numRects;
482b4b94579Smrg/*  pixman_box32_t	rects[size];   in memory but not explicitly declared */
483b4b94579Smrg};
484b4b94579Smrg
485b4b94579Smrgstruct pixman_rectangle32
486b4b94579Smrg{
487b4b94579Smrg    int32_t x, y;
488b4b94579Smrg    uint32_t width, height;
489b4b94579Smrg};
490b4b94579Smrg
491b4b94579Smrgstruct pixman_box32
492b4b94579Smrg{
493b4b94579Smrg    int32_t x1, y1, x2, y2;
494b4b94579Smrg};
495b4b94579Smrg
496b4b94579Smrgstruct pixman_region32
497b4b94579Smrg{
498b4b94579Smrg    pixman_box32_t          extents;
499b4b94579Smrg    pixman_region32_data_t  *data;
500b4b94579Smrg};
501b4b94579Smrg
502b4b94579Smrg/* creation/destruction */
503b4b94579Smrgvoid                    pixman_region32_init               (pixman_region32_t *region);
504b4b94579Smrgvoid                    pixman_region32_init_rect          (pixman_region32_t *region,
505b4b94579Smrg							    int                x,
506b4b94579Smrg							    int                y,
507b4b94579Smrg							    unsigned int       width,
508b4b94579Smrg							    unsigned int       height);
509b4b94579Smrgpixman_bool_t           pixman_region32_init_rects         (pixman_region32_t *region,
510952204abSmrg							    const pixman_box32_t *boxes,
511b4b94579Smrg							    int                count);
512b4b94579Smrgvoid                    pixman_region32_init_with_extents  (pixman_region32_t *region,
513b4b94579Smrg							    pixman_box32_t    *extents);
514952204abSmrgvoid                    pixman_region32_init_from_image    (pixman_region32_t *region,
515952204abSmrg							    pixman_image_t    *image);
516b4b94579Smrgvoid                    pixman_region32_fini               (pixman_region32_t *region);
517b4b94579Smrg
518b4b94579Smrg
519b4b94579Smrg/* manipulation */
520b4b94579Smrgvoid                    pixman_region32_translate          (pixman_region32_t *region,
521b4b94579Smrg							    int                x,
522b4b94579Smrg							    int                y);
523b4b94579Smrgpixman_bool_t           pixman_region32_copy               (pixman_region32_t *dest,
524b4b94579Smrg							    pixman_region32_t *source);
525d0321353Smrgpixman_bool_t           pixman_region32_intersect          (pixman_region32_t *new_reg,
526b4b94579Smrg							    pixman_region32_t *reg1,
527b4b94579Smrg							    pixman_region32_t *reg2);
528d0321353Smrgpixman_bool_t           pixman_region32_union              (pixman_region32_t *new_reg,
529b4b94579Smrg							    pixman_region32_t *reg1,
530b4b94579Smrg							    pixman_region32_t *reg2);
5311b18d63aSmrgpixman_bool_t		pixman_region32_intersect_rect     (pixman_region32_t *dest,
5321b18d63aSmrg							    pixman_region32_t *source,
5331b18d63aSmrg							    int                x,
5341b18d63aSmrg							    int                y,
5351b18d63aSmrg							    unsigned int       width,
5361b18d63aSmrg							    unsigned int       height);
537b4b94579Smrgpixman_bool_t           pixman_region32_union_rect         (pixman_region32_t *dest,
538b4b94579Smrg							    pixman_region32_t *source,
539b4b94579Smrg							    int                x,
540b4b94579Smrg							    int                y,
541b4b94579Smrg							    unsigned int       width,
542b4b94579Smrg							    unsigned int       height);
543d0321353Smrgpixman_bool_t           pixman_region32_subtract           (pixman_region32_t *reg_d,
544d0321353Smrg							    pixman_region32_t *reg_m,
545d0321353Smrg							    pixman_region32_t *reg_s);
546d0321353Smrgpixman_bool_t           pixman_region32_inverse            (pixman_region32_t *new_reg,
547b4b94579Smrg							    pixman_region32_t *reg1,
548d0321353Smrg							    pixman_box32_t    *inv_rect);
549b4b94579Smrgpixman_bool_t           pixman_region32_contains_point     (pixman_region32_t *region,
550b4b94579Smrg							    int                x,
551b4b94579Smrg							    int                y,
552b4b94579Smrg							    pixman_box32_t    *box);
553b4b94579Smrgpixman_region_overlap_t pixman_region32_contains_rectangle (pixman_region32_t *region,
554b4b94579Smrg							    pixman_box32_t    *prect);
555b4b94579Smrgpixman_bool_t           pixman_region32_not_empty          (pixman_region32_t *region);
556b4b94579Smrgpixman_box32_t *        pixman_region32_extents            (pixman_region32_t *region);
557b4b94579Smrgint                     pixman_region32_n_rects            (pixman_region32_t *region);
558b4b94579Smrgpixman_box32_t *        pixman_region32_rectangles         (pixman_region32_t *region,
559b4b94579Smrg							    int               *n_rects);
560b4b94579Smrgpixman_bool_t           pixman_region32_equal              (pixman_region32_t *region1,
561b4b94579Smrg							    pixman_region32_t *region2);
562b4b94579Smrgpixman_bool_t           pixman_region32_selfcheck          (pixman_region32_t *region);
563b4b94579Smrgvoid                    pixman_region32_reset              (pixman_region32_t *region,
564b4b94579Smrg							    pixman_box32_t    *box);
56581988197Sjmcneillvoid			pixman_region32_clear		   (pixman_region32_t *region);
566b4b94579Smrg
567b4b94579Smrg
568b4b94579Smrg/* Copy / Fill / Misc */
569b4b94579Smrgpixman_bool_t pixman_blt                (uint32_t           *src_bits,
570b4b94579Smrg					 uint32_t           *dst_bits,
571b4b94579Smrg					 int                 src_stride,
572b4b94579Smrg					 int                 dst_stride,
573b4b94579Smrg					 int                 src_bpp,
574b4b94579Smrg					 int                 dst_bpp,
575b4b94579Smrg					 int                 src_x,
576b4b94579Smrg					 int                 src_y,
5776ba797d6Smrg					 int                 dest_x,
5786ba797d6Smrg					 int                 dest_y,
579b4b94579Smrg					 int                 width,
580b4b94579Smrg					 int                 height);
581b4b94579Smrgpixman_bool_t pixman_fill               (uint32_t           *bits,
582b4b94579Smrg					 int                 stride,
583b4b94579Smrg					 int                 bpp,
584b4b94579Smrg					 int                 x,
585b4b94579Smrg					 int                 y,
586b4b94579Smrg					 int                 width,
587b4b94579Smrg					 int                 height,
588b4b94579Smrg					 uint32_t            _xor);
589b4b94579Smrg
590b4b94579Smrgint           pixman_version            (void);
591b4b94579Smrgconst char*   pixman_version_string     (void);
592b4b94579Smrg
593b4b94579Smrg/*
594b4b94579Smrg * Images
595b4b94579Smrg */
596b4b94579Smrgtypedef struct pixman_indexed		pixman_indexed_t;
597b4b94579Smrgtypedef struct pixman_gradient_stop	pixman_gradient_stop_t;
598b4b94579Smrg
599b4b94579Smrgtypedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size);
600b4b94579Smrgtypedef void     (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size);
601b4b94579Smrg
602dc259aabSmrgtypedef void     (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data);
603dc259aabSmrg
604b4b94579Smrgstruct pixman_gradient_stop {
605b4b94579Smrg    pixman_fixed_t x;
606b4b94579Smrg    pixman_color_t color;
607b4b94579Smrg};
608b4b94579Smrg
609b4b94579Smrg#define PIXMAN_MAX_INDEXED  256 /* XXX depth must be <= 8 */
610b4b94579Smrg
611b4b94579Smrg#if PIXMAN_MAX_INDEXED <= 256
612b4b94579Smrgtypedef uint8_t pixman_index_type;
613b4b94579Smrg#endif
614b4b94579Smrg
615b4b94579Smrgstruct pixman_indexed
616b4b94579Smrg{
617b4b94579Smrg    pixman_bool_t       color;
618b4b94579Smrg    uint32_t		rgba[PIXMAN_MAX_INDEXED];
619b4b94579Smrg    pixman_index_type	ent[32768];
620b4b94579Smrg};
621b4b94579Smrg
622b4b94579Smrg/*
623b4b94579Smrg * While the protocol is generous in format support, the
624b4b94579Smrg * sample implementation allows only packed RGB and GBR
625b4b94579Smrg * representations for data to simplify software rendering,
626b4b94579Smrg */
627b4b94579Smrg#define PIXMAN_FORMAT(bpp,type,a,r,g,b)	(((bpp) << 24) |  \
628b4b94579Smrg					 ((type) << 16) | \
629b4b94579Smrg					 ((a) << 12) |	  \
630b4b94579Smrg					 ((r) << 8) |	  \
631b4b94579Smrg					 ((g) << 4) |	  \
632b4b94579Smrg					 ((b)))
633b4b94579Smrg
634b4b94579Smrg#define PIXMAN_FORMAT_BPP(f)	(((f) >> 24)       )
635b4b94579Smrg#define PIXMAN_FORMAT_TYPE(f)	(((f) >> 16) & 0xff)
636b4b94579Smrg#define PIXMAN_FORMAT_A(f)	(((f) >> 12) & 0x0f)
637b4b94579Smrg#define PIXMAN_FORMAT_R(f)	(((f) >>  8) & 0x0f)
638b4b94579Smrg#define PIXMAN_FORMAT_G(f)	(((f) >>  4) & 0x0f)
639b4b94579Smrg#define PIXMAN_FORMAT_B(f)	(((f)      ) & 0x0f)
640b4b94579Smrg#define PIXMAN_FORMAT_RGB(f)	(((f)      ) & 0xfff)
641b4b94579Smrg#define PIXMAN_FORMAT_VIS(f)	(((f)      ) & 0xffff)
642b4b94579Smrg#define PIXMAN_FORMAT_DEPTH(f)	(PIXMAN_FORMAT_A(f) +	\
643b4b94579Smrg				 PIXMAN_FORMAT_R(f) +	\
644b4b94579Smrg				 PIXMAN_FORMAT_G(f) +	\
645b4b94579Smrg				 PIXMAN_FORMAT_B(f))
646b4b94579Smrg
647b4b94579Smrg#define PIXMAN_TYPE_OTHER	0
648b4b94579Smrg#define PIXMAN_TYPE_A		1
649b4b94579Smrg#define PIXMAN_TYPE_ARGB	2
650b4b94579Smrg#define PIXMAN_TYPE_ABGR	3
651b4b94579Smrg#define PIXMAN_TYPE_COLOR	4
652b4b94579Smrg#define PIXMAN_TYPE_GRAY	5
653b4b94579Smrg#define PIXMAN_TYPE_YUY2	6
654b4b94579Smrg#define PIXMAN_TYPE_YV12	7
655317c648bSmrg#define PIXMAN_TYPE_BGRA	8
6566ba797d6Smrg#define PIXMAN_TYPE_RGBA	9
65781988197Sjmcneill#define PIXMAN_TYPE_ARGB_SRGB	10
658b4b94579Smrg
659317c648bSmrg#define PIXMAN_FORMAT_COLOR(f)				\
660317c648bSmrg	(PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB ||	\
661317c648bSmrg	 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ABGR ||	\
6626ba797d6Smrg	 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_BGRA ||	\
6636ba797d6Smrg	 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA)
664b4b94579Smrg
665b4b94579Smrg/* 32bpp formats */
666b4b94579Smrgtypedef enum {
667d0321353Smrg    PIXMAN_a8r8g8b8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8),
668d0321353Smrg    PIXMAN_x8r8g8b8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8),
669d0321353Smrg    PIXMAN_a8b8g8r8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8),
670d0321353Smrg    PIXMAN_x8b8g8r8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8),
671d0321353Smrg    PIXMAN_b8g8r8a8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8),
672d0321353Smrg    PIXMAN_b8g8r8x8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8),
6736ba797d6Smrg    PIXMAN_r8g8b8a8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8),
6746ba797d6Smrg    PIXMAN_r8g8b8x8 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8),
6751b18d63aSmrg    PIXMAN_x14r6g6b6 =	 PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6),
676d0321353Smrg    PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10),
677d0321353Smrg    PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10),
67827693ee9Sveego    PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
67927693ee9Sveego    PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
68027693ee9Sveego
68181988197Sjmcneill/* sRGB formats */
68281988197Sjmcneill    PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8),
68381988197Sjmcneill
684b4b94579Smrg/* 24bpp formats */
685d0321353Smrg    PIXMAN_r8g8b8 =	 PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),
686d0321353Smrg    PIXMAN_b8g8r8 =	 PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8),
687952204abSmrg
688b4b94579Smrg/* 16bpp formats */
689d0321353Smrg    PIXMAN_r5g6b5 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5),
690d0321353Smrg    PIXMAN_b5g6r5 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5),
691952204abSmrg
692d0321353Smrg    PIXMAN_a1r5g5b5 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5),
693d0321353Smrg    PIXMAN_x1r5g5b5 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5),
694d0321353Smrg    PIXMAN_a1b5g5r5 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5),
695d0321353Smrg    PIXMAN_x1b5g5r5 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5),
696d0321353Smrg    PIXMAN_a4r4g4b4 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4),
697d0321353Smrg    PIXMAN_x4r4g4b4 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4),
698d0321353Smrg    PIXMAN_a4b4g4r4 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4),
699d0321353Smrg    PIXMAN_x4b4g4r4 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4),
700952204abSmrg
701b4b94579Smrg/* 8bpp formats */
702d0321353Smrg    PIXMAN_a8 =		 PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0),
703d0321353Smrg    PIXMAN_r3g3b2 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2),
704d0321353Smrg    PIXMAN_b2g3r3 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2),
705d0321353Smrg    PIXMAN_a2r2g2b2 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2),
706d0321353Smrg    PIXMAN_a2b2g2r2 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2),
707952204abSmrg
708d0321353Smrg    PIXMAN_c8 =		 PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
709d0321353Smrg    PIXMAN_g8 =		 PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
710952204abSmrg
711d0321353Smrg    PIXMAN_x4a4 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0),
712952204abSmrg
713d0321353Smrg    PIXMAN_x4c4 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
714d0321353Smrg    PIXMAN_x4g4 =	 PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
715952204abSmrg
716b4b94579Smrg/* 4bpp formats */
717d0321353Smrg    PIXMAN_a4 =		 PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0),
718d0321353Smrg    PIXMAN_r1g2b1 =	 PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1),
719d0321353Smrg    PIXMAN_b1g2r1 =	 PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1),
720d0321353Smrg    PIXMAN_a1r1g1b1 =	 PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1),
721d0321353Smrg    PIXMAN_a1b1g1r1 =	 PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1),
722952204abSmrg
723d0321353Smrg    PIXMAN_c4 =		 PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0),
724d0321353Smrg    PIXMAN_g4 =		 PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0),
725952204abSmrg
726b4b94579Smrg/* 1bpp formats */
727d0321353Smrg    PIXMAN_a1 =		 PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0),
728952204abSmrg
729d0321353Smrg    PIXMAN_g1 =		 PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
730b4b94579Smrg
731b4b94579Smrg/* YUV formats */
732d0321353Smrg    PIXMAN_yuy2 =	 PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0),
733d0321353Smrg    PIXMAN_yv12 =	 PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0)
734b4b94579Smrg} pixman_format_code_t;
735b4b94579Smrg
736b4b94579Smrg/* Querying supported format values. */
737b4b94579Smrgpixman_bool_t pixman_format_supported_destination (pixman_format_code_t format);
738b4b94579Smrgpixman_bool_t pixman_format_supported_source      (pixman_format_code_t format);
739b4b94579Smrg
740b4b94579Smrg/* Constructors */
74181988197Sjmcneillpixman_image_t *pixman_image_create_solid_fill       (const pixman_color_t         *color);
74281988197Sjmcneillpixman_image_t *pixman_image_create_linear_gradient  (const pixman_point_fixed_t   *p1,
74381988197Sjmcneill						      const pixman_point_fixed_t   *p2,
744b4b94579Smrg						      const pixman_gradient_stop_t *stops,
745b4b94579Smrg						      int                           n_stops);
74681988197Sjmcneillpixman_image_t *pixman_image_create_radial_gradient  (const pixman_point_fixed_t   *inner,
74781988197Sjmcneill						      const pixman_point_fixed_t   *outer,
748b4b94579Smrg						      pixman_fixed_t                inner_radius,
749b4b94579Smrg						      pixman_fixed_t                outer_radius,
750b4b94579Smrg						      const pixman_gradient_stop_t *stops,
751b4b94579Smrg						      int                           n_stops);
75281988197Sjmcneillpixman_image_t *pixman_image_create_conical_gradient (const pixman_point_fixed_t   *center,
753b4b94579Smrg						      pixman_fixed_t                angle,
754b4b94579Smrg						      const pixman_gradient_stop_t *stops,
755b4b94579Smrg						      int                           n_stops);
756b4b94579Smrgpixman_image_t *pixman_image_create_bits             (pixman_format_code_t          format,
757b4b94579Smrg						      int                           width,
758b4b94579Smrg						      int                           height,
759b4b94579Smrg						      uint32_t                     *bits,
760b4b94579Smrg						      int                           rowstride_bytes);
76181988197Sjmcneillpixman_image_t *pixman_image_create_bits_no_clear    (pixman_format_code_t format,
76281988197Sjmcneill						      int                  width,
76381988197Sjmcneill						      int                  height,
76481988197Sjmcneill						      uint32_t *           bits,
76581988197Sjmcneill						      int                  rowstride_bytes);
766b4b94579Smrg
767b4b94579Smrg/* Destructor */
768b4b94579Smrgpixman_image_t *pixman_image_ref                     (pixman_image_t               *image);
769b4b94579Smrgpixman_bool_t   pixman_image_unref                   (pixman_image_t               *image);
770b4b94579Smrg
771dc259aabSmrgvoid		pixman_image_set_destroy_function    (pixman_image_t		   *image,
772dc259aabSmrg						      pixman_image_destroy_func_t   function,
773dc259aabSmrg						      void			   *data);
774952204abSmrgvoid *		pixman_image_get_destroy_data        (pixman_image_t		   *image);
775b4b94579Smrg
776b4b94579Smrg/* Set properties */
777b4b94579Smrgpixman_bool_t   pixman_image_set_clip_region         (pixman_image_t               *image,
778b4b94579Smrg						      pixman_region16_t            *region);
779b4b94579Smrgpixman_bool_t   pixman_image_set_clip_region32       (pixman_image_t               *image,
780b4b94579Smrg						      pixman_region32_t            *region);
781b4b94579Smrgvoid		pixman_image_set_has_client_clip     (pixman_image_t               *image,
782b4b94579Smrg						      pixman_bool_t		    clien_clip);
783b4b94579Smrgpixman_bool_t   pixman_image_set_transform           (pixman_image_t               *image,
784b4b94579Smrg						      const pixman_transform_t     *transform);
785b4b94579Smrgvoid            pixman_image_set_repeat              (pixman_image_t               *image,
786b4b94579Smrg						      pixman_repeat_t               repeat);
787b4b94579Smrgpixman_bool_t   pixman_image_set_filter              (pixman_image_t               *image,
788b4b94579Smrg						      pixman_filter_t               filter,
789b4b94579Smrg						      const pixman_fixed_t         *filter_params,
790b4b94579Smrg						      int                           n_filter_params);
791b4b94579Smrgvoid		pixman_image_set_source_clipping     (pixman_image_t		   *image,
792b4b94579Smrg						      pixman_bool_t                 source_clipping);
793b4b94579Smrgvoid            pixman_image_set_alpha_map           (pixman_image_t               *image,
794b4b94579Smrg						      pixman_image_t               *alpha_map,
795b4b94579Smrg						      int16_t                       x,
796b4b94579Smrg						      int16_t                       y);
797b4b94579Smrgvoid            pixman_image_set_component_alpha     (pixman_image_t               *image,
798b4b94579Smrg						      pixman_bool_t                 component_alpha);
7991b18d63aSmrgpixman_bool_t   pixman_image_get_component_alpha     (pixman_image_t               *image);
800b4b94579Smrgvoid		pixman_image_set_accessors	     (pixman_image_t		   *image,
801b4b94579Smrg						      pixman_read_memory_func_t	    read_func,
802b4b94579Smrg						      pixman_write_memory_func_t    write_func);
803b4b94579Smrgvoid		pixman_image_set_indexed	     (pixman_image_t		   *image,
804b4b94579Smrg						      const pixman_indexed_t	   *indexed);
805b4b94579Smrguint32_t       *pixman_image_get_data                (pixman_image_t               *image);
806b4b94579Smrgint		pixman_image_get_width               (pixman_image_t               *image);
807b4b94579Smrgint             pixman_image_get_height              (pixman_image_t               *image);
808317c648bSmrgint		pixman_image_get_stride              (pixman_image_t               *image); /* in bytes */
809b4b94579Smrgint		pixman_image_get_depth               (pixman_image_t		   *image);
8101b18d63aSmrgpixman_format_code_t pixman_image_get_format	     (pixman_image_t		   *image);
811b4b94579Smrgpixman_bool_t	pixman_image_fill_rectangles	     (pixman_op_t		    op,
812b4b94579Smrg						      pixman_image_t		   *image,
81381988197Sjmcneill						      const pixman_color_t	   *color,
814b4b94579Smrg						      int			    n_rects,
815b4b94579Smrg						      const pixman_rectangle16_t   *rects);
816952204abSmrgpixman_bool_t   pixman_image_fill_boxes              (pixman_op_t                   op,
817952204abSmrg                                                      pixman_image_t               *dest,
81881988197Sjmcneill                                                      const pixman_color_t         *color,
819952204abSmrg                                                      int                           n_boxes,
820952204abSmrg                                                      const pixman_box32_t         *boxes);
821b4b94579Smrg
822b4b94579Smrg/* Composite */
823d0321353Smrgpixman_bool_t pixman_compute_composite_region (pixman_region16_t *region,
824d0321353Smrg					       pixman_image_t    *src_image,
825d0321353Smrg					       pixman_image_t    *mask_image,
8266ba797d6Smrg					       pixman_image_t    *dest_image,
827d0321353Smrg					       int16_t            src_x,
828d0321353Smrg					       int16_t            src_y,
829d0321353Smrg					       int16_t            mask_x,
830d0321353Smrg					       int16_t            mask_y,
831d0321353Smrg					       int16_t            dest_x,
832d0321353Smrg					       int16_t            dest_y,
833b4b94579Smrg					       uint16_t           width,
834b4b94579Smrg					       uint16_t           height);
835b4b94579Smrgvoid          pixman_image_composite          (pixman_op_t        op,
836b4b94579Smrg					       pixman_image_t    *src,
837b4b94579Smrg					       pixman_image_t    *mask,
838b4b94579Smrg					       pixman_image_t    *dest,
839b4b94579Smrg					       int16_t            src_x,
840b4b94579Smrg					       int16_t            src_y,
841b4b94579Smrg					       int16_t            mask_x,
842b4b94579Smrg					       int16_t            mask_y,
843b4b94579Smrg					       int16_t            dest_x,
844b4b94579Smrg					       int16_t            dest_y,
845b4b94579Smrg					       uint16_t           width,
846b4b94579Smrg					       uint16_t           height);
847952204abSmrgvoid          pixman_image_composite32        (pixman_op_t        op,
848952204abSmrg					       pixman_image_t    *src,
849952204abSmrg					       pixman_image_t    *mask,
850952204abSmrg					       pixman_image_t    *dest,
851952204abSmrg					       int32_t            src_x,
852952204abSmrg					       int32_t            src_y,
853952204abSmrg					       int32_t            mask_x,
854952204abSmrg					       int32_t            mask_y,
855952204abSmrg					       int32_t            dest_x,
856952204abSmrg					       int32_t            dest_y,
857952204abSmrg					       int32_t            width,
858952204abSmrg					       int32_t            height);
859b4b94579Smrg
8601b18d63aSmrg/* Executive Summary: This function is a no-op that only exists
8611b18d63aSmrg * for historical reasons.
8621b18d63aSmrg *
8631b18d63aSmrg * There used to be a bug in the X server where it would rely on
8641b18d63aSmrg * out-of-bounds accesses when it was asked to composite with a
8651b18d63aSmrg * window as the source. It would create a pixman image pointing
8661b18d63aSmrg * to some bogus position in memory, but then set a clip region
8671b18d63aSmrg * to the position where the actual bits were.
868d0321353Smrg *
869d0321353Smrg * Due to a bug in old versions of pixman, where it would not clip
870d0321353Smrg * against the image bounds when a clip region was set, this would
8711b18d63aSmrg * actually work. So when the pixman bug was fixed, a workaround was
8721b18d63aSmrg * added to allow certain out-of-bound accesses. This function disabled
8731b18d63aSmrg * those workarounds.
874d0321353Smrg *
8751b18d63aSmrg * Since 0.21.2, pixman doesn't do these workarounds anymore, so now this
8761b18d63aSmrg * function is a no-op.
877d0321353Smrg */
8781b18d63aSmrgvoid pixman_disable_out_of_bounds_workaround (void);
879d0321353Smrg
88081988197Sjmcneill/*
88181988197Sjmcneill * Glyphs
88281988197Sjmcneill */
88381988197Sjmcneilltypedef struct pixman_glyph_cache_t pixman_glyph_cache_t;
88481988197Sjmcneilltypedef struct
88581988197Sjmcneill{
88681988197Sjmcneill    int		x, y;
88781988197Sjmcneill    const void *glyph;
88881988197Sjmcneill} pixman_glyph_t;
88981988197Sjmcneill
89081988197Sjmcneillpixman_glyph_cache_t *pixman_glyph_cache_create       (void);
89181988197Sjmcneillvoid                  pixman_glyph_cache_destroy      (pixman_glyph_cache_t *cache);
89281988197Sjmcneillvoid                  pixman_glyph_cache_freeze       (pixman_glyph_cache_t *cache);
89381988197Sjmcneillvoid                  pixman_glyph_cache_thaw         (pixman_glyph_cache_t *cache);
89481988197Sjmcneillconst void *          pixman_glyph_cache_lookup       (pixman_glyph_cache_t *cache,
89581988197Sjmcneill						       void                 *font_key,
89681988197Sjmcneill						       void                 *glyph_key);
89781988197Sjmcneillconst void *          pixman_glyph_cache_insert       (pixman_glyph_cache_t *cache,
89881988197Sjmcneill						       void                 *font_key,
89981988197Sjmcneill						       void                 *glyph_key,
90081988197Sjmcneill						       int		     origin_x,
90181988197Sjmcneill						       int                   origin_y,
90281988197Sjmcneill						       pixman_image_t       *glyph_image);
90381988197Sjmcneillvoid                  pixman_glyph_cache_remove       (pixman_glyph_cache_t *cache,
90481988197Sjmcneill						       void                 *font_key,
90581988197Sjmcneill						       void                 *glyph_key);
90681988197Sjmcneillvoid                  pixman_glyph_get_extents        (pixman_glyph_cache_t *cache,
90781988197Sjmcneill						       int                   n_glyphs,
90881988197Sjmcneill						       pixman_glyph_t       *glyphs,
90981988197Sjmcneill						       pixman_box32_t       *extents);
91081988197Sjmcneillpixman_format_code_t  pixman_glyph_get_mask_format    (pixman_glyph_cache_t *cache,
91181988197Sjmcneill						       int		     n_glyphs,
91281988197Sjmcneill						       const pixman_glyph_t *glyphs);
91381988197Sjmcneillvoid                  pixman_composite_glyphs         (pixman_op_t           op,
91481988197Sjmcneill						       pixman_image_t       *src,
91581988197Sjmcneill						       pixman_image_t       *dest,
91681988197Sjmcneill						       pixman_format_code_t  mask_format,
91781988197Sjmcneill						       int32_t               src_x,
91881988197Sjmcneill						       int32_t               src_y,
91981988197Sjmcneill						       int32_t		     mask_x,
92081988197Sjmcneill						       int32_t		     mask_y,
92181988197Sjmcneill						       int32_t               dest_x,
92281988197Sjmcneill						       int32_t               dest_y,
92381988197Sjmcneill						       int32_t		     width,
92481988197Sjmcneill						       int32_t		     height,
92581988197Sjmcneill						       pixman_glyph_cache_t *cache,
92681988197Sjmcneill						       int		     n_glyphs,
92781988197Sjmcneill						       const pixman_glyph_t *glyphs);
92881988197Sjmcneillvoid                  pixman_composite_glyphs_no_mask (pixman_op_t           op,
92981988197Sjmcneill						       pixman_image_t       *src,
93081988197Sjmcneill						       pixman_image_t       *dest,
93181988197Sjmcneill						       int32_t               src_x,
93281988197Sjmcneill						       int32_t               src_y,
93381988197Sjmcneill						       int32_t               dest_x,
93481988197Sjmcneill						       int32_t               dest_y,
93581988197Sjmcneill						       pixman_glyph_cache_t *cache,
93681988197Sjmcneill						       int		     n_glyphs,
93781988197Sjmcneill						       const pixman_glyph_t *glyphs);
93881988197Sjmcneill
939b4b94579Smrg/*
940b4b94579Smrg * Trapezoids
941b4b94579Smrg */
942b4b94579Smrgtypedef struct pixman_edge pixman_edge_t;
943b4b94579Smrgtypedef struct pixman_trapezoid pixman_trapezoid_t;
944b4b94579Smrgtypedef struct pixman_trap pixman_trap_t;
945b4b94579Smrgtypedef struct pixman_span_fix pixman_span_fix_t;
9466ba797d6Smrgtypedef struct pixman_triangle pixman_triangle_t;
947b4b94579Smrg
948b4b94579Smrg/*
949b4b94579Smrg * An edge structure.  This represents a single polygon edge
950b4b94579Smrg * and can be quickly stepped across small or large gaps in the
951b4b94579Smrg * sample grid
952b4b94579Smrg */
953b4b94579Smrgstruct pixman_edge
954b4b94579Smrg{
955b4b94579Smrg    pixman_fixed_t	x;
956b4b94579Smrg    pixman_fixed_t	e;
957d0321353Smrg    pixman_fixed_t	stepx;
958d0321353Smrg    pixman_fixed_t	signdx;
959d0321353Smrg    pixman_fixed_t	dy;
960d0321353Smrg    pixman_fixed_t	dx;
961d0321353Smrg
962d0321353Smrg    pixman_fixed_t	stepx_small;
963d0321353Smrg    pixman_fixed_t	stepx_big;
964d0321353Smrg    pixman_fixed_t	dx_small;
965d0321353Smrg    pixman_fixed_t	dx_big;
966b4b94579Smrg};
967b4b94579Smrg
968b4b94579Smrgstruct pixman_trapezoid
969b4b94579Smrg{
970d0321353Smrg    pixman_fixed_t	top, bottom;
971b4b94579Smrg    pixman_line_fixed_t	left, right;
972b4b94579Smrg};
973b4b94579Smrg
9746ba797d6Smrgstruct pixman_triangle
9756ba797d6Smrg{
9766ba797d6Smrg    pixman_point_fixed_t p1, p2, p3;
9776ba797d6Smrg};
978b4b94579Smrg
979b4b94579Smrg/* whether 't' is a well defined not obviously empty trapezoid */
980d0321353Smrg#define pixman_trapezoid_valid(t)				   \
981b4b94579Smrg    ((t)->left.p1.y != (t)->left.p2.y &&			   \
982b4b94579Smrg     (t)->right.p1.y != (t)->right.p2.y &&			   \
983b4b94579Smrg     (int) ((t)->bottom - (t)->top) > 0)
984b4b94579Smrg
985b4b94579Smrgstruct pixman_span_fix
986b4b94579Smrg{
987b4b94579Smrg    pixman_fixed_t	l, r, y;
988b4b94579Smrg};
989b4b94579Smrg
990b4b94579Smrgstruct pixman_trap
991b4b94579Smrg{
992b4b94579Smrg    pixman_span_fix_t	top, bot;
993b4b94579Smrg};
994b4b94579Smrg
995b4b94579Smrgpixman_fixed_t pixman_sample_ceil_y        (pixman_fixed_t             y,
996b4b94579Smrg					    int                        bpp);
997b4b94579Smrgpixman_fixed_t pixman_sample_floor_y       (pixman_fixed_t             y,
998b4b94579Smrg					    int                        bpp);
999b4b94579Smrgvoid           pixman_edge_step            (pixman_edge_t             *e,
1000b4b94579Smrg					    int                        n);
1001b4b94579Smrgvoid           pixman_edge_init            (pixman_edge_t             *e,
1002b4b94579Smrg					    int                        bpp,
1003b4b94579Smrg					    pixman_fixed_t             y_start,
1004b4b94579Smrg					    pixman_fixed_t             x_top,
1005b4b94579Smrg					    pixman_fixed_t             y_top,
1006b4b94579Smrg					    pixman_fixed_t             x_bot,
1007b4b94579Smrg					    pixman_fixed_t             y_bot);
1008b4b94579Smrgvoid           pixman_line_fixed_edge_init (pixman_edge_t             *e,
1009b4b94579Smrg					    int                        bpp,
1010b4b94579Smrg					    pixman_fixed_t             y,
1011b4b94579Smrg					    const pixman_line_fixed_t *line,
1012b4b94579Smrg					    int                        x_off,
1013b4b94579Smrg					    int                        y_off);
1014b4b94579Smrgvoid           pixman_rasterize_edges      (pixman_image_t            *image,
1015b4b94579Smrg					    pixman_edge_t             *l,
1016b4b94579Smrg					    pixman_edge_t             *r,
1017b4b94579Smrg					    pixman_fixed_t             t,
1018b4b94579Smrg					    pixman_fixed_t             b);
1019b4b94579Smrgvoid           pixman_add_traps            (pixman_image_t            *image,
1020b4b94579Smrg					    int16_t                    x_off,
1021b4b94579Smrg					    int16_t                    y_off,
1022b4b94579Smrg					    int                        ntrap,
102381988197Sjmcneill					    const pixman_trap_t       *traps);
1024b4b94579Smrgvoid           pixman_add_trapezoids       (pixman_image_t            *image,
1025b4b94579Smrg					    int16_t                    x_off,
1026b4b94579Smrg					    int                        y_off,
1027b4b94579Smrg					    int                        ntraps,
1028b4b94579Smrg					    const pixman_trapezoid_t  *traps);
1029b4b94579Smrgvoid           pixman_rasterize_trapezoid  (pixman_image_t            *image,
1030b4b94579Smrg					    const pixman_trapezoid_t  *trap,
1031b4b94579Smrg					    int                        x_off,
1032b4b94579Smrg					    int                        y_off);
10336ba797d6Smrgvoid          pixman_composite_trapezoids (pixman_op_t		       op,
10346ba797d6Smrg					   pixman_image_t *	       src,
10356ba797d6Smrg					   pixman_image_t *	       dst,
10366ba797d6Smrg					   pixman_format_code_t	       mask_format,
10376ba797d6Smrg					   int			       x_src,
10386ba797d6Smrg					   int			       y_src,
10396ba797d6Smrg					   int			       x_dst,
10406ba797d6Smrg					   int			       y_dst,
10416ba797d6Smrg					   int			       n_traps,
10426ba797d6Smrg					   const pixman_trapezoid_t *  traps);
10436ba797d6Smrgvoid          pixman_composite_triangles (pixman_op_t		       op,
10446ba797d6Smrg					  pixman_image_t *	       src,
10456ba797d6Smrg					  pixman_image_t *	       dst,
10466ba797d6Smrg					  pixman_format_code_t	       mask_format,
10476ba797d6Smrg					  int			       x_src,
10486ba797d6Smrg					  int			       y_src,
10496ba797d6Smrg					  int			       x_dst,
10506ba797d6Smrg					  int			       y_dst,
10516ba797d6Smrg					  int			       n_tris,
10526ba797d6Smrg					  const pixman_triangle_t *    tris);
10536ba797d6Smrgvoid	      pixman_add_triangles       (pixman_image_t              *image,
10546ba797d6Smrg					  int32_t	               x_off,
10556ba797d6Smrg					  int32_t	               y_off,
10566ba797d6Smrg					  int	                       n_tris,
10576ba797d6Smrg					  const pixman_triangle_t     *tris);
1058b4b94579Smrg
1059952204abSmrgPIXMAN_END_DECLS
1060952204abSmrg
1061b4b94579Smrg#endif /* PIXMAN_H__ */
1062