Back to index

lightning-sunbird  0.9+nobinonly
pixman.h
Go to the documentation of this file.
00001 #ifndef _PIXMAN_H_
00002 #define _PIXMAN_H_
00003 
00004 
00005 /* pixman.h - a merge of pixregion.h and ic.h */
00006 
00007 
00008 /* from pixregion.h */
00009 
00010 
00011 /***********************************************************
00012 
00013 Copyright 1987, 1998  The Open Group
00014 
00015 Permission to use, copy, modify, distribute, and sell this software and its
00016 documentation for any purpose is hereby granted without fee, provided that
00017 the above copyright notice appear in all copies and that both that
00018 copyright notice and this permission notice appear in supporting
00019 documentation.
00020 
00021 The above copyright notice and this permission notice shall be included in
00022 all copies or substantial portions of the Software.
00023 
00024 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00025 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00026 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00027 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00028 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00029 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00030 
00031 Except as contained in this notice, the name of The Open Group shall not be
00032 used in advertising or otherwise to promote the sale, use or other dealings
00033 in this Software without prior written authorization from The Open Group.
00034 
00035 
00036 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
00037 
00038                         All Rights Reserved
00039 
00040 Permission to use, copy, modify, and distribute this software and its 
00041 documentation for any purpose and without fee is hereby granted, 
00042 provided that the above copyright notice appear in all copies and that
00043 both that copyright notice and this permission notice appear in 
00044 supporting documentation, and that the name of Digital not be
00045 used in advertising or publicity pertaining to distribution of the
00046 software without specific, written prior permission.  
00047 
00048 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00049 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00050 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00051 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00052 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00053 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00054 SOFTWARE.
00055 
00056 ******************************************************************/
00057 /* $Id: pixman.h,v 1.6.4.1 2005/09/27 23:09:03 vladimir%pobox.com Exp $ */
00058 
00059 /* libic.h */
00060 
00061 /*
00062  * Copyright © 1998 Keith Packard
00063  *
00064  * Permission to use, copy, modify, distribute, and sell this software and its
00065  * documentation for any purpose is hereby granted without fee, provided that
00066  * the above copyright notice appear in all copies and that both that
00067  * copyright notice and this permission notice appear in supporting
00068  * documentation, and that the name of Keith Packard not be used in
00069  * advertising or publicity pertaining to distribution of the software without
00070  * specific, written prior permission.  Keith Packard makes no
00071  * representations about the suitability of this software for any purpose.  It
00072  * is provided "as is" without express or implied warranty.
00073  *
00074  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
00075  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
00076  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00077  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
00078  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
00079  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00080  * PERFORMANCE OF THIS SOFTWARE.
00081  */
00082 
00083 
00084 #if defined (__SVR4) && defined (__sun)
00085 # include <sys/int_types.h>
00086 #elif defined (__OpenBSD__) || defined (_AIX)
00087 # include <inttypes.h>
00088 #elif defined(_MSC_VER)
00089   typedef __int8 int8_t;
00090   typedef unsigned __int8 uint8_t;
00091   typedef __int16 int16_t;
00092   typedef unsigned __int16 uint16_t;
00093   typedef __int32 int32_t;
00094   typedef unsigned __int32 uint32_t;
00095   typedef __int64 int64_t;
00096   typedef unsigned __int64 uint64_t;
00097 # ifndef HAVE_UINT64_T
00098 #  define HAVE_UINT64_T 1
00099 # endif
00100 #else
00101 # include <stdint.h>
00102 #endif
00103 
00104 #include "pixman-remap.h"
00105 
00106 #if defined(__cplusplus) || defined(c_plusplus)
00107 extern "C" {
00108 #endif
00109 
00110 /* pixregion.h */
00111 
00112 typedef struct pixman_region16 pixman_region16_t;
00113 
00114 typedef struct pixman_box16 {
00115     short x1, y1, x2, y2;
00116 } pixman_box16_t;
00117 
00118 typedef enum {
00119     PIXMAN_REGION_STATUS_FAILURE,
00120     PIXMAN_REGION_STATUS_SUCCESS
00121 } pixman_region_status_t;
00122 
00123 /* creation/destruction */
00124 
00125 pixman_region16_t *
00126 pixman_region_create (void);
00127 
00128 pixman_region16_t *
00129 pixman_region_create_simple (pixman_box16_t *extents);
00130 
00131 void
00132 pixman_region_destroy (pixman_region16_t *region);
00133 
00134 /* manipulation */
00135 
00136 void
00137 pixman_region_translate (pixman_region16_t *region, int x, int y);
00138 
00139 pixman_region_status_t
00140 pixman_region_copy (pixman_region16_t *dest, pixman_region16_t *source);
00141 
00142 pixman_region_status_t
00143 pixman_region_intersect (pixman_region16_t *newReg, pixman_region16_t *reg1, pixman_region16_t *reg2);
00144 
00145 pixman_region_status_t
00146 pixman_region_union (pixman_region16_t *newReg, pixman_region16_t *reg1, pixman_region16_t *reg2);
00147 
00148 pixman_region_status_t
00149 pixman_region_union_rect(pixman_region16_t *dest, pixman_region16_t *source,
00150                       int x, int y, unsigned int width, unsigned int height);
00151 
00152 pixman_region_status_t
00153 pixman_region_subtract (pixman_region16_t *regD, pixman_region16_t *regM, pixman_region16_t *regS);
00154 
00155 pixman_region_status_t
00156 pixman_region_inverse (pixman_region16_t *newReg, pixman_region16_t *reg1, pixman_box16_t *invRect);
00157 
00158 /* XXX: Need to fix this so it doesn't depend on an X data structure
00159 pixman_region16_t *
00160 RectsTopixman_region16_t (int nrects, xRectanglePtr prect, int ctype);
00161 */
00162 
00163 /* querying */
00164 
00165 /* XXX: These should proably be combined: pixman_region_get_rects? */
00166 int
00167 pixman_region_num_rects (pixman_region16_t *region);
00168 
00169 pixman_box16_t *
00170 pixman_region_rects (pixman_region16_t *region);
00171 
00172 /* XXX: Change to an enum */
00173 #define rgnOUT 0
00174 #define rgnIN  1
00175 #define rgnPART 2
00176 
00177 int
00178 pixman_region_contains_point (pixman_region16_t *region, int x, int y, pixman_box16_t *box);
00179 
00180 int
00181 pixman_region_contains_rectangle (pixman_region16_t *pixman_region16_t, pixman_box16_t *prect);
00182 
00183 int
00184 pixman_region_not_empty (pixman_region16_t *region);
00185 
00186 pixman_box16_t *
00187 pixman_region_extents (pixman_region16_t *region);
00188 
00189 /* mucking around */
00190 
00191 /* WARNING: calling pixman_region_append may leave dest as an invalid
00192    region. Follow-up with pixman_region_validate to fix it up. */
00193 pixman_region_status_t
00194 pixman_region_append (pixman_region16_t *dest, pixman_region16_t *region);
00195 
00196 pixman_region_status_t
00197 pixman_region_validate (pixman_region16_t *badreg, int *pOverlap);
00198 
00199 /* Unclassified functionality
00200  * XXX: Do all of these need to be exported?
00201  */
00202 
00203 void
00204 pixman_region_reset (pixman_region16_t *region, pixman_box16_t *pBox);
00205 
00206 void
00207 pixman_region_empty (pixman_region16_t *region);
00208 
00209 
00210 /* ic.h */
00211 
00212 
00213 /* icformat.c */
00214 typedef enum pixman_operator {
00215     PIXMAN_OPERATOR_CLEAR,
00216     PIXMAN_OPERATOR_SRC,
00217     PIXMAN_OPERATOR_DST,
00218     PIXMAN_OPERATOR_OVER,
00219     PIXMAN_OPERATOR_OVER_REVERSE,
00220     PIXMAN_OPERATOR_IN,
00221     PIXMAN_OPERATOR_IN_REVERSE,
00222     PIXMAN_OPERATOR_OUT,
00223     PIXMAN_OPERATOR_OUT_REVERSE,
00224     PIXMAN_OPERATOR_ATOP,
00225     PIXMAN_OPERATOR_ATOP_REVERSE,
00226     PIXMAN_OPERATOR_XOR,
00227     PIXMAN_OPERATOR_ADD,
00228     PIXMAN_OPERATOR_SATURATE
00229 } pixman_operator_t;
00230 
00231 typedef enum pixman_format_name {
00232     PIXMAN_FORMAT_NAME_ARGB32,
00233     PIXMAN_FORMAT_NAME_RGB24,
00234     PIXMAN_FORMAT_NAME_A8,
00235     PIXMAN_FORMAT_NAME_A1
00236 } pixman_format_name_t;
00237 
00238 typedef struct pixman_format pixman_format_t;
00239 
00240 pixman_format_t *
00241 pixman_format_create (pixman_format_name_t name);
00242 
00243 pixman_format_t *
00244 pixman_format_create_masks (int bpp,
00245                          int alpha_mask,
00246                          int red_mask,
00247                          int green_mask,
00248                          int blue_mask);
00249 
00250 void
00251 pixman_format_destroy (pixman_format_t *format);
00252 
00253 void
00254 pixman_format_get_masks (pixman_format_t *format,
00255                          int *bpp,
00256                          int *alpha_mask,
00257                          int *red_mask,
00258                          int *green_mask,
00259                          int *blue_mask);
00260 
00261 /* icimage.c */
00262 
00263 typedef struct pixman_image pixman_image_t;
00264 
00265 pixman_image_t *
00266 pixman_image_create (pixman_format_t      *format,
00267                    int      width,
00268                    int      height);
00269 
00270 /*
00271  * This single define controls the basic size of data manipulated
00272  * by this software; it must be log2(sizeof (pixman_bits_t) * 8)
00273  */
00274 
00275 /* We use a 32-bit size on all platforms, (even those with native 64
00276  * bit types). This is consistent with the code currently in the X
00277  * server, so it goes through much more well-tested code paths, (we
00278  * saw rendering bugs when we tried IC_SHIFT==6 and uint64_t for
00279  * pixman_bits_t on 64-bit platofrms). In addition, Keith says that
00280  * his testing indicates that using 32-bits everywhere is a
00281  * performance win in any case, (presumably due to 32-bit datapaths
00282  * between the processor and the video card).
00283 */
00284 #ifndef IC_SHIFT
00285 #define IC_SHIFT 5
00286 #define FB_SHIFT IC_SHIFT
00287 typedef uint32_t pixman_bits_t;
00288 #endif
00289 
00290 pixman_image_t *
00291 pixman_image_create_for_data (pixman_bits_t *data,
00292                            pixman_format_t *format,
00293                            int width, int height,
00294                            int bpp, int stride);
00295 
00296 void
00297 pixman_image_destroy (pixman_image_t *image);
00298 
00299 int
00300 pixman_image_set_clip_region (pixman_image_t     *image,
00301                            pixman_region16_t     *region);
00302 
00303 typedef int32_t pixman_fixed16_16_t;
00304 
00305 typedef struct pixman_point_fixed {
00306     pixman_fixed16_16_t  x, y;
00307 } pixman_point_fixed_t;
00308 
00309 typedef struct pixman_line_fixed {
00310     pixman_point_fixed_t    p1, p2;
00311 } pixman_line_fixed_t;
00312 
00313 /* XXX: It's goofy that pixman_rectangle_t has integers while all the other
00314    datatypes have fixed-point values. (Though by design,
00315    pixman_fill_rectangles is designed to fill only whole pixels) */
00316 typedef struct pixman_rectangle {
00317     short x, y;
00318     unsigned short width, height;
00319 } pixman_rectangle_t;
00320 
00321 typedef struct pixman_triangle {
00322     pixman_point_fixed_t    p1, p2, p3;
00323 } pixman_triangle_t;
00324 
00325 typedef struct pixman_trapezoid {
00326     pixman_fixed16_16_t  top, bottom;
00327     pixman_line_fixed_t     left, right;
00328 } pixman_trapezoid_t;
00329 
00330 typedef struct pixman_vector {
00331     pixman_fixed16_16_t    vector[3];
00332 } pixman_vector_t;
00333 
00334 typedef struct pixman_transform {
00335     pixman_fixed16_16_t  matrix[3][3];
00336 } pixman_transform_t;
00337 
00338 typedef enum {
00339     PIXMAN_FILTER_FAST,
00340     PIXMAN_FILTER_GOOD,
00341     PIXMAN_FILTER_BEST,
00342     PIXMAN_FILTER_NEAREST,
00343     PIXMAN_FILTER_BILINEAR
00344 } pixman_filter_t;
00345 
00346 void
00347 pixman_image_set_component_alpha (pixman_image_t *image,
00348                               int          component_alpha);
00349 
00350 int
00351 pixman_image_set_transform (pixman_image_t       *image,
00352                          pixman_transform_t      *transform);
00353 
00354 void
00355 pixman_image_set_repeat (pixman_image_t   *image,
00356                       int          repeat);
00357 
00358 void
00359 pixman_image_set_filter (pixman_image_t          *image,
00360                       pixman_filter_t     filter);
00361 
00362 int
00363 pixman_image_get_width (pixman_image_t    *image);
00364 
00365 int
00366 pixman_image_get_height (pixman_image_t   *image);
00367 
00368 int
00369 pixman_image_get_stride (pixman_image_t   *image);
00370 
00371 int
00372 pixman_image_get_depth (pixman_image_t    *image);
00373 
00374 pixman_format_t *
00375 pixman_image_get_format (pixman_image_t   *image);
00376 
00377 pixman_bits_t *
00378 pixman_image_get_data (pixman_image_t     *image);
00379 
00380 /* iccolor.c */
00381 
00382 /* XXX: Do we really need a struct here? Only pixman_rectangle_t uses this. */
00383 typedef struct pixman_color {
00384     unsigned short   red;
00385     unsigned short   green;
00386     unsigned short   blue;
00387     unsigned short   alpha;
00388 } pixman_color_t;
00389 
00390 void
00391 pixman_color_to_pixel (const pixman_format_t     *format,
00392                      const pixman_color_t *color,
00393                      pixman_bits_t        *pixel);
00394 
00395 void
00396 pixman_pixel_to_color (const pixman_format_t     *format,
00397                      pixman_bits_t        pixel,
00398                      pixman_color_t              *color);
00399 
00400 /* icrect.c */
00401 
00402 void
00403 pixman_fill_rectangle (pixman_operator_t  op,
00404                      pixman_image_t              *dst,
00405                      const pixman_color_t *color,
00406                      int                  x,
00407                      int                  y,
00408                      unsigned int         width,
00409                      unsigned int         height);
00410 
00411 void
00412 pixman_fill_rectangles (pixman_operator_t        op,
00413                      pixman_image_t                     *dst,
00414                      const pixman_color_t        *color,
00415                      const pixman_rectangle_t    *rects,
00416                      int                         nRects);
00417 
00418 /* ictrap.c */
00419 
00420 void
00421 pixman_composite_trapezoids (pixman_operator_t          op,
00422                           pixman_image_t         *src,
00423                           pixman_image_t         *dst,
00424                           int                    xSrc,
00425                           int                    ySrc,
00426                           const pixman_trapezoid_t *traps,
00427                           int                    ntrap);
00428 
00429 void
00430 pixman_add_trapezoids (pixman_image_t            *dst,
00431                      int                  x_off,
00432                      int                  y_off,
00433                      const pixman_trapezoid_t    *traps,
00434                      int                  ntraps);
00435 
00436 /* ictri.c */
00437 
00438 void
00439 pixman_composite_triangles (pixman_operator_t           op,
00440                          pixman_image_t          *src,
00441                          pixman_image_t          *dst,
00442                          int                            xSrc,
00443                          int                            ySrc,
00444                          const pixman_triangle_t *tris,
00445                          int                            ntris);
00446 
00447 void
00448 pixman_composite_tri_strip (pixman_operator_t           op,
00449                          pixman_image_t          *src,
00450                          pixman_image_t          *dst,
00451                          int                            xSrc,
00452                          int                            ySrc,
00453                          const pixman_point_fixed_t     *points,
00454                          int                            npoints);
00455 
00456 
00457 void
00458 pixman_composite_tri_fan (pixman_operator_t             op,
00459                        pixman_image_t            *src,
00460                        pixman_image_t            *dst,
00461                        int                       xSrc,
00462                        int                       ySrc,
00463                        const pixman_point_fixed_t       *points,
00464                        int                       npoints);
00465 
00466 /* ic.c */
00467 
00468 void
00469 pixman_composite (pixman_operator_t       op,
00470                 pixman_image_t     *iSrc,
00471                 pixman_image_t     *iMask,
00472                 pixman_image_t     *iDst,
00473                 int                xSrc,
00474                 int                ySrc,
00475                 int                xMask,
00476                 int                yMask,
00477                 int                xDst,
00478                 int                yDst,
00479                 int                width,
00480                 int                height);
00481 
00482 
00483 
00484 #if defined(__cplusplus) || defined(c_plusplus)
00485 }
00486 #endif
00487 
00488 #endif /* _PIXMAN_H_ */