pixman.h revision 6ba797d6
1b4b94579Smrg/*********************************************************** 2b4b94579Smrg 3b4b94579SmrgCopyright 1987, 1998 The Open Group 4b4b94579Smrg 5b4b94579SmrgPermission to use, copy, modify, distribute, and sell this software and its 6b4b94579Smrgdocumentation for any purpose is hereby granted without fee, provided that 7b4b94579Smrgthe above copyright notice appear in all copies and that both that 8b4b94579Smrgcopyright notice and this permission notice appear in supporting 9b4b94579Smrgdocumentation. 10b4b94579Smrg 11b4b94579SmrgThe above copyright notice and this permission notice shall be included in 12b4b94579Smrgall copies or substantial portions of the Software. 13b4b94579Smrg 14b4b94579SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15b4b94579SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16b4b94579SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17b4b94579SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18b4b94579SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19b4b94579SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20b4b94579Smrg 21b4b94579SmrgExcept as contained in this notice, the name of The Open Group shall not be 22b4b94579Smrgused in advertising or otherwise to promote the sale, use or other dealings 23b4b94579Smrgin this Software without prior written authorization from The Open Group. 24b4b94579Smrg 25b4b94579SmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 26b4b94579Smrg 27b4b94579Smrg All Rights Reserved 28b4b94579Smrg 29b4b94579SmrgPermission to use, copy, modify, and distribute this software and its 30b4b94579Smrgdocumentation for any purpose and without fee is hereby granted, 31b4b94579Smrgprovided that the above copyright notice appear in all copies and that 32b4b94579Smrgboth that copyright notice and this permission notice appear in 33b4b94579Smrgsupporting documentation, and that the name of Digital not be 34b4b94579Smrgused in advertising or publicity pertaining to distribution of the 35b4b94579Smrgsoftware without specific, written prior permission. 36b4b94579Smrg 37b4b94579SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38b4b94579SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39b4b94579SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40b4b94579SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41b4b94579SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42b4b94579SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43b4b94579SmrgSOFTWARE. 44b4b94579Smrg 45b4b94579Smrg******************************************************************/ 46b4b94579Smrg/* 47b4b94579Smrg * Copyright © 1998, 2004 Keith Packard 48b4b94579Smrg * Copyright 2007 Red Hat, Inc. 49b4b94579Smrg * 50b4b94579Smrg * Permission to use, copy, modify, distribute, and sell this software and its 51b4b94579Smrg * documentation for any purpose is hereby granted without fee, provided that 52b4b94579Smrg * the above copyright notice appear in all copies and that both that 53b4b94579Smrg * copyright notice and this permission notice appear in supporting 54b4b94579Smrg * documentation, and that the name of Keith Packard not be used in 55b4b94579Smrg * advertising or publicity pertaining to distribution of the software without 56b4b94579Smrg * specific, written prior permission. Keith Packard makes no 57b4b94579Smrg * representations about the suitability of this software for any purpose. It 58b4b94579Smrg * is provided "as is" without express or implied warranty. 59b4b94579Smrg * 60b4b94579Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 61b4b94579Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 62b4b94579Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 63b4b94579Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 64b4b94579Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 65b4b94579Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 66b4b94579Smrg * PERFORMANCE OF THIS SOFTWARE. 67b4b94579Smrg */ 68b4b94579Smrg 69b4b94579Smrg#ifndef PIXMAN_H__ 70b4b94579Smrg#define PIXMAN_H__ 71b4b94579Smrg 72b4b94579Smrg#include <pixman-version.h> 73b4b94579Smrg 74952204abSmrg#ifdef __cplusplus 75952204abSmrg#define PIXMAN_BEGIN_DECLS extern "C" { 76952204abSmrg#define PIXMAN_END_DECLS } 77952204abSmrg#else 78952204abSmrg#define PIXMAN_BEGIN_DECLS 79952204abSmrg#define PIXMAN_END_DECLS 80952204abSmrg#endif 81952204abSmrg 82952204abSmrgPIXMAN_BEGIN_DECLS 83952204abSmrg 84b4b94579Smrg/* 85b4b94579Smrg * Standard integers 86b4b94579Smrg */ 87952204abSmrg 88952204abSmrg#if !defined (PIXMAN_DONT_DEFINE_STDINT) 89952204abSmrg 90952204abSmrg#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__) || defined (__HP_cc) 91b4b94579Smrg# include <inttypes.h> 92952204abSmrg/* VS 2010 (_MSC_VER 1600) has stdint.h */ 93952204abSmrg#elif defined (_MSC_VER) && _MSC_VER < 1600 94b4b94579Smrgtypedef __int8 int8_t; 95b4b94579Smrgtypedef unsigned __int8 uint8_t; 96b4b94579Smrgtypedef __int16 int16_t; 97b4b94579Smrgtypedef unsigned __int16 uint16_t; 98b4b94579Smrgtypedef __int32 int32_t; 99b4b94579Smrgtypedef unsigned __int32 uint32_t; 100b4b94579Smrgtypedef __int64 int64_t; 101b4b94579Smrgtypedef unsigned __int64 uint64_t; 10227693ee9Sveego#elif defined (_AIX) 10327693ee9Sveego# include <sys/inttypes.h> 104b4b94579Smrg#else 105b4b94579Smrg# include <stdint.h> 106b4b94579Smrg#endif 107b4b94579Smrg 108952204abSmrg#endif 109952204abSmrg 110b4b94579Smrg/* 111b4b94579Smrg * Boolean 112b4b94579Smrg */ 113b4b94579Smrgtypedef int pixman_bool_t; 114b4b94579Smrg 115b4b94579Smrg/* 116b4b94579Smrg * Fixpoint numbers 117b4b94579Smrg */ 118b4b94579Smrgtypedef int64_t pixman_fixed_32_32_t; 119b4b94579Smrgtypedef pixman_fixed_32_32_t pixman_fixed_48_16_t; 120b4b94579Smrgtypedef uint32_t pixman_fixed_1_31_t; 121b4b94579Smrgtypedef uint32_t pixman_fixed_1_16_t; 122b4b94579Smrgtypedef int32_t pixman_fixed_16_16_t; 123b4b94579Smrgtypedef pixman_fixed_16_16_t pixman_fixed_t; 124b4b94579Smrg 125b4b94579Smrg#define pixman_fixed_e ((pixman_fixed_t) 1) 126b4b94579Smrg#define pixman_fixed_1 (pixman_int_to_fixed(1)) 127b4b94579Smrg#define pixman_fixed_1_minus_e (pixman_fixed_1 - pixman_fixed_e) 128952204abSmrg#define pixman_fixed_minus_1 (pixman_int_to_fixed(-1)) 129b4b94579Smrg#define pixman_fixed_to_int(f) ((int) ((f) >> 16)) 130b4b94579Smrg#define pixman_int_to_fixed(i) ((pixman_fixed_t) ((i) << 16)) 131b4b94579Smrg#define pixman_fixed_to_double(f) (double) ((f) / (double) pixman_fixed_1) 132b4b94579Smrg#define pixman_double_to_fixed(d) ((pixman_fixed_t) ((d) * 65536.0)) 133b4b94579Smrg#define pixman_fixed_frac(f) ((f) & pixman_fixed_1_minus_e) 134b4b94579Smrg#define pixman_fixed_floor(f) ((f) & ~pixman_fixed_1_minus_e) 135b4b94579Smrg#define pixman_fixed_ceil(f) pixman_fixed_floor ((f) + pixman_fixed_1_minus_e) 136b4b94579Smrg#define pixman_fixed_fraction(f) ((f) & pixman_fixed_1_minus_e) 137b4b94579Smrg#define pixman_fixed_mod_2(f) ((f) & (pixman_fixed1 | pixman_fixed_1_minus_e)) 138b4b94579Smrg#define pixman_max_fixed_48_16 ((pixman_fixed_48_16_t) 0x7fffffff) 139b4b94579Smrg#define pixman_min_fixed_48_16 (-((pixman_fixed_48_16_t) 1 << 31)) 140b4b94579Smrg 141b4b94579Smrg/* 142b4b94579Smrg * Misc structs 143b4b94579Smrg */ 144b4b94579Smrgtypedef struct pixman_color pixman_color_t; 145b4b94579Smrgtypedef struct pixman_point_fixed pixman_point_fixed_t; 146b4b94579Smrgtypedef struct pixman_line_fixed pixman_line_fixed_t; 147b4b94579Smrgtypedef struct pixman_vector pixman_vector_t; 148b4b94579Smrgtypedef struct pixman_transform pixman_transform_t; 149b4b94579Smrg 150b4b94579Smrgstruct pixman_color 151b4b94579Smrg{ 152b4b94579Smrg uint16_t red; 153b4b94579Smrg uint16_t green; 154b4b94579Smrg uint16_t blue; 155b4b94579Smrg uint16_t alpha; 156b4b94579Smrg}; 157b4b94579Smrg 158b4b94579Smrgstruct pixman_point_fixed 159b4b94579Smrg{ 160b4b94579Smrg pixman_fixed_t x; 161b4b94579Smrg pixman_fixed_t y; 162b4b94579Smrg}; 163b4b94579Smrg 164b4b94579Smrgstruct pixman_line_fixed 165b4b94579Smrg{ 166b4b94579Smrg pixman_point_fixed_t p1, p2; 167b4b94579Smrg}; 168b4b94579Smrg 169317c648bSmrg/* 170317c648bSmrg * Fixed point matrices 171317c648bSmrg */ 172317c648bSmrg 173b4b94579Smrgstruct pixman_vector 174b4b94579Smrg{ 175b4b94579Smrg pixman_fixed_t vector[3]; 176b4b94579Smrg}; 177b4b94579Smrg 178b4b94579Smrgstruct pixman_transform 179b4b94579Smrg{ 180b4b94579Smrg pixman_fixed_t matrix[3][3]; 181b4b94579Smrg}; 182b4b94579Smrg 183317c648bSmrg/* forward declaration (sorry) */ 184317c648bSmrgstruct pixman_box16; 185952204abSmrgtypedef union pixman_image pixman_image_t; 186317c648bSmrg 187d0321353Smrgvoid pixman_transform_init_identity (struct pixman_transform *matrix); 188d0321353Smrgpixman_bool_t pixman_transform_point_3d (const struct pixman_transform *transform, 189d0321353Smrg struct pixman_vector *vector); 190d0321353Smrgpixman_bool_t pixman_transform_point (const struct pixman_transform *transform, 191d0321353Smrg struct pixman_vector *vector); 192d0321353Smrgpixman_bool_t pixman_transform_multiply (struct pixman_transform *dst, 193d0321353Smrg const struct pixman_transform *l, 194d0321353Smrg const struct pixman_transform *r); 195d0321353Smrgvoid pixman_transform_init_scale (struct pixman_transform *t, 196d0321353Smrg pixman_fixed_t sx, 197d0321353Smrg pixman_fixed_t sy); 198d0321353Smrgpixman_bool_t pixman_transform_scale (struct pixman_transform *forward, 199d0321353Smrg struct pixman_transform *reverse, 200d0321353Smrg pixman_fixed_t sx, 201d0321353Smrg pixman_fixed_t sy); 202d0321353Smrgvoid pixman_transform_init_rotate (struct pixman_transform *t, 203d0321353Smrg pixman_fixed_t cos, 204d0321353Smrg pixman_fixed_t sin); 205d0321353Smrgpixman_bool_t pixman_transform_rotate (struct pixman_transform *forward, 206d0321353Smrg struct pixman_transform *reverse, 207d0321353Smrg pixman_fixed_t c, 208d0321353Smrg pixman_fixed_t s); 209d0321353Smrgvoid pixman_transform_init_translate (struct pixman_transform *t, 210d0321353Smrg pixman_fixed_t tx, 211d0321353Smrg pixman_fixed_t ty); 212d0321353Smrgpixman_bool_t pixman_transform_translate (struct pixman_transform *forward, 213d0321353Smrg struct pixman_transform *reverse, 214d0321353Smrg pixman_fixed_t tx, 215d0321353Smrg pixman_fixed_t ty); 216d0321353Smrgpixman_bool_t pixman_transform_bounds (const struct pixman_transform *matrix, 217d0321353Smrg struct pixman_box16 *b); 218d0321353Smrgpixman_bool_t pixman_transform_invert (struct pixman_transform *dst, 219d0321353Smrg const struct pixman_transform *src); 220d0321353Smrgpixman_bool_t pixman_transform_is_identity (const struct pixman_transform *t); 221d0321353Smrgpixman_bool_t pixman_transform_is_scale (const struct pixman_transform *t); 222d0321353Smrgpixman_bool_t pixman_transform_is_int_translate (const struct pixman_transform *t); 223d0321353Smrgpixman_bool_t pixman_transform_is_inverse (const struct pixman_transform *a, 224d0321353Smrg const struct pixman_transform *b); 225317c648bSmrg 226317c648bSmrg/* 227317c648bSmrg * Floating point matrices 228317c648bSmrg */ 229d0321353Smrgstruct pixman_f_vector 230d0321353Smrg{ 231317c648bSmrg double v[3]; 232317c648bSmrg}; 233317c648bSmrg 234d0321353Smrgstruct pixman_f_transform 235d0321353Smrg{ 236317c648bSmrg double m[3][3]; 237317c648bSmrg}; 238317c648bSmrg 239d0321353Smrgpixman_bool_t pixman_transform_from_pixman_f_transform (struct pixman_transform *t, 240d0321353Smrg const struct pixman_f_transform *ft); 241d0321353Smrgvoid pixman_f_transform_from_pixman_transform (struct pixman_f_transform *ft, 242d0321353Smrg const struct pixman_transform *t); 243d0321353Smrgpixman_bool_t pixman_f_transform_invert (struct pixman_f_transform *dst, 244d0321353Smrg const struct pixman_f_transform *src); 245d0321353Smrgpixman_bool_t pixman_f_transform_point (const struct pixman_f_transform *t, 246d0321353Smrg struct pixman_f_vector *v); 247d0321353Smrgvoid pixman_f_transform_point_3d (const struct pixman_f_transform *t, 248d0321353Smrg struct pixman_f_vector *v); 249d0321353Smrgvoid pixman_f_transform_multiply (struct pixman_f_transform *dst, 250d0321353Smrg const struct pixman_f_transform *l, 251d0321353Smrg const struct pixman_f_transform *r); 252d0321353Smrgvoid pixman_f_transform_init_scale (struct pixman_f_transform *t, 253d0321353Smrg double sx, 254d0321353Smrg double sy); 255d0321353Smrgpixman_bool_t pixman_f_transform_scale (struct pixman_f_transform *forward, 256d0321353Smrg struct pixman_f_transform *reverse, 257d0321353Smrg double sx, 258d0321353Smrg double sy); 259d0321353Smrgvoid pixman_f_transform_init_rotate (struct pixman_f_transform *t, 260d0321353Smrg double cos, 261d0321353Smrg double sin); 262d0321353Smrgpixman_bool_t pixman_f_transform_rotate (struct pixman_f_transform *forward, 263d0321353Smrg struct pixman_f_transform *reverse, 264d0321353Smrg double c, 265d0321353Smrg double s); 266d0321353Smrgvoid pixman_f_transform_init_translate (struct pixman_f_transform *t, 267d0321353Smrg double tx, 268d0321353Smrg double ty); 269d0321353Smrgpixman_bool_t pixman_f_transform_translate (struct pixman_f_transform *forward, 270d0321353Smrg struct pixman_f_transform *reverse, 271d0321353Smrg double tx, 272d0321353Smrg double ty); 273d0321353Smrgpixman_bool_t pixman_f_transform_bounds (const struct pixman_f_transform *t, 274d0321353Smrg struct pixman_box16 *b); 275d0321353Smrgvoid pixman_f_transform_init_identity (struct pixman_f_transform *t); 276317c648bSmrg 277b4b94579Smrgtypedef enum 278b4b94579Smrg{ 279b4b94579Smrg PIXMAN_REPEAT_NONE, 280b4b94579Smrg PIXMAN_REPEAT_NORMAL, 281b4b94579Smrg PIXMAN_REPEAT_PAD, 282b4b94579Smrg PIXMAN_REPEAT_REFLECT 283b4b94579Smrg} pixman_repeat_t; 284b4b94579Smrg 285b4b94579Smrgtypedef enum 286b4b94579Smrg{ 287b4b94579Smrg PIXMAN_FILTER_FAST, 288b4b94579Smrg PIXMAN_FILTER_GOOD, 289b4b94579Smrg PIXMAN_FILTER_BEST, 290b4b94579Smrg PIXMAN_FILTER_NEAREST, 291b4b94579Smrg PIXMAN_FILTER_BILINEAR, 292b4b94579Smrg PIXMAN_FILTER_CONVOLUTION 293b4b94579Smrg} pixman_filter_t; 294b4b94579Smrg 295b4b94579Smrgtypedef enum 296b4b94579Smrg{ 297b4b94579Smrg PIXMAN_OP_CLEAR = 0x00, 298b4b94579Smrg PIXMAN_OP_SRC = 0x01, 299b4b94579Smrg PIXMAN_OP_DST = 0x02, 300b4b94579Smrg PIXMAN_OP_OVER = 0x03, 301b4b94579Smrg PIXMAN_OP_OVER_REVERSE = 0x04, 302b4b94579Smrg PIXMAN_OP_IN = 0x05, 303b4b94579Smrg PIXMAN_OP_IN_REVERSE = 0x06, 304b4b94579Smrg PIXMAN_OP_OUT = 0x07, 305b4b94579Smrg PIXMAN_OP_OUT_REVERSE = 0x08, 306b4b94579Smrg PIXMAN_OP_ATOP = 0x09, 307b4b94579Smrg PIXMAN_OP_ATOP_REVERSE = 0x0a, 308b4b94579Smrg PIXMAN_OP_XOR = 0x0b, 309b4b94579Smrg PIXMAN_OP_ADD = 0x0c, 310b4b94579Smrg PIXMAN_OP_SATURATE = 0x0d, 311b4b94579Smrg 312b4b94579Smrg PIXMAN_OP_DISJOINT_CLEAR = 0x10, 313b4b94579Smrg PIXMAN_OP_DISJOINT_SRC = 0x11, 314b4b94579Smrg PIXMAN_OP_DISJOINT_DST = 0x12, 315b4b94579Smrg PIXMAN_OP_DISJOINT_OVER = 0x13, 316b4b94579Smrg PIXMAN_OP_DISJOINT_OVER_REVERSE = 0x14, 317b4b94579Smrg PIXMAN_OP_DISJOINT_IN = 0x15, 318b4b94579Smrg PIXMAN_OP_DISJOINT_IN_REVERSE = 0x16, 319b4b94579Smrg PIXMAN_OP_DISJOINT_OUT = 0x17, 320b4b94579Smrg PIXMAN_OP_DISJOINT_OUT_REVERSE = 0x18, 321b4b94579Smrg PIXMAN_OP_DISJOINT_ATOP = 0x19, 322b4b94579Smrg PIXMAN_OP_DISJOINT_ATOP_REVERSE = 0x1a, 323b4b94579Smrg PIXMAN_OP_DISJOINT_XOR = 0x1b, 324b4b94579Smrg 325b4b94579Smrg PIXMAN_OP_CONJOINT_CLEAR = 0x20, 326b4b94579Smrg PIXMAN_OP_CONJOINT_SRC = 0x21, 327b4b94579Smrg PIXMAN_OP_CONJOINT_DST = 0x22, 328b4b94579Smrg PIXMAN_OP_CONJOINT_OVER = 0x23, 329b4b94579Smrg PIXMAN_OP_CONJOINT_OVER_REVERSE = 0x24, 330b4b94579Smrg PIXMAN_OP_CONJOINT_IN = 0x25, 331b4b94579Smrg PIXMAN_OP_CONJOINT_IN_REVERSE = 0x26, 332b4b94579Smrg PIXMAN_OP_CONJOINT_OUT = 0x27, 333b4b94579Smrg PIXMAN_OP_CONJOINT_OUT_REVERSE = 0x28, 334b4b94579Smrg PIXMAN_OP_CONJOINT_ATOP = 0x29, 335b4b94579Smrg PIXMAN_OP_CONJOINT_ATOP_REVERSE = 0x2a, 336b4b94579Smrg PIXMAN_OP_CONJOINT_XOR = 0x2b, 337b4b94579Smrg 338dc259aabSmrg PIXMAN_OP_MULTIPLY = 0x30, 339dc259aabSmrg PIXMAN_OP_SCREEN = 0x31, 340dc259aabSmrg PIXMAN_OP_OVERLAY = 0x32, 341dc259aabSmrg PIXMAN_OP_DARKEN = 0x33, 342dc259aabSmrg PIXMAN_OP_LIGHTEN = 0x34, 343dc259aabSmrg PIXMAN_OP_COLOR_DODGE = 0x35, 344dc259aabSmrg PIXMAN_OP_COLOR_BURN = 0x36, 345dc259aabSmrg PIXMAN_OP_HARD_LIGHT = 0x37, 346dc259aabSmrg PIXMAN_OP_SOFT_LIGHT = 0x38, 347dc259aabSmrg PIXMAN_OP_DIFFERENCE = 0x39, 348dc259aabSmrg PIXMAN_OP_EXCLUSION = 0x3a, 349dc259aabSmrg PIXMAN_OP_HSL_HUE = 0x3b, 350dc259aabSmrg PIXMAN_OP_HSL_SATURATION = 0x3c, 351dc259aabSmrg PIXMAN_OP_HSL_COLOR = 0x3d, 352952204abSmrg PIXMAN_OP_HSL_LUMINOSITY = 0x3e 353dc259aabSmrg 354952204abSmrg#ifdef PIXMAN_USE_INTERNAL_API 355952204abSmrg , 356952204abSmrg PIXMAN_N_OPERATORS, 357952204abSmrg PIXMAN_OP_NONE = PIXMAN_N_OPERATORS 358952204abSmrg#endif 359b4b94579Smrg} pixman_op_t; 360b4b94579Smrg 361b4b94579Smrg/* 362b4b94579Smrg * Regions 363b4b94579Smrg */ 364b4b94579Smrgtypedef struct pixman_region16_data pixman_region16_data_t; 365b4b94579Smrgtypedef struct pixman_box16 pixman_box16_t; 366b4b94579Smrgtypedef struct pixman_rectangle16 pixman_rectangle16_t; 367b4b94579Smrgtypedef struct pixman_region16 pixman_region16_t; 368b4b94579Smrg 369b4b94579Smrgstruct pixman_region16_data { 370b4b94579Smrg long size; 371b4b94579Smrg long numRects; 372b4b94579Smrg/* pixman_box16_t rects[size]; in memory but not explicitly declared */ 373b4b94579Smrg}; 374b4b94579Smrg 375b4b94579Smrgstruct pixman_rectangle16 376b4b94579Smrg{ 377d0321353Smrg int16_t x, y; 378d0321353Smrg uint16_t width, height; 379b4b94579Smrg}; 380b4b94579Smrg 381b4b94579Smrgstruct pixman_box16 382b4b94579Smrg{ 383b4b94579Smrg int16_t x1, y1, x2, y2; 384b4b94579Smrg}; 385b4b94579Smrg 386b4b94579Smrgstruct pixman_region16 387b4b94579Smrg{ 388b4b94579Smrg pixman_box16_t extents; 389d0321353Smrg pixman_region16_data_t *data; 390b4b94579Smrg}; 391b4b94579Smrg 392b4b94579Smrgtypedef enum 393b4b94579Smrg{ 394b4b94579Smrg PIXMAN_REGION_OUT, 395b4b94579Smrg PIXMAN_REGION_IN, 396b4b94579Smrg PIXMAN_REGION_PART 397b4b94579Smrg} pixman_region_overlap_t; 398b4b94579Smrg 399d0321353Smrg/* This function exists only to make it possible to preserve 400d0321353Smrg * the X ABI - it should go away at first opportunity. 401b4b94579Smrg */ 402d0321353Smrgvoid pixman_region_set_static_pointers (pixman_box16_t *empty_box, 403d0321353Smrg pixman_region16_data_t *empty_data, 404d0321353Smrg pixman_region16_data_t *broken_data); 405b4b94579Smrg 406b4b94579Smrg/* creation/destruction */ 407d0321353Smrgvoid pixman_region_init (pixman_region16_t *region); 408d0321353Smrgvoid pixman_region_init_rect (pixman_region16_t *region, 409d0321353Smrg int x, 410d0321353Smrg int y, 411d0321353Smrg unsigned int width, 412d0321353Smrg unsigned int height); 413d0321353Smrgpixman_bool_t pixman_region_init_rects (pixman_region16_t *region, 414952204abSmrg const pixman_box16_t *boxes, 415d0321353Smrg int count); 416d0321353Smrgvoid pixman_region_init_with_extents (pixman_region16_t *region, 417d0321353Smrg pixman_box16_t *extents); 418952204abSmrgvoid pixman_region_init_from_image (pixman_region16_t *region, 419952204abSmrg pixman_image_t *image); 420d0321353Smrgvoid pixman_region_fini (pixman_region16_t *region); 421b4b94579Smrg 422b4b94579Smrg 423d0321353Smrg/* manipulation */ 424d0321353Smrgvoid pixman_region_translate (pixman_region16_t *region, 425d0321353Smrg int x, 426d0321353Smrg int y); 427d0321353Smrgpixman_bool_t pixman_region_copy (pixman_region16_t *dest, 428d0321353Smrg pixman_region16_t *source); 429d0321353Smrgpixman_bool_t pixman_region_intersect (pixman_region16_t *new_reg, 430d0321353Smrg pixman_region16_t *reg1, 431d0321353Smrg pixman_region16_t *reg2); 432d0321353Smrgpixman_bool_t pixman_region_union (pixman_region16_t *new_reg, 433d0321353Smrg pixman_region16_t *reg1, 434d0321353Smrg pixman_region16_t *reg2); 435d0321353Smrgpixman_bool_t pixman_region_union_rect (pixman_region16_t *dest, 436d0321353Smrg pixman_region16_t *source, 437d0321353Smrg int x, 438d0321353Smrg int y, 439d0321353Smrg unsigned int width, 440d0321353Smrg unsigned int height); 4411b18d63aSmrgpixman_bool_t pixman_region_intersect_rect (pixman_region16_t *dest, 4421b18d63aSmrg pixman_region16_t *source, 4431b18d63aSmrg int x, 4441b18d63aSmrg int y, 4451b18d63aSmrg unsigned int width, 4461b18d63aSmrg unsigned int height); 447d0321353Smrgpixman_bool_t pixman_region_subtract (pixman_region16_t *reg_d, 448d0321353Smrg pixman_region16_t *reg_m, 449d0321353Smrg pixman_region16_t *reg_s); 450d0321353Smrgpixman_bool_t pixman_region_inverse (pixman_region16_t *new_reg, 451d0321353Smrg pixman_region16_t *reg1, 452d0321353Smrg pixman_box16_t *inv_rect); 453d0321353Smrgpixman_bool_t pixman_region_contains_point (pixman_region16_t *region, 454d0321353Smrg int x, 455d0321353Smrg int y, 456d0321353Smrg pixman_box16_t *box); 457952204abSmrgpixman_region_overlap_t pixman_region_contains_rectangle (pixman_region16_t *region, 458d0321353Smrg pixman_box16_t *prect); 459d0321353Smrgpixman_bool_t pixman_region_not_empty (pixman_region16_t *region); 460d0321353Smrgpixman_box16_t * pixman_region_extents (pixman_region16_t *region); 461d0321353Smrgint pixman_region_n_rects (pixman_region16_t *region); 462d0321353Smrgpixman_box16_t * pixman_region_rectangles (pixman_region16_t *region, 463d0321353Smrg int *n_rects); 464d0321353Smrgpixman_bool_t pixman_region_equal (pixman_region16_t *region1, 465d0321353Smrg pixman_region16_t *region2); 466d0321353Smrgpixman_bool_t pixman_region_selfcheck (pixman_region16_t *region); 467d0321353Smrgvoid pixman_region_reset (pixman_region16_t *region, 468d0321353Smrg pixman_box16_t *box); 469b4b94579Smrg/* 470b4b94579Smrg * 32 bit regions 471b4b94579Smrg */ 472b4b94579Smrgtypedef struct pixman_region32_data pixman_region32_data_t; 473b4b94579Smrgtypedef struct pixman_box32 pixman_box32_t; 474b4b94579Smrgtypedef struct pixman_rectangle32 pixman_rectangle32_t; 475b4b94579Smrgtypedef struct pixman_region32 pixman_region32_t; 476b4b94579Smrg 477b4b94579Smrgstruct pixman_region32_data { 478b4b94579Smrg long size; 479b4b94579Smrg long numRects; 480b4b94579Smrg/* pixman_box32_t rects[size]; in memory but not explicitly declared */ 481b4b94579Smrg}; 482b4b94579Smrg 483b4b94579Smrgstruct pixman_rectangle32 484b4b94579Smrg{ 485b4b94579Smrg int32_t x, y; 486b4b94579Smrg uint32_t width, height; 487b4b94579Smrg}; 488b4b94579Smrg 489b4b94579Smrgstruct pixman_box32 490b4b94579Smrg{ 491b4b94579Smrg int32_t x1, y1, x2, y2; 492b4b94579Smrg}; 493b4b94579Smrg 494b4b94579Smrgstruct pixman_region32 495b4b94579Smrg{ 496b4b94579Smrg pixman_box32_t extents; 497b4b94579Smrg pixman_region32_data_t *data; 498b4b94579Smrg}; 499b4b94579Smrg 500b4b94579Smrg/* creation/destruction */ 501b4b94579Smrgvoid pixman_region32_init (pixman_region32_t *region); 502b4b94579Smrgvoid pixman_region32_init_rect (pixman_region32_t *region, 503b4b94579Smrg int x, 504b4b94579Smrg int y, 505b4b94579Smrg unsigned int width, 506b4b94579Smrg unsigned int height); 507b4b94579Smrgpixman_bool_t pixman_region32_init_rects (pixman_region32_t *region, 508952204abSmrg const pixman_box32_t *boxes, 509b4b94579Smrg int count); 510b4b94579Smrgvoid pixman_region32_init_with_extents (pixman_region32_t *region, 511b4b94579Smrg pixman_box32_t *extents); 512952204abSmrgvoid pixman_region32_init_from_image (pixman_region32_t *region, 513952204abSmrg pixman_image_t *image); 514b4b94579Smrgvoid pixman_region32_fini (pixman_region32_t *region); 515b4b94579Smrg 516b4b94579Smrg 517b4b94579Smrg/* manipulation */ 518b4b94579Smrgvoid pixman_region32_translate (pixman_region32_t *region, 519b4b94579Smrg int x, 520b4b94579Smrg int y); 521b4b94579Smrgpixman_bool_t pixman_region32_copy (pixman_region32_t *dest, 522b4b94579Smrg pixman_region32_t *source); 523d0321353Smrgpixman_bool_t pixman_region32_intersect (pixman_region32_t *new_reg, 524b4b94579Smrg pixman_region32_t *reg1, 525b4b94579Smrg pixman_region32_t *reg2); 526d0321353Smrgpixman_bool_t pixman_region32_union (pixman_region32_t *new_reg, 527b4b94579Smrg pixman_region32_t *reg1, 528b4b94579Smrg pixman_region32_t *reg2); 5291b18d63aSmrgpixman_bool_t pixman_region32_intersect_rect (pixman_region32_t *dest, 5301b18d63aSmrg pixman_region32_t *source, 5311b18d63aSmrg int x, 5321b18d63aSmrg int y, 5331b18d63aSmrg unsigned int width, 5341b18d63aSmrg unsigned int height); 535b4b94579Smrgpixman_bool_t pixman_region32_union_rect (pixman_region32_t *dest, 536b4b94579Smrg pixman_region32_t *source, 537b4b94579Smrg int x, 538b4b94579Smrg int y, 539b4b94579Smrg unsigned int width, 540b4b94579Smrg unsigned int height); 541d0321353Smrgpixman_bool_t pixman_region32_subtract (pixman_region32_t *reg_d, 542d0321353Smrg pixman_region32_t *reg_m, 543d0321353Smrg pixman_region32_t *reg_s); 544d0321353Smrgpixman_bool_t pixman_region32_inverse (pixman_region32_t *new_reg, 545b4b94579Smrg pixman_region32_t *reg1, 546d0321353Smrg pixman_box32_t *inv_rect); 547b4b94579Smrgpixman_bool_t pixman_region32_contains_point (pixman_region32_t *region, 548b4b94579Smrg int x, 549b4b94579Smrg int y, 550b4b94579Smrg pixman_box32_t *box); 551b4b94579Smrgpixman_region_overlap_t pixman_region32_contains_rectangle (pixman_region32_t *region, 552b4b94579Smrg pixman_box32_t *prect); 553b4b94579Smrgpixman_bool_t pixman_region32_not_empty (pixman_region32_t *region); 554b4b94579Smrgpixman_box32_t * pixman_region32_extents (pixman_region32_t *region); 555b4b94579Smrgint pixman_region32_n_rects (pixman_region32_t *region); 556b4b94579Smrgpixman_box32_t * pixman_region32_rectangles (pixman_region32_t *region, 557b4b94579Smrg int *n_rects); 558b4b94579Smrgpixman_bool_t pixman_region32_equal (pixman_region32_t *region1, 559b4b94579Smrg pixman_region32_t *region2); 560b4b94579Smrgpixman_bool_t pixman_region32_selfcheck (pixman_region32_t *region); 561b4b94579Smrgvoid pixman_region32_reset (pixman_region32_t *region, 562b4b94579Smrg pixman_box32_t *box); 563b4b94579Smrg 564b4b94579Smrg 565b4b94579Smrg/* Copy / Fill / Misc */ 566b4b94579Smrgpixman_bool_t pixman_blt (uint32_t *src_bits, 567b4b94579Smrg uint32_t *dst_bits, 568b4b94579Smrg int src_stride, 569b4b94579Smrg int dst_stride, 570b4b94579Smrg int src_bpp, 571b4b94579Smrg int dst_bpp, 572b4b94579Smrg int src_x, 573b4b94579Smrg int src_y, 5746ba797d6Smrg int dest_x, 5756ba797d6Smrg int dest_y, 576b4b94579Smrg int width, 577b4b94579Smrg int height); 578b4b94579Smrgpixman_bool_t pixman_fill (uint32_t *bits, 579b4b94579Smrg int stride, 580b4b94579Smrg int bpp, 581b4b94579Smrg int x, 582b4b94579Smrg int y, 583b4b94579Smrg int width, 584b4b94579Smrg int height, 585b4b94579Smrg uint32_t _xor); 586b4b94579Smrg 587b4b94579Smrgint pixman_version (void); 588b4b94579Smrgconst char* pixman_version_string (void); 589b4b94579Smrg 590b4b94579Smrg/* 591b4b94579Smrg * Images 592b4b94579Smrg */ 593b4b94579Smrgtypedef struct pixman_indexed pixman_indexed_t; 594b4b94579Smrgtypedef struct pixman_gradient_stop pixman_gradient_stop_t; 595b4b94579Smrg 596b4b94579Smrgtypedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size); 597b4b94579Smrgtypedef void (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size); 598b4b94579Smrg 599dc259aabSmrgtypedef void (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data); 600dc259aabSmrg 601b4b94579Smrgstruct pixman_gradient_stop { 602b4b94579Smrg pixman_fixed_t x; 603b4b94579Smrg pixman_color_t color; 604b4b94579Smrg}; 605b4b94579Smrg 606b4b94579Smrg#define PIXMAN_MAX_INDEXED 256 /* XXX depth must be <= 8 */ 607b4b94579Smrg 608b4b94579Smrg#if PIXMAN_MAX_INDEXED <= 256 609b4b94579Smrgtypedef uint8_t pixman_index_type; 610b4b94579Smrg#endif 611b4b94579Smrg 612b4b94579Smrgstruct pixman_indexed 613b4b94579Smrg{ 614b4b94579Smrg pixman_bool_t color; 615b4b94579Smrg uint32_t rgba[PIXMAN_MAX_INDEXED]; 616b4b94579Smrg pixman_index_type ent[32768]; 617b4b94579Smrg}; 618b4b94579Smrg 619b4b94579Smrg/* 620b4b94579Smrg * While the protocol is generous in format support, the 621b4b94579Smrg * sample implementation allows only packed RGB and GBR 622b4b94579Smrg * representations for data to simplify software rendering, 623b4b94579Smrg */ 624b4b94579Smrg#define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ 625b4b94579Smrg ((type) << 16) | \ 626b4b94579Smrg ((a) << 12) | \ 627b4b94579Smrg ((r) << 8) | \ 628b4b94579Smrg ((g) << 4) | \ 629b4b94579Smrg ((b))) 630b4b94579Smrg 631b4b94579Smrg#define PIXMAN_FORMAT_BPP(f) (((f) >> 24) ) 632b4b94579Smrg#define PIXMAN_FORMAT_TYPE(f) (((f) >> 16) & 0xff) 633b4b94579Smrg#define PIXMAN_FORMAT_A(f) (((f) >> 12) & 0x0f) 634b4b94579Smrg#define PIXMAN_FORMAT_R(f) (((f) >> 8) & 0x0f) 635b4b94579Smrg#define PIXMAN_FORMAT_G(f) (((f) >> 4) & 0x0f) 636b4b94579Smrg#define PIXMAN_FORMAT_B(f) (((f) ) & 0x0f) 637b4b94579Smrg#define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff) 638b4b94579Smrg#define PIXMAN_FORMAT_VIS(f) (((f) ) & 0xffff) 639b4b94579Smrg#define PIXMAN_FORMAT_DEPTH(f) (PIXMAN_FORMAT_A(f) + \ 640b4b94579Smrg PIXMAN_FORMAT_R(f) + \ 641b4b94579Smrg PIXMAN_FORMAT_G(f) + \ 642b4b94579Smrg PIXMAN_FORMAT_B(f)) 643b4b94579Smrg 644b4b94579Smrg#define PIXMAN_TYPE_OTHER 0 645b4b94579Smrg#define PIXMAN_TYPE_A 1 646b4b94579Smrg#define PIXMAN_TYPE_ARGB 2 647b4b94579Smrg#define PIXMAN_TYPE_ABGR 3 648b4b94579Smrg#define PIXMAN_TYPE_COLOR 4 649b4b94579Smrg#define PIXMAN_TYPE_GRAY 5 650b4b94579Smrg#define PIXMAN_TYPE_YUY2 6 651b4b94579Smrg#define PIXMAN_TYPE_YV12 7 652317c648bSmrg#define PIXMAN_TYPE_BGRA 8 6536ba797d6Smrg#define PIXMAN_TYPE_RGBA 9 654b4b94579Smrg 655317c648bSmrg#define PIXMAN_FORMAT_COLOR(f) \ 656317c648bSmrg (PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB || \ 657317c648bSmrg PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ABGR || \ 6586ba797d6Smrg PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_BGRA || \ 6596ba797d6Smrg PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA) 660b4b94579Smrg 661b4b94579Smrg/* 32bpp formats */ 662b4b94579Smrgtypedef enum { 663d0321353Smrg PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8), 664d0321353Smrg PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8), 665d0321353Smrg PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8), 666d0321353Smrg PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8), 667d0321353Smrg PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8), 668d0321353Smrg PIXMAN_b8g8r8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8), 6696ba797d6Smrg PIXMAN_r8g8b8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8), 6706ba797d6Smrg PIXMAN_r8g8b8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8), 6711b18d63aSmrg PIXMAN_x14r6g6b6 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6), 672d0321353Smrg PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), 673d0321353Smrg PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), 67427693ee9Sveego PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), 67527693ee9Sveego PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), 67627693ee9Sveego 677b4b94579Smrg/* 24bpp formats */ 678d0321353Smrg PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8), 679d0321353Smrg PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8), 680952204abSmrg 681b4b94579Smrg/* 16bpp formats */ 682d0321353Smrg PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5), 683d0321353Smrg PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5), 684952204abSmrg 685d0321353Smrg PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5), 686d0321353Smrg PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5), 687d0321353Smrg PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5), 688d0321353Smrg PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5), 689d0321353Smrg PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4), 690d0321353Smrg PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4), 691d0321353Smrg PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4), 692d0321353Smrg PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4), 693952204abSmrg 694b4b94579Smrg/* 8bpp formats */ 695d0321353Smrg PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0), 696d0321353Smrg PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2), 697d0321353Smrg PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2), 698d0321353Smrg PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2), 699d0321353Smrg PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2), 700952204abSmrg 701d0321353Smrg PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), 702d0321353Smrg PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), 703952204abSmrg 704d0321353Smrg PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0), 705952204abSmrg 706d0321353Smrg PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), 707d0321353Smrg PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), 708952204abSmrg 709b4b94579Smrg/* 4bpp formats */ 710d0321353Smrg PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0), 711d0321353Smrg PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1), 712d0321353Smrg PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1), 713d0321353Smrg PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1), 714d0321353Smrg PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1), 715952204abSmrg 716d0321353Smrg PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0), 717d0321353Smrg PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0), 718952204abSmrg 719b4b94579Smrg/* 1bpp formats */ 720d0321353Smrg PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0), 721952204abSmrg 722d0321353Smrg PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0), 723b4b94579Smrg 724b4b94579Smrg/* YUV formats */ 725d0321353Smrg PIXMAN_yuy2 = PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0), 726d0321353Smrg PIXMAN_yv12 = PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0) 727b4b94579Smrg} pixman_format_code_t; 728b4b94579Smrg 729b4b94579Smrg/* Querying supported format values. */ 730b4b94579Smrgpixman_bool_t pixman_format_supported_destination (pixman_format_code_t format); 731b4b94579Smrgpixman_bool_t pixman_format_supported_source (pixman_format_code_t format); 732b4b94579Smrg 733b4b94579Smrg/* Constructors */ 734b4b94579Smrgpixman_image_t *pixman_image_create_solid_fill (pixman_color_t *color); 735b4b94579Smrgpixman_image_t *pixman_image_create_linear_gradient (pixman_point_fixed_t *p1, 736b4b94579Smrg pixman_point_fixed_t *p2, 737b4b94579Smrg const pixman_gradient_stop_t *stops, 738b4b94579Smrg int n_stops); 739b4b94579Smrgpixman_image_t *pixman_image_create_radial_gradient (pixman_point_fixed_t *inner, 740b4b94579Smrg pixman_point_fixed_t *outer, 741b4b94579Smrg pixman_fixed_t inner_radius, 742b4b94579Smrg pixman_fixed_t outer_radius, 743b4b94579Smrg const pixman_gradient_stop_t *stops, 744b4b94579Smrg int n_stops); 745b4b94579Smrgpixman_image_t *pixman_image_create_conical_gradient (pixman_point_fixed_t *center, 746b4b94579Smrg pixman_fixed_t angle, 747b4b94579Smrg const pixman_gradient_stop_t *stops, 748b4b94579Smrg int n_stops); 749b4b94579Smrgpixman_image_t *pixman_image_create_bits (pixman_format_code_t format, 750b4b94579Smrg int width, 751b4b94579Smrg int height, 752b4b94579Smrg uint32_t *bits, 753b4b94579Smrg int rowstride_bytes); 754b4b94579Smrg 755b4b94579Smrg/* Destructor */ 756b4b94579Smrgpixman_image_t *pixman_image_ref (pixman_image_t *image); 757b4b94579Smrgpixman_bool_t pixman_image_unref (pixman_image_t *image); 758b4b94579Smrg 759dc259aabSmrgvoid pixman_image_set_destroy_function (pixman_image_t *image, 760dc259aabSmrg pixman_image_destroy_func_t function, 761dc259aabSmrg void *data); 762952204abSmrgvoid * pixman_image_get_destroy_data (pixman_image_t *image); 763b4b94579Smrg 764b4b94579Smrg/* Set properties */ 765b4b94579Smrgpixman_bool_t pixman_image_set_clip_region (pixman_image_t *image, 766b4b94579Smrg pixman_region16_t *region); 767b4b94579Smrgpixman_bool_t pixman_image_set_clip_region32 (pixman_image_t *image, 768b4b94579Smrg pixman_region32_t *region); 769b4b94579Smrgvoid pixman_image_set_has_client_clip (pixman_image_t *image, 770b4b94579Smrg pixman_bool_t clien_clip); 771b4b94579Smrgpixman_bool_t pixman_image_set_transform (pixman_image_t *image, 772b4b94579Smrg const pixman_transform_t *transform); 773b4b94579Smrgvoid pixman_image_set_repeat (pixman_image_t *image, 774b4b94579Smrg pixman_repeat_t repeat); 775b4b94579Smrgpixman_bool_t pixman_image_set_filter (pixman_image_t *image, 776b4b94579Smrg pixman_filter_t filter, 777b4b94579Smrg const pixman_fixed_t *filter_params, 778b4b94579Smrg int n_filter_params); 779b4b94579Smrgvoid pixman_image_set_source_clipping (pixman_image_t *image, 780b4b94579Smrg pixman_bool_t source_clipping); 781b4b94579Smrgvoid pixman_image_set_alpha_map (pixman_image_t *image, 782b4b94579Smrg pixman_image_t *alpha_map, 783b4b94579Smrg int16_t x, 784b4b94579Smrg int16_t y); 785b4b94579Smrgvoid pixman_image_set_component_alpha (pixman_image_t *image, 786b4b94579Smrg pixman_bool_t component_alpha); 7871b18d63aSmrgpixman_bool_t pixman_image_get_component_alpha (pixman_image_t *image); 788b4b94579Smrgvoid pixman_image_set_accessors (pixman_image_t *image, 789b4b94579Smrg pixman_read_memory_func_t read_func, 790b4b94579Smrg pixman_write_memory_func_t write_func); 791b4b94579Smrgvoid pixman_image_set_indexed (pixman_image_t *image, 792b4b94579Smrg const pixman_indexed_t *indexed); 793b4b94579Smrguint32_t *pixman_image_get_data (pixman_image_t *image); 794b4b94579Smrgint pixman_image_get_width (pixman_image_t *image); 795b4b94579Smrgint pixman_image_get_height (pixman_image_t *image); 796317c648bSmrgint pixman_image_get_stride (pixman_image_t *image); /* in bytes */ 797b4b94579Smrgint pixman_image_get_depth (pixman_image_t *image); 7981b18d63aSmrgpixman_format_code_t pixman_image_get_format (pixman_image_t *image); 799b4b94579Smrgpixman_bool_t pixman_image_fill_rectangles (pixman_op_t op, 800b4b94579Smrg pixman_image_t *image, 801b4b94579Smrg pixman_color_t *color, 802b4b94579Smrg int n_rects, 803b4b94579Smrg const pixman_rectangle16_t *rects); 804952204abSmrgpixman_bool_t pixman_image_fill_boxes (pixman_op_t op, 805952204abSmrg pixman_image_t *dest, 806952204abSmrg pixman_color_t *color, 807952204abSmrg int n_boxes, 808952204abSmrg const pixman_box32_t *boxes); 809b4b94579Smrg 810b4b94579Smrg/* Composite */ 811d0321353Smrgpixman_bool_t pixman_compute_composite_region (pixman_region16_t *region, 812d0321353Smrg pixman_image_t *src_image, 813d0321353Smrg pixman_image_t *mask_image, 8146ba797d6Smrg pixman_image_t *dest_image, 815d0321353Smrg int16_t src_x, 816d0321353Smrg int16_t src_y, 817d0321353Smrg int16_t mask_x, 818d0321353Smrg int16_t mask_y, 819d0321353Smrg int16_t dest_x, 820d0321353Smrg int16_t dest_y, 821b4b94579Smrg uint16_t width, 822b4b94579Smrg uint16_t height); 823b4b94579Smrgvoid pixman_image_composite (pixman_op_t op, 824b4b94579Smrg pixman_image_t *src, 825b4b94579Smrg pixman_image_t *mask, 826b4b94579Smrg pixman_image_t *dest, 827b4b94579Smrg int16_t src_x, 828b4b94579Smrg int16_t src_y, 829b4b94579Smrg int16_t mask_x, 830b4b94579Smrg int16_t mask_y, 831b4b94579Smrg int16_t dest_x, 832b4b94579Smrg int16_t dest_y, 833b4b94579Smrg uint16_t width, 834b4b94579Smrg uint16_t height); 835952204abSmrgvoid pixman_image_composite32 (pixman_op_t op, 836952204abSmrg pixman_image_t *src, 837952204abSmrg pixman_image_t *mask, 838952204abSmrg pixman_image_t *dest, 839952204abSmrg int32_t src_x, 840952204abSmrg int32_t src_y, 841952204abSmrg int32_t mask_x, 842952204abSmrg int32_t mask_y, 843952204abSmrg int32_t dest_x, 844952204abSmrg int32_t dest_y, 845952204abSmrg int32_t width, 846952204abSmrg int32_t height); 847b4b94579Smrg 8481b18d63aSmrg/* Executive Summary: This function is a no-op that only exists 8491b18d63aSmrg * for historical reasons. 8501b18d63aSmrg * 8511b18d63aSmrg * There used to be a bug in the X server where it would rely on 8521b18d63aSmrg * out-of-bounds accesses when it was asked to composite with a 8531b18d63aSmrg * window as the source. It would create a pixman image pointing 8541b18d63aSmrg * to some bogus position in memory, but then set a clip region 8551b18d63aSmrg * to the position where the actual bits were. 856d0321353Smrg * 857d0321353Smrg * Due to a bug in old versions of pixman, where it would not clip 858d0321353Smrg * against the image bounds when a clip region was set, this would 8591b18d63aSmrg * actually work. So when the pixman bug was fixed, a workaround was 8601b18d63aSmrg * added to allow certain out-of-bound accesses. This function disabled 8611b18d63aSmrg * those workarounds. 862d0321353Smrg * 8631b18d63aSmrg * Since 0.21.2, pixman doesn't do these workarounds anymore, so now this 8641b18d63aSmrg * function is a no-op. 865d0321353Smrg */ 8661b18d63aSmrgvoid pixman_disable_out_of_bounds_workaround (void); 867d0321353Smrg 868b4b94579Smrg/* 869b4b94579Smrg * Trapezoids 870b4b94579Smrg */ 871b4b94579Smrgtypedef struct pixman_edge pixman_edge_t; 872b4b94579Smrgtypedef struct pixman_trapezoid pixman_trapezoid_t; 873b4b94579Smrgtypedef struct pixman_trap pixman_trap_t; 874b4b94579Smrgtypedef struct pixman_span_fix pixman_span_fix_t; 8756ba797d6Smrgtypedef struct pixman_triangle pixman_triangle_t; 876b4b94579Smrg 877b4b94579Smrg/* 878b4b94579Smrg * An edge structure. This represents a single polygon edge 879b4b94579Smrg * and can be quickly stepped across small or large gaps in the 880b4b94579Smrg * sample grid 881b4b94579Smrg */ 882b4b94579Smrgstruct pixman_edge 883b4b94579Smrg{ 884b4b94579Smrg pixman_fixed_t x; 885b4b94579Smrg pixman_fixed_t e; 886d0321353Smrg pixman_fixed_t stepx; 887d0321353Smrg pixman_fixed_t signdx; 888d0321353Smrg pixman_fixed_t dy; 889d0321353Smrg pixman_fixed_t dx; 890d0321353Smrg 891d0321353Smrg pixman_fixed_t stepx_small; 892d0321353Smrg pixman_fixed_t stepx_big; 893d0321353Smrg pixman_fixed_t dx_small; 894d0321353Smrg pixman_fixed_t dx_big; 895b4b94579Smrg}; 896b4b94579Smrg 897b4b94579Smrgstruct pixman_trapezoid 898b4b94579Smrg{ 899d0321353Smrg pixman_fixed_t top, bottom; 900b4b94579Smrg pixman_line_fixed_t left, right; 901b4b94579Smrg}; 902b4b94579Smrg 9036ba797d6Smrgstruct pixman_triangle 9046ba797d6Smrg{ 9056ba797d6Smrg pixman_point_fixed_t p1, p2, p3; 9066ba797d6Smrg}; 907b4b94579Smrg 908b4b94579Smrg/* whether 't' is a well defined not obviously empty trapezoid */ 909d0321353Smrg#define pixman_trapezoid_valid(t) \ 910b4b94579Smrg ((t)->left.p1.y != (t)->left.p2.y && \ 911b4b94579Smrg (t)->right.p1.y != (t)->right.p2.y && \ 912b4b94579Smrg (int) ((t)->bottom - (t)->top) > 0) 913b4b94579Smrg 914b4b94579Smrgstruct pixman_span_fix 915b4b94579Smrg{ 916b4b94579Smrg pixman_fixed_t l, r, y; 917b4b94579Smrg}; 918b4b94579Smrg 919b4b94579Smrgstruct pixman_trap 920b4b94579Smrg{ 921b4b94579Smrg pixman_span_fix_t top, bot; 922b4b94579Smrg}; 923b4b94579Smrg 924b4b94579Smrgpixman_fixed_t pixman_sample_ceil_y (pixman_fixed_t y, 925b4b94579Smrg int bpp); 926b4b94579Smrgpixman_fixed_t pixman_sample_floor_y (pixman_fixed_t y, 927b4b94579Smrg int bpp); 928b4b94579Smrgvoid pixman_edge_step (pixman_edge_t *e, 929b4b94579Smrg int n); 930b4b94579Smrgvoid pixman_edge_init (pixman_edge_t *e, 931b4b94579Smrg int bpp, 932b4b94579Smrg pixman_fixed_t y_start, 933b4b94579Smrg pixman_fixed_t x_top, 934b4b94579Smrg pixman_fixed_t y_top, 935b4b94579Smrg pixman_fixed_t x_bot, 936b4b94579Smrg pixman_fixed_t y_bot); 937b4b94579Smrgvoid pixman_line_fixed_edge_init (pixman_edge_t *e, 938b4b94579Smrg int bpp, 939b4b94579Smrg pixman_fixed_t y, 940b4b94579Smrg const pixman_line_fixed_t *line, 941b4b94579Smrg int x_off, 942b4b94579Smrg int y_off); 943b4b94579Smrgvoid pixman_rasterize_edges (pixman_image_t *image, 944b4b94579Smrg pixman_edge_t *l, 945b4b94579Smrg pixman_edge_t *r, 946b4b94579Smrg pixman_fixed_t t, 947b4b94579Smrg pixman_fixed_t b); 948b4b94579Smrgvoid pixman_add_traps (pixman_image_t *image, 949b4b94579Smrg int16_t x_off, 950b4b94579Smrg int16_t y_off, 951b4b94579Smrg int ntrap, 952b4b94579Smrg pixman_trap_t *traps); 953b4b94579Smrgvoid pixman_add_trapezoids (pixman_image_t *image, 954b4b94579Smrg int16_t x_off, 955b4b94579Smrg int y_off, 956b4b94579Smrg int ntraps, 957b4b94579Smrg const pixman_trapezoid_t *traps); 958b4b94579Smrgvoid pixman_rasterize_trapezoid (pixman_image_t *image, 959b4b94579Smrg const pixman_trapezoid_t *trap, 960b4b94579Smrg int x_off, 961b4b94579Smrg int y_off); 9626ba797d6Smrgvoid pixman_composite_trapezoids (pixman_op_t op, 9636ba797d6Smrg pixman_image_t * src, 9646ba797d6Smrg pixman_image_t * dst, 9656ba797d6Smrg pixman_format_code_t mask_format, 9666ba797d6Smrg int x_src, 9676ba797d6Smrg int y_src, 9686ba797d6Smrg int x_dst, 9696ba797d6Smrg int y_dst, 9706ba797d6Smrg int n_traps, 9716ba797d6Smrg const pixman_trapezoid_t * traps); 9726ba797d6Smrgvoid pixman_composite_triangles (pixman_op_t op, 9736ba797d6Smrg pixman_image_t * src, 9746ba797d6Smrg pixman_image_t * dst, 9756ba797d6Smrg pixman_format_code_t mask_format, 9766ba797d6Smrg int x_src, 9776ba797d6Smrg int y_src, 9786ba797d6Smrg int x_dst, 9796ba797d6Smrg int y_dst, 9806ba797d6Smrg int n_tris, 9816ba797d6Smrg const pixman_triangle_t * tris); 9826ba797d6Smrgvoid pixman_add_triangles (pixman_image_t *image, 9836ba797d6Smrg int32_t x_off, 9846ba797d6Smrg int32_t y_off, 9856ba797d6Smrg int n_tris, 9866ba797d6Smrg const pixman_triangle_t *tris); 987b4b94579Smrg 988952204abSmrgPIXMAN_END_DECLS 989952204abSmrg 990b4b94579Smrg#endif /* PIXMAN_H__ */ 991