Home | History | Annotate | Line # | Download | only in fb
      1 /*
      2  *
      3  * Copyright  1998 Keith Packard
      4  *
      5  * Permission to use, copy, modify, distribute, and sell this software and its
      6  * documentation for any purpose is hereby granted without fee, provided that
      7  * the above copyright notice appear in all copies and that both that
      8  * copyright notice and this permission notice appear in supporting
      9  * documentation, and that the name of Keith Packard not be used in
     10  * advertising or publicity pertaining to distribution of the software without
     11  * specific, written prior permission.  Keith Packard makes no
     12  * representations about the suitability of this software for any purpose.  It
     13  * is provided "as is" without express or implied warranty.
     14  *
     15  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
     17  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     18  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
     19  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
     20  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     21  * PERFORMANCE OF THIS SOFTWARE.
     22  */
     23 
     24 
     25 #ifndef _FB_H_
     26 #define _FB_H_
     27 
     28 #include <X11/X.h>
     29 #include <pixman.h>
     30 
     31 #include "scrnintstr.h"
     32 #include "pixmap.h"
     33 #include "pixmapstr.h"
     34 #include "region.h"
     35 #include "gcstruct.h"
     36 #include "colormap.h"
     37 #include "miscstruct.h"
     38 #include "servermd.h"
     39 #include "windowstr.h"
     40 #include "privates.h"
     41 #include "mi.h"
     42 #include "migc.h"
     43 #include "mibstore.h"
     44 #include "picturestr.h"
     45 
     46 #ifdef FB_ACCESS_WRAPPER
     47 
     48 #include "wfbrename.h"
     49 #define FBPREFIX(x) wfb##x
     50 #define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr))))
     51 #define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr))))
     52 
     53 #define MEMCPY_WRAPPED(dst, src, size) do {                       \
     54     size_t _i;                                                    \
     55     CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src);           \
     56     for(_i = 0; _i < size; _i++) {                                \
     57         WRITE(_dst +_i, READ(_src + _i));                         \
     58     }                                                             \
     59 } while(0)
     60 
     61 #define MEMSET_WRAPPED(dst, val, size) do {                       \
     62     size_t _i;                                                    \
     63     CARD8 *_dst = (CARD8*)(dst);                                  \
     64     for(_i = 0; _i < size; _i++) {                                \
     65         WRITE(_dst +_i, (val));                                   \
     66     }                                                             \
     67 } while(0)
     68 
     69 #else
     70 
     71 #define FBPREFIX(x) fb##x
     72 #define WRITE(ptr, val) (*(ptr) = (val))
     73 #define READ(ptr) (*(ptr))
     74 #define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size))
     75 #define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size))
     76 
     77 #endif
     78 
     79 /*
     80  * This single define controls the basic size of data manipulated
     81  * by this software; it must be log2(sizeof (FbBits) * 8)
     82  */
     83 
     84 #ifndef FB_SHIFT
     85 #define FB_SHIFT    LOG2_BITMAP_PAD
     86 #endif
     87 
     88 #if FB_SHIFT < LOG2_BITMAP_PAD
     89     error FB_SHIFT must be >= LOG2_BITMAP_PAD
     90 #endif
     91 
     92 #define FB_UNIT	    (1 << FB_SHIFT)
     93 #define FB_HALFUNIT (1 << (FB_SHIFT-1))
     94 #define FB_MASK	    (FB_UNIT - 1)
     95 #define FB_ALLONES  ((FbBits) -1)
     96 
     97 #if GLYPHPADBYTES != 4
     98 #error "GLYPHPADBYTES must be 4"
     99 #endif
    100 /* whether to bother to include 24bpp support */
    101 #ifndef FBNO24BIT
    102 #define FB_24BIT
    103 #endif
    104 
    105 /*
    106  * Unless otherwise instructed, fb includes code to advertise 24bpp
    107  * windows with 32bpp image format for application compatibility
    108  */
    109 
    110 #ifdef FB_24BIT
    111 #ifndef FBNO24_32
    112 #define FB_24_32BIT
    113 #endif
    114 #endif
    115 
    116 #define FB_STIP_SHIFT	LOG2_BITMAP_PAD
    117 #define FB_STIP_UNIT	(1 << FB_STIP_SHIFT)
    118 #define FB_STIP_MASK	(FB_STIP_UNIT - 1)
    119 #define FB_STIP_ALLONES	((FbStip) -1)
    120 
    121 #define FB_STIP_ODDSTRIDE(s)	(((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
    122 #define FB_STIP_ODDPTR(p)	((((long) (p)) & (FB_MASK >> 3)) != 0)
    123 
    124 #define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
    125 #define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
    126 
    127 #define FbFullMask(n)   ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
    128 
    129 #if FB_SHIFT == 6
    130 # ifdef WIN32
    131 typedef unsigned __int64    FbBits;
    132 # else
    133 #  if defined(__alpha__) || defined(__alpha) || \
    134       defined(ia64) || defined(__ia64__) || \
    135       defined(__sparc64__) || defined(_LP64) || \
    136       defined(__s390x__) || \
    137       defined(amd64) || defined (__amd64__) || \
    138       defined (__powerpc64__)
    139 typedef unsigned long	    FbBits;
    140 #  else
    141 typedef unsigned long long  FbBits;
    142 #  endif
    143 # endif
    144 #endif
    145 
    146 #if FB_SHIFT == 5
    147 typedef CARD32		    FbBits;
    148 #endif
    149 
    150 #if FB_SHIFT == 4
    151 typedef CARD16		    FbBits;
    152 #endif
    153 
    154 #if LOG2_BITMAP_PAD == FB_SHIFT
    155 typedef FbBits		    FbStip;
    156 #else
    157 # if LOG2_BITMAP_PAD == 5
    158 typedef CARD32		    FbStip;
    159 # endif
    160 #endif
    161 
    162 typedef int		    FbStride;
    163 
    164 
    165 #ifdef FB_DEBUG
    166 extern _X_EXPORT void fbValidateDrawable(DrawablePtr d);
    167 extern _X_EXPORT void fbInitializeDrawable(DrawablePtr d);
    168 extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
    169 #define FB_HEAD_BITS   (FbStip) (0xbaadf00d)
    170 #define FB_TAIL_BITS   (FbStip) (0xbaddf0ad)
    171 #else
    172 #define fbValidateDrawable(d)
    173 #define fdInitializeDrawable(d)
    174 #endif
    175 
    176 #include "fbrop.h"
    177 
    178 #if BITMAP_BIT_ORDER == LSBFirst
    179 #define FbScrLeft(x,n)	((x) >> (n))
    180 #define FbScrRight(x,n)	((x) << (n))
    181 /* #define FbLeftBits(x,n)	((x) & ((((FbBits) 1) << (n)) - 1)) */
    182 #define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
    183 #define FbStipMoveLsb(x,s,n)	(FbStipRight (x,(s)-(n)))
    184 #define FbPatternOffsetBits	0
    185 #else
    186 #define FbScrLeft(x,n)	((x) << (n))
    187 #define FbScrRight(x,n)	((x) >> (n))
    188 /* #define FbLeftBits(x,n)	((x) >> (FB_UNIT - (n))) */
    189 #define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
    190 #define FbStipMoveLsb(x,s,n)	(x)
    191 #define FbPatternOffsetBits	(sizeof (FbBits) - 1)
    192 #endif
    193 
    194 #include "micoord.h"
    195 
    196 #define FbStipLeft(x,n)	FbScrLeft(x,n)
    197 #define FbStipRight(x,n) FbScrRight(x,n)
    198 
    199 #define FbRotLeft(x,n)	FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
    200 #define FbRotRight(x,n)	FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
    201 
    202 #define FbRotStipLeft(x,n)  FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
    203 #define FbRotStipRight(x,n)  FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
    204 
    205 #define FbLeftMask(x)	    ( ((x) & FB_MASK) ? \
    206 			     FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
    207 #define FbRightMask(x)	    ( ((FB_UNIT - (x)) & FB_MASK) ? \
    208 			     FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
    209 
    210 #define FbLeftStipMask(x)   ( ((x) & FB_STIP_MASK) ? \
    211 			     FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
    212 #define FbRightStipMask(x)  ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
    213 			     FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
    214 
    215 #define FbBitsMask(x,w)	(FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
    216 			 FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
    217 
    218 #define FbStipMask(x,w)	(FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
    219 			 FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
    220 
    221 
    222 #define FbMaskBits(x,w,l,n,r) { \
    223     n = (w); \
    224     r = FbRightMask((x)+n); \
    225     l = FbLeftMask(x); \
    226     if (l) { \
    227 	n -= FB_UNIT - ((x) & FB_MASK); \
    228 	if (n < 0) { \
    229 	    n = 0; \
    230 	    l &= r; \
    231 	    r = 0; \
    232 	} \
    233     } \
    234     n >>= FB_SHIFT; \
    235 }
    236 
    237 #ifdef FBNOPIXADDR
    238 #define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
    239 #define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
    240     *dst = FbDoMaskRRop(*dst,and,xor,l); \
    241 }
    242 #define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
    243     *dst = FbDoMaskRRop(*dst,and,xor,r); \
    244 }
    245 #else
    246 
    247 #define FbByteMaskInvalid   0x10
    248 
    249 #define FbPatternOffset(o,t)  ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
    250 
    251 #define FbPtrOffset(p,o,t)		((t *) ((CARD8 *) (p) + (o)))
    252 #define FbSelectPatternPart(xor,o,t)	((xor) >> (FbPatternOffset (o,t) << 3))
    253 #define FbStorePart(dst,off,t,xor)	(WRITE(FbPtrOffset(dst,off,t), \
    254 					 FbSelectPart(xor,off,t)))
    255 #ifndef FbSelectPart
    256 #define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
    257 #endif
    258 
    259 #define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
    260     n = (w); \
    261     lb = 0; \
    262     rb = 0; \
    263     r = FbRightMask((x)+n); \
    264     if (r) { \
    265 	/* compute right byte length */ \
    266 	if ((copy) && (((x) + n) & 7) == 0) { \
    267 	    rb = (((x) + n) & FB_MASK) >> 3; \
    268 	} else { \
    269 	    rb = FbByteMaskInvalid; \
    270 	} \
    271     } \
    272     l = FbLeftMask(x); \
    273     if (l) { \
    274 	/* compute left byte length */ \
    275 	if ((copy) && ((x) & 7) == 0) { \
    276 	    lb = ((x) & FB_MASK) >> 3; \
    277 	} else { \
    278 	    lb = FbByteMaskInvalid; \
    279 	} \
    280 	/* subtract out the portion painted by leftMask */ \
    281 	n -= FB_UNIT - ((x) & FB_MASK); \
    282 	if (n < 0) { \
    283 	    if (lb != FbByteMaskInvalid) { \
    284 		if (rb == FbByteMaskInvalid) { \
    285 		    lb = FbByteMaskInvalid; \
    286 		} else if (rb) { \
    287 		    lb |= (rb - lb) << (FB_SHIFT - 3); \
    288 		    rb = 0; \
    289 		} \
    290 	    } \
    291 	    n = 0; \
    292 	    l &= r; \
    293 	    r = 0; \
    294 	}\
    295     } \
    296     n >>= FB_SHIFT; \
    297 }
    298 
    299 #if FB_SHIFT == 6
    300 #define FbDoLeftMaskByteRRop6Cases(dst,xor) \
    301     case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
    302 	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
    303 	break; \
    304     case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
    305 	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
    306 	FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
    307 	break; \
    308     case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
    309 	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
    310 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    311 	break; \
    312     case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
    313 	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
    314 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    315 	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
    316 	break; \
    317     case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
    318 	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
    319 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    320 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    321 	break; \
    322     case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
    323 	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
    324 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    325 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    326 	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
    327 	break; \
    328     case (sizeof (FbBits) - 7): \
    329 	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
    330 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    331 	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
    332 	break; \
    333     case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
    334 	FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
    335 	break; \
    336     case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
    337 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    338 	break; \
    339     case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
    340 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    341 	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
    342 	break; \
    343     case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
    344 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    345 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    346 	break; \
    347     case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
    348 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    349 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    350 	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
    351 	break; \
    352     case (sizeof (FbBits) - 6): \
    353 	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
    354 	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
    355 	break; \
    356     case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
    357 	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
    358 	break; \
    359     case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
    360 	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
    361 	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
    362 	break; \
    363     case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
    364 	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
    365 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    366 	break; \
    367     case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
    368 	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
    369 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    370 	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
    371 	break; \
    372     case (sizeof (FbBits) - 5): \
    373 	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
    374 	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
    375 	break; \
    376     case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
    377 	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
    378 	break; \
    379     case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
    380 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    381 	break; \
    382     case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
    383 	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
    384 	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
    385 	break; \
    386     case (sizeof (FbBits) - 4): \
    387 	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
    388 	break;
    389 
    390 #define FbDoRightMaskByteRRop6Cases(dst,xor) \
    391     case 4: \
    392 	FbStorePart(dst,0,CARD32,xor); \
    393 	break; \
    394     case 5: \
    395 	FbStorePart(dst,0,CARD32,xor); \
    396 	FbStorePart(dst,4,CARD8,xor); \
    397 	break; \
    398     case 6: \
    399 	FbStorePart(dst,0,CARD32,xor); \
    400 	FbStorePart(dst,4,CARD16,xor); \
    401 	break; \
    402     case 7: \
    403 	FbStorePart(dst,0,CARD32,xor); \
    404 	FbStorePart(dst,4,CARD16,xor); \
    405 	FbStorePart(dst,6,CARD8,xor); \
    406 	break;
    407 #else
    408 #define FbDoLeftMaskByteRRop6Cases(dst,xor)
    409 #define FbDoRightMaskByteRRop6Cases(dst,xor)
    410 #endif
    411 
    412 #define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
    413     switch (lb) { \
    414     FbDoLeftMaskByteRRop6Cases(dst,xor) \
    415     case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
    416 	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
    417 	break; \
    418     case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
    419 	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
    420 	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
    421 	break; \
    422     case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
    423 	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
    424 	break; \
    425     case sizeof (FbBits) - 3: \
    426 	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
    427     case sizeof (FbBits) - 2: \
    428 	FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
    429 	break; \
    430     case sizeof (FbBits) - 1: \
    431 	FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
    432 	break; \
    433     default: \
    434 	WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \
    435 	break; \
    436     } \
    437 }
    438 
    439 
    440 #define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
    441     switch (rb) { \
    442     case 1: \
    443 	FbStorePart(dst,0,CARD8,xor); \
    444 	break; \
    445     case 2: \
    446 	FbStorePart(dst,0,CARD16,xor); \
    447 	break; \
    448     case 3: \
    449 	FbStorePart(dst,0,CARD16,xor); \
    450 	FbStorePart(dst,2,CARD8,xor); \
    451 	break; \
    452     FbDoRightMaskByteRRop6Cases(dst,xor) \
    453     default: \
    454 	WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
    455     } \
    456 }
    457 #endif
    458 
    459 #define FbMaskStip(x,w,l,n,r) { \
    460     n = (w); \
    461     r = FbRightStipMask((x)+n); \
    462     l = FbLeftStipMask(x); \
    463     if (l) { \
    464 	n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
    465 	if (n < 0) { \
    466 	    n = 0; \
    467 	    l &= r; \
    468 	    r = 0; \
    469 	} \
    470     } \
    471     n >>= FB_STIP_SHIFT; \
    472 }
    473 
    474 /*
    475  * These macros are used to transparently stipple
    476  * in copy mode; the expected usage is with 'n' constant
    477  * so all of the conditional parts collapse into a minimal
    478  * sequence of partial word writes
    479  *
    480  * 'n' is the bytemask of which bytes to store, 'a' is the address
    481  * of the FbBits base unit, 'o' is the offset within that unit
    482  *
    483  * The term "lane" comes from the hardware term "byte-lane" which
    484  */
    485 
    486 #define FbLaneCase1(n,a,o)						\
    487     if ((n) == 0x01) {							\
    488 	WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), fgxor);		\
    489     }
    490 
    491 #define FbLaneCase2(n,a,o)						\
    492     if ((n) == 0x03) {							\
    493 	WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), fgxor);	\
    494     } else {								\
    495 	FbLaneCase1((n)&1,a,o)						\
    496 	FbLaneCase1((n)>>1,a,(o)+1)					\
    497     }
    498 
    499 #define FbLaneCase4(n,a,o)						\
    500     if ((n) == 0x0f) {							\
    501 	WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), fgxor);	\
    502     } else {								\
    503 	FbLaneCase2((n)&3,a,o)						\
    504 	FbLaneCase2((n)>>2,a,(o)+2)					\
    505     }
    506 
    507 #define FbLaneCase8(n,a,o)						\
    508     if ((n) == 0x0ff) {							\
    509 	*(FbBits *) ((a)+(o)) = fgxor;					\
    510     } else {								\
    511 	FbLaneCase4((n)&15,a,o)						\
    512 	FbLaneCase4((n)>>4,a,(o)+4)					\
    513     }
    514 
    515 #if FB_SHIFT == 6
    516 #define FbLaneCase(n,a)   FbLaneCase8(n,(CARD8 *) (a),0)
    517 #endif
    518 
    519 #if FB_SHIFT == 5
    520 #define FbLaneCase(n,a)   FbLaneCase4(n,(CARD8 *) (a),0)
    521 #endif
    522 
    523 /* Rotate a filled pixel value to the specified alignement */
    524 #define FbRot24(p,b)	    (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
    525 #define FbRot24Stip(p,b)    (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
    526 
    527 /* step a filled pixel value to the next/previous FB_UNIT alignment */
    528 #define FbNext24Pix(p)	(FbRot24(p,(24-FB_UNIT%24)))
    529 #define FbPrev24Pix(p)	(FbRot24(p,FB_UNIT%24))
    530 #define FbNext24Stip(p)	(FbRot24(p,(24-FB_STIP_UNIT%24)))
    531 #define FbPrev24Stip(p)	(FbRot24(p,FB_STIP_UNIT%24))
    532 
    533 /* step a rotation value to the next/previous rotation value */
    534 #if FB_UNIT == 64
    535 #define FbNext24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
    536 #define FbPrev24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
    537 
    538 #if IMAGE_BYTE_ORDER == MSBFirst
    539 #define FbFirst24Rot(x)		(((x) + 8) % 24)
    540 #else
    541 #define FbFirst24Rot(x)		((x) % 24)
    542 #endif
    543 
    544 #endif
    545 
    546 #if FB_UNIT == 32
    547 #define FbNext24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
    548 #define FbPrev24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
    549 
    550 #if IMAGE_BYTE_ORDER == MSBFirst
    551 #define FbFirst24Rot(x)		(((x) + 16) % 24)
    552 #else
    553 #define FbFirst24Rot(x)		((x) % 24)
    554 #endif
    555 #endif
    556 
    557 #define FbNext24RotStip(r)        ((r) == 0 ? 16 : (r) - 8)
    558 #define FbPrev24RotStip(r)        ((r) == 16 ? 0 : (r) + 8)
    559 
    560 /* Whether 24-bit specific code is needed for this filled pixel value */
    561 #define FbCheck24Pix(p)	((p) == FbNext24Pix(p))
    562 
    563 /* Macros for dealing with dashing */
    564 
    565 #define FbDashDeclare	\
    566     unsigned char	*__dash, *__firstDash, *__lastDash
    567 
    568 #define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) {	    \
    569     (even) = TRUE;					    \
    570     __firstDash = (pGC)->dash;				    \
    571     __lastDash = __firstDash + (pGC)->numInDashList;	    \
    572     (dashOffset) %= (pPriv)->dashLength;		    \
    573 							    \
    574     __dash = __firstDash;				    \
    575     while ((dashOffset) >= ((dashlen) = *__dash))	    \
    576     {							    \
    577 	(dashOffset) -= (dashlen);			    \
    578 	(even) = 1-(even);				    \
    579 	if (++__dash == __lastDash)			    \
    580 	    __dash = __firstDash;			    \
    581     }							    \
    582     (dashlen) -= (dashOffset);				    \
    583 }
    584 
    585 #define FbDashNext(dashlen) {				    \
    586     if (++__dash == __lastDash)				    \
    587 	__dash = __firstDash;				    \
    588     (dashlen) = *__dash;				    \
    589 }
    590 
    591 /* as numInDashList is always even, this case can skip a test */
    592 
    593 #define FbDashNextEven(dashlen) {			    \
    594     (dashlen) = *++__dash;				    \
    595 }
    596 
    597 #define FbDashNextOdd(dashlen)	FbDashNext(dashlen)
    598 
    599 #define FbDashStep(dashlen,even) {			    \
    600     if (!--(dashlen)) {					    \
    601 	FbDashNext(dashlen);				    \
    602 	(even) = 1-(even);				    \
    603     }							    \
    604 }
    605 
    606 extern _X_EXPORT DevPrivateKey
    607 fbGetGCPrivateKey (void);
    608 
    609 extern _X_EXPORT DevPrivateKey
    610 fbGetWinPrivateKey (void);
    611 
    612 extern _X_EXPORT const GCOps	fbGCOps;
    613 extern _X_EXPORT const GCFuncs	fbGCFuncs;
    614 
    615 #ifdef FB_24_32BIT
    616 #define FB_SCREEN_PRIVATE
    617 #endif
    618 
    619 /* Framebuffer access wrapper */
    620 typedef FbBits (*ReadMemoryProcPtr)(const void *src, int size);
    621 typedef void (*WriteMemoryProcPtr)(void *dst, FbBits value, int size);
    622 typedef void (*SetupWrapProcPtr)(ReadMemoryProcPtr  *pRead,
    623                                  WriteMemoryProcPtr *pWrite,
    624                                  DrawablePtr         pDraw);
    625 typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
    626 
    627 #ifdef FB_ACCESS_WRAPPER
    628 
    629 #define fbPrepareAccess(pDraw) \
    630 	fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \
    631 		&wfbReadMemory, \
    632 		&wfbWriteMemory, \
    633 		(pDraw))
    634 #define fbFinishAccess(pDraw) \
    635 	fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw)
    636 
    637 #else
    638 
    639 #define fbPrepareAccess(pPix)
    640 #define fbFinishAccess(pDraw)
    641 
    642 #endif
    643 
    644 
    645 #ifdef FB_SCREEN_PRIVATE
    646 extern _X_EXPORT DevPrivateKey
    647 fbGetScreenPrivateKey(void);
    648 
    649 /* private field of a screen */
    650 typedef struct {
    651     unsigned char	win32bpp;	/* window bpp for 32-bpp images */
    652     unsigned char	pix32bpp;	/* pixmap bpp for 32-bpp images */
    653 #ifdef FB_ACCESS_WRAPPER
    654     SetupWrapProcPtr	setupWrap;	/* driver hook to set pixmap access wrapping */
    655     FinishWrapProcPtr	finishWrap;	/* driver hook to clean up pixmap access wrapping */
    656 #endif
    657 } FbScreenPrivRec, *FbScreenPrivPtr;
    658 
    659 #define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
    660 				     dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
    661 #endif
    662 
    663 /* private field of GC */
    664 typedef struct {
    665     FbBits		and, xor;	/* reduced rop values */
    666     FbBits		bgand, bgxor;	/* for stipples */
    667     FbBits		fg, bg, pm;	/* expanded and filled */
    668     unsigned int	dashLength;	/* total of all dash elements */
    669     unsigned char    	evenStipple;	/* stipple is even */
    670     unsigned char    	bpp;		/* current drawable bpp */
    671 } FbGCPrivRec, *FbGCPrivPtr;
    672 
    673 #define fbGetGCPrivate(pGC)	((FbGCPrivPtr)\
    674 				 dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
    675 
    676 #define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
    677 #define fbGetExpose(pGC)	((pGC)->fExpose)
    678 #define fbGetFreeCompClip(pGC)	((pGC)->freeCompClip)
    679 #define fbGetRotatedPixmap(pGC)	((pGC)->pRotatedPixmap)
    680 
    681 #define fbGetScreenPixmap(s)	((PixmapPtr) (s)->devPrivate)
    682 #define fbGetWindowPixmap(pWin)	((PixmapPtr)\
    683 				 dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
    684 
    685 #ifdef ROOTLESS
    686 #define __fbPixDrawableX(pPix)	((pPix)->drawable.x)
    687 #define __fbPixDrawableY(pPix)	((pPix)->drawable.y)
    688 #else
    689 #define __fbPixDrawableX(pPix)	0
    690 #define __fbPixDrawableY(pPix)	0
    691 #endif
    692 
    693 #ifdef COMPOSITE
    694 #define __fbPixOffXWin(pPix)	(__fbPixDrawableX(pPix) - (pPix)->screen_x)
    695 #define __fbPixOffYWin(pPix)	(__fbPixDrawableY(pPix) - (pPix)->screen_y)
    696 #else
    697 #define __fbPixOffXWin(pPix)	(__fbPixDrawableX(pPix))
    698 #define __fbPixOffYWin(pPix)	(__fbPixDrawableY(pPix))
    699 #endif
    700 #define __fbPixOffXPix(pPix)	(__fbPixDrawableX(pPix))
    701 #define __fbPixOffYPix(pPix)	(__fbPixDrawableY(pPix))
    702 
    703 #define fbGetDrawablePixmap(pDrawable, pixmap, xoff, yoff) {			\
    704     if ((pDrawable)->type != DRAWABLE_PIXMAP) { 				\
    705 	(pixmap) = fbGetWindowPixmap(pDrawable);				\
    706 	(xoff) = __fbPixOffXWin(pixmap); 					\
    707 	(yoff) = __fbPixOffYWin(pixmap); 					\
    708     } else { 									\
    709 	(pixmap) = (PixmapPtr) (pDrawable);					\
    710 	(xoff) = __fbPixOffXPix(pixmap); 					\
    711 	(yoff) = __fbPixOffYPix(pixmap); 					\
    712     } 										\
    713     fbPrepareAccess(pDrawable); 						\
    714 }
    715 
    716 #define fbGetPixmapBitsData(pixmap, pointer, stride, bpp) {			\
    717     (pointer) = (FbBits *) (pixmap)->devPrivate.ptr; 			       	\
    718     (stride) = ((int) (pixmap)->devKind) / sizeof (FbBits); (void)(stride);	\
    719     (bpp) = (pixmap)->drawable.bitsPerPixel;  (void)(bpp); 			\
    720 }
    721 
    722 #define fbGetPixmapStipData(pixmap, pointer, stride, bpp) {			\
    723     (pointer) = (FbStip *) (pixmap)->devPrivate.ptr; 			       	\
    724     (stride) = ((int) (pixmap)->devKind) / sizeof (FbStip); (void)(stride);	\
    725     (bpp) = (pixmap)->drawable.bitsPerPixel;  (void)(bpp); 			\
    726 }
    727 
    728 #define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { 		\
    729     PixmapPtr   _pPix; 								\
    730     fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); 				\
    731     fbGetPixmapBitsData(_pPix, pointer, stride, bpp);				\
    732 }
    733 
    734 #define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { 	\
    735     PixmapPtr   _pPix; 								\
    736     fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff);				\
    737     fbGetPixmapStipData(_pPix, pointer, stride, bpp);				\
    738 }
    739 
    740 /*
    741  * XFree86 empties the root BorderClip when the VT is inactive,
    742  * here's a macro which uses that to disable GetImage and GetSpans
    743  */
    744 
    745 #define fbWindowEnabled(pWin) \
    746     RegionNotEmpty(&(pWin)->drawable.pScreen->root->borderClip)
    747 
    748 #define fbDrawableEnabled(pDrawable) \
    749     ((pDrawable)->type == DRAWABLE_PIXMAP ? \
    750      TRUE : fbWindowEnabled((WindowPtr) pDrawable))
    751 
    752 #define FbPowerOfTwo(w)	    (((w) & ((w) - 1)) == 0)
    753 /*
    754  * Accelerated tiles are power of 2 width <= FB_UNIT
    755  */
    756 #define FbEvenTile(w)	    ((w) <= FB_UNIT && FbPowerOfTwo(w))
    757 /*
    758  * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
    759  * with dstBpp a power of 2 as well
    760  */
    761 #define FbEvenStip(w,bpp)   ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
    762 
    763 /*
    764  * fb24_32.c
    765  */
    766 extern _X_EXPORT void
    767 fb24_32GetSpans(DrawablePtr	pDrawable,
    768 		int		wMax,
    769 		DDXPointPtr	ppt,
    770 		int		*pwidth,
    771 		int		nspans,
    772 		char		*pchardstStart);
    773 
    774 extern _X_EXPORT void
    775 fb24_32SetSpans (DrawablePtr	    pDrawable,
    776 		 GCPtr		    pGC,
    777 		 char		    *src,
    778 		 DDXPointPtr	    ppt,
    779 		 int		    *pwidth,
    780 		 int		    nspans,
    781 		 int		    fSorted);
    782 
    783 extern _X_EXPORT void
    784 fb24_32PutZImage (DrawablePtr	pDrawable,
    785 		  RegionPtr	pClip,
    786 		  int		alu,
    787 		  FbBits	pm,
    788 		  int		x,
    789 		  int		y,
    790 		  int		width,
    791 		  int		height,
    792 		  CARD8		*src,
    793 		  FbStride	srcStride);
    794 
    795 extern _X_EXPORT void
    796 fb24_32GetImage (DrawablePtr     pDrawable,
    797 		 int             x,
    798 		 int             y,
    799 		 int             w,
    800 		 int             h,
    801 		 unsigned int    format,
    802 		 unsigned long   planeMask,
    803 		 char            *d);
    804 
    805 extern _X_EXPORT void
    806 fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
    807 		 DrawablePtr pDstDrawable,
    808 		 GCPtr       pGC,
    809 		 BoxPtr      pbox,
    810 		 int         nbox,
    811 		 int         dx,
    812 		 int         dy,
    813 		 Bool        reverse,
    814 		 Bool        upsidedown,
    815 		 Pixel       bitplane,
    816 		 void        *closure);
    817 
    818 extern _X_EXPORT PixmapPtr
    819 fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
    820 
    821 extern _X_EXPORT Bool
    822 fb24_32CreateScreenResources(ScreenPtr pScreen);
    823 
    824 extern _X_EXPORT Bool
    825 fb24_32ModifyPixmapHeader (PixmapPtr   pPixmap,
    826 			   int         width,
    827 			   int         height,
    828 			   int         depth,
    829 			   int         bitsPerPixel,
    830 			   int         devKind,
    831 			   pointer     pPixData);
    832 
    833 /*
    834  * fballpriv.c
    835  */
    836 extern _X_EXPORT Bool
    837 fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);
    838 
    839 /*
    840  * fbarc.c
    841  */
    842 
    843 extern _X_EXPORT void
    844 fbPolyArc (DrawablePtr	pDrawable,
    845 	   GCPtr	pGC,
    846 	   int		narcs,
    847 	   xArc		*parcs);
    848 
    849 /*
    850  * fbbits.c
    851  */
    852 
    853 extern _X_EXPORT void
    854 fbBresSolid8(DrawablePtr    pDrawable,
    855 	     GCPtr	    pGC,
    856 	     int	    dashOffset,
    857 	     int	    signdx,
    858 	     int	    signdy,
    859 	     int	    axis,
    860 	     int	    x,
    861 	     int	    y,
    862 	     int	    e,
    863 	     int	    e1,
    864 	     int	    e3,
    865 	     int	    len);
    866 
    867 extern _X_EXPORT void
    868 fbBresDash8 (DrawablePtr    pDrawable,
    869 	     GCPtr	    pGC,
    870 	     int	    dashOffset,
    871 	     int	    signdx,
    872 	     int	    signdy,
    873 	     int	    axis,
    874 	     int	    x,
    875 	     int	    y,
    876 	     int	    e,
    877 	     int	    e1,
    878 	     int	    e3,
    879 	     int	    len);
    880 
    881 extern _X_EXPORT void
    882 fbDots8 (FbBits	    *dst,
    883 	 FbStride   dstStride,
    884 	 int	    dstBpp,
    885 	 BoxPtr	    pBox,
    886 	 xPoint	    *pts,
    887 	 int	    npt,
    888 	 int	    xorg,
    889 	 int	    yorg,
    890 	 int	    xoff,
    891 	 int	    yoff,
    892 	 FbBits	    and,
    893 	 FbBits	    xor);
    894 
    895 extern _X_EXPORT void
    896 fbArc8 (FbBits	    *dst,
    897 	FbStride    dstStride,
    898 	int	    dstBpp,
    899 	xArc	    *arc,
    900 	int	    dx,
    901 	int	    dy,
    902 	FbBits	    and,
    903 	FbBits	    xor);
    904 
    905 extern _X_EXPORT void
    906 fbGlyph8 (FbBits    *dstLine,
    907 	  FbStride  dstStride,
    908 	  int	    dstBpp,
    909 	  FbStip    *stipple,
    910 	  FbBits    fg,
    911 	  int	    height,
    912 	  int	    shift);
    913 
    914 extern _X_EXPORT void
    915 fbPolyline8 (DrawablePtr    pDrawable,
    916 	     GCPtr	    pGC,
    917 	     int	    mode,
    918 	     int	    npt,
    919 	     DDXPointPtr    ptsOrig);
    920 
    921 extern _X_EXPORT void
    922 fbPolySegment8 (DrawablePtr pDrawable,
    923 		GCPtr	    pGC,
    924 		int	    nseg,
    925 		xSegment    *pseg);
    926 
    927 extern _X_EXPORT void
    928 fbBresSolid16(DrawablePtr   pDrawable,
    929 	      GCPtr	    pGC,
    930 	      int	    dashOffset,
    931 	      int	    signdx,
    932 	      int	    signdy,
    933 	      int	    axis,
    934 	      int	    x,
    935 	      int	    y,
    936 	      int	    e,
    937 	      int	    e1,
    938 	      int	    e3,
    939 	      int	    len);
    940 
    941 extern _X_EXPORT void
    942 fbBresDash16(DrawablePtr    pDrawable,
    943 	     GCPtr	    pGC,
    944 	     int	    dashOffset,
    945 	     int	    signdx,
    946 	     int	    signdy,
    947 	     int	    axis,
    948 	     int	    x,
    949 	     int	    y,
    950 	     int	    e,
    951 	     int	    e1,
    952 	     int	    e3,
    953 	     int	    len);
    954 
    955 extern _X_EXPORT void
    956 fbDots16(FbBits	    *dst,
    957 	 FbStride   dstStride,
    958 	 int	    dstBpp,
    959 	 BoxPtr	    pBox,
    960 	 xPoint	    *pts,
    961 	 int	    npt,
    962 	 int	    xorg,
    963 	 int	    yorg,
    964 	 int	    xoff,
    965 	 int	    yoff,
    966 	 FbBits	    and,
    967 	 FbBits	    xor);
    968 
    969 extern _X_EXPORT void
    970 fbArc16(FbBits	    *dst,
    971 	FbStride    dstStride,
    972 	int	    dstBpp,
    973 	xArc	    *arc,
    974 	int	    dx,
    975 	int	    dy,
    976 	FbBits	    and,
    977 	FbBits	    xor);
    978 
    979 extern _X_EXPORT void
    980 fbGlyph16(FbBits    *dstLine,
    981 	  FbStride  dstStride,
    982 	  int	    dstBpp,
    983 	  FbStip    *stipple,
    984 	  FbBits    fg,
    985 	  int	    height,
    986 	  int	    shift);
    987 
    988 extern _X_EXPORT void
    989 fbPolyline16 (DrawablePtr   pDrawable,
    990 	      GCPtr	    pGC,
    991 	      int	    mode,
    992 	      int	    npt,
    993 	      DDXPointPtr   ptsOrig);
    994 
    995 extern _X_EXPORT void
    996 fbPolySegment16 (DrawablePtr	pDrawable,
    997 		 GCPtr		pGC,
    998 		 int		nseg,
    999 		 xSegment	*pseg);
   1000 
   1001 
   1002 extern _X_EXPORT void
   1003 fbBresSolid24(DrawablePtr   pDrawable,
   1004 	      GCPtr	    pGC,
   1005 	      int	    dashOffset,
   1006 	      int	    signdx,
   1007 	      int	    signdy,
   1008 	      int	    axis,
   1009 	      int	    x,
   1010 	      int	    y,
   1011 	      int	    e,
   1012 	      int	    e1,
   1013 	      int	    e3,
   1014 	      int	    len);
   1015 
   1016 extern _X_EXPORT void
   1017 fbBresDash24(DrawablePtr    pDrawable,
   1018 	     GCPtr	    pGC,
   1019 	     int	    dashOffset,
   1020 	     int	    signdx,
   1021 	     int	    signdy,
   1022 	     int	    axis,
   1023 	     int	    x,
   1024 	     int	    y,
   1025 	     int	    e,
   1026 	     int	    e1,
   1027 	     int	    e3,
   1028 	     int	    len);
   1029 
   1030 extern _X_EXPORT void
   1031 fbDots24(FbBits	    *dst,
   1032 	 FbStride   dstStride,
   1033 	 int	    dstBpp,
   1034 	 BoxPtr	    pBox,
   1035 	 xPoint	    *pts,
   1036 	 int	    npt,
   1037 	 int	    xorg,
   1038 	 int	    yorg,
   1039 	 int	    xoff,
   1040 	 int	    yoff,
   1041 	 FbBits	    and,
   1042 	 FbBits	    xor);
   1043 
   1044 extern _X_EXPORT void
   1045 fbArc24(FbBits	    *dst,
   1046 	FbStride    dstStride,
   1047 	int	    dstBpp,
   1048 	xArc	    *arc,
   1049 	int	    dx,
   1050 	int	    dy,
   1051 	FbBits	    and,
   1052 	FbBits	    xor);
   1053 
   1054 extern _X_EXPORT void
   1055 fbGlyph24(FbBits    *dstLine,
   1056 	  FbStride  dstStride,
   1057 	  int	    dstBpp,
   1058 	  FbStip    *stipple,
   1059 	  FbBits    fg,
   1060 	  int	    height,
   1061 	  int	    shift);
   1062 
   1063 extern _X_EXPORT void
   1064 fbPolyline24 (DrawablePtr   pDrawable,
   1065 	      GCPtr	    pGC,
   1066 	      int	    mode,
   1067 	      int	    npt,
   1068 	      DDXPointPtr   ptsOrig);
   1069 
   1070 extern _X_EXPORT void
   1071 fbPolySegment24 (DrawablePtr	pDrawable,
   1072 		 GCPtr		pGC,
   1073 		 int		nseg,
   1074 		 xSegment	*pseg);
   1075 
   1076 
   1077 extern _X_EXPORT void
   1078 fbBresSolid32(DrawablePtr   pDrawable,
   1079 	      GCPtr	    pGC,
   1080 	      int	    dashOffset,
   1081 	      int	    signdx,
   1082 	      int	    signdy,
   1083 	      int	    axis,
   1084 	      int	    x,
   1085 	      int	    y,
   1086 	      int	    e,
   1087 	      int	    e1,
   1088 	      int	    e3,
   1089 	      int	    len);
   1090 
   1091 extern _X_EXPORT void
   1092 fbBresDash32(DrawablePtr    pDrawable,
   1093 	     GCPtr	    pGC,
   1094 	     int	    dashOffset,
   1095 	     int	    signdx,
   1096 	     int	    signdy,
   1097 	     int	    axis,
   1098 	     int	    x,
   1099 	     int	    y,
   1100 	     int	    e,
   1101 	     int	    e1,
   1102 	     int	    e3,
   1103 	     int	    len);
   1104 
   1105 extern _X_EXPORT void
   1106 fbDots32(FbBits	    *dst,
   1107 	 FbStride   dstStride,
   1108 	 int	    dstBpp,
   1109 	 BoxPtr	    pBox,
   1110 	 xPoint	    *pts,
   1111 	 int	    npt,
   1112 	 int	    xorg,
   1113 	 int	    yorg,
   1114 	 int	    xoff,
   1115 	 int	    yoff,
   1116 	 FbBits	    and,
   1117 	 FbBits	    xor);
   1118 
   1119 extern _X_EXPORT void
   1120 fbArc32(FbBits	    *dst,
   1121 	FbStride    dstStride,
   1122 	int	    dstBpp,
   1123 	xArc	    *arc,
   1124 	int	    dx,
   1125 	int	    dy,
   1126 	FbBits	    and,
   1127 	FbBits	    xor);
   1128 
   1129 extern _X_EXPORT void
   1130 fbGlyph32(FbBits    *dstLine,
   1131 	  FbStride  dstStride,
   1132 	  int	    dstBpp,
   1133 	  FbStip    *stipple,
   1134 	  FbBits    fg,
   1135 	  int	    height,
   1136 	  int	    shift);
   1137 extern _X_EXPORT void
   1138 fbPolyline32 (DrawablePtr   pDrawable,
   1139 	      GCPtr	    pGC,
   1140 	      int	    mode,
   1141 	      int	    npt,
   1142 	      DDXPointPtr   ptsOrig);
   1143 
   1144 extern _X_EXPORT void
   1145 fbPolySegment32 (DrawablePtr	pDrawable,
   1146 		 GCPtr		pGC,
   1147 		 int		nseg,
   1148 		 xSegment	*pseg);
   1149 
   1150 /*
   1151  * fbblt.c
   1152  */
   1153 extern _X_EXPORT void
   1154 fbBlt (FbBits   *src,
   1155        FbStride	srcStride,
   1156        int	srcX,
   1157 
   1158        FbBits   *dst,
   1159        FbStride dstStride,
   1160        int	dstX,
   1161 
   1162        int	width,
   1163        int	height,
   1164 
   1165        int	alu,
   1166        FbBits	pm,
   1167        int	bpp,
   1168 
   1169        Bool	reverse,
   1170        Bool	upsidedown);
   1171 
   1172 extern _X_EXPORT void
   1173 fbBlt24 (FbBits	    *srcLine,
   1174 	 FbStride   srcStride,
   1175 	 int	    srcX,
   1176 
   1177 	 FbBits	    *dstLine,
   1178 	 FbStride   dstStride,
   1179 	 int	    dstX,
   1180 
   1181 	 int	    width,
   1182 	 int	    height,
   1183 
   1184 	 int	    alu,
   1185 	 FbBits	    pm,
   1186 
   1187 	 Bool	    reverse,
   1188 	 Bool	    upsidedown);
   1189 
   1190 extern _X_EXPORT void
   1191 fbBltStip (FbStip   *src,
   1192 	   FbStride srcStride,	    /* in FbStip units, not FbBits units */
   1193 	   int	    srcX,
   1194 
   1195 	   FbStip   *dst,
   1196 	   FbStride dstStride,	    /* in FbStip units, not FbBits units */
   1197 	   int	    dstX,
   1198 
   1199 	   int	    width,
   1200 	   int	    height,
   1201 
   1202 	   int	    alu,
   1203 	   FbBits   pm,
   1204 	   int	    bpp);
   1205 
   1206 /*
   1207  * fbbltone.c
   1208  */
   1209 extern _X_EXPORT void
   1210 fbBltOne (FbStip   *src,
   1211 	  FbStride srcStride,
   1212 	  int	   srcX,
   1213 	  FbBits   *dst,
   1214 	  FbStride dstStride,
   1215 	  int	   dstX,
   1216 	  int	   dstBpp,
   1217 
   1218 	  int	   width,
   1219 	  int	   height,
   1220 
   1221 	  FbBits   fgand,
   1222 	  FbBits   fbxor,
   1223 	  FbBits   bgand,
   1224 	  FbBits   bgxor);
   1225 
   1226 #ifdef FB_24BIT
   1227 extern _X_EXPORT void
   1228 fbBltOne24 (FbStip    *src,
   1229 	  FbStride  srcStride,	    /* FbStip units per scanline */
   1230 	  int	    srcX,	    /* bit position of source */
   1231 	  FbBits    *dst,
   1232 	  FbStride  dstStride,	    /* FbBits units per scanline */
   1233 	  int	    dstX,	    /* bit position of dest */
   1234 	  int	    dstBpp,	    /* bits per destination unit */
   1235 
   1236 	  int	    width,	    /* width in bits of destination */
   1237 	  int	    height,	    /* height in scanlines */
   1238 
   1239 	  FbBits    fgand,	    /* rrop values */
   1240 	  FbBits    fgxor,
   1241 	  FbBits    bgand,
   1242 	  FbBits    bgxor);
   1243 #endif
   1244 
   1245 extern _X_EXPORT void
   1246 fbBltPlane (FbBits	    *src,
   1247 	    FbStride	    srcStride,
   1248 	    int		    srcX,
   1249 	    int		    srcBpp,
   1250 
   1251 	    FbStip	    *dst,
   1252 	    FbStride	    dstStride,
   1253 	    int		    dstX,
   1254 
   1255 	    int		    width,
   1256 	    int		    height,
   1257 
   1258 	    FbStip	    fgand,
   1259 	    FbStip	    fgxor,
   1260 	    FbStip	    bgand,
   1261 	    FbStip	    bgxor,
   1262 	    Pixel	    planeMask);
   1263 
   1264 /*
   1265  * fbcmap_mi.c
   1266  */
   1267 extern _X_EXPORT int
   1268 fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
   1269 
   1270 extern _X_EXPORT void
   1271 fbInstallColormap(ColormapPtr pmap);
   1272 
   1273 extern _X_EXPORT void
   1274 fbUninstallColormap(ColormapPtr pmap);
   1275 
   1276 extern _X_EXPORT void
   1277 fbResolveColor(unsigned short	*pred,
   1278 	       unsigned short	*pgreen,
   1279 	       unsigned short	*pblue,
   1280 	       VisualPtr	pVisual);
   1281 
   1282 extern _X_EXPORT Bool
   1283 fbInitializeColormap(ColormapPtr pmap);
   1284 
   1285 extern _X_EXPORT Bool
   1286 mfbCreateColormap(ColormapPtr pmap);
   1287 
   1288 extern _X_EXPORT int
   1289 fbExpandDirectColors (ColormapPtr   pmap,
   1290 		      int	    ndef,
   1291 		      xColorItem    *indefs,
   1292 		      xColorItem    *outdefs);
   1293 
   1294 extern _X_EXPORT Bool
   1295 fbCreateDefColormap(ScreenPtr pScreen);
   1296 
   1297 extern _X_EXPORT void
   1298 fbClearVisualTypes(void);
   1299 
   1300 extern _X_EXPORT Bool
   1301 fbHasVisualTypes (int depth);
   1302 
   1303 extern _X_EXPORT Bool
   1304 fbSetVisualTypes (int depth, int visuals, int bitsPerRGB);
   1305 
   1306 extern _X_EXPORT Bool
   1307 fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
   1308 			  Pixel redMask, Pixel greenMask, Pixel blueMask);
   1309 
   1310 extern _X_EXPORT Bool
   1311 fbInitVisuals (VisualPtr    *visualp,
   1312 	       DepthPtr	    *depthp,
   1313 	       int	    *nvisualp,
   1314 	       int	    *ndepthp,
   1315 	       int	    *rootDepthp,
   1316 	       VisualID	    *defaultVisp,
   1317 	       unsigned long	sizes,
   1318 	       int	    bitsPerRGB);
   1319 
   1320 /*
   1321  * fbcopy.c
   1322  */
   1323 
   1324 /* Compatibility definition, to be removed at next ABI change. */
   1325 typedef void   (*fbCopyProc) (DrawablePtr  pSrcDrawable,
   1326                               DrawablePtr  pDstDrawable,
   1327                               GCPtr        pGC,
   1328                               BoxPtr       pDstBox,
   1329                               int          nbox,
   1330                               int          dx,
   1331                               int          dy,
   1332                               Bool         reverse,
   1333                               Bool         upsidedown,
   1334                               Pixel        bitplane,
   1335                               void         *closure);
   1336 
   1337 extern _X_EXPORT void
   1338 fbCopyNtoN (DrawablePtr	pSrcDrawable,
   1339 	    DrawablePtr	pDstDrawable,
   1340 	    GCPtr	pGC,
   1341 	    BoxPtr	pbox,
   1342 	    int		nbox,
   1343 	    int		dx,
   1344 	    int		dy,
   1345 	    Bool	reverse,
   1346 	    Bool	upsidedown,
   1347 	    Pixel	bitplane,
   1348 	    void	*closure);
   1349 
   1350 /* Compatibility wrapper, to be removed at next ABI change. */
   1351 extern _X_EXPORT void
   1352 fbCopyRegion (DrawablePtr   pSrcDrawable,
   1353              DrawablePtr   pDstDrawable,
   1354              GCPtr         pGC,
   1355              RegionPtr     pDstRegion,
   1356              int           dx,
   1357              int           dy,
   1358              fbCopyProc    copyProc,
   1359              Pixel         bitPlane,
   1360              void          *closure);
   1361 
   1362 /* Compatibility wrapper, to be removed at next ABI change. */
   1363 extern _X_EXPORT RegionPtr
   1364 fbDoCopy (DrawablePtr  pSrcDrawable,
   1365          DrawablePtr   pDstDrawable,
   1366          GCPtr         pGC,
   1367          int           xIn,
   1368          int           yIn,
   1369          int           widthSrc,
   1370          int           heightSrc,
   1371          int           xOut,
   1372          int           yOut,
   1373          fbCopyProc    copyProc,
   1374          Pixel         bitplane,
   1375          void          *closure);
   1376 
   1377 extern _X_EXPORT void
   1378 fbCopy1toN (DrawablePtr	pSrcDrawable,
   1379 	    DrawablePtr	pDstDrawable,
   1380 	    GCPtr	pGC,
   1381 	    BoxPtr	pbox,
   1382 	    int		nbox,
   1383 	    int		dx,
   1384 	    int		dy,
   1385 	    Bool	reverse,
   1386 	    Bool	upsidedown,
   1387 	    Pixel	bitplane,
   1388 	    void	*closure);
   1389 
   1390 extern _X_EXPORT void
   1391 fbCopyNto1 (DrawablePtr	pSrcDrawable,
   1392 	    DrawablePtr	pDstDrawable,
   1393 	    GCPtr	pGC,
   1394 	    BoxPtr	pbox,
   1395 	    int		nbox,
   1396 	    int		dx,
   1397 	    int		dy,
   1398 	    Bool	reverse,
   1399 	    Bool	upsidedown,
   1400 	    Pixel	bitplane,
   1401 	    void	*closure);
   1402 
   1403 extern _X_EXPORT RegionPtr
   1404 fbCopyArea (DrawablePtr	pSrcDrawable,
   1405 	    DrawablePtr	pDstDrawable,
   1406 	    GCPtr	pGC,
   1407 	    int		xIn,
   1408 	    int		yIn,
   1409 	    int		widthSrc,
   1410 	    int		heightSrc,
   1411 	    int		xOut,
   1412 	    int		yOut);
   1413 
   1414 extern _X_EXPORT RegionPtr
   1415 fbCopyPlane (DrawablePtr    pSrcDrawable,
   1416 	     DrawablePtr    pDstDrawable,
   1417 	     GCPtr	    pGC,
   1418 	     int	    xIn,
   1419 	     int	    yIn,
   1420 	     int	    widthSrc,
   1421 	     int	    heightSrc,
   1422 	     int	    xOut,
   1423 	     int	    yOut,
   1424 	     unsigned long  bitplane);
   1425 
   1426 /*
   1427  * fbfill.c
   1428  */
   1429 extern _X_EXPORT void
   1430 fbFill (DrawablePtr pDrawable,
   1431 	GCPtr	    pGC,
   1432 	int	    x,
   1433 	int	    y,
   1434 	int	    width,
   1435 	int	    height);
   1436 
   1437 extern _X_EXPORT void
   1438 fbSolidBoxClipped (DrawablePtr	pDrawable,
   1439 		   RegionPtr	pClip,
   1440 		   int		xa,
   1441 		   int		ya,
   1442 		   int		xb,
   1443 		   int		yb,
   1444 		   FbBits	and,
   1445 		   FbBits	xor);
   1446 
   1447 /*
   1448  * fbfillrect.c
   1449  */
   1450 extern _X_EXPORT void
   1451 fbPolyFillRect(DrawablePtr  pDrawable,
   1452 	       GCPtr	    pGC,
   1453 	       int	    nrectInit,
   1454 	       xRectangle   *prectInit);
   1455 
   1456 #define fbPolyFillArc miPolyFillArc
   1457 
   1458 #define fbFillPolygon miFillPolygon
   1459 
   1460 /*
   1461  * fbfillsp.c
   1462  */
   1463 extern _X_EXPORT void
   1464 fbFillSpans (DrawablePtr    pDrawable,
   1465 	     GCPtr	    pGC,
   1466 	     int	    nInit,
   1467 	     DDXPointPtr    pptInit,
   1468 	     int	    *pwidthInit,
   1469 	     int	    fSorted);
   1470 
   1471 
   1472 /*
   1473  * fbgc.c
   1474  */
   1475 
   1476 extern _X_EXPORT Bool
   1477 fbCreateGC(GCPtr pGC);
   1478 
   1479 extern _X_EXPORT void
   1480 fbPadPixmap (PixmapPtr pPixmap);
   1481 
   1482 extern _X_EXPORT void
   1483 fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
   1484 
   1485 /*
   1486  * fbgetsp.c
   1487  */
   1488 extern _X_EXPORT void
   1489 fbGetSpans(DrawablePtr	pDrawable,
   1490 	   int		wMax,
   1491 	   DDXPointPtr	ppt,
   1492 	   int		*pwidth,
   1493 	   int		nspans,
   1494 	   char		*pchardstStart);
   1495 
   1496 /*
   1497  * fbglyph.c
   1498  */
   1499 
   1500 extern _X_EXPORT Bool
   1501 fbGlyphIn (RegionPtr	pRegion,
   1502 	   int		x,
   1503 	   int		y,
   1504 	   int		width,
   1505 	   int		height);
   1506 
   1507 extern _X_EXPORT void
   1508 fbPolyGlyphBlt (DrawablePtr	pDrawable,
   1509 		GCPtr		pGC,
   1510 		int		x,
   1511 		int		y,
   1512 		unsigned int	nglyph,
   1513 		CharInfoPtr	*ppci,
   1514 		pointer		pglyphBase);
   1515 
   1516 extern _X_EXPORT void
   1517 fbImageGlyphBlt (DrawablePtr	pDrawable,
   1518 		 GCPtr		pGC,
   1519 		 int		x,
   1520 		 int		y,
   1521 		 unsigned int	nglyph,
   1522 		 CharInfoPtr	*ppci,
   1523 		 pointer	pglyphBase);
   1524 
   1525 /*
   1526  * fbimage.c
   1527  */
   1528 
   1529 extern _X_EXPORT void
   1530 fbPutImage (DrawablePtr	pDrawable,
   1531 	    GCPtr	pGC,
   1532 	    int		depth,
   1533 	    int		x,
   1534 	    int		y,
   1535 	    int		w,
   1536 	    int		h,
   1537 	    int		leftPad,
   1538 	    int		format,
   1539 	    char	*pImage);
   1540 
   1541 extern _X_EXPORT void
   1542 fbPutZImage (DrawablePtr	pDrawable,
   1543 	     RegionPtr		pClip,
   1544 	     int		alu,
   1545 	     FbBits		pm,
   1546 	     int		x,
   1547 	     int		y,
   1548 	     int		width,
   1549 	     int		height,
   1550 	     FbStip		*src,
   1551 	     FbStride		srcStride);
   1552 
   1553 extern _X_EXPORT void
   1554 fbPutXYImage (DrawablePtr	pDrawable,
   1555 	      RegionPtr		pClip,
   1556 	      FbBits		fg,
   1557 	      FbBits		bg,
   1558 	      FbBits		pm,
   1559 	      int		alu,
   1560 	      Bool		opaque,
   1561 
   1562 	      int		x,
   1563 	      int		y,
   1564 	      int		width,
   1565 	      int		height,
   1566 
   1567 	      FbStip		*src,
   1568 	      FbStride		srcStride,
   1569 	      int		srcX);
   1570 
   1571 extern _X_EXPORT void
   1572 fbGetImage (DrawablePtr	    pDrawable,
   1573 	    int		    x,
   1574 	    int		    y,
   1575 	    int		    w,
   1576 	    int		    h,
   1577 	    unsigned int    format,
   1578 	    unsigned long   planeMask,
   1579 	    char	    *d);
   1580 /*
   1581  * fbline.c
   1582  */
   1583 
   1584 extern _X_EXPORT void
   1585 fbZeroLine (DrawablePtr	pDrawable,
   1586 	    GCPtr	pGC,
   1587 	    int		mode,
   1588 	    int		npt,
   1589 	    DDXPointPtr	ppt);
   1590 
   1591 extern _X_EXPORT void
   1592 fbZeroSegment (DrawablePtr  pDrawable,
   1593 	       GCPtr	    pGC,
   1594 	       int	    nseg,
   1595 	       xSegment	    *pSegs);
   1596 
   1597 extern _X_EXPORT void
   1598 fbPolyLine (DrawablePtr	pDrawable,
   1599 	    GCPtr	pGC,
   1600 	    int		mode,
   1601 	    int		npt,
   1602 	    DDXPointPtr	ppt);
   1603 
   1604 extern _X_EXPORT void
   1605 fbFixCoordModePrevious (int npt,
   1606 			DDXPointPtr ppt);
   1607 
   1608 extern _X_EXPORT void
   1609 fbPolySegment (DrawablePtr  pDrawable,
   1610 	       GCPtr	    pGC,
   1611 	       int	    nseg,
   1612 	       xSegment	    *pseg);
   1613 
   1614 #define fbPolyRectangle	miPolyRectangle
   1615 
   1616 /*
   1617  * fbpict.c
   1618  */
   1619 
   1620 extern _X_EXPORT Bool
   1621 fbPictureInit (ScreenPtr pScreen,
   1622 	       PictFormatPtr formats,
   1623 	       int nformats);
   1624 
   1625 /*
   1626  * fbpixmap.c
   1627  */
   1628 
   1629 extern _X_EXPORT PixmapPtr
   1630 fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
   1631 		   unsigned usage_hint);
   1632 
   1633 extern _X_EXPORT PixmapPtr
   1634 fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
   1635 		unsigned usage_hint);
   1636 
   1637 extern _X_EXPORT Bool
   1638 fbDestroyPixmap (PixmapPtr pPixmap);
   1639 
   1640 extern _X_EXPORT RegionPtr
   1641 fbPixmapToRegion(PixmapPtr pPix);
   1642 
   1643 /*
   1644  * fbpoint.c
   1645  */
   1646 
   1647 extern _X_EXPORT void
   1648 fbDots (FbBits	    *dstOrig,
   1649 	FbStride    dstStride,
   1650 	int	    dstBpp,
   1651 	BoxPtr	    pBox,
   1652 	xPoint	    *pts,
   1653 	int	    npt,
   1654 	int	    xorg,
   1655 	int	    yorg,
   1656 	int	    xoff,
   1657 	int	    yoff,
   1658 	FbBits	    andOrig,
   1659 	FbBits	    xorOrig);
   1660 
   1661 extern _X_EXPORT void
   1662 fbPolyPoint (DrawablePtr    pDrawable,
   1663 	     GCPtr	    pGC,
   1664 	     int	    mode,
   1665 	     int	    npt,
   1666 	     xPoint	    *pptInit);
   1667 
   1668 /*
   1669  * fbpush.c
   1670  */
   1671 extern _X_EXPORT void
   1672 fbPushPattern (DrawablePtr  pDrawable,
   1673 	       GCPtr	    pGC,
   1674 
   1675 	       FbStip	    *src,
   1676 	       FbStride	    srcStride,
   1677 	       int	    srcX,
   1678 
   1679 	       int	    x,
   1680 	       int	    y,
   1681 
   1682 	       int	    width,
   1683 	       int	    height);
   1684 
   1685 extern _X_EXPORT void
   1686 fbPushFill (DrawablePtr	pDrawable,
   1687 	    GCPtr	pGC,
   1688 
   1689 	    FbStip	*src,
   1690 	    FbStride	srcStride,
   1691 	    int		srcX,
   1692 
   1693 	    int		x,
   1694 	    int		y,
   1695 	    int		width,
   1696 	    int		height);
   1697 
   1698 extern _X_EXPORT void
   1699 fbPushImage (DrawablePtr    pDrawable,
   1700 	     GCPtr	    pGC,
   1701 
   1702 	     FbStip	    *src,
   1703 	     FbStride	    srcStride,
   1704 	     int	    srcX,
   1705 
   1706 	     int	    x,
   1707 	     int	    y,
   1708 	     int	    width,
   1709 	     int	    height);
   1710 
   1711 extern _X_EXPORT void
   1712 fbPushPixels (GCPtr	    pGC,
   1713 	      PixmapPtr	    pBitmap,
   1714 	      DrawablePtr   pDrawable,
   1715 	      int	    dx,
   1716 	      int	    dy,
   1717 	      int	    xOrg,
   1718 	      int	    yOrg);
   1719 
   1720 
   1721 /*
   1722  * fbscreen.c
   1723  */
   1724 
   1725 extern _X_EXPORT Bool
   1726 fbCloseScreen (int indx, ScreenPtr pScreen);
   1727 
   1728 extern _X_EXPORT Bool
   1729 fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
   1730 
   1731 extern _X_EXPORT Bool
   1732 fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
   1733 
   1734 extern _X_EXPORT void
   1735 fbQueryBestSize (int class,
   1736 		 unsigned short *width, unsigned short *height,
   1737 		 ScreenPtr pScreen);
   1738 
   1739 extern _X_EXPORT PixmapPtr
   1740 _fbGetWindowPixmap (WindowPtr pWindow);
   1741 
   1742 extern _X_EXPORT void
   1743 _fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap);
   1744 
   1745 extern _X_EXPORT Bool
   1746 fbSetupScreen(ScreenPtr	pScreen,
   1747 	      pointer	pbits,		/* pointer to screen bitmap */
   1748 	      int	xsize, 		/* in pixels */
   1749 	      int	ysize,
   1750 	      int	dpix,		/* dots per inch */
   1751 	      int	dpiy,
   1752 	      int	width,		/* pixel width of frame buffer */
   1753 	      int	bpp);		/* bits per pixel of frame buffer */
   1754 
   1755 extern _X_EXPORT Bool
   1756 wfbFinishScreenInit(ScreenPtr	pScreen,
   1757 		    pointer	pbits,
   1758 		    int		xsize,
   1759 		    int		ysize,
   1760 		    int		dpix,
   1761 		    int		dpiy,
   1762 		    int		width,
   1763 		    int		bpp,
   1764 		    SetupWrapProcPtr setupWrap,
   1765 		    FinishWrapProcPtr finishWrap);
   1766 
   1767 extern _X_EXPORT Bool
   1768 wfbScreenInit(ScreenPtr	pScreen,
   1769 	      pointer	pbits,
   1770 	      int	xsize,
   1771 	      int	ysize,
   1772 	      int	dpix,
   1773 	      int	dpiy,
   1774 	      int	width,
   1775 	      int	bpp,
   1776 	      SetupWrapProcPtr setupWrap,
   1777 	      FinishWrapProcPtr finishWrap);
   1778 
   1779 extern _X_EXPORT Bool
   1780 fbFinishScreenInit(ScreenPtr	pScreen,
   1781 		   pointer	pbits,
   1782 		   int		xsize,
   1783 		   int		ysize,
   1784 		   int		dpix,
   1785 		   int		dpiy,
   1786 		   int		width,
   1787 		   int		bpp);
   1788 
   1789 extern _X_EXPORT Bool
   1790 fbScreenInit(ScreenPtr	pScreen,
   1791 	     pointer	pbits,
   1792 	     int	xsize,
   1793 	     int	ysize,
   1794 	     int	dpix,
   1795 	     int	dpiy,
   1796 	     int	width,
   1797 	     int	bpp);
   1798 
   1799 /*
   1800  * fbseg.c
   1801  */
   1802 typedef void	FbBres (DrawablePtr	pDrawable,
   1803 			GCPtr		pGC,
   1804 			int		dashOffset,
   1805 			int		signdx,
   1806 			int		signdy,
   1807 			int		axis,
   1808 			int		x,
   1809 			int		y,
   1810 			int		e,
   1811 			int		e1,
   1812 			int		e3,
   1813 			int		len);
   1814 
   1815 extern _X_EXPORT FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
   1816 /*
   1817  * fbsetsp.c
   1818  */
   1819 
   1820 extern _X_EXPORT void
   1821 fbSetSpans (DrawablePtr	    pDrawable,
   1822 	    GCPtr	    pGC,
   1823 	    char	    *src,
   1824 	    DDXPointPtr	    ppt,
   1825 	    int		    *pwidth,
   1826 	    int		    nspans,
   1827 	    int		    fSorted);
   1828 
   1829 extern _X_EXPORT FbBres *
   1830 fbSelectBres (DrawablePtr   pDrawable,
   1831 	      GCPtr	    pGC);
   1832 
   1833 extern _X_EXPORT void
   1834 fbBres (DrawablePtr	pDrawable,
   1835 	GCPtr		pGC,
   1836 	int		dashOffset,
   1837 	int		signdx,
   1838 	int		signdy,
   1839 	int		axis,
   1840 	int		x,
   1841 	int		y,
   1842 	int		e,
   1843 	int		e1,
   1844 	int		e3,
   1845 	int		len);
   1846 
   1847 extern _X_EXPORT void
   1848 fbSegment (DrawablePtr	pDrawable,
   1849 	   GCPtr	pGC,
   1850 	   int		xa,
   1851 	   int		ya,
   1852 	   int		xb,
   1853 	   int		yb,
   1854 	   Bool		drawLast,
   1855 	   int		*dashOffset);
   1856 
   1857 
   1858 /*
   1859  * fbsolid.c
   1860  */
   1861 
   1862 extern _X_EXPORT void
   1863 fbSolid (FbBits	    *dst,
   1864 	 FbStride   dstStride,
   1865 	 int	    dstX,
   1866 	 int	    bpp,
   1867 
   1868 	 int	    width,
   1869 	 int	    height,
   1870 
   1871 	 FbBits	    and,
   1872 	 FbBits	    xor);
   1873 
   1874 #ifdef FB_24BIT
   1875 extern _X_EXPORT void
   1876 fbSolid24 (FbBits   *dst,
   1877 	   FbStride dstStride,
   1878 	   int	    dstX,
   1879 
   1880 	   int	    width,
   1881 	   int	    height,
   1882 
   1883 	   FbBits   and,
   1884 	   FbBits   xor);
   1885 #endif
   1886 
   1887 /*
   1888  * fbstipple.c
   1889  */
   1890 
   1891 extern _X_EXPORT void
   1892 fbTransparentSpan (FbBits   *dst,
   1893 		   FbBits   stip,
   1894 		   FbBits   fgxor,
   1895 		   int	    n);
   1896 
   1897 extern _X_EXPORT void
   1898 fbEvenStipple (FbBits   *dst,
   1899 	       FbStride dstStride,
   1900 	       int	dstX,
   1901 	       int	dstBpp,
   1902 
   1903 	       int	width,
   1904 	       int	height,
   1905 
   1906 	       FbStip   *stip,
   1907 	       FbStride	stipStride,
   1908 	       int	stipHeight,
   1909 
   1910 	       FbBits   fgand,
   1911 	       FbBits   fgxor,
   1912 	       FbBits   bgand,
   1913 	       FbBits   bgxor,
   1914 
   1915 	       int	xRot,
   1916 	       int	yRot);
   1917 
   1918 extern _X_EXPORT void
   1919 fbOddStipple (FbBits	*dst,
   1920 	      FbStride	dstStride,
   1921 	      int	dstX,
   1922 	      int	dstBpp,
   1923 
   1924 	      int	width,
   1925 	      int	height,
   1926 
   1927 	      FbStip	*stip,
   1928 	      FbStride	stipStride,
   1929 	      int	stipWidth,
   1930 	      int	stipHeight,
   1931 
   1932 	      FbBits	fgand,
   1933 	      FbBits	fgxor,
   1934 	      FbBits	bgand,
   1935 	      FbBits	bgxor,
   1936 
   1937 	      int	xRot,
   1938 	      int	yRot);
   1939 
   1940 extern _X_EXPORT void
   1941 fbStipple (FbBits   *dst,
   1942 	   FbStride dstStride,
   1943 	   int	    dstX,
   1944 	   int	    dstBpp,
   1945 
   1946 	   int	    width,
   1947 	   int	    height,
   1948 
   1949 	   FbStip   *stip,
   1950 	   FbStride stipStride,
   1951 	   int	    stipWidth,
   1952 	   int	    stipHeight,
   1953 	   Bool	    even,
   1954 
   1955 	   FbBits   fgand,
   1956 	   FbBits   fgxor,
   1957 	   FbBits   bgand,
   1958 	   FbBits   bgxor,
   1959 
   1960 	   int	    xRot,
   1961 	   int	    yRot);
   1962 
   1963 /*
   1964  * fbtile.c
   1965  */
   1966 
   1967 extern _X_EXPORT void
   1968 fbEvenTile (FbBits	*dst,
   1969 	    FbStride	dstStride,
   1970 	    int		dstX,
   1971 
   1972 	    int		width,
   1973 	    int		height,
   1974 
   1975 	    FbBits	*tile,
   1976 	    FbStride	tileStride,
   1977 	    int		tileHeight,
   1978 
   1979 	    int		alu,
   1980 	    FbBits	pm,
   1981 	    int		xRot,
   1982 	    int		yRot);
   1983 
   1984 extern _X_EXPORT void
   1985 fbOddTile (FbBits	*dst,
   1986 	   FbStride	dstStride,
   1987 	   int		dstX,
   1988 
   1989 	   int		width,
   1990 	   int		height,
   1991 
   1992 	   FbBits	*tile,
   1993 	   FbStride	tileStride,
   1994 	   int		tileWidth,
   1995 	   int		tileHeight,
   1996 
   1997 	   int		alu,
   1998 	   FbBits	pm,
   1999 	   int		bpp,
   2000 
   2001 	   int		xRot,
   2002 	   int		yRot);
   2003 
   2004 extern _X_EXPORT void
   2005 fbTile (FbBits	    *dst,
   2006 	FbStride    dstStride,
   2007 	int	    dstX,
   2008 
   2009 	int	    width,
   2010 	int	    height,
   2011 
   2012 	FbBits	    *tile,
   2013 	FbStride    tileStride,
   2014 	int	    tileWidth,
   2015 	int	    tileHeight,
   2016 
   2017 	int	    alu,
   2018 	FbBits	    pm,
   2019 	int	    bpp,
   2020 
   2021 	int	    xRot,
   2022 	int	    yRot);
   2023 
   2024 /*
   2025  * fbutil.c
   2026  */
   2027 extern _X_EXPORT FbBits
   2028 fbReplicatePixel (Pixel p, int bpp);
   2029 
   2030 extern _X_EXPORT void
   2031 fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp);
   2032 
   2033 #ifdef FB_ACCESS_WRAPPER
   2034 extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory;
   2035 extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory;
   2036 #endif
   2037 
   2038 /*
   2039  * fbwindow.c
   2040  */
   2041 
   2042 extern _X_EXPORT Bool
   2043 fbCreateWindow(WindowPtr pWin);
   2044 
   2045 extern _X_EXPORT Bool
   2046 fbDestroyWindow(WindowPtr pWin);
   2047 
   2048 extern _X_EXPORT Bool
   2049 fbMapWindow(WindowPtr pWindow);
   2050 
   2051 extern _X_EXPORT Bool
   2052 fbPositionWindow(WindowPtr pWin, int x, int y);
   2053 
   2054 extern _X_EXPORT Bool
   2055 fbUnmapWindow(WindowPtr pWindow);
   2056 
   2057 extern _X_EXPORT void
   2058 fbCopyWindowProc (DrawablePtr	pSrcDrawable,
   2059 		  DrawablePtr	pDstDrawable,
   2060 		  GCPtr		pGC,
   2061 		  BoxPtr	pbox,
   2062 		  int		nbox,
   2063 		  int		dx,
   2064 		  int		dy,
   2065 		  Bool		reverse,
   2066 		  Bool		upsidedown,
   2067 		  Pixel		bitplane,
   2068 		  void		*closure);
   2069 
   2070 extern _X_EXPORT void
   2071 fbCopyWindow(WindowPtr	    pWin,
   2072 	     DDXPointRec    ptOldOrg,
   2073 	     RegionPtr	    prgnSrc);
   2074 
   2075 extern _X_EXPORT Bool
   2076 fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
   2077 
   2078 extern _X_EXPORT void
   2079 fbFillRegionSolid (DrawablePtr	pDrawable,
   2080 		   RegionPtr	pRegion,
   2081 		   FbBits	and,
   2082 		   FbBits	xor);
   2083 
   2084 extern _X_EXPORT pixman_image_t *
   2085 image_from_pict (PicturePtr	pict,
   2086 		 Bool		has_clip,
   2087 		 int		*xoff,
   2088 		 int		*yoff);
   2089 
   2090 extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
   2091 
   2092 #endif /* _FB_H_ */
   2093 
   2094