pixman.h revision 3ebd81ec
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)) 1303ebd81ecSjoerg#define pixman_int_to_fixed(i) ((pixman_fixed_t) ((i) * 65536)) 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 */ 2299a0cb412Smrgtypedef struct pixman_f_transform pixman_f_transform_t; 2309a0cb412Smrgtypedef struct pixman_f_vector pixman_f_vector_t; 2319a0cb412Smrg 232d0321353Smrgstruct pixman_f_vector 233d0321353Smrg{ 234317c648bSmrg double v[3]; 235317c648bSmrg}; 236317c648bSmrg 237d0321353Smrgstruct pixman_f_transform 238d0321353Smrg{ 239317c648bSmrg double m[3][3]; 240317c648bSmrg}; 241317c648bSmrg 242d0321353Smrgpixman_bool_t pixman_transform_from_pixman_f_transform (struct pixman_transform *t, 243d0321353Smrg const struct pixman_f_transform *ft); 244d0321353Smrgvoid pixman_f_transform_from_pixman_transform (struct pixman_f_transform *ft, 245d0321353Smrg const struct pixman_transform *t); 246d0321353Smrgpixman_bool_t pixman_f_transform_invert (struct pixman_f_transform *dst, 247d0321353Smrg const struct pixman_f_transform *src); 248d0321353Smrgpixman_bool_t pixman_f_transform_point (const struct pixman_f_transform *t, 249d0321353Smrg struct pixman_f_vector *v); 250d0321353Smrgvoid pixman_f_transform_point_3d (const struct pixman_f_transform *t, 251d0321353Smrg struct pixman_f_vector *v); 252d0321353Smrgvoid pixman_f_transform_multiply (struct pixman_f_transform *dst, 253d0321353Smrg const struct pixman_f_transform *l, 254d0321353Smrg const struct pixman_f_transform *r); 255d0321353Smrgvoid pixman_f_transform_init_scale (struct pixman_f_transform *t, 256d0321353Smrg double sx, 257d0321353Smrg double sy); 258d0321353Smrgpixman_bool_t pixman_f_transform_scale (struct pixman_f_transform *forward, 259d0321353Smrg struct pixman_f_transform *reverse, 260d0321353Smrg double sx, 261d0321353Smrg double sy); 262d0321353Smrgvoid pixman_f_transform_init_rotate (struct pixman_f_transform *t, 263d0321353Smrg double cos, 264d0321353Smrg double sin); 265d0321353Smrgpixman_bool_t pixman_f_transform_rotate (struct pixman_f_transform *forward, 266d0321353Smrg struct pixman_f_transform *reverse, 267d0321353Smrg double c, 268d0321353Smrg double s); 269d0321353Smrgvoid pixman_f_transform_init_translate (struct pixman_f_transform *t, 270d0321353Smrg double tx, 271d0321353Smrg double ty); 272d0321353Smrgpixman_bool_t pixman_f_transform_translate (struct pixman_f_transform *forward, 273d0321353Smrg struct pixman_f_transform *reverse, 274d0321353Smrg double tx, 275d0321353Smrg double ty); 276d0321353Smrgpixman_bool_t pixman_f_transform_bounds (const struct pixman_f_transform *t, 277d0321353Smrg struct pixman_box16 *b); 278d0321353Smrgvoid pixman_f_transform_init_identity (struct pixman_f_transform *t); 279317c648bSmrg 280b4b94579Smrgtypedef enum 281b4b94579Smrg{ 282b4b94579Smrg PIXMAN_REPEAT_NONE, 283b4b94579Smrg PIXMAN_REPEAT_NORMAL, 284b4b94579Smrg PIXMAN_REPEAT_PAD, 285b4b94579Smrg PIXMAN_REPEAT_REFLECT 286b4b94579Smrg} pixman_repeat_t; 287b4b94579Smrg 288b4b94579Smrgtypedef enum 289b4b94579Smrg{ 290b4b94579Smrg PIXMAN_FILTER_FAST, 291b4b94579Smrg PIXMAN_FILTER_GOOD, 292b4b94579Smrg PIXMAN_FILTER_BEST, 293b4b94579Smrg PIXMAN_FILTER_NEAREST, 294b4b94579Smrg PIXMAN_FILTER_BILINEAR, 2959a0cb412Smrg PIXMAN_FILTER_CONVOLUTION, 2969a0cb412Smrg 2979a0cb412Smrg /* The SEPARABLE_CONVOLUTION filter takes the following parameters: 2989a0cb412Smrg * 2999a0cb412Smrg * width: integer given as 16.16 fixpoint number 3009a0cb412Smrg * height: integer given as 16.16 fixpoint number 3019a0cb412Smrg * x_phase_bits: integer given as 16.16 fixpoint 3029a0cb412Smrg * y_phase_bits: integer given as 16.16 fixpoint 3039a0cb412Smrg * xtables: (1 << x_phase_bits) tables of size width 3049a0cb412Smrg * ytables: (1 << y_phase_bits) tables of size height 3059a0cb412Smrg * 3069a0cb412Smrg * When sampling at (x, y), the location is first rounded to one of 3079a0cb412Smrg * n_x_phases * n_y_phases subpixel positions. These subpixel positions 3089a0cb412Smrg * determine an xtable and a ytable to use. 3099a0cb412Smrg * 3109a0cb412Smrg * Conceptually a width x height matrix is then formed in which each entry 3119a0cb412Smrg * is the product of the corresponding entries in the x and y tables. 3129a0cb412Smrg * This matrix is then aligned with the image pixels such that its center 3139a0cb412Smrg * is as close as possible to the subpixel location chosen earlier. Then 3149a0cb412Smrg * the image is convolved with the matrix and the resulting pixel returned. 3159a0cb412Smrg */ 3169a0cb412Smrg PIXMAN_FILTER_SEPARABLE_CONVOLUTION 317b4b94579Smrg} pixman_filter_t; 318b4b94579Smrg 319b4b94579Smrgtypedef enum 320b4b94579Smrg{ 321b4b94579Smrg PIXMAN_OP_CLEAR = 0x00, 322b4b94579Smrg PIXMAN_OP_SRC = 0x01, 323b4b94579Smrg PIXMAN_OP_DST = 0x02, 324b4b94579Smrg PIXMAN_OP_OVER = 0x03, 325b4b94579Smrg PIXMAN_OP_OVER_REVERSE = 0x04, 326b4b94579Smrg PIXMAN_OP_IN = 0x05, 327b4b94579Smrg PIXMAN_OP_IN_REVERSE = 0x06, 328b4b94579Smrg PIXMAN_OP_OUT = 0x07, 329b4b94579Smrg PIXMAN_OP_OUT_REVERSE = 0x08, 330b4b94579Smrg PIXMAN_OP_ATOP = 0x09, 331b4b94579Smrg PIXMAN_OP_ATOP_REVERSE = 0x0a, 332b4b94579Smrg PIXMAN_OP_XOR = 0x0b, 333b4b94579Smrg PIXMAN_OP_ADD = 0x0c, 334b4b94579Smrg PIXMAN_OP_SATURATE = 0x0d, 335b4b94579Smrg 336b4b94579Smrg PIXMAN_OP_DISJOINT_CLEAR = 0x10, 337b4b94579Smrg PIXMAN_OP_DISJOINT_SRC = 0x11, 338b4b94579Smrg PIXMAN_OP_DISJOINT_DST = 0x12, 339b4b94579Smrg PIXMAN_OP_DISJOINT_OVER = 0x13, 340b4b94579Smrg PIXMAN_OP_DISJOINT_OVER_REVERSE = 0x14, 341b4b94579Smrg PIXMAN_OP_DISJOINT_IN = 0x15, 342b4b94579Smrg PIXMAN_OP_DISJOINT_IN_REVERSE = 0x16, 343b4b94579Smrg PIXMAN_OP_DISJOINT_OUT = 0x17, 344b4b94579Smrg PIXMAN_OP_DISJOINT_OUT_REVERSE = 0x18, 345b4b94579Smrg PIXMAN_OP_DISJOINT_ATOP = 0x19, 346b4b94579Smrg PIXMAN_OP_DISJOINT_ATOP_REVERSE = 0x1a, 347b4b94579Smrg PIXMAN_OP_DISJOINT_XOR = 0x1b, 348b4b94579Smrg 349b4b94579Smrg PIXMAN_OP_CONJOINT_CLEAR = 0x20, 350b4b94579Smrg PIXMAN_OP_CONJOINT_SRC = 0x21, 351b4b94579Smrg PIXMAN_OP_CONJOINT_DST = 0x22, 352b4b94579Smrg PIXMAN_OP_CONJOINT_OVER = 0x23, 353b4b94579Smrg PIXMAN_OP_CONJOINT_OVER_REVERSE = 0x24, 354b4b94579Smrg PIXMAN_OP_CONJOINT_IN = 0x25, 355b4b94579Smrg PIXMAN_OP_CONJOINT_IN_REVERSE = 0x26, 356b4b94579Smrg PIXMAN_OP_CONJOINT_OUT = 0x27, 357b4b94579Smrg PIXMAN_OP_CONJOINT_OUT_REVERSE = 0x28, 358b4b94579Smrg PIXMAN_OP_CONJOINT_ATOP = 0x29, 359b4b94579Smrg PIXMAN_OP_CONJOINT_ATOP_REVERSE = 0x2a, 360b4b94579Smrg PIXMAN_OP_CONJOINT_XOR = 0x2b, 361b4b94579Smrg 362dc259aabSmrg PIXMAN_OP_MULTIPLY = 0x30, 363dc259aabSmrg PIXMAN_OP_SCREEN = 0x31, 364dc259aabSmrg PIXMAN_OP_OVERLAY = 0x32, 365dc259aabSmrg PIXMAN_OP_DARKEN = 0x33, 366dc259aabSmrg PIXMAN_OP_LIGHTEN = 0x34, 367dc259aabSmrg PIXMAN_OP_COLOR_DODGE = 0x35, 368dc259aabSmrg PIXMAN_OP_COLOR_BURN = 0x36, 369dc259aabSmrg PIXMAN_OP_HARD_LIGHT = 0x37, 370dc259aabSmrg PIXMAN_OP_SOFT_LIGHT = 0x38, 371dc259aabSmrg PIXMAN_OP_DIFFERENCE = 0x39, 372dc259aabSmrg PIXMAN_OP_EXCLUSION = 0x3a, 373dc259aabSmrg PIXMAN_OP_HSL_HUE = 0x3b, 374dc259aabSmrg PIXMAN_OP_HSL_SATURATION = 0x3c, 375dc259aabSmrg PIXMAN_OP_HSL_COLOR = 0x3d, 376952204abSmrg PIXMAN_OP_HSL_LUMINOSITY = 0x3e 377dc259aabSmrg 378952204abSmrg#ifdef PIXMAN_USE_INTERNAL_API 379952204abSmrg , 380952204abSmrg PIXMAN_N_OPERATORS, 381afd9aa65Sapb PIXMAN_OP_NONE = PIXMAN_N_OPERATORS, 382afd9aa65Sapb PIXMAN_OP_any = PIXMAN_N_OPERATORS + 1 383952204abSmrg#endif 384b4b94579Smrg} pixman_op_t; 385b4b94579Smrg 386b4b94579Smrg/* 387b4b94579Smrg * Regions 388b4b94579Smrg */ 389b4b94579Smrgtypedef struct pixman_region16_data pixman_region16_data_t; 390b4b94579Smrgtypedef struct pixman_box16 pixman_box16_t; 391b4b94579Smrgtypedef struct pixman_rectangle16 pixman_rectangle16_t; 392b4b94579Smrgtypedef struct pixman_region16 pixman_region16_t; 393b4b94579Smrg 394b4b94579Smrgstruct pixman_region16_data { 395b4b94579Smrg long size; 396b4b94579Smrg long numRects; 397b4b94579Smrg/* pixman_box16_t rects[size]; in memory but not explicitly declared */ 398b4b94579Smrg}; 399b4b94579Smrg 400b4b94579Smrgstruct pixman_rectangle16 401b4b94579Smrg{ 402d0321353Smrg int16_t x, y; 403d0321353Smrg uint16_t width, height; 404b4b94579Smrg}; 405b4b94579Smrg 406b4b94579Smrgstruct pixman_box16 407b4b94579Smrg{ 408b4b94579Smrg int16_t x1, y1, x2, y2; 409b4b94579Smrg}; 410b4b94579Smrg 411b4b94579Smrgstruct pixman_region16 412b4b94579Smrg{ 413b4b94579Smrg pixman_box16_t extents; 414d0321353Smrg pixman_region16_data_t *data; 415b4b94579Smrg}; 416b4b94579Smrg 417b4b94579Smrgtypedef enum 418b4b94579Smrg{ 419b4b94579Smrg PIXMAN_REGION_OUT, 420b4b94579Smrg PIXMAN_REGION_IN, 421b4b94579Smrg PIXMAN_REGION_PART 422b4b94579Smrg} pixman_region_overlap_t; 423b4b94579Smrg 424d0321353Smrg/* This function exists only to make it possible to preserve 425d0321353Smrg * the X ABI - it should go away at first opportunity. 426b4b94579Smrg */ 427d0321353Smrgvoid pixman_region_set_static_pointers (pixman_box16_t *empty_box, 428d0321353Smrg pixman_region16_data_t *empty_data, 429d0321353Smrg pixman_region16_data_t *broken_data); 430b4b94579Smrg 431b4b94579Smrg/* creation/destruction */ 432d0321353Smrgvoid pixman_region_init (pixman_region16_t *region); 433d0321353Smrgvoid pixman_region_init_rect (pixman_region16_t *region, 434d0321353Smrg int x, 435d0321353Smrg int y, 436d0321353Smrg unsigned int width, 437d0321353Smrg unsigned int height); 438d0321353Smrgpixman_bool_t pixman_region_init_rects (pixman_region16_t *region, 439952204abSmrg const pixman_box16_t *boxes, 440d0321353Smrg int count); 441d0321353Smrgvoid pixman_region_init_with_extents (pixman_region16_t *region, 442d0321353Smrg pixman_box16_t *extents); 443952204abSmrgvoid pixman_region_init_from_image (pixman_region16_t *region, 444952204abSmrg pixman_image_t *image); 445d0321353Smrgvoid pixman_region_fini (pixman_region16_t *region); 446b4b94579Smrg 447b4b94579Smrg 448d0321353Smrg/* manipulation */ 449d0321353Smrgvoid pixman_region_translate (pixman_region16_t *region, 450d0321353Smrg int x, 451d0321353Smrg int y); 452d0321353Smrgpixman_bool_t pixman_region_copy (pixman_region16_t *dest, 453d0321353Smrg pixman_region16_t *source); 454d0321353Smrgpixman_bool_t pixman_region_intersect (pixman_region16_t *new_reg, 455d0321353Smrg pixman_region16_t *reg1, 456d0321353Smrg pixman_region16_t *reg2); 457d0321353Smrgpixman_bool_t pixman_region_union (pixman_region16_t *new_reg, 458d0321353Smrg pixman_region16_t *reg1, 459d0321353Smrg pixman_region16_t *reg2); 460d0321353Smrgpixman_bool_t pixman_region_union_rect (pixman_region16_t *dest, 461d0321353Smrg pixman_region16_t *source, 462d0321353Smrg int x, 463d0321353Smrg int y, 464d0321353Smrg unsigned int width, 465d0321353Smrg unsigned int height); 4661b18d63aSmrgpixman_bool_t pixman_region_intersect_rect (pixman_region16_t *dest, 4671b18d63aSmrg pixman_region16_t *source, 4681b18d63aSmrg int x, 4691b18d63aSmrg int y, 4701b18d63aSmrg unsigned int width, 4711b18d63aSmrg unsigned int height); 472d0321353Smrgpixman_bool_t pixman_region_subtract (pixman_region16_t *reg_d, 473d0321353Smrg pixman_region16_t *reg_m, 474d0321353Smrg pixman_region16_t *reg_s); 475d0321353Smrgpixman_bool_t pixman_region_inverse (pixman_region16_t *new_reg, 476d0321353Smrg pixman_region16_t *reg1, 477d0321353Smrg pixman_box16_t *inv_rect); 478d0321353Smrgpixman_bool_t pixman_region_contains_point (pixman_region16_t *region, 479d0321353Smrg int x, 480d0321353Smrg int y, 481d0321353Smrg pixman_box16_t *box); 482952204abSmrgpixman_region_overlap_t pixman_region_contains_rectangle (pixman_region16_t *region, 483d0321353Smrg pixman_box16_t *prect); 484d0321353Smrgpixman_bool_t pixman_region_not_empty (pixman_region16_t *region); 485d0321353Smrgpixman_box16_t * pixman_region_extents (pixman_region16_t *region); 486d0321353Smrgint pixman_region_n_rects (pixman_region16_t *region); 487d0321353Smrgpixman_box16_t * pixman_region_rectangles (pixman_region16_t *region, 488d0321353Smrg int *n_rects); 489d0321353Smrgpixman_bool_t pixman_region_equal (pixman_region16_t *region1, 490d0321353Smrg pixman_region16_t *region2); 491d0321353Smrgpixman_bool_t pixman_region_selfcheck (pixman_region16_t *region); 492d0321353Smrgvoid pixman_region_reset (pixman_region16_t *region, 493d0321353Smrg pixman_box16_t *box); 49481988197Sjmcneillvoid pixman_region_clear (pixman_region16_t *region); 495b4b94579Smrg/* 496b4b94579Smrg * 32 bit regions 497b4b94579Smrg */ 498b4b94579Smrgtypedef struct pixman_region32_data pixman_region32_data_t; 499b4b94579Smrgtypedef struct pixman_box32 pixman_box32_t; 500b4b94579Smrgtypedef struct pixman_rectangle32 pixman_rectangle32_t; 501b4b94579Smrgtypedef struct pixman_region32 pixman_region32_t; 502b4b94579Smrg 503b4b94579Smrgstruct pixman_region32_data { 504b4b94579Smrg long size; 505b4b94579Smrg long numRects; 506b4b94579Smrg/* pixman_box32_t rects[size]; in memory but not explicitly declared */ 507b4b94579Smrg}; 508b4b94579Smrg 509b4b94579Smrgstruct pixman_rectangle32 510b4b94579Smrg{ 511b4b94579Smrg int32_t x, y; 512b4b94579Smrg uint32_t width, height; 513b4b94579Smrg}; 514b4b94579Smrg 515b4b94579Smrgstruct pixman_box32 516b4b94579Smrg{ 517b4b94579Smrg int32_t x1, y1, x2, y2; 518b4b94579Smrg}; 519b4b94579Smrg 520b4b94579Smrgstruct pixman_region32 521b4b94579Smrg{ 522b4b94579Smrg pixman_box32_t extents; 523b4b94579Smrg pixman_region32_data_t *data; 524b4b94579Smrg}; 525b4b94579Smrg 526b4b94579Smrg/* creation/destruction */ 527b4b94579Smrgvoid pixman_region32_init (pixman_region32_t *region); 528b4b94579Smrgvoid pixman_region32_init_rect (pixman_region32_t *region, 529b4b94579Smrg int x, 530b4b94579Smrg int y, 531b4b94579Smrg unsigned int width, 532b4b94579Smrg unsigned int height); 533b4b94579Smrgpixman_bool_t pixman_region32_init_rects (pixman_region32_t *region, 534952204abSmrg const pixman_box32_t *boxes, 535b4b94579Smrg int count); 536b4b94579Smrgvoid pixman_region32_init_with_extents (pixman_region32_t *region, 537b4b94579Smrg pixman_box32_t *extents); 538952204abSmrgvoid pixman_region32_init_from_image (pixman_region32_t *region, 539952204abSmrg pixman_image_t *image); 540b4b94579Smrgvoid pixman_region32_fini (pixman_region32_t *region); 541b4b94579Smrg 542b4b94579Smrg 543b4b94579Smrg/* manipulation */ 544b4b94579Smrgvoid pixman_region32_translate (pixman_region32_t *region, 545b4b94579Smrg int x, 546b4b94579Smrg int y); 547b4b94579Smrgpixman_bool_t pixman_region32_copy (pixman_region32_t *dest, 548b4b94579Smrg pixman_region32_t *source); 549d0321353Smrgpixman_bool_t pixman_region32_intersect (pixman_region32_t *new_reg, 550b4b94579Smrg pixman_region32_t *reg1, 551b4b94579Smrg pixman_region32_t *reg2); 552d0321353Smrgpixman_bool_t pixman_region32_union (pixman_region32_t *new_reg, 553b4b94579Smrg pixman_region32_t *reg1, 554b4b94579Smrg pixman_region32_t *reg2); 5551b18d63aSmrgpixman_bool_t pixman_region32_intersect_rect (pixman_region32_t *dest, 5561b18d63aSmrg pixman_region32_t *source, 5571b18d63aSmrg int x, 5581b18d63aSmrg int y, 5591b18d63aSmrg unsigned int width, 5601b18d63aSmrg unsigned int height); 561b4b94579Smrgpixman_bool_t pixman_region32_union_rect (pixman_region32_t *dest, 562b4b94579Smrg pixman_region32_t *source, 563b4b94579Smrg int x, 564b4b94579Smrg int y, 565b4b94579Smrg unsigned int width, 566b4b94579Smrg unsigned int height); 567d0321353Smrgpixman_bool_t pixman_region32_subtract (pixman_region32_t *reg_d, 568d0321353Smrg pixman_region32_t *reg_m, 569d0321353Smrg pixman_region32_t *reg_s); 570d0321353Smrgpixman_bool_t pixman_region32_inverse (pixman_region32_t *new_reg, 571b4b94579Smrg pixman_region32_t *reg1, 572d0321353Smrg pixman_box32_t *inv_rect); 573b4b94579Smrgpixman_bool_t pixman_region32_contains_point (pixman_region32_t *region, 574b4b94579Smrg int x, 575b4b94579Smrg int y, 576b4b94579Smrg pixman_box32_t *box); 577b4b94579Smrgpixman_region_overlap_t pixman_region32_contains_rectangle (pixman_region32_t *region, 578b4b94579Smrg pixman_box32_t *prect); 579b4b94579Smrgpixman_bool_t pixman_region32_not_empty (pixman_region32_t *region); 580b4b94579Smrgpixman_box32_t * pixman_region32_extents (pixman_region32_t *region); 581b4b94579Smrgint pixman_region32_n_rects (pixman_region32_t *region); 582b4b94579Smrgpixman_box32_t * pixman_region32_rectangles (pixman_region32_t *region, 583b4b94579Smrg int *n_rects); 584b4b94579Smrgpixman_bool_t pixman_region32_equal (pixman_region32_t *region1, 585b4b94579Smrg pixman_region32_t *region2); 586b4b94579Smrgpixman_bool_t pixman_region32_selfcheck (pixman_region32_t *region); 587b4b94579Smrgvoid pixman_region32_reset (pixman_region32_t *region, 588b4b94579Smrg pixman_box32_t *box); 58981988197Sjmcneillvoid pixman_region32_clear (pixman_region32_t *region); 590b4b94579Smrg 591b4b94579Smrg 592b4b94579Smrg/* Copy / Fill / Misc */ 593b4b94579Smrgpixman_bool_t pixman_blt (uint32_t *src_bits, 594b4b94579Smrg uint32_t *dst_bits, 595b4b94579Smrg int src_stride, 596b4b94579Smrg int dst_stride, 597b4b94579Smrg int src_bpp, 598b4b94579Smrg int dst_bpp, 599b4b94579Smrg int src_x, 600b4b94579Smrg int src_y, 6016ba797d6Smrg int dest_x, 6026ba797d6Smrg int dest_y, 603b4b94579Smrg int width, 604b4b94579Smrg int height); 605b4b94579Smrgpixman_bool_t pixman_fill (uint32_t *bits, 606b4b94579Smrg int stride, 607b4b94579Smrg int bpp, 608b4b94579Smrg int x, 609b4b94579Smrg int y, 610b4b94579Smrg int width, 611b4b94579Smrg int height, 612b4b94579Smrg uint32_t _xor); 613b4b94579Smrg 614b4b94579Smrgint pixman_version (void); 615b4b94579Smrgconst char* pixman_version_string (void); 616b4b94579Smrg 617b4b94579Smrg/* 618b4b94579Smrg * Images 619b4b94579Smrg */ 620b4b94579Smrgtypedef struct pixman_indexed pixman_indexed_t; 621b4b94579Smrgtypedef struct pixman_gradient_stop pixman_gradient_stop_t; 622b4b94579Smrg 623b4b94579Smrgtypedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size); 624b4b94579Smrgtypedef void (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size); 625b4b94579Smrg 626dc259aabSmrgtypedef void (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data); 627dc259aabSmrg 628b4b94579Smrgstruct pixman_gradient_stop { 629b4b94579Smrg pixman_fixed_t x; 630b4b94579Smrg pixman_color_t color; 631b4b94579Smrg}; 632b4b94579Smrg 633b4b94579Smrg#define PIXMAN_MAX_INDEXED 256 /* XXX depth must be <= 8 */ 634b4b94579Smrg 635b4b94579Smrg#if PIXMAN_MAX_INDEXED <= 256 636b4b94579Smrgtypedef uint8_t pixman_index_type; 637b4b94579Smrg#endif 638b4b94579Smrg 639b4b94579Smrgstruct pixman_indexed 640b4b94579Smrg{ 641b4b94579Smrg pixman_bool_t color; 642b4b94579Smrg uint32_t rgba[PIXMAN_MAX_INDEXED]; 643b4b94579Smrg pixman_index_type ent[32768]; 644b4b94579Smrg}; 645b4b94579Smrg 646b4b94579Smrg/* 647b4b94579Smrg * While the protocol is generous in format support, the 648b4b94579Smrg * sample implementation allows only packed RGB and GBR 649b4b94579Smrg * representations for data to simplify software rendering, 650b4b94579Smrg */ 651b4b94579Smrg#define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ 652b4b94579Smrg ((type) << 16) | \ 653b4b94579Smrg ((a) << 12) | \ 654b4b94579Smrg ((r) << 8) | \ 655b4b94579Smrg ((g) << 4) | \ 656b4b94579Smrg ((b))) 657b4b94579Smrg 658b4b94579Smrg#define PIXMAN_FORMAT_BPP(f) (((f) >> 24) ) 659b4b94579Smrg#define PIXMAN_FORMAT_TYPE(f) (((f) >> 16) & 0xff) 660b4b94579Smrg#define PIXMAN_FORMAT_A(f) (((f) >> 12) & 0x0f) 661b4b94579Smrg#define PIXMAN_FORMAT_R(f) (((f) >> 8) & 0x0f) 662b4b94579Smrg#define PIXMAN_FORMAT_G(f) (((f) >> 4) & 0x0f) 663b4b94579Smrg#define PIXMAN_FORMAT_B(f) (((f) ) & 0x0f) 664b4b94579Smrg#define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff) 665b4b94579Smrg#define PIXMAN_FORMAT_VIS(f) (((f) ) & 0xffff) 666b4b94579Smrg#define PIXMAN_FORMAT_DEPTH(f) (PIXMAN_FORMAT_A(f) + \ 667b4b94579Smrg PIXMAN_FORMAT_R(f) + \ 668b4b94579Smrg PIXMAN_FORMAT_G(f) + \ 669b4b94579Smrg PIXMAN_FORMAT_B(f)) 670b4b94579Smrg 671b4b94579Smrg#define PIXMAN_TYPE_OTHER 0 672b4b94579Smrg#define PIXMAN_TYPE_A 1 673b4b94579Smrg#define PIXMAN_TYPE_ARGB 2 674b4b94579Smrg#define PIXMAN_TYPE_ABGR 3 675b4b94579Smrg#define PIXMAN_TYPE_COLOR 4 676b4b94579Smrg#define PIXMAN_TYPE_GRAY 5 677b4b94579Smrg#define PIXMAN_TYPE_YUY2 6 678b4b94579Smrg#define PIXMAN_TYPE_YV12 7 679317c648bSmrg#define PIXMAN_TYPE_BGRA 8 6806ba797d6Smrg#define PIXMAN_TYPE_RGBA 9 68181988197Sjmcneill#define PIXMAN_TYPE_ARGB_SRGB 10 682b4b94579Smrg 683317c648bSmrg#define PIXMAN_FORMAT_COLOR(f) \ 684317c648bSmrg (PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB || \ 685317c648bSmrg PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ABGR || \ 6866ba797d6Smrg PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_BGRA || \ 6876ba797d6Smrg PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA) 688b4b94579Smrg 689b4b94579Smrg/* 32bpp formats */ 690b4b94579Smrgtypedef enum { 691d0321353Smrg PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8), 692d0321353Smrg PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8), 693d0321353Smrg PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8), 694d0321353Smrg PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8), 695d0321353Smrg PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8), 696d0321353Smrg PIXMAN_b8g8r8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8), 6976ba797d6Smrg PIXMAN_r8g8b8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8), 6986ba797d6Smrg PIXMAN_r8g8b8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8), 6991b18d63aSmrg PIXMAN_x14r6g6b6 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6), 700d0321353Smrg PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), 701d0321353Smrg PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), 70227693ee9Sveego PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), 70327693ee9Sveego PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), 70427693ee9Sveego 70581988197Sjmcneill/* sRGB formats */ 70681988197Sjmcneill PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8), 70781988197Sjmcneill 708b4b94579Smrg/* 24bpp formats */ 709d0321353Smrg PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8), 710d0321353Smrg PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8), 711952204abSmrg 712b4b94579Smrg/* 16bpp formats */ 713d0321353Smrg PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5), 714d0321353Smrg PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5), 715952204abSmrg 716d0321353Smrg PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5), 717d0321353Smrg PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5), 718d0321353Smrg PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5), 719d0321353Smrg PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5), 720d0321353Smrg PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4), 721d0321353Smrg PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4), 722d0321353Smrg PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4), 723d0321353Smrg PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4), 724952204abSmrg 725b4b94579Smrg/* 8bpp formats */ 726d0321353Smrg PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0), 727d0321353Smrg PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2), 728d0321353Smrg PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2), 729d0321353Smrg PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2), 730d0321353Smrg PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2), 731952204abSmrg 732d0321353Smrg PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), 733d0321353Smrg PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), 734952204abSmrg 735d0321353Smrg PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0), 736952204abSmrg 737d0321353Smrg PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), 738d0321353Smrg PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), 739952204abSmrg 740b4b94579Smrg/* 4bpp formats */ 741d0321353Smrg PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0), 742d0321353Smrg PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1), 743d0321353Smrg PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1), 744d0321353Smrg PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1), 745d0321353Smrg PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1), 746952204abSmrg 747d0321353Smrg PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0), 748d0321353Smrg PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0), 749952204abSmrg 750b4b94579Smrg/* 1bpp formats */ 751d0321353Smrg PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0), 752952204abSmrg 753d0321353Smrg PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0), 754b4b94579Smrg 755b4b94579Smrg/* YUV formats */ 756d0321353Smrg PIXMAN_yuy2 = PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0), 757d0321353Smrg PIXMAN_yv12 = PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0) 758b4b94579Smrg} pixman_format_code_t; 759b4b94579Smrg 760b4b94579Smrg/* Querying supported format values. */ 761b4b94579Smrgpixman_bool_t pixman_format_supported_destination (pixman_format_code_t format); 762b4b94579Smrgpixman_bool_t pixman_format_supported_source (pixman_format_code_t format); 763b4b94579Smrg 764b4b94579Smrg/* Constructors */ 76581988197Sjmcneillpixman_image_t *pixman_image_create_solid_fill (const pixman_color_t *color); 76681988197Sjmcneillpixman_image_t *pixman_image_create_linear_gradient (const pixman_point_fixed_t *p1, 76781988197Sjmcneill const pixman_point_fixed_t *p2, 768b4b94579Smrg const pixman_gradient_stop_t *stops, 769b4b94579Smrg int n_stops); 77081988197Sjmcneillpixman_image_t *pixman_image_create_radial_gradient (const pixman_point_fixed_t *inner, 77181988197Sjmcneill const pixman_point_fixed_t *outer, 772b4b94579Smrg pixman_fixed_t inner_radius, 773b4b94579Smrg pixman_fixed_t outer_radius, 774b4b94579Smrg const pixman_gradient_stop_t *stops, 775b4b94579Smrg int n_stops); 77681988197Sjmcneillpixman_image_t *pixman_image_create_conical_gradient (const pixman_point_fixed_t *center, 777b4b94579Smrg pixman_fixed_t angle, 778b4b94579Smrg const pixman_gradient_stop_t *stops, 779b4b94579Smrg int n_stops); 780b4b94579Smrgpixman_image_t *pixman_image_create_bits (pixman_format_code_t format, 781b4b94579Smrg int width, 782b4b94579Smrg int height, 783b4b94579Smrg uint32_t *bits, 784b4b94579Smrg int rowstride_bytes); 78581988197Sjmcneillpixman_image_t *pixman_image_create_bits_no_clear (pixman_format_code_t format, 78681988197Sjmcneill int width, 78781988197Sjmcneill int height, 78881988197Sjmcneill uint32_t * bits, 78981988197Sjmcneill int rowstride_bytes); 790b4b94579Smrg 791b4b94579Smrg/* Destructor */ 792b4b94579Smrgpixman_image_t *pixman_image_ref (pixman_image_t *image); 793b4b94579Smrgpixman_bool_t pixman_image_unref (pixman_image_t *image); 794b4b94579Smrg 795dc259aabSmrgvoid pixman_image_set_destroy_function (pixman_image_t *image, 796dc259aabSmrg pixman_image_destroy_func_t function, 797dc259aabSmrg void *data); 798952204abSmrgvoid * pixman_image_get_destroy_data (pixman_image_t *image); 799b4b94579Smrg 800b4b94579Smrg/* Set properties */ 801b4b94579Smrgpixman_bool_t pixman_image_set_clip_region (pixman_image_t *image, 802b4b94579Smrg pixman_region16_t *region); 803b4b94579Smrgpixman_bool_t pixman_image_set_clip_region32 (pixman_image_t *image, 804b4b94579Smrg pixman_region32_t *region); 805b4b94579Smrgvoid pixman_image_set_has_client_clip (pixman_image_t *image, 806b4b94579Smrg pixman_bool_t clien_clip); 807b4b94579Smrgpixman_bool_t pixman_image_set_transform (pixman_image_t *image, 808b4b94579Smrg const pixman_transform_t *transform); 809b4b94579Smrgvoid pixman_image_set_repeat (pixman_image_t *image, 810b4b94579Smrg pixman_repeat_t repeat); 811b4b94579Smrgpixman_bool_t pixman_image_set_filter (pixman_image_t *image, 812b4b94579Smrg pixman_filter_t filter, 813b4b94579Smrg const pixman_fixed_t *filter_params, 814b4b94579Smrg int n_filter_params); 815b4b94579Smrgvoid pixman_image_set_source_clipping (pixman_image_t *image, 816b4b94579Smrg pixman_bool_t source_clipping); 817b4b94579Smrgvoid pixman_image_set_alpha_map (pixman_image_t *image, 818b4b94579Smrg pixman_image_t *alpha_map, 819b4b94579Smrg int16_t x, 820b4b94579Smrg int16_t y); 821b4b94579Smrgvoid pixman_image_set_component_alpha (pixman_image_t *image, 822b4b94579Smrg pixman_bool_t component_alpha); 8231b18d63aSmrgpixman_bool_t pixman_image_get_component_alpha (pixman_image_t *image); 824b4b94579Smrgvoid pixman_image_set_accessors (pixman_image_t *image, 825b4b94579Smrg pixman_read_memory_func_t read_func, 826b4b94579Smrg pixman_write_memory_func_t write_func); 827b4b94579Smrgvoid pixman_image_set_indexed (pixman_image_t *image, 828b4b94579Smrg const pixman_indexed_t *indexed); 829b4b94579Smrguint32_t *pixman_image_get_data (pixman_image_t *image); 830b4b94579Smrgint pixman_image_get_width (pixman_image_t *image); 831b4b94579Smrgint pixman_image_get_height (pixman_image_t *image); 832317c648bSmrgint pixman_image_get_stride (pixman_image_t *image); /* in bytes */ 833b4b94579Smrgint pixman_image_get_depth (pixman_image_t *image); 8341b18d63aSmrgpixman_format_code_t pixman_image_get_format (pixman_image_t *image); 8359a0cb412Smrg 8369a0cb412Smrgtypedef enum 8379a0cb412Smrg{ 8389a0cb412Smrg PIXMAN_KERNEL_IMPULSE, 8399a0cb412Smrg PIXMAN_KERNEL_BOX, 8409a0cb412Smrg PIXMAN_KERNEL_LINEAR, 8419a0cb412Smrg PIXMAN_KERNEL_CUBIC, 8429a0cb412Smrg PIXMAN_KERNEL_GAUSSIAN, 8439a0cb412Smrg PIXMAN_KERNEL_LANCZOS2, 8449a0cb412Smrg PIXMAN_KERNEL_LANCZOS3, 8459a0cb412Smrg PIXMAN_KERNEL_LANCZOS3_STRETCHED /* Jim Blinn's 'nice' filter */ 8469a0cb412Smrg} pixman_kernel_t; 8479a0cb412Smrg 8489a0cb412Smrg/* Create the parameter list for a SEPARABLE_CONVOLUTION filter 8499a0cb412Smrg * with the given kernels and scale parameters. 8509a0cb412Smrg */ 8519a0cb412Smrgpixman_fixed_t * 8529a0cb412Smrgpixman_filter_create_separable_convolution (int *n_values, 8539a0cb412Smrg pixman_fixed_t scale_x, 8549a0cb412Smrg pixman_fixed_t scale_y, 8559a0cb412Smrg pixman_kernel_t reconstruct_x, 8569a0cb412Smrg pixman_kernel_t reconstruct_y, 8579a0cb412Smrg pixman_kernel_t sample_x, 8589a0cb412Smrg pixman_kernel_t sample_y, 8599a0cb412Smrg int subsample_bits_x, 8609a0cb412Smrg int subsample_bits_y); 8619a0cb412Smrg 862b4b94579Smrgpixman_bool_t pixman_image_fill_rectangles (pixman_op_t op, 863b4b94579Smrg pixman_image_t *image, 86481988197Sjmcneill const pixman_color_t *color, 865b4b94579Smrg int n_rects, 866b4b94579Smrg const pixman_rectangle16_t *rects); 867952204abSmrgpixman_bool_t pixman_image_fill_boxes (pixman_op_t op, 868952204abSmrg pixman_image_t *dest, 86981988197Sjmcneill const pixman_color_t *color, 870952204abSmrg int n_boxes, 871952204abSmrg const pixman_box32_t *boxes); 872b4b94579Smrg 873b4b94579Smrg/* Composite */ 874d0321353Smrgpixman_bool_t pixman_compute_composite_region (pixman_region16_t *region, 875d0321353Smrg pixman_image_t *src_image, 876d0321353Smrg pixman_image_t *mask_image, 8776ba797d6Smrg pixman_image_t *dest_image, 878d0321353Smrg int16_t src_x, 879d0321353Smrg int16_t src_y, 880d0321353Smrg int16_t mask_x, 881d0321353Smrg int16_t mask_y, 882d0321353Smrg int16_t dest_x, 883d0321353Smrg int16_t dest_y, 884b4b94579Smrg uint16_t width, 885b4b94579Smrg uint16_t height); 886b4b94579Smrgvoid pixman_image_composite (pixman_op_t op, 887b4b94579Smrg pixman_image_t *src, 888b4b94579Smrg pixman_image_t *mask, 889b4b94579Smrg pixman_image_t *dest, 890b4b94579Smrg int16_t src_x, 891b4b94579Smrg int16_t src_y, 892b4b94579Smrg int16_t mask_x, 893b4b94579Smrg int16_t mask_y, 894b4b94579Smrg int16_t dest_x, 895b4b94579Smrg int16_t dest_y, 896b4b94579Smrg uint16_t width, 897b4b94579Smrg uint16_t height); 898952204abSmrgvoid pixman_image_composite32 (pixman_op_t op, 899952204abSmrg pixman_image_t *src, 900952204abSmrg pixman_image_t *mask, 901952204abSmrg pixman_image_t *dest, 902952204abSmrg int32_t src_x, 903952204abSmrg int32_t src_y, 904952204abSmrg int32_t mask_x, 905952204abSmrg int32_t mask_y, 906952204abSmrg int32_t dest_x, 907952204abSmrg int32_t dest_y, 908952204abSmrg int32_t width, 909952204abSmrg int32_t height); 910b4b94579Smrg 9111b18d63aSmrg/* Executive Summary: This function is a no-op that only exists 9121b18d63aSmrg * for historical reasons. 9131b18d63aSmrg * 9141b18d63aSmrg * There used to be a bug in the X server where it would rely on 9151b18d63aSmrg * out-of-bounds accesses when it was asked to composite with a 9161b18d63aSmrg * window as the source. It would create a pixman image pointing 9171b18d63aSmrg * to some bogus position in memory, but then set a clip region 9181b18d63aSmrg * to the position where the actual bits were. 919d0321353Smrg * 920d0321353Smrg * Due to a bug in old versions of pixman, where it would not clip 921d0321353Smrg * against the image bounds when a clip region was set, this would 9221b18d63aSmrg * actually work. So when the pixman bug was fixed, a workaround was 9231b18d63aSmrg * added to allow certain out-of-bound accesses. This function disabled 9241b18d63aSmrg * those workarounds. 925d0321353Smrg * 9261b18d63aSmrg * Since 0.21.2, pixman doesn't do these workarounds anymore, so now this 9271b18d63aSmrg * function is a no-op. 928d0321353Smrg */ 9291b18d63aSmrgvoid pixman_disable_out_of_bounds_workaround (void); 930d0321353Smrg 93181988197Sjmcneill/* 93281988197Sjmcneill * Glyphs 93381988197Sjmcneill */ 93481988197Sjmcneilltypedef struct pixman_glyph_cache_t pixman_glyph_cache_t; 93581988197Sjmcneilltypedef struct 93681988197Sjmcneill{ 93781988197Sjmcneill int x, y; 93881988197Sjmcneill const void *glyph; 93981988197Sjmcneill} pixman_glyph_t; 94081988197Sjmcneill 94181988197Sjmcneillpixman_glyph_cache_t *pixman_glyph_cache_create (void); 94281988197Sjmcneillvoid pixman_glyph_cache_destroy (pixman_glyph_cache_t *cache); 94381988197Sjmcneillvoid pixman_glyph_cache_freeze (pixman_glyph_cache_t *cache); 94481988197Sjmcneillvoid pixman_glyph_cache_thaw (pixman_glyph_cache_t *cache); 94581988197Sjmcneillconst void * pixman_glyph_cache_lookup (pixman_glyph_cache_t *cache, 94681988197Sjmcneill void *font_key, 94781988197Sjmcneill void *glyph_key); 94881988197Sjmcneillconst void * pixman_glyph_cache_insert (pixman_glyph_cache_t *cache, 94981988197Sjmcneill void *font_key, 95081988197Sjmcneill void *glyph_key, 95181988197Sjmcneill int origin_x, 95281988197Sjmcneill int origin_y, 95381988197Sjmcneill pixman_image_t *glyph_image); 95481988197Sjmcneillvoid pixman_glyph_cache_remove (pixman_glyph_cache_t *cache, 95581988197Sjmcneill void *font_key, 95681988197Sjmcneill void *glyph_key); 95781988197Sjmcneillvoid pixman_glyph_get_extents (pixman_glyph_cache_t *cache, 95881988197Sjmcneill int n_glyphs, 95981988197Sjmcneill pixman_glyph_t *glyphs, 96081988197Sjmcneill pixman_box32_t *extents); 96181988197Sjmcneillpixman_format_code_t pixman_glyph_get_mask_format (pixman_glyph_cache_t *cache, 96281988197Sjmcneill int n_glyphs, 96381988197Sjmcneill const pixman_glyph_t *glyphs); 96481988197Sjmcneillvoid pixman_composite_glyphs (pixman_op_t op, 96581988197Sjmcneill pixman_image_t *src, 96681988197Sjmcneill pixman_image_t *dest, 96781988197Sjmcneill pixman_format_code_t mask_format, 96881988197Sjmcneill int32_t src_x, 96981988197Sjmcneill int32_t src_y, 97081988197Sjmcneill int32_t mask_x, 97181988197Sjmcneill int32_t mask_y, 97281988197Sjmcneill int32_t dest_x, 97381988197Sjmcneill int32_t dest_y, 97481988197Sjmcneill int32_t width, 97581988197Sjmcneill int32_t height, 97681988197Sjmcneill pixman_glyph_cache_t *cache, 97781988197Sjmcneill int n_glyphs, 97881988197Sjmcneill const pixman_glyph_t *glyphs); 97981988197Sjmcneillvoid pixman_composite_glyphs_no_mask (pixman_op_t op, 98081988197Sjmcneill pixman_image_t *src, 98181988197Sjmcneill pixman_image_t *dest, 98281988197Sjmcneill int32_t src_x, 98381988197Sjmcneill int32_t src_y, 98481988197Sjmcneill int32_t dest_x, 98581988197Sjmcneill int32_t dest_y, 98681988197Sjmcneill pixman_glyph_cache_t *cache, 98781988197Sjmcneill int n_glyphs, 98881988197Sjmcneill const pixman_glyph_t *glyphs); 98981988197Sjmcneill 990b4b94579Smrg/* 991b4b94579Smrg * Trapezoids 992b4b94579Smrg */ 993b4b94579Smrgtypedef struct pixman_edge pixman_edge_t; 994b4b94579Smrgtypedef struct pixman_trapezoid pixman_trapezoid_t; 995b4b94579Smrgtypedef struct pixman_trap pixman_trap_t; 996b4b94579Smrgtypedef struct pixman_span_fix pixman_span_fix_t; 9976ba797d6Smrgtypedef struct pixman_triangle pixman_triangle_t; 998b4b94579Smrg 999b4b94579Smrg/* 1000b4b94579Smrg * An edge structure. This represents a single polygon edge 1001b4b94579Smrg * and can be quickly stepped across small or large gaps in the 1002b4b94579Smrg * sample grid 1003b4b94579Smrg */ 1004b4b94579Smrgstruct pixman_edge 1005b4b94579Smrg{ 1006b4b94579Smrg pixman_fixed_t x; 1007b4b94579Smrg pixman_fixed_t e; 1008d0321353Smrg pixman_fixed_t stepx; 1009d0321353Smrg pixman_fixed_t signdx; 1010d0321353Smrg pixman_fixed_t dy; 1011d0321353Smrg pixman_fixed_t dx; 1012d0321353Smrg 1013d0321353Smrg pixman_fixed_t stepx_small; 1014d0321353Smrg pixman_fixed_t stepx_big; 1015d0321353Smrg pixman_fixed_t dx_small; 1016d0321353Smrg pixman_fixed_t dx_big; 1017b4b94579Smrg}; 1018b4b94579Smrg 1019b4b94579Smrgstruct pixman_trapezoid 1020b4b94579Smrg{ 1021d0321353Smrg pixman_fixed_t top, bottom; 1022b4b94579Smrg pixman_line_fixed_t left, right; 1023b4b94579Smrg}; 1024b4b94579Smrg 10256ba797d6Smrgstruct pixman_triangle 10266ba797d6Smrg{ 10276ba797d6Smrg pixman_point_fixed_t p1, p2, p3; 10286ba797d6Smrg}; 1029b4b94579Smrg 1030b4b94579Smrg/* whether 't' is a well defined not obviously empty trapezoid */ 1031d0321353Smrg#define pixman_trapezoid_valid(t) \ 1032b4b94579Smrg ((t)->left.p1.y != (t)->left.p2.y && \ 1033b4b94579Smrg (t)->right.p1.y != (t)->right.p2.y && \ 1034f83768c3Smrg ((t)->bottom > (t)->top)) 1035b4b94579Smrg 1036b4b94579Smrgstruct pixman_span_fix 1037b4b94579Smrg{ 1038b4b94579Smrg pixman_fixed_t l, r, y; 1039b4b94579Smrg}; 1040b4b94579Smrg 1041b4b94579Smrgstruct pixman_trap 1042b4b94579Smrg{ 1043b4b94579Smrg pixman_span_fix_t top, bot; 1044b4b94579Smrg}; 1045b4b94579Smrg 1046b4b94579Smrgpixman_fixed_t pixman_sample_ceil_y (pixman_fixed_t y, 1047b4b94579Smrg int bpp); 1048b4b94579Smrgpixman_fixed_t pixman_sample_floor_y (pixman_fixed_t y, 1049b4b94579Smrg int bpp); 1050b4b94579Smrgvoid pixman_edge_step (pixman_edge_t *e, 1051b4b94579Smrg int n); 1052b4b94579Smrgvoid pixman_edge_init (pixman_edge_t *e, 1053b4b94579Smrg int bpp, 1054b4b94579Smrg pixman_fixed_t y_start, 1055b4b94579Smrg pixman_fixed_t x_top, 1056b4b94579Smrg pixman_fixed_t y_top, 1057b4b94579Smrg pixman_fixed_t x_bot, 1058b4b94579Smrg pixman_fixed_t y_bot); 1059b4b94579Smrgvoid pixman_line_fixed_edge_init (pixman_edge_t *e, 1060b4b94579Smrg int bpp, 1061b4b94579Smrg pixman_fixed_t y, 1062b4b94579Smrg const pixman_line_fixed_t *line, 1063b4b94579Smrg int x_off, 1064b4b94579Smrg int y_off); 1065b4b94579Smrgvoid pixman_rasterize_edges (pixman_image_t *image, 1066b4b94579Smrg pixman_edge_t *l, 1067b4b94579Smrg pixman_edge_t *r, 1068b4b94579Smrg pixman_fixed_t t, 1069b4b94579Smrg pixman_fixed_t b); 1070b4b94579Smrgvoid pixman_add_traps (pixman_image_t *image, 1071b4b94579Smrg int16_t x_off, 1072b4b94579Smrg int16_t y_off, 1073b4b94579Smrg int ntrap, 107481988197Sjmcneill const pixman_trap_t *traps); 1075b4b94579Smrgvoid pixman_add_trapezoids (pixman_image_t *image, 1076b4b94579Smrg int16_t x_off, 1077b4b94579Smrg int y_off, 1078b4b94579Smrg int ntraps, 1079b4b94579Smrg const pixman_trapezoid_t *traps); 1080b4b94579Smrgvoid pixman_rasterize_trapezoid (pixman_image_t *image, 1081b4b94579Smrg const pixman_trapezoid_t *trap, 1082b4b94579Smrg int x_off, 1083b4b94579Smrg int y_off); 10846ba797d6Smrgvoid pixman_composite_trapezoids (pixman_op_t op, 10856ba797d6Smrg pixman_image_t * src, 10866ba797d6Smrg pixman_image_t * dst, 10876ba797d6Smrg pixman_format_code_t mask_format, 10886ba797d6Smrg int x_src, 10896ba797d6Smrg int y_src, 10906ba797d6Smrg int x_dst, 10916ba797d6Smrg int y_dst, 10926ba797d6Smrg int n_traps, 10936ba797d6Smrg const pixman_trapezoid_t * traps); 10946ba797d6Smrgvoid pixman_composite_triangles (pixman_op_t op, 10956ba797d6Smrg pixman_image_t * src, 10966ba797d6Smrg pixman_image_t * dst, 10976ba797d6Smrg pixman_format_code_t mask_format, 10986ba797d6Smrg int x_src, 10996ba797d6Smrg int y_src, 11006ba797d6Smrg int x_dst, 11016ba797d6Smrg int y_dst, 11026ba797d6Smrg int n_tris, 11036ba797d6Smrg const pixman_triangle_t * tris); 11046ba797d6Smrgvoid pixman_add_triangles (pixman_image_t *image, 11056ba797d6Smrg int32_t x_off, 11066ba797d6Smrg int32_t y_off, 11076ba797d6Smrg int n_tris, 11086ba797d6Smrg const pixman_triangle_t *tris); 1109b4b94579Smrg 1110952204abSmrgPIXMAN_END_DECLS 1111952204abSmrg 1112b4b94579Smrg#endif /* PIXMAN_H__ */ 1113