pixman.h revision dc259aab
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
74b4b94579Smrg/*
75b4b94579Smrg * Standard integers
76b4b94579Smrg */
77317c648bSmrg#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__)
78b4b94579Smrg#  include <inttypes.h>
79b4b94579Smrg#elif defined (_MSC_VER)
80b4b94579Smrgtypedef __int8 int8_t;
81b4b94579Smrgtypedef unsigned __int8 uint8_t;
82b4b94579Smrgtypedef __int16 int16_t;
83b4b94579Smrgtypedef unsigned __int16 uint16_t;
84b4b94579Smrgtypedef __int32 int32_t;
85b4b94579Smrgtypedef unsigned __int32 uint32_t;
86b4b94579Smrgtypedef __int64 int64_t;
87b4b94579Smrgtypedef unsigned __int64 uint64_t;
8827693ee9Sveego#elif defined (_AIX)
8927693ee9Sveego#  include <sys/inttypes.h>
90b4b94579Smrg#else
91b4b94579Smrg#  include <stdint.h>
92b4b94579Smrg#endif
93b4b94579Smrg
94b4b94579Smrg/*
95b4b94579Smrg * Boolean
96b4b94579Smrg */
97b4b94579Smrgtypedef int pixman_bool_t;
98b4b94579Smrg
99b4b94579Smrg/*
100b4b94579Smrg * Fixpoint numbers
101b4b94579Smrg */
102b4b94579Smrgtypedef int64_t			pixman_fixed_32_32_t;
103b4b94579Smrgtypedef pixman_fixed_32_32_t	pixman_fixed_48_16_t;
104b4b94579Smrgtypedef uint32_t		pixman_fixed_1_31_t;
105b4b94579Smrgtypedef uint32_t		pixman_fixed_1_16_t;
106b4b94579Smrgtypedef int32_t			pixman_fixed_16_16_t;
107b4b94579Smrgtypedef pixman_fixed_16_16_t	pixman_fixed_t;
108b4b94579Smrg
109b4b94579Smrg#define pixman_fixed_e			((pixman_fixed_t) 1)
110b4b94579Smrg#define pixman_fixed_1			(pixman_int_to_fixed(1))
111b4b94579Smrg#define pixman_fixed_1_minus_e		(pixman_fixed_1 - pixman_fixed_e)
112b4b94579Smrg#define pixman_fixed_to_int(f)		((int) ((f) >> 16))
113b4b94579Smrg#define pixman_int_to_fixed(i)		((pixman_fixed_t) ((i) << 16))
114b4b94579Smrg#define pixman_fixed_to_double(f)	(double) ((f) / (double) pixman_fixed_1)
115b4b94579Smrg#define pixman_double_to_fixed(d)	((pixman_fixed_t) ((d) * 65536.0))
116b4b94579Smrg#define pixman_fixed_frac(f)		((f) & pixman_fixed_1_minus_e)
117b4b94579Smrg#define pixman_fixed_floor(f)		((f) & ~pixman_fixed_1_minus_e)
118b4b94579Smrg#define pixman_fixed_ceil(f)		pixman_fixed_floor ((f) + pixman_fixed_1_minus_e)
119b4b94579Smrg#define pixman_fixed_fraction(f)	((f) & pixman_fixed_1_minus_e)
120b4b94579Smrg#define pixman_fixed_mod_2(f)		((f) & (pixman_fixed1 | pixman_fixed_1_minus_e))
121b4b94579Smrg#define pixman_max_fixed_48_16		((pixman_fixed_48_16_t) 0x7fffffff)
122b4b94579Smrg#define pixman_min_fixed_48_16		(-((pixman_fixed_48_16_t) 1 << 31))
123b4b94579Smrg
124b4b94579Smrg/*
125b4b94579Smrg * Misc structs
126b4b94579Smrg */
127b4b94579Smrgtypedef struct pixman_color pixman_color_t;
128b4b94579Smrgtypedef struct pixman_point_fixed pixman_point_fixed_t;
129b4b94579Smrgtypedef struct pixman_line_fixed pixman_line_fixed_t;
130b4b94579Smrgtypedef struct pixman_vector pixman_vector_t;
131b4b94579Smrgtypedef struct pixman_transform pixman_transform_t;
132b4b94579Smrg
133b4b94579Smrgstruct pixman_color
134b4b94579Smrg{
135b4b94579Smrg    uint16_t	red;
136b4b94579Smrg    uint16_t    green;
137b4b94579Smrg    uint16_t    blue;
138b4b94579Smrg    uint16_t    alpha;
139b4b94579Smrg};
140b4b94579Smrg
141b4b94579Smrgstruct pixman_point_fixed
142b4b94579Smrg{
143b4b94579Smrg    pixman_fixed_t	x;
144b4b94579Smrg    pixman_fixed_t	y;
145b4b94579Smrg};
146b4b94579Smrg
147b4b94579Smrgstruct pixman_line_fixed
148b4b94579Smrg{
149b4b94579Smrg    pixman_point_fixed_t	p1, p2;
150b4b94579Smrg};
151b4b94579Smrg
152317c648bSmrg/*
153317c648bSmrg * Fixed point matrices
154317c648bSmrg */
155317c648bSmrg
156b4b94579Smrgstruct pixman_vector
157b4b94579Smrg{
158b4b94579Smrg    pixman_fixed_t	vector[3];
159b4b94579Smrg};
160b4b94579Smrg
161b4b94579Smrgstruct pixman_transform
162b4b94579Smrg{
163b4b94579Smrg    pixman_fixed_t	matrix[3][3];
164b4b94579Smrg};
165b4b94579Smrg
166317c648bSmrg/* forward declaration (sorry) */
167317c648bSmrgstruct pixman_box16;
168317c648bSmrg
169317c648bSmrgvoid
170317c648bSmrgpixman_transform_init_identity(struct pixman_transform *matrix);
171317c648bSmrg
172317c648bSmrgpixman_bool_t
173317c648bSmrgpixman_transform_point_3d (const struct pixman_transform *transform,
174317c648bSmrg			   struct pixman_vector *vector);
175317c648bSmrg
176317c648bSmrgpixman_bool_t
177317c648bSmrgpixman_transform_point(const struct pixman_transform *transform,
178317c648bSmrg		       struct pixman_vector *vector);
179317c648bSmrg
180317c648bSmrgpixman_bool_t
181317c648bSmrgpixman_transform_multiply (struct pixman_transform *dst,
182317c648bSmrg			   const struct pixman_transform *l,
183317c648bSmrg			   const struct pixman_transform *r);
184317c648bSmrg
185317c648bSmrgvoid
186317c648bSmrgpixman_transform_init_scale (struct pixman_transform *t,
187317c648bSmrg			     pixman_fixed_t sx,
188317c648bSmrg			     pixman_fixed_t sy);
189317c648bSmrg
190317c648bSmrgpixman_bool_t
191317c648bSmrgpixman_transform_scale(struct pixman_transform *forward,
192317c648bSmrg		       struct pixman_transform *reverse,
193317c648bSmrg		       pixman_fixed_t sx, pixman_fixed_t sy);
194317c648bSmrg
195317c648bSmrgvoid
196317c648bSmrgpixman_transform_init_rotate(struct pixman_transform *t,
197317c648bSmrg			     pixman_fixed_t cos,
198317c648bSmrg			     pixman_fixed_t sin);
199317c648bSmrg
200317c648bSmrgpixman_bool_t
201317c648bSmrgpixman_transform_rotate(struct pixman_transform *forward,
202317c648bSmrg			struct pixman_transform *reverse,
203317c648bSmrg			pixman_fixed_t c, pixman_fixed_t s);
204317c648bSmrg
205317c648bSmrgvoid
206317c648bSmrgpixman_transform_init_translate(struct pixman_transform *t,
207317c648bSmrg				pixman_fixed_t tx, pixman_fixed_t ty);
208317c648bSmrg
209317c648bSmrg
210317c648bSmrgpixman_bool_t
211317c648bSmrgpixman_transform_translate(struct pixman_transform *forward,
212317c648bSmrg			   struct pixman_transform *reverse,
213317c648bSmrg			   pixman_fixed_t tx, pixman_fixed_t ty);
214317c648bSmrg
215317c648bSmrgpixman_bool_t
216317c648bSmrgpixman_transform_bounds(const struct pixman_transform *matrix,
217317c648bSmrg			struct pixman_box16 *b);
218317c648bSmrg
219317c648bSmrg
220317c648bSmrgpixman_bool_t
221317c648bSmrgpixman_transform_invert (struct pixman_transform *dst,
222317c648bSmrg			 const struct pixman_transform *src);
223317c648bSmrg
224317c648bSmrgpixman_bool_t
225317c648bSmrgpixman_transform_is_identity(const struct pixman_transform *t);
226317c648bSmrg
227317c648bSmrgpixman_bool_t
228317c648bSmrgpixman_transform_is_scale(const struct pixman_transform *t);
229317c648bSmrg
230317c648bSmrgpixman_bool_t
231317c648bSmrgpixman_transform_is_int_translate(const struct pixman_transform *t);
232317c648bSmrg
233317c648bSmrgpixman_bool_t
234317c648bSmrgpixman_transform_is_inverse (const struct pixman_transform *a,
235317c648bSmrg			     const struct pixman_transform *b);
236317c648bSmrg
237317c648bSmrg
238317c648bSmrg/*
239317c648bSmrg * Floating point matrices
240317c648bSmrg */
241317c648bSmrgstruct pixman_f_vector {
242317c648bSmrg    double  v[3];
243317c648bSmrg};
244317c648bSmrg
245317c648bSmrgstruct pixman_f_transform {
246317c648bSmrg    double  m[3][3];
247317c648bSmrg};
248317c648bSmrg
249317c648bSmrgpixman_bool_t
250317c648bSmrgpixman_transform_from_pixman_f_transform (struct pixman_transform *t,
251317c648bSmrg					  const struct pixman_f_transform *ft);
252317c648bSmrg
253317c648bSmrgvoid
254317c648bSmrgpixman_f_transform_from_pixman_transform (struct pixman_f_transform *ft,
255317c648bSmrg					  const struct pixman_transform *t);
256317c648bSmrg
257317c648bSmrgpixman_bool_t
258317c648bSmrgpixman_transform_from_pixman_f_transform (struct pixman_transform *t,
259317c648bSmrg					  const struct pixman_f_transform *ft);
260317c648bSmrg
261317c648bSmrgpixman_bool_t
262317c648bSmrgpixman_f_transform_invert (struct pixman_f_transform *dst,
263317c648bSmrg			   const struct pixman_f_transform *src);
264317c648bSmrg
265317c648bSmrgpixman_bool_t
266317c648bSmrgpixman_f_transform_point (const struct pixman_f_transform *t,
267317c648bSmrg			  struct pixman_f_vector *v);
268317c648bSmrg
269317c648bSmrgvoid
270317c648bSmrgpixman_f_transform_point_3d (const struct pixman_f_transform *t,
271317c648bSmrg			     struct pixman_f_vector	*v);
272317c648bSmrg
273317c648bSmrg
274317c648bSmrgvoid
275317c648bSmrgpixman_f_transform_multiply (struct pixman_f_transform *dst,
276317c648bSmrg			     const struct pixman_f_transform *l,
277317c648bSmrg			     const struct pixman_f_transform *r);
278317c648bSmrg
279317c648bSmrgvoid
280317c648bSmrgpixman_f_transform_init_scale (struct pixman_f_transform *t, double sx, double sy);
281317c648bSmrg
282317c648bSmrgpixman_bool_t
283317c648bSmrgpixman_f_transform_scale (struct pixman_f_transform *forward,
284317c648bSmrg			  struct pixman_f_transform *reverse,
285317c648bSmrg			  double sx, double sy);
286317c648bSmrg
287317c648bSmrgvoid
288317c648bSmrgpixman_f_transform_init_rotate (struct pixman_f_transform *t, double cos, double sin);
289317c648bSmrg
290317c648bSmrgpixman_bool_t
291317c648bSmrgpixman_f_transform_rotate (struct pixman_f_transform *forward,
292317c648bSmrg			   struct pixman_f_transform *reverse,
293317c648bSmrg			   double c, double s);
294317c648bSmrg
295317c648bSmrgvoid
296317c648bSmrgpixman_f_transform_init_translate (struct pixman_f_transform *t, double tx, double ty);
297317c648bSmrg
298317c648bSmrgpixman_bool_t
299317c648bSmrgpixman_f_transform_translate (struct pixman_f_transform *forward,
300317c648bSmrg			      struct pixman_f_transform *reverse,
301317c648bSmrg			      double tx, double ty);
302317c648bSmrg
303317c648bSmrgpixman_bool_t
304317c648bSmrgpixman_f_transform_bounds (const struct pixman_f_transform *t, struct pixman_box16 *b);
305317c648bSmrg
306317c648bSmrgvoid
307317c648bSmrgpixman_f_transform_init_identity (struct pixman_f_transform *t);
308317c648bSmrg
309b4b94579Smrg/* Don't blame me, blame XRender */
310b4b94579Smrgtypedef enum
311b4b94579Smrg{
312b4b94579Smrg    PIXMAN_REPEAT_NONE,
313b4b94579Smrg    PIXMAN_REPEAT_NORMAL,
314b4b94579Smrg    PIXMAN_REPEAT_PAD,
315b4b94579Smrg    PIXMAN_REPEAT_REFLECT
316b4b94579Smrg} pixman_repeat_t;
317b4b94579Smrg
318b4b94579Smrgtypedef enum
319b4b94579Smrg{
320b4b94579Smrg    PIXMAN_FILTER_FAST,
321b4b94579Smrg    PIXMAN_FILTER_GOOD,
322b4b94579Smrg    PIXMAN_FILTER_BEST,
323b4b94579Smrg    PIXMAN_FILTER_NEAREST,
324b4b94579Smrg    PIXMAN_FILTER_BILINEAR,
325b4b94579Smrg    PIXMAN_FILTER_CONVOLUTION
326b4b94579Smrg} pixman_filter_t;
327b4b94579Smrg
328b4b94579Smrgtypedef enum
329b4b94579Smrg{
330b4b94579Smrg    PIXMAN_OP_CLEAR			= 0x00,
331b4b94579Smrg    PIXMAN_OP_SRC			= 0x01,
332b4b94579Smrg    PIXMAN_OP_DST			= 0x02,
333b4b94579Smrg    PIXMAN_OP_OVER			= 0x03,
334b4b94579Smrg    PIXMAN_OP_OVER_REVERSE		= 0x04,
335b4b94579Smrg    PIXMAN_OP_IN			= 0x05,
336b4b94579Smrg    PIXMAN_OP_IN_REVERSE		= 0x06,
337b4b94579Smrg    PIXMAN_OP_OUT			= 0x07,
338b4b94579Smrg    PIXMAN_OP_OUT_REVERSE		= 0x08,
339b4b94579Smrg    PIXMAN_OP_ATOP			= 0x09,
340b4b94579Smrg    PIXMAN_OP_ATOP_REVERSE		= 0x0a,
341b4b94579Smrg    PIXMAN_OP_XOR			= 0x0b,
342b4b94579Smrg    PIXMAN_OP_ADD			= 0x0c,
343b4b94579Smrg    PIXMAN_OP_SATURATE			= 0x0d,
344b4b94579Smrg
345b4b94579Smrg    PIXMAN_OP_DISJOINT_CLEAR		= 0x10,
346b4b94579Smrg    PIXMAN_OP_DISJOINT_SRC		= 0x11,
347b4b94579Smrg    PIXMAN_OP_DISJOINT_DST		= 0x12,
348b4b94579Smrg    PIXMAN_OP_DISJOINT_OVER		= 0x13,
349b4b94579Smrg    PIXMAN_OP_DISJOINT_OVER_REVERSE	= 0x14,
350b4b94579Smrg    PIXMAN_OP_DISJOINT_IN		= 0x15,
351b4b94579Smrg    PIXMAN_OP_DISJOINT_IN_REVERSE	= 0x16,
352b4b94579Smrg    PIXMAN_OP_DISJOINT_OUT		= 0x17,
353b4b94579Smrg    PIXMAN_OP_DISJOINT_OUT_REVERSE	= 0x18,
354b4b94579Smrg    PIXMAN_OP_DISJOINT_ATOP		= 0x19,
355b4b94579Smrg    PIXMAN_OP_DISJOINT_ATOP_REVERSE	= 0x1a,
356b4b94579Smrg    PIXMAN_OP_DISJOINT_XOR		= 0x1b,
357b4b94579Smrg
358b4b94579Smrg    PIXMAN_OP_CONJOINT_CLEAR		= 0x20,
359b4b94579Smrg    PIXMAN_OP_CONJOINT_SRC		= 0x21,
360b4b94579Smrg    PIXMAN_OP_CONJOINT_DST		= 0x22,
361b4b94579Smrg    PIXMAN_OP_CONJOINT_OVER		= 0x23,
362b4b94579Smrg    PIXMAN_OP_CONJOINT_OVER_REVERSE	= 0x24,
363b4b94579Smrg    PIXMAN_OP_CONJOINT_IN		= 0x25,
364b4b94579Smrg    PIXMAN_OP_CONJOINT_IN_REVERSE	= 0x26,
365b4b94579Smrg    PIXMAN_OP_CONJOINT_OUT		= 0x27,
366b4b94579Smrg    PIXMAN_OP_CONJOINT_OUT_REVERSE	= 0x28,
367b4b94579Smrg    PIXMAN_OP_CONJOINT_ATOP		= 0x29,
368b4b94579Smrg    PIXMAN_OP_CONJOINT_ATOP_REVERSE	= 0x2a,
369b4b94579Smrg    PIXMAN_OP_CONJOINT_XOR		= 0x2b,
370b4b94579Smrg
371dc259aabSmrg    PIXMAN_OP_MULTIPLY                  = 0x30,
372dc259aabSmrg    PIXMAN_OP_SCREEN                    = 0x31,
373dc259aabSmrg    PIXMAN_OP_OVERLAY                   = 0x32,
374dc259aabSmrg    PIXMAN_OP_DARKEN                    = 0x33,
375dc259aabSmrg    PIXMAN_OP_LIGHTEN                   = 0x34,
376dc259aabSmrg    PIXMAN_OP_COLOR_DODGE               = 0x35,
377dc259aabSmrg    PIXMAN_OP_COLOR_BURN                = 0x36,
378dc259aabSmrg    PIXMAN_OP_HARD_LIGHT                = 0x37,
379dc259aabSmrg    PIXMAN_OP_SOFT_LIGHT                = 0x38,
380dc259aabSmrg    PIXMAN_OP_DIFFERENCE                = 0x39,
381dc259aabSmrg    PIXMAN_OP_EXCLUSION                 = 0x3a,
382dc259aabSmrg    PIXMAN_OP_HSL_HUE			= 0x3b,
383dc259aabSmrg    PIXMAN_OP_HSL_SATURATION		= 0x3c,
384dc259aabSmrg    PIXMAN_OP_HSL_COLOR			= 0x3d,
385dc259aabSmrg    PIXMAN_OP_HSL_LUMINOSITY		= 0x3e,
386dc259aabSmrg
387317c648bSmrg    PIXMAN_OP_NONE,
388317c648bSmrg    PIXMAN_OP_LAST = PIXMAN_OP_NONE
389b4b94579Smrg} pixman_op_t;
390b4b94579Smrg
391b4b94579Smrg/*
392b4b94579Smrg * Regions
393b4b94579Smrg */
394b4b94579Smrgtypedef struct pixman_region16_data	pixman_region16_data_t;
395b4b94579Smrgtypedef struct pixman_box16		pixman_box16_t;
396b4b94579Smrgtypedef struct pixman_rectangle16	pixman_rectangle16_t;
397b4b94579Smrgtypedef struct pixman_region16		pixman_region16_t;
398b4b94579Smrg
399b4b94579Smrgstruct pixman_region16_data {
400b4b94579Smrg    long		size;
401b4b94579Smrg    long		numRects;
402b4b94579Smrg/*  pixman_box16_t	rects[size];   in memory but not explicitly declared */
403b4b94579Smrg};
404b4b94579Smrg
405b4b94579Smrgstruct pixman_rectangle16
406b4b94579Smrg{
407b4b94579Smrg    int16_t x, y;
408b4b94579Smrg    uint16_t width, height;
409b4b94579Smrg};
410b4b94579Smrg
411b4b94579Smrgstruct pixman_box16
412b4b94579Smrg{
413b4b94579Smrg    int16_t x1, y1, x2, y2;
414b4b94579Smrg};
415b4b94579Smrg
416b4b94579Smrgstruct pixman_region16
417b4b94579Smrg{
418b4b94579Smrg    pixman_box16_t          extents;
419b4b94579Smrg    pixman_region16_data_t  *data;
420b4b94579Smrg};
421b4b94579Smrg
422b4b94579Smrgtypedef enum
423b4b94579Smrg{
424b4b94579Smrg    PIXMAN_REGION_OUT,
425b4b94579Smrg    PIXMAN_REGION_IN,
426b4b94579Smrg    PIXMAN_REGION_PART
427b4b94579Smrg} pixman_region_overlap_t;
428b4b94579Smrg
429b4b94579Smrg/* This function exists only to make it possible to preserve the X ABI - it should
430b4b94579Smrg * go away at first opportunity.
431b4b94579Smrg */
432b4b94579Smrgvoid                    pixman_region_set_static_pointers (pixman_box16_t         *empty_box,
433b4b94579Smrg							   pixman_region16_data_t *empty_data,
434b4b94579Smrg							   pixman_region16_data_t *broken_data);
435b4b94579Smrg
436b4b94579Smrg
437b4b94579Smrg/* creation/destruction */
438b4b94579Smrgvoid                    pixman_region_init                (pixman_region16_t      *region);
439b4b94579Smrgvoid                    pixman_region_init_rect           (pixman_region16_t      *region,
440b4b94579Smrg							   int                     x,
441b4b94579Smrg							   int                     y,
442b4b94579Smrg							   unsigned int            width,
443b4b94579Smrg							   unsigned int            height);
444b4b94579Smrgpixman_bool_t           pixman_region_init_rects          (pixman_region16_t      *region,
445b4b94579Smrg							   pixman_box16_t         *boxes,
446b4b94579Smrg							   int                     count);
447b4b94579Smrgvoid                    pixman_region_init_with_extents   (pixman_region16_t      *region,
448b4b94579Smrg							   pixman_box16_t         *extents);
449b4b94579Smrgvoid                    pixman_region_fini                (pixman_region16_t      *region);
450b4b94579Smrg
451b4b94579Smrg
452b4b94579Smrg/* manipulation */
453b4b94579Smrgvoid                    pixman_region_translate           (pixman_region16_t      *region,
454b4b94579Smrg							   int                     x,
455b4b94579Smrg							   int                     y);
456b4b94579Smrgpixman_bool_t           pixman_region_copy                (pixman_region16_t      *dest,
457b4b94579Smrg							   pixman_region16_t      *source);
458b4b94579Smrgpixman_bool_t           pixman_region_intersect           (pixman_region16_t      *newReg,
459b4b94579Smrg							   pixman_region16_t      *reg1,
460b4b94579Smrg							   pixman_region16_t      *reg2);
461b4b94579Smrgpixman_bool_t           pixman_region_union               (pixman_region16_t      *newReg,
462b4b94579Smrg							   pixman_region16_t      *reg1,
463b4b94579Smrg							   pixman_region16_t      *reg2);
464b4b94579Smrgpixman_bool_t           pixman_region_union_rect          (pixman_region16_t      *dest,
465b4b94579Smrg							   pixman_region16_t      *source,
466b4b94579Smrg							   int                     x,
467b4b94579Smrg							   int                     y,
468b4b94579Smrg							   unsigned int            width,
469b4b94579Smrg							   unsigned int            height);
470b4b94579Smrgpixman_bool_t           pixman_region_subtract            (pixman_region16_t      *regD,
471b4b94579Smrg							   pixman_region16_t      *regM,
472b4b94579Smrg							   pixman_region16_t      *regS);
473b4b94579Smrgpixman_bool_t           pixman_region_inverse             (pixman_region16_t      *newReg,
474b4b94579Smrg							   pixman_region16_t      *reg1,
475b4b94579Smrg							   pixman_box16_t         *invRect);
476b4b94579Smrgpixman_bool_t           pixman_region_contains_point      (pixman_region16_t      *region,
477b4b94579Smrg							   int                     x,
478b4b94579Smrg							   int                     y,
479b4b94579Smrg							   pixman_box16_t         *box);
480b4b94579Smrgpixman_region_overlap_t pixman_region_contains_rectangle  (pixman_region16_t      *pixman_region16_t,
481b4b94579Smrg							   pixman_box16_t         *prect);
482b4b94579Smrgpixman_bool_t           pixman_region_not_empty           (pixman_region16_t      *region);
483b4b94579Smrgpixman_box16_t *        pixman_region_extents             (pixman_region16_t      *region);
484b4b94579Smrgint                     pixman_region_n_rects             (pixman_region16_t      *region);
485b4b94579Smrgpixman_box16_t *        pixman_region_rectangles          (pixman_region16_t      *region,
486b4b94579Smrg							   int                    *n_rects);
487b4b94579Smrgpixman_bool_t           pixman_region_equal               (pixman_region16_t      *region1,
488b4b94579Smrg							   pixman_region16_t      *region2);
489b4b94579Smrgpixman_bool_t           pixman_region_selfcheck           (pixman_region16_t      *region);
490b4b94579Smrgvoid                    pixman_region_reset               (pixman_region16_t      *region,
491b4b94579Smrg							   pixman_box16_t         *box);
492b4b94579Smrg
493b4b94579Smrg/*
494b4b94579Smrg * 32 bit regions
495b4b94579Smrg */
496b4b94579Smrgtypedef struct pixman_region32_data	pixman_region32_data_t;
497b4b94579Smrgtypedef struct pixman_box32		pixman_box32_t;
498b4b94579Smrgtypedef struct pixman_rectangle32	pixman_rectangle32_t;
499b4b94579Smrgtypedef struct pixman_region32		pixman_region32_t;
500b4b94579Smrg
501b4b94579Smrgstruct pixman_region32_data {
502b4b94579Smrg    long		size;
503b4b94579Smrg    long		numRects;
504b4b94579Smrg/*  pixman_box32_t	rects[size];   in memory but not explicitly declared */
505b4b94579Smrg};
506b4b94579Smrg
507b4b94579Smrgstruct pixman_rectangle32
508b4b94579Smrg{
509b4b94579Smrg    int32_t x, y;
510b4b94579Smrg    uint32_t width, height;
511b4b94579Smrg};
512b4b94579Smrg
513b4b94579Smrgstruct pixman_box32
514b4b94579Smrg{
515b4b94579Smrg    int32_t x1, y1, x2, y2;
516b4b94579Smrg};
517b4b94579Smrg
518b4b94579Smrgstruct pixman_region32
519b4b94579Smrg{
520b4b94579Smrg    pixman_box32_t          extents;
521b4b94579Smrg    pixman_region32_data_t  *data;
522b4b94579Smrg};
523b4b94579Smrg
524b4b94579Smrg/* creation/destruction */
525b4b94579Smrgvoid                    pixman_region32_init               (pixman_region32_t *region);
526b4b94579Smrgvoid                    pixman_region32_init_rect          (pixman_region32_t *region,
527b4b94579Smrg							    int                x,
528b4b94579Smrg							    int                y,
529b4b94579Smrg							    unsigned int       width,
530b4b94579Smrg							    unsigned int       height);
531b4b94579Smrgpixman_bool_t           pixman_region32_init_rects         (pixman_region32_t *region,
532b4b94579Smrg							    pixman_box32_t    *boxes,
533b4b94579Smrg							    int                count);
534b4b94579Smrgvoid                    pixman_region32_init_with_extents  (pixman_region32_t *region,
535b4b94579Smrg							    pixman_box32_t    *extents);
536b4b94579Smrgvoid                    pixman_region32_fini               (pixman_region32_t *region);
537b4b94579Smrg
538b4b94579Smrg
539b4b94579Smrg/* manipulation */
540b4b94579Smrgvoid                    pixman_region32_translate          (pixman_region32_t *region,
541b4b94579Smrg							    int                x,
542b4b94579Smrg							    int                y);
543b4b94579Smrgpixman_bool_t           pixman_region32_copy               (pixman_region32_t *dest,
544b4b94579Smrg							    pixman_region32_t *source);
545b4b94579Smrgpixman_bool_t           pixman_region32_intersect          (pixman_region32_t *newReg,
546b4b94579Smrg							    pixman_region32_t *reg1,
547b4b94579Smrg							    pixman_region32_t *reg2);
548b4b94579Smrgpixman_bool_t           pixman_region32_union              (pixman_region32_t *newReg,
549b4b94579Smrg							    pixman_region32_t *reg1,
550b4b94579Smrg							    pixman_region32_t *reg2);
551b4b94579Smrgpixman_bool_t           pixman_region32_union_rect         (pixman_region32_t *dest,
552b4b94579Smrg							    pixman_region32_t *source,
553b4b94579Smrg							    int                x,
554b4b94579Smrg							    int                y,
555b4b94579Smrg							    unsigned int       width,
556b4b94579Smrg							    unsigned int       height);
557b4b94579Smrgpixman_bool_t           pixman_region32_subtract           (pixman_region32_t *regD,
558b4b94579Smrg							    pixman_region32_t *regM,
559b4b94579Smrg							    pixman_region32_t *regS);
560b4b94579Smrgpixman_bool_t           pixman_region32_inverse            (pixman_region32_t *newReg,
561b4b94579Smrg							    pixman_region32_t *reg1,
562b4b94579Smrg							    pixman_box32_t    *invRect);
563b4b94579Smrgpixman_bool_t           pixman_region32_contains_point     (pixman_region32_t *region,
564b4b94579Smrg							    int                x,
565b4b94579Smrg							    int                y,
566b4b94579Smrg							    pixman_box32_t    *box);
567b4b94579Smrgpixman_region_overlap_t pixman_region32_contains_rectangle (pixman_region32_t *region,
568b4b94579Smrg							    pixman_box32_t    *prect);
569b4b94579Smrgpixman_bool_t           pixman_region32_not_empty          (pixman_region32_t *region);
570b4b94579Smrgpixman_box32_t *        pixman_region32_extents            (pixman_region32_t *region);
571b4b94579Smrgint                     pixman_region32_n_rects            (pixman_region32_t *region);
572b4b94579Smrgpixman_box32_t *        pixman_region32_rectangles         (pixman_region32_t *region,
573b4b94579Smrg							    int               *n_rects);
574b4b94579Smrgpixman_bool_t           pixman_region32_equal              (pixman_region32_t *region1,
575b4b94579Smrg							    pixman_region32_t *region2);
576b4b94579Smrgpixman_bool_t           pixman_region32_selfcheck          (pixman_region32_t *region);
577b4b94579Smrgvoid                    pixman_region32_reset              (pixman_region32_t *region,
578b4b94579Smrg							    pixman_box32_t    *box);
579b4b94579Smrg
580b4b94579Smrg
581b4b94579Smrg/* Copy / Fill / Misc */
582b4b94579Smrgpixman_bool_t pixman_blt                (uint32_t           *src_bits,
583b4b94579Smrg					 uint32_t           *dst_bits,
584b4b94579Smrg					 int                 src_stride,
585b4b94579Smrg					 int                 dst_stride,
586b4b94579Smrg					 int                 src_bpp,
587b4b94579Smrg					 int                 dst_bpp,
588b4b94579Smrg					 int                 src_x,
589b4b94579Smrg					 int                 src_y,
590b4b94579Smrg					 int                 dst_x,
591b4b94579Smrg					 int                 dst_y,
592b4b94579Smrg					 int                 width,
593b4b94579Smrg					 int                 height);
594b4b94579Smrgpixman_bool_t pixman_fill               (uint32_t           *bits,
595b4b94579Smrg					 int                 stride,
596b4b94579Smrg					 int                 bpp,
597b4b94579Smrg					 int                 x,
598b4b94579Smrg					 int                 y,
599b4b94579Smrg					 int                 width,
600b4b94579Smrg					 int                 height,
601b4b94579Smrg					 uint32_t            _xor);
602b4b94579Smrg
603b4b94579Smrgint           pixman_version            (void);
604b4b94579Smrgconst char*   pixman_version_string     (void);
605b4b94579Smrg
606b4b94579Smrg/*
607b4b94579Smrg * Images
608b4b94579Smrg */
609b4b94579Smrgtypedef  union pixman_image		pixman_image_t;
610b4b94579Smrgtypedef struct pixman_indexed		pixman_indexed_t;
611b4b94579Smrgtypedef struct pixman_gradient_stop	pixman_gradient_stop_t;
612b4b94579Smrg
613b4b94579Smrgtypedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size);
614b4b94579Smrgtypedef void     (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size);
615b4b94579Smrg
616dc259aabSmrgtypedef void     (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data);
617dc259aabSmrg
618b4b94579Smrgstruct pixman_gradient_stop {
619b4b94579Smrg    pixman_fixed_t x;
620b4b94579Smrg    pixman_color_t color;
621b4b94579Smrg};
622b4b94579Smrg
623b4b94579Smrg#define PIXMAN_MAX_INDEXED  256 /* XXX depth must be <= 8 */
624b4b94579Smrg
625b4b94579Smrg#if PIXMAN_MAX_INDEXED <= 256
626b4b94579Smrgtypedef uint8_t pixman_index_type;
627b4b94579Smrg#endif
628b4b94579Smrg
629b4b94579Smrgstruct pixman_indexed
630b4b94579Smrg{
631b4b94579Smrg    pixman_bool_t       color;
632b4b94579Smrg    uint32_t		rgba[PIXMAN_MAX_INDEXED];
633b4b94579Smrg    pixman_index_type	ent[32768];
634b4b94579Smrg};
635b4b94579Smrg
636b4b94579Smrg/*
637b4b94579Smrg * While the protocol is generous in format support, the
638b4b94579Smrg * sample implementation allows only packed RGB and GBR
639b4b94579Smrg * representations for data to simplify software rendering,
640b4b94579Smrg */
641b4b94579Smrg#define PIXMAN_FORMAT(bpp,type,a,r,g,b)	(((bpp) << 24) |  \
642b4b94579Smrg					 ((type) << 16) | \
643b4b94579Smrg					 ((a) << 12) |	  \
644b4b94579Smrg					 ((r) << 8) |	  \
645b4b94579Smrg					 ((g) << 4) |	  \
646b4b94579Smrg					 ((b)))
647b4b94579Smrg
648b4b94579Smrg#define PIXMAN_FORMAT_BPP(f)	(((f) >> 24)       )
649b4b94579Smrg#define PIXMAN_FORMAT_TYPE(f)	(((f) >> 16) & 0xff)
650b4b94579Smrg#define PIXMAN_FORMAT_A(f)	(((f) >> 12) & 0x0f)
651b4b94579Smrg#define PIXMAN_FORMAT_R(f)	(((f) >>  8) & 0x0f)
652b4b94579Smrg#define PIXMAN_FORMAT_G(f)	(((f) >>  4) & 0x0f)
653b4b94579Smrg#define PIXMAN_FORMAT_B(f)	(((f)      ) & 0x0f)
654b4b94579Smrg#define PIXMAN_FORMAT_RGB(f)	(((f)      ) & 0xfff)
655b4b94579Smrg#define PIXMAN_FORMAT_VIS(f)	(((f)      ) & 0xffff)
656b4b94579Smrg#define PIXMAN_FORMAT_DEPTH(f)	(PIXMAN_FORMAT_A(f) +	\
657b4b94579Smrg				 PIXMAN_FORMAT_R(f) +	\
658b4b94579Smrg				 PIXMAN_FORMAT_G(f) +	\
659b4b94579Smrg				 PIXMAN_FORMAT_B(f))
660b4b94579Smrg
661b4b94579Smrg#define PIXMAN_TYPE_OTHER	0
662b4b94579Smrg#define PIXMAN_TYPE_A		1
663b4b94579Smrg#define PIXMAN_TYPE_ARGB	2
664b4b94579Smrg#define PIXMAN_TYPE_ABGR	3
665b4b94579Smrg#define PIXMAN_TYPE_COLOR	4
666b4b94579Smrg#define PIXMAN_TYPE_GRAY	5
667b4b94579Smrg#define PIXMAN_TYPE_YUY2	6
668b4b94579Smrg#define PIXMAN_TYPE_YV12	7
669317c648bSmrg#define PIXMAN_TYPE_BGRA	8
670b4b94579Smrg
671317c648bSmrg#define PIXMAN_FORMAT_COLOR(f)				\
672317c648bSmrg	(PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB ||	\
673317c648bSmrg	 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ABGR ||	\
674317c648bSmrg	 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_BGRA)
675b4b94579Smrg
676b4b94579Smrg/* 32bpp formats */
677b4b94579Smrgtypedef enum {
678b4b94579Smrg    PIXMAN_a8r8g8b8 =	PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8),
679b4b94579Smrg    PIXMAN_x8r8g8b8 =	PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8),
680b4b94579Smrg    PIXMAN_a8b8g8r8 =	PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8),
681b4b94579Smrg    PIXMAN_x8b8g8r8 =	PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8),
682317c648bSmrg    PIXMAN_b8g8r8a8 =	PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8),
683317c648bSmrg    PIXMAN_b8g8r8x8 =	PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8),
68427693ee9Sveego    PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
68527693ee9Sveego    PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
68627693ee9Sveego
687b4b94579Smrg/* 24bpp formats */
688b4b94579Smrg    PIXMAN_r8g8b8 =	PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),
689b4b94579Smrg    PIXMAN_b8g8r8 =	PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8),
690b4b94579Smrg
691b4b94579Smrg/* 16bpp formats */
692b4b94579Smrg    PIXMAN_r5g6b5 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5),
693b4b94579Smrg    PIXMAN_b5g6r5 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5),
694b4b94579Smrg
695b4b94579Smrg    PIXMAN_a1r5g5b5 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5),
696b4b94579Smrg    PIXMAN_x1r5g5b5 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5),
697b4b94579Smrg    PIXMAN_a1b5g5r5 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5),
698b4b94579Smrg    PIXMAN_x1b5g5r5 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5),
699b4b94579Smrg    PIXMAN_a4r4g4b4 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4),
700b4b94579Smrg    PIXMAN_x4r4g4b4 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4),
701b4b94579Smrg    PIXMAN_a4b4g4r4 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4),
702b4b94579Smrg    PIXMAN_x4b4g4r4 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4),
703b4b94579Smrg
704b4b94579Smrg/* 8bpp formats */
705b4b94579Smrg    PIXMAN_a8 =		PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0),
706b4b94579Smrg    PIXMAN_r3g3b2 =	PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2),
707b4b94579Smrg    PIXMAN_b2g3r3 =	PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2),
708b4b94579Smrg    PIXMAN_a2r2g2b2 =	PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2),
709b4b94579Smrg    PIXMAN_a2b2g2r2 =	PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2),
710b4b94579Smrg
711b4b94579Smrg    PIXMAN_c8 =		PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
712b4b94579Smrg    PIXMAN_g8 =		PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
713b4b94579Smrg
714b4b94579Smrg    PIXMAN_x4a4 =	PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0),
715b4b94579Smrg
716b4b94579Smrg    PIXMAN_x4c4 =	PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
717b4b94579Smrg    PIXMAN_x4g4 =	PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
718b4b94579Smrg
719b4b94579Smrg/* 4bpp formats */
720b4b94579Smrg    PIXMAN_a4 =		PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0),
721b4b94579Smrg    PIXMAN_r1g2b1 =	PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1),
722b4b94579Smrg    PIXMAN_b1g2r1 =	PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1),
723b4b94579Smrg    PIXMAN_a1r1g1b1 =	PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1),
724b4b94579Smrg    PIXMAN_a1b1g1r1 =	PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1),
725b4b94579Smrg
726b4b94579Smrg    PIXMAN_c4 =		PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0),
727b4b94579Smrg    PIXMAN_g4 =		PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0),
728b4b94579Smrg
729b4b94579Smrg/* 1bpp formats */
730b4b94579Smrg    PIXMAN_a1 =		PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0),
731b4b94579Smrg
732b4b94579Smrg    PIXMAN_g1 =		PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
733b4b94579Smrg
734b4b94579Smrg/* YUV formats */
735b4b94579Smrg    PIXMAN_yuy2 =	PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0),
736b4b94579Smrg    PIXMAN_yv12 =	PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0)
737b4b94579Smrg} pixman_format_code_t;
738b4b94579Smrg
739b4b94579Smrg/* Querying supported format values. */
740b4b94579Smrgpixman_bool_t pixman_format_supported_destination (pixman_format_code_t format);
741b4b94579Smrgpixman_bool_t pixman_format_supported_source      (pixman_format_code_t format);
742b4b94579Smrg
743b4b94579Smrg/* Constructors */
744b4b94579Smrgpixman_image_t *pixman_image_create_solid_fill       (pixman_color_t               *color);
745b4b94579Smrgpixman_image_t *pixman_image_create_linear_gradient  (pixman_point_fixed_t         *p1,
746b4b94579Smrg						      pixman_point_fixed_t         *p2,
747b4b94579Smrg						      const pixman_gradient_stop_t *stops,
748b4b94579Smrg						      int                           n_stops);
749b4b94579Smrgpixman_image_t *pixman_image_create_radial_gradient  (pixman_point_fixed_t         *inner,
750b4b94579Smrg						      pixman_point_fixed_t         *outer,
751b4b94579Smrg						      pixman_fixed_t                inner_radius,
752b4b94579Smrg						      pixman_fixed_t                outer_radius,
753b4b94579Smrg						      const pixman_gradient_stop_t *stops,
754b4b94579Smrg						      int                           n_stops);
755b4b94579Smrgpixman_image_t *pixman_image_create_conical_gradient (pixman_point_fixed_t         *center,
756b4b94579Smrg						      pixman_fixed_t                angle,
757b4b94579Smrg						      const pixman_gradient_stop_t *stops,
758b4b94579Smrg						      int                           n_stops);
759b4b94579Smrgpixman_image_t *pixman_image_create_bits             (pixman_format_code_t          format,
760b4b94579Smrg						      int                           width,
761b4b94579Smrg						      int                           height,
762b4b94579Smrg						      uint32_t                     *bits,
763b4b94579Smrg						      int                           rowstride_bytes);
764b4b94579Smrg
765b4b94579Smrg/* Destructor */
766b4b94579Smrgpixman_image_t *pixman_image_ref                     (pixman_image_t               *image);
767b4b94579Smrgpixman_bool_t   pixman_image_unref                   (pixman_image_t               *image);
768b4b94579Smrg
769dc259aabSmrgvoid		pixman_image_set_destroy_function    (pixman_image_t		   *image,
770dc259aabSmrg						      pixman_image_destroy_func_t   function,
771dc259aabSmrg						      void			   *data);
772b4b94579Smrg
773b4b94579Smrg/* Set properties */
774b4b94579Smrgpixman_bool_t   pixman_image_set_clip_region         (pixman_image_t               *image,
775b4b94579Smrg						      pixman_region16_t            *region);
776b4b94579Smrgpixman_bool_t   pixman_image_set_clip_region32       (pixman_image_t               *image,
777b4b94579Smrg						      pixman_region32_t            *region);
778b4b94579Smrgvoid		pixman_image_set_has_client_clip     (pixman_image_t               *image,
779b4b94579Smrg						      pixman_bool_t		    clien_clip);
780b4b94579Smrgpixman_bool_t   pixman_image_set_transform           (pixman_image_t               *image,
781b4b94579Smrg						      const pixman_transform_t     *transform);
782b4b94579Smrgvoid            pixman_image_set_repeat              (pixman_image_t               *image,
783b4b94579Smrg						      pixman_repeat_t               repeat);
784b4b94579Smrgpixman_bool_t   pixman_image_set_filter              (pixman_image_t               *image,
785b4b94579Smrg						      pixman_filter_t               filter,
786b4b94579Smrg						      const pixman_fixed_t         *filter_params,
787b4b94579Smrg						      int                           n_filter_params);
788b4b94579Smrgvoid		pixman_image_set_source_clipping     (pixman_image_t		   *image,
789b4b94579Smrg						      pixman_bool_t                 source_clipping);
790b4b94579Smrgvoid            pixman_image_set_alpha_map           (pixman_image_t               *image,
791b4b94579Smrg						      pixman_image_t               *alpha_map,
792b4b94579Smrg						      int16_t                       x,
793b4b94579Smrg						      int16_t                       y);
794b4b94579Smrgvoid            pixman_image_set_component_alpha     (pixman_image_t               *image,
795b4b94579Smrg						      pixman_bool_t                 component_alpha);
796b4b94579Smrgvoid		pixman_image_set_accessors	     (pixman_image_t		   *image,
797b4b94579Smrg						      pixman_read_memory_func_t	    read_func,
798b4b94579Smrg						      pixman_write_memory_func_t    write_func);
799b4b94579Smrgvoid		pixman_image_set_indexed	     (pixman_image_t		   *image,
800b4b94579Smrg						      const pixman_indexed_t	   *indexed);
801b4b94579Smrguint32_t       *pixman_image_get_data                (pixman_image_t               *image);
802b4b94579Smrgint		pixman_image_get_width               (pixman_image_t               *image);
803b4b94579Smrgint             pixman_image_get_height              (pixman_image_t               *image);
804317c648bSmrgint		pixman_image_get_stride              (pixman_image_t               *image); /* in bytes */
805b4b94579Smrgint		pixman_image_get_depth               (pixman_image_t		   *image);
806b4b94579Smrgpixman_bool_t	pixman_image_fill_rectangles	     (pixman_op_t		    op,
807b4b94579Smrg						      pixman_image_t		   *image,
808b4b94579Smrg						      pixman_color_t		   *color,
809b4b94579Smrg						      int			    n_rects,
810b4b94579Smrg						      const pixman_rectangle16_t   *rects);
811b4b94579Smrg
812b4b94579Smrg/* Composite */
813b4b94579Smrgpixman_bool_t pixman_compute_composite_region (pixman_region16_t *pRegion,
814b4b94579Smrg					       pixman_image_t    *pSrc,
815b4b94579Smrg					       pixman_image_t    *pMask,
816b4b94579Smrg					       pixman_image_t    *pDst,
817b4b94579Smrg					       int16_t            xSrc,
818b4b94579Smrg					       int16_t            ySrc,
819b4b94579Smrg					       int16_t            xMask,
820b4b94579Smrg					       int16_t            yMask,
821b4b94579Smrg					       int16_t            xDst,
822b4b94579Smrg					       int16_t            yDst,
823b4b94579Smrg					       uint16_t           width,
824b4b94579Smrg					       uint16_t           height);
825b4b94579Smrgvoid          pixman_image_composite          (pixman_op_t        op,
826b4b94579Smrg					       pixman_image_t    *src,
827b4b94579Smrg					       pixman_image_t    *mask,
828b4b94579Smrg					       pixman_image_t    *dest,
829b4b94579Smrg					       int16_t            src_x,
830b4b94579Smrg					       int16_t            src_y,
831b4b94579Smrg					       int16_t            mask_x,
832b4b94579Smrg					       int16_t            mask_y,
833b4b94579Smrg					       int16_t            dest_x,
834b4b94579Smrg					       int16_t            dest_y,
835b4b94579Smrg					       uint16_t           width,
836b4b94579Smrg					       uint16_t           height);
837b4b94579Smrg
838b4b94579Smrg/*
839b4b94579Smrg * Trapezoids
840b4b94579Smrg */
841b4b94579Smrgtypedef struct pixman_edge pixman_edge_t;
842b4b94579Smrgtypedef struct pixman_trapezoid pixman_trapezoid_t;
843b4b94579Smrgtypedef struct pixman_trap pixman_trap_t;
844b4b94579Smrgtypedef struct pixman_span_fix pixman_span_fix_t;
845b4b94579Smrg
846b4b94579Smrg/*
847b4b94579Smrg * An edge structure.  This represents a single polygon edge
848b4b94579Smrg * and can be quickly stepped across small or large gaps in the
849b4b94579Smrg * sample grid
850b4b94579Smrg */
851b4b94579Smrgstruct pixman_edge
852b4b94579Smrg{
853b4b94579Smrg    pixman_fixed_t	x;
854b4b94579Smrg    pixman_fixed_t	e;
855b4b94579Smrg    pixman_fixed_t   stepx;
856b4b94579Smrg    pixman_fixed_t   signdx;
857b4b94579Smrg    pixman_fixed_t   dy;
858b4b94579Smrg    pixman_fixed_t   dx;
859b4b94579Smrg
860b4b94579Smrg    pixman_fixed_t   stepx_small;
861b4b94579Smrg    pixman_fixed_t   stepx_big;
862b4b94579Smrg    pixman_fixed_t   dx_small;
863b4b94579Smrg    pixman_fixed_t   dx_big;
864b4b94579Smrg};
865b4b94579Smrg
866b4b94579Smrgstruct pixman_trapezoid
867b4b94579Smrg{
868b4b94579Smrg    pixman_fixed_t  top, bottom;
869b4b94579Smrg    pixman_line_fixed_t	left, right;
870b4b94579Smrg};
871b4b94579Smrg
872b4b94579Smrg
873b4b94579Smrg/* whether 't' is a well defined not obviously empty trapezoid */
874b4b94579Smrg#define pixman_trapezoid_valid(t)				\
875b4b94579Smrg    ((t)->left.p1.y != (t)->left.p2.y &&			   \
876b4b94579Smrg     (t)->right.p1.y != (t)->right.p2.y &&			   \
877b4b94579Smrg     (int) ((t)->bottom - (t)->top) > 0)
878b4b94579Smrg
879b4b94579Smrgstruct pixman_span_fix
880b4b94579Smrg{
881b4b94579Smrg    pixman_fixed_t	l, r, y;
882b4b94579Smrg};
883b4b94579Smrg
884b4b94579Smrgstruct pixman_trap
885b4b94579Smrg{
886b4b94579Smrg    pixman_span_fix_t	top, bot;
887b4b94579Smrg};
888b4b94579Smrg
889b4b94579Smrgpixman_fixed_t pixman_sample_ceil_y        (pixman_fixed_t             y,
890b4b94579Smrg					    int                        bpp);
891b4b94579Smrgpixman_fixed_t pixman_sample_floor_y       (pixman_fixed_t             y,
892b4b94579Smrg					    int                        bpp);
893b4b94579Smrgvoid           pixman_edge_step            (pixman_edge_t             *e,
894b4b94579Smrg					    int                        n);
895b4b94579Smrgvoid           pixman_edge_init            (pixman_edge_t             *e,
896b4b94579Smrg					    int                        bpp,
897b4b94579Smrg					    pixman_fixed_t             y_start,
898b4b94579Smrg					    pixman_fixed_t             x_top,
899b4b94579Smrg					    pixman_fixed_t             y_top,
900b4b94579Smrg					    pixman_fixed_t             x_bot,
901b4b94579Smrg					    pixman_fixed_t             y_bot);
902b4b94579Smrgvoid           pixman_line_fixed_edge_init (pixman_edge_t             *e,
903b4b94579Smrg					    int                        bpp,
904b4b94579Smrg					    pixman_fixed_t             y,
905b4b94579Smrg					    const pixman_line_fixed_t *line,
906b4b94579Smrg					    int                        x_off,
907b4b94579Smrg					    int                        y_off);
908b4b94579Smrgvoid           pixman_rasterize_edges      (pixman_image_t            *image,
909b4b94579Smrg					    pixman_edge_t             *l,
910b4b94579Smrg					    pixman_edge_t             *r,
911b4b94579Smrg					    pixman_fixed_t             t,
912b4b94579Smrg					    pixman_fixed_t             b);
913b4b94579Smrgvoid           pixman_add_traps            (pixman_image_t            *image,
914b4b94579Smrg					    int16_t                    x_off,
915b4b94579Smrg					    int16_t                    y_off,
916b4b94579Smrg					    int                        ntrap,
917b4b94579Smrg					    pixman_trap_t             *traps);
918b4b94579Smrgvoid           pixman_add_trapezoids       (pixman_image_t            *image,
919b4b94579Smrg					    int16_t                    x_off,
920b4b94579Smrg					    int                        y_off,
921b4b94579Smrg					    int                        ntraps,
922b4b94579Smrg					    const pixman_trapezoid_t  *traps);
923b4b94579Smrgvoid           pixman_rasterize_trapezoid  (pixman_image_t            *image,
924b4b94579Smrg					    const pixman_trapezoid_t  *trap,
925b4b94579Smrg					    int                        x_off,
926b4b94579Smrg					    int                        y_off);
927b4b94579Smrg
928b4b94579Smrg
929b4b94579Smrg#endif /* PIXMAN_H__ */
930