105b261ecSmrg/*
205b261ecSmrg *
305b261ecSmrg * Copyright © 1998 Keith Packard
405b261ecSmrg *
505b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its
605b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that
705b261ecSmrg * the above copyright notice appear in all copies and that both that
805b261ecSmrg * copyright notice and this permission notice appear in supporting
905b261ecSmrg * documentation, and that the name of Keith Packard not be used in
1005b261ecSmrg * advertising or publicity pertaining to distribution of the software without
1105b261ecSmrg * specific, written prior permission.  Keith Packard makes no
1205b261ecSmrg * representations about the suitability of this software for any purpose.  It
1305b261ecSmrg * is provided "as is" without express or implied warranty.
1405b261ecSmrg *
1505b261ecSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1605b261ecSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1705b261ecSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1805b261ecSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1905b261ecSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
2005b261ecSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2105b261ecSmrg * PERFORMANCE OF THIS SOFTWARE.
2205b261ecSmrg */
2305b261ecSmrg
2405b261ecSmrg#ifndef _FB_H_
2505b261ecSmrg#define _FB_H_
2605b261ecSmrg
2705b261ecSmrg#include <X11/X.h>
2805b261ecSmrg#include <pixman.h>
2905b261ecSmrg
3005b261ecSmrg#include "scrnintstr.h"
3105b261ecSmrg#include "pixmap.h"
3205b261ecSmrg#include "pixmapstr.h"
3305b261ecSmrg#include "region.h"
3405b261ecSmrg#include "gcstruct.h"
3505b261ecSmrg#include "colormap.h"
3605b261ecSmrg#include "miscstruct.h"
3705b261ecSmrg#include "servermd.h"
3805b261ecSmrg#include "windowstr.h"
394642e01fSmrg#include "privates.h"
4005b261ecSmrg#include "mi.h"
4105b261ecSmrg#include "migc.h"
4205b261ecSmrg#include "picturestr.h"
4305b261ecSmrg
4405b261ecSmrg#ifdef FB_ACCESS_WRAPPER
4505b261ecSmrg
4605b261ecSmrg#include "wfbrename.h"
4705b261ecSmrg#define FBPREFIX(x) wfb##x
4805b261ecSmrg#define WRITE(ptr, val) ((*wfbWriteMemory)((ptr), (val), sizeof(*(ptr))))
4905b261ecSmrg#define READ(ptr) ((*wfbReadMemory)((ptr), sizeof(*(ptr))))
5005b261ecSmrg
5105b261ecSmrg#define MEMCPY_WRAPPED(dst, src, size) do {                       \
5205b261ecSmrg    size_t _i;                                                    \
5305b261ecSmrg    CARD8 *_dst = (CARD8*)(dst), *_src = (CARD8*)(src);           \
5405b261ecSmrg    for(_i = 0; _i < size; _i++) {                                \
5505b261ecSmrg        WRITE(_dst +_i, READ(_src + _i));                         \
5605b261ecSmrg    }                                                             \
5705b261ecSmrg} while(0)
5805b261ecSmrg
5905b261ecSmrg#define MEMSET_WRAPPED(dst, val, size) do {                       \
6005b261ecSmrg    size_t _i;                                                    \
6105b261ecSmrg    CARD8 *_dst = (CARD8*)(dst);                                  \
6205b261ecSmrg    for(_i = 0; _i < size; _i++) {                                \
6305b261ecSmrg        WRITE(_dst +_i, (val));                                   \
6405b261ecSmrg    }                                                             \
6505b261ecSmrg} while(0)
6605b261ecSmrg
6705b261ecSmrg#else
6805b261ecSmrg
6905b261ecSmrg#define FBPREFIX(x) fb##x
7005b261ecSmrg#define WRITE(ptr, val) (*(ptr) = (val))
7105b261ecSmrg#define READ(ptr) (*(ptr))
7205b261ecSmrg#define MEMCPY_WRAPPED(dst, src, size) memcpy((dst), (src), (size))
7305b261ecSmrg#define MEMSET_WRAPPED(dst, val, size) memset((dst), (val), (size))
7405b261ecSmrg
7505b261ecSmrg#endif
7605b261ecSmrg
7705b261ecSmrg/*
7805b261ecSmrg * This single define controls the basic size of data manipulated
7905b261ecSmrg * by this software; it must be log2(sizeof (FbBits) * 8)
8005b261ecSmrg */
8105b261ecSmrg
8205b261ecSmrg#ifndef FB_SHIFT
8305b261ecSmrg#define FB_SHIFT    LOG2_BITMAP_PAD
8405b261ecSmrg#endif
8505b261ecSmrg
8605b261ecSmrg#define FB_UNIT	    (1 << FB_SHIFT)
8705b261ecSmrg#define FB_MASK	    (FB_UNIT - 1)
8805b261ecSmrg#define FB_ALLONES  ((FbBits) -1)
8905b261ecSmrg#if GLYPHPADBYTES != 4
9005b261ecSmrg#error "GLYPHPADBYTES must be 4"
9105b261ecSmrg#endif
9205b261ecSmrg#define FB_STIP_SHIFT	LOG2_BITMAP_PAD
9305b261ecSmrg#define FB_STIP_UNIT	(1 << FB_STIP_SHIFT)
9405b261ecSmrg#define FB_STIP_MASK	(FB_STIP_UNIT - 1)
9505b261ecSmrg#define FB_STIP_ALLONES	((FbStip) -1)
9605b261ecSmrg#define FB_STIP_ODDSTRIDE(s)	(((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
9705b261ecSmrg#define FB_STIP_ODDPTR(p)	((((long) (p)) & (FB_MASK >> 3)) != 0)
9805b261ecSmrg#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
9905b261ecSmrg#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
10005b261ecSmrg#define FbFullMask(n)   ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
10105b261ecSmrg
10205b261ecSmrg#if FB_SHIFT == 5
10335c4bbdfSmrgtypedef CARD32 FbBits;
10435c4bbdfSmrg#else
10535c4bbdfSmrg#error "Unsupported FB_SHIFT"
10605b261ecSmrg#endif
10705b261ecSmrg
10805b261ecSmrg#if LOG2_BITMAP_PAD == FB_SHIFT
10935c4bbdfSmrgtypedef FbBits FbStip;
11005b261ecSmrg#endif
11105b261ecSmrg
11235c4bbdfSmrgtypedef int FbStride;
11305b261ecSmrg
11405b261ecSmrg#ifdef FB_DEBUG
1156747b715Smrgextern _X_EXPORT void fbValidateDrawable(DrawablePtr d);
1166747b715Smrgextern _X_EXPORT void fbInitializeDrawable(DrawablePtr d);
11735c4bbdfSmrgextern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
11835c4bbdfSmrg
11905b261ecSmrg#define FB_HEAD_BITS   (FbStip) (0xbaadf00d)
12005b261ecSmrg#define FB_TAIL_BITS   (FbStip) (0xbaddf0ad)
12105b261ecSmrg#else
12205b261ecSmrg#define fbValidateDrawable(d)
12305b261ecSmrg#define fdInitializeDrawable(d)
12405b261ecSmrg#endif
12505b261ecSmrg
12605b261ecSmrg#include "fbrop.h"
12705b261ecSmrg
12805b261ecSmrg#if BITMAP_BIT_ORDER == LSBFirst
12905b261ecSmrg#define FbScrLeft(x,n)	((x) >> (n))
13005b261ecSmrg#define FbScrRight(x,n)	((x) << (n))
13105b261ecSmrg/* #define FbLeftBits(x,n)	((x) & ((((FbBits) 1) << (n)) - 1)) */
13205b261ecSmrg#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
13305b261ecSmrg#define FbStipMoveLsb(x,s,n)	(FbStipRight (x,(s)-(n)))
13405b261ecSmrg#define FbPatternOffsetBits	0
13505b261ecSmrg#else
13605b261ecSmrg#define FbScrLeft(x,n)	((x) << (n))
13705b261ecSmrg#define FbScrRight(x,n)	((x) >> (n))
13805b261ecSmrg/* #define FbLeftBits(x,n)	((x) >> (FB_UNIT - (n))) */
13905b261ecSmrg#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
14005b261ecSmrg#define FbStipMoveLsb(x,s,n)	(x)
14105b261ecSmrg#define FbPatternOffsetBits	(sizeof (FbBits) - 1)
14205b261ecSmrg#endif
14305b261ecSmrg
14405b261ecSmrg#include "micoord.h"
14505b261ecSmrg
14605b261ecSmrg#define FbStipLeft(x,n)	FbScrLeft(x,n)
14705b261ecSmrg#define FbStipRight(x,n) FbScrRight(x,n)
14805b261ecSmrg
14905b261ecSmrg#define FbRotLeft(x,n)	FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
15005b261ecSmrg#define FbRotRight(x,n)	FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
15105b261ecSmrg
15205b261ecSmrg#define FbRotStipLeft(x,n)  FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
15305b261ecSmrg#define FbRotStipRight(x,n)  FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
15405b261ecSmrg
15505b261ecSmrg#define FbLeftMask(x)	    ( ((x) & FB_MASK) ? \
15605b261ecSmrg			     FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
15705b261ecSmrg#define FbRightMask(x)	    ( ((FB_UNIT - (x)) & FB_MASK) ? \
15805b261ecSmrg			     FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
15905b261ecSmrg
16005b261ecSmrg#define FbLeftStipMask(x)   ( ((x) & FB_STIP_MASK) ? \
16105b261ecSmrg			     FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
16205b261ecSmrg#define FbRightStipMask(x)  ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
16305b261ecSmrg			     FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
16405b261ecSmrg
16505b261ecSmrg#define FbBitsMask(x,w)	(FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
16605b261ecSmrg			 FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
16705b261ecSmrg
16805b261ecSmrg#define FbStipMask(x,w)	(FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
16905b261ecSmrg			 FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
17005b261ecSmrg
17105b261ecSmrg#define FbMaskBits(x,w,l,n,r) { \
17205b261ecSmrg    n = (w); \
17305b261ecSmrg    r = FbRightMask((x)+n); \
17405b261ecSmrg    l = FbLeftMask(x); \
17505b261ecSmrg    if (l) { \
17605b261ecSmrg	n -= FB_UNIT - ((x) & FB_MASK); \
17705b261ecSmrg	if (n < 0) { \
17805b261ecSmrg	    n = 0; \
17905b261ecSmrg	    l &= r; \
18005b261ecSmrg	    r = 0; \
18105b261ecSmrg	} \
18205b261ecSmrg    } \
18305b261ecSmrg    n >>= FB_SHIFT; \
18405b261ecSmrg}
18505b261ecSmrg
18605b261ecSmrg#define FbByteMaskInvalid   0x10
18705b261ecSmrg
18805b261ecSmrg#define FbPatternOffset(o,t)  ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
18905b261ecSmrg
19005b261ecSmrg#define FbPtrOffset(p,o,t)		((t *) ((CARD8 *) (p) + (o)))
19105b261ecSmrg#define FbSelectPatternPart(xor,o,t)	((xor) >> (FbPatternOffset (o,t) << 3))
19205b261ecSmrg#define FbStorePart(dst,off,t,xor)	(WRITE(FbPtrOffset(dst,off,t), \
19305b261ecSmrg					 FbSelectPart(xor,off,t)))
19405b261ecSmrg#ifndef FbSelectPart
19505b261ecSmrg#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
19605b261ecSmrg#endif
19705b261ecSmrg
19805b261ecSmrg#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
19905b261ecSmrg    n = (w); \
20005b261ecSmrg    lb = 0; \
20105b261ecSmrg    rb = 0; \
20205b261ecSmrg    r = FbRightMask((x)+n); \
20305b261ecSmrg    if (r) { \
20405b261ecSmrg	/* compute right byte length */ \
20505b261ecSmrg	if ((copy) && (((x) + n) & 7) == 0) { \
20605b261ecSmrg	    rb = (((x) + n) & FB_MASK) >> 3; \
20705b261ecSmrg	} else { \
20805b261ecSmrg	    rb = FbByteMaskInvalid; \
20905b261ecSmrg	} \
21005b261ecSmrg    } \
21105b261ecSmrg    l = FbLeftMask(x); \
21205b261ecSmrg    if (l) { \
21305b261ecSmrg	/* compute left byte length */ \
21405b261ecSmrg	if ((copy) && ((x) & 7) == 0) { \
21505b261ecSmrg	    lb = ((x) & FB_MASK) >> 3; \
21605b261ecSmrg	} else { \
21705b261ecSmrg	    lb = FbByteMaskInvalid; \
21805b261ecSmrg	} \
21905b261ecSmrg	/* subtract out the portion painted by leftMask */ \
22005b261ecSmrg	n -= FB_UNIT - ((x) & FB_MASK); \
22105b261ecSmrg	if (n < 0) { \
22205b261ecSmrg	    if (lb != FbByteMaskInvalid) { \
22305b261ecSmrg		if (rb == FbByteMaskInvalid) { \
22405b261ecSmrg		    lb = FbByteMaskInvalid; \
22505b261ecSmrg		} else if (rb) { \
22605b261ecSmrg		    lb |= (rb - lb) << (FB_SHIFT - 3); \
22705b261ecSmrg		    rb = 0; \
22805b261ecSmrg		} \
22905b261ecSmrg	    } \
23005b261ecSmrg	    n = 0; \
23105b261ecSmrg	    l &= r; \
23205b261ecSmrg	    r = 0; \
23305b261ecSmrg	}\
23405b261ecSmrg    } \
23505b261ecSmrg    n >>= FB_SHIFT; \
23605b261ecSmrg}
23705b261ecSmrg
23805b261ecSmrg#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
23905b261ecSmrg    switch (lb) { \
24005b261ecSmrg    case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
24105b261ecSmrg	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
24205b261ecSmrg	break; \
24305b261ecSmrg    case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
24405b261ecSmrg	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
24505b261ecSmrg	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
24605b261ecSmrg	break; \
24705b261ecSmrg    case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
24805b261ecSmrg	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
24905b261ecSmrg	break; \
25005b261ecSmrg    case sizeof (FbBits) - 3: \
25105b261ecSmrg	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
25205b261ecSmrg    case sizeof (FbBits) - 2: \
25305b261ecSmrg	FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
25405b261ecSmrg	break; \
25505b261ecSmrg    case sizeof (FbBits) - 1: \
25605b261ecSmrg	FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
25705b261ecSmrg	break; \
25805b261ecSmrg    default: \
25905b261ecSmrg	WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, l)); \
26005b261ecSmrg	break; \
26105b261ecSmrg    } \
26205b261ecSmrg}
26305b261ecSmrg
26405b261ecSmrg#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
26505b261ecSmrg    switch (rb) { \
26605b261ecSmrg    case 1: \
26705b261ecSmrg	FbStorePart(dst,0,CARD8,xor); \
26805b261ecSmrg	break; \
26905b261ecSmrg    case 2: \
27005b261ecSmrg	FbStorePart(dst,0,CARD16,xor); \
27105b261ecSmrg	break; \
27205b261ecSmrg    case 3: \
27305b261ecSmrg	FbStorePart(dst,0,CARD16,xor); \
27405b261ecSmrg	FbStorePart(dst,2,CARD8,xor); \
27505b261ecSmrg	break; \
27605b261ecSmrg    default: \
27705b261ecSmrg	WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
27805b261ecSmrg    } \
27905b261ecSmrg}
28005b261ecSmrg
28105b261ecSmrg#define FbMaskStip(x,w,l,n,r) { \
28205b261ecSmrg    n = (w); \
28305b261ecSmrg    r = FbRightStipMask((x)+n); \
28405b261ecSmrg    l = FbLeftStipMask(x); \
28505b261ecSmrg    if (l) { \
28605b261ecSmrg	n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
28705b261ecSmrg	if (n < 0) { \
28805b261ecSmrg	    n = 0; \
28905b261ecSmrg	    l &= r; \
29005b261ecSmrg	    r = 0; \
29105b261ecSmrg	} \
29205b261ecSmrg    } \
29305b261ecSmrg    n >>= FB_STIP_SHIFT; \
29405b261ecSmrg}
29505b261ecSmrg
29605b261ecSmrg/*
29705b261ecSmrg * These macros are used to transparently stipple
29805b261ecSmrg * in copy mode; the expected usage is with 'n' constant
29905b261ecSmrg * so all of the conditional parts collapse into a minimal
30005b261ecSmrg * sequence of partial word writes
30105b261ecSmrg *
30205b261ecSmrg * 'n' is the bytemask of which bytes to store, 'a' is the address
30305b261ecSmrg * of the FbBits base unit, 'o' is the offset within that unit
30405b261ecSmrg *
30505b261ecSmrg * The term "lane" comes from the hardware term "byte-lane" which
30605b261ecSmrg */
30705b261ecSmrg
3086747b715Smrg#define FbLaneCase1(n,a,o)						\
3096747b715Smrg    if ((n) == 0x01) {							\
3106747b715Smrg	WRITE((CARD8 *) ((a)+FbPatternOffset(o,CARD8)), fgxor);		\
3116747b715Smrg    }
3126747b715Smrg
3136747b715Smrg#define FbLaneCase2(n,a,o)						\
3146747b715Smrg    if ((n) == 0x03) {							\
3156747b715Smrg	WRITE((CARD16 *) ((a)+FbPatternOffset(o,CARD16)), fgxor);	\
3166747b715Smrg    } else {								\
3176747b715Smrg	FbLaneCase1((n)&1,a,o)						\
3186747b715Smrg	FbLaneCase1((n)>>1,a,(o)+1)					\
3196747b715Smrg    }
3206747b715Smrg
3216747b715Smrg#define FbLaneCase4(n,a,o)						\
3226747b715Smrg    if ((n) == 0x0f) {							\
3236747b715Smrg	WRITE((CARD32 *) ((a)+FbPatternOffset(o,CARD32)), fgxor);	\
3246747b715Smrg    } else {								\
3256747b715Smrg	FbLaneCase2((n)&3,a,o)						\
3266747b715Smrg	FbLaneCase2((n)>>2,a,(o)+2)					\
3276747b715Smrg    }
3286747b715Smrg
32905b261ecSmrg#define FbLaneCase(n,a)   FbLaneCase4(n,(CARD8 *) (a),0)
33005b261ecSmrg
33105b261ecSmrg/* Macros for dealing with dashing */
33205b261ecSmrg
33305b261ecSmrg#define FbDashDeclare	\
33405b261ecSmrg    unsigned char	*__dash, *__firstDash, *__lastDash
33535c4bbdfSmrg
33605b261ecSmrg#define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) {	    \
33705b261ecSmrg    (even) = TRUE;					    \
33805b261ecSmrg    __firstDash = (pGC)->dash;				    \
33905b261ecSmrg    __lastDash = __firstDash + (pGC)->numInDashList;	    \
34005b261ecSmrg    (dashOffset) %= (pPriv)->dashLength;		    \
34105b261ecSmrg							    \
34205b261ecSmrg    __dash = __firstDash;				    \
34305b261ecSmrg    while ((dashOffset) >= ((dashlen) = *__dash))	    \
34405b261ecSmrg    {							    \
34505b261ecSmrg	(dashOffset) -= (dashlen);			    \
34605b261ecSmrg	(even) = 1-(even);				    \
34705b261ecSmrg	if (++__dash == __lastDash)			    \
34805b261ecSmrg	    __dash = __firstDash;			    \
34905b261ecSmrg    }							    \
35005b261ecSmrg    (dashlen) -= (dashOffset);				    \
35105b261ecSmrg}
35205b261ecSmrg
35305b261ecSmrg#define FbDashNext(dashlen) {				    \
35405b261ecSmrg    if (++__dash == __lastDash)				    \
35505b261ecSmrg	__dash = __firstDash;				    \
35605b261ecSmrg    (dashlen) = *__dash;				    \
35705b261ecSmrg}
35805b261ecSmrg
35905b261ecSmrg/* as numInDashList is always even, this case can skip a test */
36005b261ecSmrg
36105b261ecSmrg#define FbDashNextEven(dashlen) {			    \
36205b261ecSmrg    (dashlen) = *++__dash;				    \
36305b261ecSmrg}
36405b261ecSmrg
36505b261ecSmrg#define FbDashNextOdd(dashlen)	FbDashNext(dashlen)
36605b261ecSmrg
36705b261ecSmrg#define FbDashStep(dashlen,even) {			    \
36805b261ecSmrg    if (!--(dashlen)) {					    \
36905b261ecSmrg	FbDashNext(dashlen);				    \
37005b261ecSmrg	(even) = 1-(even);				    \
37105b261ecSmrg    }							    \
37205b261ecSmrg}
37305b261ecSmrg
37435c4bbdfSmrgextern _X_EXPORT const GCOps fbGCOps;
37535c4bbdfSmrgextern _X_EXPORT const GCFuncs fbGCFuncs;
37605b261ecSmrg
37705b261ecSmrg/* Framebuffer access wrapper */
37835c4bbdfSmrgtypedef FbBits(*ReadMemoryProcPtr) (const void *src, int size);
37935c4bbdfSmrgtypedef void (*WriteMemoryProcPtr) (void *dst, FbBits value, int size);
38035c4bbdfSmrgtypedef void (*SetupWrapProcPtr) (ReadMemoryProcPtr * pRead,
38135c4bbdfSmrg                                  WriteMemoryProcPtr * pWrite,
38235c4bbdfSmrg                                  DrawablePtr pDraw);
38335c4bbdfSmrgtypedef void (*FinishWrapProcPtr) (DrawablePtr pDraw);
38405b261ecSmrg
38505b261ecSmrg#ifdef FB_ACCESS_WRAPPER
38605b261ecSmrg
38705b261ecSmrg#define fbPrepareAccess(pDraw) \
38805b261ecSmrg	fbGetScreenPrivate((pDraw)->pScreen)->setupWrap( \
38905b261ecSmrg		&wfbReadMemory, \
39005b261ecSmrg		&wfbWriteMemory, \
39105b261ecSmrg		(pDraw))
39205b261ecSmrg#define fbFinishAccess(pDraw) \
39305b261ecSmrg	fbGetScreenPrivate((pDraw)->pScreen)->finishWrap(pDraw)
39405b261ecSmrg
39505b261ecSmrg#else
39605b261ecSmrg
39705b261ecSmrg#define fbPrepareAccess(pPix)
39805b261ecSmrg#define fbFinishAccess(pDraw)
39905b261ecSmrg
40005b261ecSmrg#endif
40105b261ecSmrg
4026747b715Smrgextern _X_EXPORT DevPrivateKey
4036747b715SmrgfbGetScreenPrivateKey(void);
40405b261ecSmrg
40505b261ecSmrg/* private field of a screen */
40605b261ecSmrgtypedef struct {
40705b261ecSmrg#ifdef FB_ACCESS_WRAPPER
40835c4bbdfSmrg    SetupWrapProcPtr setupWrap; /* driver hook to set pixmap access wrapping */
40935c4bbdfSmrg    FinishWrapProcPtr finishWrap;       /* driver hook to clean up pixmap access wrapping */
41005b261ecSmrg#endif
41135c4bbdfSmrg    DevPrivateKeyRec    gcPrivateKeyRec;
41235c4bbdfSmrg    DevPrivateKeyRec    winPrivateKeyRec;
41305b261ecSmrg} FbScreenPrivRec, *FbScreenPrivPtr;
41405b261ecSmrg
41505b261ecSmrg#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
4166747b715Smrg				     dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
41705b261ecSmrg
41805b261ecSmrg/* private field of GC */
41905b261ecSmrgtypedef struct {
42035c4bbdfSmrg    FbBits and, xor;            /* reduced rop values */
42135c4bbdfSmrg    FbBits bgand, bgxor;        /* for stipples */
42235c4bbdfSmrg    FbBits fg, bg, pm;          /* expanded and filled */
42335c4bbdfSmrg    unsigned int dashLength;    /* total of all dash elements */
42405b261ecSmrg} FbGCPrivRec, *FbGCPrivPtr;
42505b261ecSmrg
42635c4bbdfSmrg#define fbGetGCPrivateKey(pGC)  (&fbGetScreenPrivate((pGC)->pScreen)->gcPrivateKeyRec)
42735c4bbdfSmrg
42805b261ecSmrg#define fbGetGCPrivate(pGC)	((FbGCPrivPtr)\
42935c4bbdfSmrg				 dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey(pGC)))
43005b261ecSmrg
43105b261ecSmrg#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
43205b261ecSmrg#define fbGetExpose(pGC)	((pGC)->fExpose)
43305b261ecSmrg
43405b261ecSmrg#define fbGetScreenPixmap(s)	((PixmapPtr) (s)->devPrivate)
43535c4bbdfSmrg
43635c4bbdfSmrg#define fbGetWinPrivateKey(pWin)        (&fbGetScreenPrivate(((DrawablePtr) (pWin))->pScreen)->winPrivateKeyRec)
43735c4bbdfSmrg
43805b261ecSmrg#define fbGetWindowPixmap(pWin)	((PixmapPtr)\
43935c4bbdfSmrg				 dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey(pWin)))
44005b261ecSmrg
44105b261ecSmrg#define __fbPixDrawableX(pPix)	((pPix)->drawable.x)
44205b261ecSmrg#define __fbPixDrawableY(pPix)	((pPix)->drawable.y)
44305b261ecSmrg
44405b261ecSmrg#ifdef COMPOSITE
44505b261ecSmrg#define __fbPixOffXWin(pPix)	(__fbPixDrawableX(pPix) - (pPix)->screen_x)
44605b261ecSmrg#define __fbPixOffYWin(pPix)	(__fbPixDrawableY(pPix) - (pPix)->screen_y)
44705b261ecSmrg#else
44805b261ecSmrg#define __fbPixOffXWin(pPix)	(__fbPixDrawableX(pPix))
44905b261ecSmrg#define __fbPixOffYWin(pPix)	(__fbPixDrawableY(pPix))
45005b261ecSmrg#endif
45105b261ecSmrg#define __fbPixOffXPix(pPix)	(__fbPixDrawableX(pPix))
45205b261ecSmrg#define __fbPixOffYPix(pPix)	(__fbPixDrawableY(pPix))
45305b261ecSmrg
4546747b715Smrg#define fbGetDrawablePixmap(pDrawable, pixmap, xoff, yoff) {			\
4556747b715Smrg    if ((pDrawable)->type != DRAWABLE_PIXMAP) { 				\
4566747b715Smrg	(pixmap) = fbGetWindowPixmap(pDrawable);				\
4576747b715Smrg	(xoff) = __fbPixOffXWin(pixmap); 					\
4586747b715Smrg	(yoff) = __fbPixOffYWin(pixmap); 					\
4596747b715Smrg    } else { 									\
4606747b715Smrg	(pixmap) = (PixmapPtr) (pDrawable);					\
4616747b715Smrg	(xoff) = __fbPixOffXPix(pixmap); 					\
4626747b715Smrg	(yoff) = __fbPixOffYPix(pixmap); 					\
4636747b715Smrg    } 										\
4646747b715Smrg    fbPrepareAccess(pDrawable); 						\
46505b261ecSmrg}
46605b261ecSmrg
4676747b715Smrg#define fbGetPixmapBitsData(pixmap, pointer, stride, bpp) {			\
4686747b715Smrg    (pointer) = (FbBits *) (pixmap)->devPrivate.ptr; 			       	\
4696747b715Smrg    (stride) = ((int) (pixmap)->devKind) / sizeof (FbBits); (void)(stride);	\
4706747b715Smrg    (bpp) = (pixmap)->drawable.bitsPerPixel;  (void)(bpp); 			\
4716747b715Smrg}
4726747b715Smrg
4736747b715Smrg#define fbGetPixmapStipData(pixmap, pointer, stride, bpp) {			\
4746747b715Smrg    (pointer) = (FbStip *) (pixmap)->devPrivate.ptr; 			       	\
4756747b715Smrg    (stride) = ((int) (pixmap)->devKind) / sizeof (FbStip); (void)(stride);	\
4766747b715Smrg    (bpp) = (pixmap)->drawable.bitsPerPixel;  (void)(bpp); 			\
4776747b715Smrg}
4786747b715Smrg
4796747b715Smrg#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { 		\
4806747b715Smrg    PixmapPtr   _pPix; 								\
4816747b715Smrg    fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff); 				\
4826747b715Smrg    fbGetPixmapBitsData(_pPix, pointer, stride, bpp);				\
4836747b715Smrg}
4846747b715Smrg
4856747b715Smrg#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { 	\
4866747b715Smrg    PixmapPtr   _pPix; 								\
4876747b715Smrg    fbGetDrawablePixmap(pDrawable, _pPix, xoff, yoff);				\
4886747b715Smrg    fbGetPixmapStipData(_pPix, pointer, stride, bpp);				\
48905b261ecSmrg}
49005b261ecSmrg
49105b261ecSmrg/*
49205b261ecSmrg * XFree86 empties the root BorderClip when the VT is inactive,
49305b261ecSmrg * here's a macro which uses that to disable GetImage and GetSpans
49405b261ecSmrg */
49505b261ecSmrg
49605b261ecSmrg#define fbWindowEnabled(pWin) \
4971b5d61b8Smrg    RegionNotEmpty(&(pWin)->borderClip)
49805b261ecSmrg
49905b261ecSmrg#define fbDrawableEnabled(pDrawable) \
50005b261ecSmrg    ((pDrawable)->type == DRAWABLE_PIXMAP ? \
50105b261ecSmrg     TRUE : fbWindowEnabled((WindowPtr) pDrawable))
50205b261ecSmrg
50305b261ecSmrg#define FbPowerOfTwo(w)	    (((w) & ((w) - 1)) == 0)
50405b261ecSmrg/*
50505b261ecSmrg * Accelerated tiles are power of 2 width <= FB_UNIT
50605b261ecSmrg */
50705b261ecSmrg#define FbEvenTile(w)	    ((w) <= FB_UNIT && FbPowerOfTwo(w))
50805b261ecSmrg
50905b261ecSmrg/*
51005b261ecSmrg * fballpriv.c
51105b261ecSmrg */
5126747b715Smrgextern _X_EXPORT Bool
51335c4bbdfSmrgfbAllocatePrivates(ScreenPtr pScreen);
51435c4bbdfSmrg
51505b261ecSmrg/*
51605b261ecSmrg * fbarc.c
51705b261ecSmrg */
51805b261ecSmrg
5196747b715Smrgextern _X_EXPORT void
52035c4bbdfSmrgfbPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * parcs);
52105b261ecSmrg
52205b261ecSmrg/*
52305b261ecSmrg * fbbits.c
52405b261ecSmrg */
52505b261ecSmrg
5266747b715Smrgextern _X_EXPORT void
52735c4bbdfSmrg
52835c4bbdfSmrgfbBresSolid8(DrawablePtr pDrawable,
52935c4bbdfSmrg             GCPtr pGC,
53035c4bbdfSmrg             int dashOffset,
53135c4bbdfSmrg             int signdx,
53235c4bbdfSmrg             int signdy,
53335c4bbdfSmrg             int axis, int x, int y, int e, int e1, int e3, int len);
53435c4bbdfSmrg
53535c4bbdfSmrgextern _X_EXPORT void
53635c4bbdfSmrg
53735c4bbdfSmrgfbBresDash8(DrawablePtr pDrawable,
53835c4bbdfSmrg            GCPtr pGC,
53935c4bbdfSmrg            int dashOffset,
54035c4bbdfSmrg            int signdx,
54135c4bbdfSmrg            int signdy, int axis, int x, int y, int e, int e1, int e3, int len);
54235c4bbdfSmrg
54335c4bbdfSmrgextern _X_EXPORT void
54435c4bbdfSmrg
54535c4bbdfSmrgfbDots8(FbBits * dst,
54635c4bbdfSmrg        FbStride dstStride,
54735c4bbdfSmrg        int dstBpp,
54835c4bbdfSmrg        BoxPtr pBox,
54935c4bbdfSmrg        xPoint * pts,
55035c4bbdfSmrg        int npt,
55135c4bbdfSmrg        int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor);
55235c4bbdfSmrg
55335c4bbdfSmrgextern _X_EXPORT void
55435c4bbdfSmrg
55535c4bbdfSmrgfbArc8(FbBits * dst,
55635c4bbdfSmrg       FbStride dstStride,
55735c4bbdfSmrg       int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
55835c4bbdfSmrg
55935c4bbdfSmrgextern _X_EXPORT void
56035c4bbdfSmrg
56135c4bbdfSmrgfbGlyph8(FbBits * dstLine,
56235c4bbdfSmrg         FbStride dstStride,
56335c4bbdfSmrg         int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
56435c4bbdfSmrg
56535c4bbdfSmrgextern _X_EXPORT void
56635c4bbdfSmrg
56735c4bbdfSmrgfbPolyline8(DrawablePtr pDrawable,
56835c4bbdfSmrg            GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
56935c4bbdfSmrg
57035c4bbdfSmrgextern _X_EXPORT void
57135c4bbdfSmrg fbPolySegment8(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
57235c4bbdfSmrg
57335c4bbdfSmrgextern _X_EXPORT void
57435c4bbdfSmrg
57535c4bbdfSmrgfbBresSolid16(DrawablePtr pDrawable,
57635c4bbdfSmrg              GCPtr pGC,
57735c4bbdfSmrg              int dashOffset,
57835c4bbdfSmrg              int signdx,
57935c4bbdfSmrg              int signdy,
58035c4bbdfSmrg              int axis, int x, int y, int e, int e1, int e3, int len);
58135c4bbdfSmrg
58235c4bbdfSmrgextern _X_EXPORT void
58335c4bbdfSmrg
58435c4bbdfSmrgfbBresDash16(DrawablePtr pDrawable,
58535c4bbdfSmrg             GCPtr pGC,
58635c4bbdfSmrg             int dashOffset,
58735c4bbdfSmrg             int signdx,
58835c4bbdfSmrg             int signdy,
58935c4bbdfSmrg             int axis, int x, int y, int e, int e1, int e3, int len);
59035c4bbdfSmrg
59135c4bbdfSmrgextern _X_EXPORT void
59235c4bbdfSmrg
59335c4bbdfSmrgfbDots16(FbBits * dst,
59435c4bbdfSmrg         FbStride dstStride,
59535c4bbdfSmrg         int dstBpp,
59635c4bbdfSmrg         BoxPtr pBox,
59735c4bbdfSmrg         xPoint * pts,
59835c4bbdfSmrg         int npt,
59935c4bbdfSmrg         int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor);
60035c4bbdfSmrg
60135c4bbdfSmrgextern _X_EXPORT void
60235c4bbdfSmrg
60335c4bbdfSmrgfbArc16(FbBits * dst,
60435c4bbdfSmrg        FbStride dstStride,
60535c4bbdfSmrg        int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
60635c4bbdfSmrg
60735c4bbdfSmrgextern _X_EXPORT void
60835c4bbdfSmrg
60935c4bbdfSmrgfbGlyph16(FbBits * dstLine,
61035c4bbdfSmrg          FbStride dstStride,
61135c4bbdfSmrg          int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
61235c4bbdfSmrg
61335c4bbdfSmrgextern _X_EXPORT void
61435c4bbdfSmrg
61535c4bbdfSmrgfbPolyline16(DrawablePtr pDrawable,
61635c4bbdfSmrg             GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
61735c4bbdfSmrg
61835c4bbdfSmrgextern _X_EXPORT void
61935c4bbdfSmrg fbPolySegment16(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
62035c4bbdfSmrg
62135c4bbdfSmrgextern _X_EXPORT void
62235c4bbdfSmrg
62335c4bbdfSmrgfbBresSolid32(DrawablePtr pDrawable,
62435c4bbdfSmrg              GCPtr pGC,
62535c4bbdfSmrg              int dashOffset,
62635c4bbdfSmrg              int signdx,
62735c4bbdfSmrg              int signdy,
62835c4bbdfSmrg              int axis, int x, int y, int e, int e1, int e3, int len);
62935c4bbdfSmrg
63035c4bbdfSmrgextern _X_EXPORT void
63135c4bbdfSmrg
63235c4bbdfSmrgfbBresDash32(DrawablePtr pDrawable,
63335c4bbdfSmrg             GCPtr pGC,
63435c4bbdfSmrg             int dashOffset,
63535c4bbdfSmrg             int signdx,
63635c4bbdfSmrg             int signdy,
63735c4bbdfSmrg             int axis, int x, int y, int e, int e1, int e3, int len);
63835c4bbdfSmrg
63935c4bbdfSmrgextern _X_EXPORT void
64035c4bbdfSmrg
64135c4bbdfSmrgfbDots32(FbBits * dst,
64235c4bbdfSmrg         FbStride dstStride,
64335c4bbdfSmrg         int dstBpp,
64435c4bbdfSmrg         BoxPtr pBox,
64535c4bbdfSmrg         xPoint * pts,
64635c4bbdfSmrg         int npt,
64735c4bbdfSmrg         int xorg, int yorg, int xoff, int yoff, FbBits and, FbBits xor);
64835c4bbdfSmrg
64935c4bbdfSmrgextern _X_EXPORT void
65035c4bbdfSmrg
65135c4bbdfSmrgfbArc32(FbBits * dst,
65235c4bbdfSmrg        FbStride dstStride,
65335c4bbdfSmrg        int dstBpp, xArc * arc, int dx, int dy, FbBits and, FbBits xor);
65435c4bbdfSmrg
65535c4bbdfSmrgextern _X_EXPORT void
65635c4bbdfSmrg
65735c4bbdfSmrgfbGlyph32(FbBits * dstLine,
65835c4bbdfSmrg          FbStride dstStride,
65935c4bbdfSmrg          int dstBpp, FbStip * stipple, FbBits fg, int height, int shift);
66035c4bbdfSmrgextern _X_EXPORT void
66135c4bbdfSmrg
66235c4bbdfSmrgfbPolyline32(DrawablePtr pDrawable,
66335c4bbdfSmrg             GCPtr pGC, int mode, int npt, DDXPointPtr ptsOrig);
66435c4bbdfSmrg
66535c4bbdfSmrgextern _X_EXPORT void
66635c4bbdfSmrg fbPolySegment32(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
66705b261ecSmrg
66805b261ecSmrg/*
66905b261ecSmrg * fbblt.c
67005b261ecSmrg */
6716747b715Smrgextern _X_EXPORT void
67235c4bbdfSmrg
67335c4bbdfSmrgfbBlt(FbBits * src,
67435c4bbdfSmrg      FbStride srcStride,
67535c4bbdfSmrg      int srcX,
67635c4bbdfSmrg      FbBits * dst,
67735c4bbdfSmrg      FbStride dstStride,
67835c4bbdfSmrg      int dstX,
67935c4bbdfSmrg      int width,
68035c4bbdfSmrg      int height, int alu, FbBits pm, int bpp, Bool reverse, Bool upsidedown);
68135c4bbdfSmrg
68235c4bbdfSmrgextern _X_EXPORT void
68335c4bbdfSmrg fbBltStip(FbStip * src, FbStride srcStride,    /* in FbStip units, not FbBits units */
68435c4bbdfSmrg           int srcX, FbStip * dst, FbStride dstStride,  /* in FbStip units, not FbBits units */
68535c4bbdfSmrg           int dstX, int width, int height, int alu, FbBits pm, int bpp);
68635c4bbdfSmrg
68705b261ecSmrg/*
68805b261ecSmrg * fbbltone.c
68905b261ecSmrg */
6906747b715Smrgextern _X_EXPORT void
69105b261ecSmrg
69235c4bbdfSmrgfbBltOne(FbStip * src,
69335c4bbdfSmrg         FbStride srcStride,
69435c4bbdfSmrg         int srcX,
69535c4bbdfSmrg         FbBits * dst,
69635c4bbdfSmrg         FbStride dstStride,
69735c4bbdfSmrg         int dstX,
69835c4bbdfSmrg         int dstBpp,
69935c4bbdfSmrg         int width,
70035c4bbdfSmrg         int height, FbBits fgand, FbBits fbxor, FbBits bgand, FbBits bgxor);
70135c4bbdfSmrg
70235c4bbdfSmrgextern _X_EXPORT void
70335c4bbdfSmrg
70435c4bbdfSmrgfbBltPlane(FbBits * src,
70535c4bbdfSmrg           FbStride srcStride,
70635c4bbdfSmrg           int srcX,
70735c4bbdfSmrg           int srcBpp,
70835c4bbdfSmrg           FbStip * dst,
70935c4bbdfSmrg           FbStride dstStride,
71035c4bbdfSmrg           int dstX,
71135c4bbdfSmrg           int width,
71235c4bbdfSmrg           int height,
71335c4bbdfSmrg           FbStip fgand,
71435c4bbdfSmrg           FbStip fgxor, FbStip bgand, FbStip bgxor, Pixel planeMask);
71505b261ecSmrg
71605b261ecSmrg/*
7179ace9065Smrg * fbcmap_mi.c
71805b261ecSmrg */
7196747b715Smrgextern _X_EXPORT int
72035c4bbdfSmrg fbListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps);
72105b261ecSmrg
7226747b715Smrgextern _X_EXPORT void
72335c4bbdfSmrg fbInstallColormap(ColormapPtr pmap);
72405b261ecSmrg
7256747b715Smrgextern _X_EXPORT void
72635c4bbdfSmrg fbUninstallColormap(ColormapPtr pmap);
72705b261ecSmrg
7286747b715Smrgextern _X_EXPORT void
72935c4bbdfSmrg
73035c4bbdfSmrgfbResolveColor(unsigned short *pred,
73135c4bbdfSmrg               unsigned short *pgreen,
73235c4bbdfSmrg               unsigned short *pblue, VisualPtr pVisual);
73305b261ecSmrg
7346747b715Smrgextern _X_EXPORT Bool
73535c4bbdfSmrg fbInitializeColormap(ColormapPtr pmap);
73605b261ecSmrg
737b2450a3aStsutsuiextern _X_EXPORT Bool
738b2450a3aStsutsui mfbCreateColormap(ColormapPtr pmap);
739b2450a3aStsutsui
7406747b715Smrgextern _X_EXPORT int
74135c4bbdfSmrg
74235c4bbdfSmrgfbExpandDirectColors(ColormapPtr pmap,
74335c4bbdfSmrg                     int ndef, xColorItem * indefs, xColorItem * outdefs);
74405b261ecSmrg
7456747b715Smrgextern _X_EXPORT Bool
74635c4bbdfSmrg fbCreateDefColormap(ScreenPtr pScreen);
74705b261ecSmrg
7486747b715Smrgextern _X_EXPORT void
74935c4bbdfSmrg fbClearVisualTypes(void);
75005b261ecSmrg
7516747b715Smrgextern _X_EXPORT Bool
75235c4bbdfSmrg fbSetVisualTypes(int depth, int visuals, int bitsPerRGB);
75305b261ecSmrg
7546747b715Smrgextern _X_EXPORT Bool
75535c4bbdfSmrgfbSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
75635c4bbdfSmrg                         Pixel redMask, Pixel greenMask, Pixel blueMask);
75705b261ecSmrg
7586747b715Smrgextern _X_EXPORT Bool
75935c4bbdfSmrg
76035c4bbdfSmrgfbInitVisuals(VisualPtr * visualp,
76135c4bbdfSmrg              DepthPtr * depthp,
76235c4bbdfSmrg              int *nvisualp,
76335c4bbdfSmrg              int *ndepthp,
76435c4bbdfSmrg              int *rootDepthp,
76535c4bbdfSmrg              VisualID * defaultVisp, unsigned long sizes, int bitsPerRGB);
76605b261ecSmrg
76705b261ecSmrg/*
76805b261ecSmrg * fbcopy.c
76905b261ecSmrg */
77005b261ecSmrg
77135c4bbdfSmrgextern _X_EXPORT void
77235c4bbdfSmrg
77335c4bbdfSmrgfbCopyNtoN(DrawablePtr pSrcDrawable,
77435c4bbdfSmrg           DrawablePtr pDstDrawable,
77535c4bbdfSmrg           GCPtr pGC,
77635c4bbdfSmrg           BoxPtr pbox,
77735c4bbdfSmrg           int nbox,
77835c4bbdfSmrg           int dx,
77935c4bbdfSmrg           int dy,
78035c4bbdfSmrg           Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
78135c4bbdfSmrg
78235c4bbdfSmrgextern _X_EXPORT void
78335c4bbdfSmrg
78435c4bbdfSmrgfbCopy1toN(DrawablePtr pSrcDrawable,
78535c4bbdfSmrg           DrawablePtr pDstDrawable,
78635c4bbdfSmrg           GCPtr pGC,
78735c4bbdfSmrg           BoxPtr pbox,
78835c4bbdfSmrg           int nbox,
78935c4bbdfSmrg           int dx,
79035c4bbdfSmrg           int dy,
79135c4bbdfSmrg           Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
79235c4bbdfSmrg
79335c4bbdfSmrgextern _X_EXPORT void
79435c4bbdfSmrg
79535c4bbdfSmrgfbCopyNto1(DrawablePtr pSrcDrawable,
79635c4bbdfSmrg           DrawablePtr pDstDrawable,
79735c4bbdfSmrg           GCPtr pGC,
79835c4bbdfSmrg           BoxPtr pbox,
79935c4bbdfSmrg           int nbox,
80035c4bbdfSmrg           int dx,
80135c4bbdfSmrg           int dy,
80235c4bbdfSmrg           Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
80305b261ecSmrg
8046747b715Smrgextern _X_EXPORT RegionPtr
80535c4bbdfSmrg
80635c4bbdfSmrgfbCopyArea(DrawablePtr pSrcDrawable,
80735c4bbdfSmrg           DrawablePtr pDstDrawable,
80835c4bbdfSmrg           GCPtr pGC,
80935c4bbdfSmrg           int xIn, int yIn, int widthSrc, int heightSrc, int xOut, int yOut);
81005b261ecSmrg
8116747b715Smrgextern _X_EXPORT RegionPtr
81235c4bbdfSmrg
81335c4bbdfSmrgfbCopyPlane(DrawablePtr pSrcDrawable,
81435c4bbdfSmrg            DrawablePtr pDstDrawable,
81535c4bbdfSmrg            GCPtr pGC,
81635c4bbdfSmrg            int xIn,
81735c4bbdfSmrg            int yIn,
81835c4bbdfSmrg            int widthSrc,
81935c4bbdfSmrg            int heightSrc, int xOut, int yOut, unsigned long bitplane);
82005b261ecSmrg
82105b261ecSmrg/*
82205b261ecSmrg * fbfill.c
82305b261ecSmrg */
8246747b715Smrgextern _X_EXPORT void
82535c4bbdfSmrg fbFill(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height);
82605b261ecSmrg
8276747b715Smrgextern _X_EXPORT void
82835c4bbdfSmrg
82935c4bbdfSmrgfbSolidBoxClipped(DrawablePtr pDrawable,
83035c4bbdfSmrg                  RegionPtr pClip,
83135c4bbdfSmrg                  int xa, int ya, int xb, int yb, FbBits and, FbBits xor);
83205b261ecSmrg
83305b261ecSmrg/*
83405b261ecSmrg * fbfillrect.c
83505b261ecSmrg */
8366747b715Smrgextern _X_EXPORT void
83735c4bbdfSmrg
83835c4bbdfSmrgfbPolyFillRect(DrawablePtr pDrawable,
83935c4bbdfSmrg               GCPtr pGC, int nrectInit, xRectangle *prectInit);
84005b261ecSmrg
84105b261ecSmrg#define fbPolyFillArc miPolyFillArc
84205b261ecSmrg
84305b261ecSmrg#define fbFillPolygon miFillPolygon
84405b261ecSmrg
84505b261ecSmrg/*
84605b261ecSmrg * fbfillsp.c
84705b261ecSmrg */
8486747b715Smrgextern _X_EXPORT void
84905b261ecSmrg
85035c4bbdfSmrgfbFillSpans(DrawablePtr pDrawable,
85135c4bbdfSmrg            GCPtr pGC,
85235c4bbdfSmrg            int nInit, DDXPointPtr pptInit, int *pwidthInit, int fSorted);
85305b261ecSmrg
85405b261ecSmrg/*
85505b261ecSmrg * fbgc.c
85605b261ecSmrg */
85705b261ecSmrg
8586747b715Smrgextern _X_EXPORT Bool
85935c4bbdfSmrg fbCreateGC(GCPtr pGC);
86005b261ecSmrg
8616747b715Smrgextern _X_EXPORT void
86235c4bbdfSmrg fbPadPixmap(PixmapPtr pPixmap);
86335c4bbdfSmrg
8646747b715Smrgextern _X_EXPORT void
86535c4bbdfSmrg fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
86605b261ecSmrg
86705b261ecSmrg/*
86805b261ecSmrg * fbgetsp.c
86905b261ecSmrg */
8706747b715Smrgextern _X_EXPORT void
87135c4bbdfSmrg
87235c4bbdfSmrgfbGetSpans(DrawablePtr pDrawable,
87335c4bbdfSmrg           int wMax,
87435c4bbdfSmrg           DDXPointPtr ppt, int *pwidth, int nspans, char *pchardstStart);
87505b261ecSmrg
87605b261ecSmrg/*
87705b261ecSmrg * fbglyph.c
87805b261ecSmrg */
87905b261ecSmrg
88035c4bbdfSmrgextern _X_EXPORT void
88135c4bbdfSmrg
88235c4bbdfSmrgfbPolyGlyphBlt(DrawablePtr pDrawable,
88335c4bbdfSmrg               GCPtr pGC,
88435c4bbdfSmrg               int x,
88535c4bbdfSmrg               int y,
88635c4bbdfSmrg               unsigned int nglyph, CharInfoPtr * ppci, void *pglyphBase);
88735c4bbdfSmrg
88835c4bbdfSmrgextern _X_EXPORT void
88935c4bbdfSmrg
89035c4bbdfSmrgfbImageGlyphBlt(DrawablePtr pDrawable,
89135c4bbdfSmrg                GCPtr pGC,
89235c4bbdfSmrg                int x,
89335c4bbdfSmrg                int y,
89435c4bbdfSmrg                unsigned int nglyph, CharInfoPtr * ppci, void *pglyphBase);
89505b261ecSmrg
89605b261ecSmrg/*
89705b261ecSmrg * fbimage.c
89805b261ecSmrg */
89905b261ecSmrg
9006747b715Smrgextern _X_EXPORT void
90135c4bbdfSmrg
90235c4bbdfSmrgfbPutImage(DrawablePtr pDrawable,
90335c4bbdfSmrg           GCPtr pGC,
90435c4bbdfSmrg           int depth,
90535c4bbdfSmrg           int x, int y, int w, int h, int leftPad, int format, char *pImage);
90605b261ecSmrg
9076747b715Smrgextern _X_EXPORT void
90835c4bbdfSmrg
90935c4bbdfSmrgfbPutZImage(DrawablePtr pDrawable,
91035c4bbdfSmrg            RegionPtr pClip,
91135c4bbdfSmrg            int alu,
91235c4bbdfSmrg            FbBits pm,
91335c4bbdfSmrg            int x,
91435c4bbdfSmrg            int y, int width, int height, FbStip * src, FbStride srcStride);
91535c4bbdfSmrg
91635c4bbdfSmrgextern _X_EXPORT void
91735c4bbdfSmrg
91835c4bbdfSmrgfbPutXYImage(DrawablePtr pDrawable,
91935c4bbdfSmrg             RegionPtr pClip,
92035c4bbdfSmrg             FbBits fg,
92135c4bbdfSmrg             FbBits bg,
92235c4bbdfSmrg             FbBits pm,
92335c4bbdfSmrg             int alu,
92435c4bbdfSmrg             Bool opaque,
92535c4bbdfSmrg             int x,
92635c4bbdfSmrg             int y,
92735c4bbdfSmrg             int width, int height, FbStip * src, FbStride srcStride, int srcX);
92805b261ecSmrg
9296747b715Smrgextern _X_EXPORT void
93035c4bbdfSmrg
93135c4bbdfSmrgfbGetImage(DrawablePtr pDrawable,
93235c4bbdfSmrg           int x,
93335c4bbdfSmrg           int y,
93435c4bbdfSmrg           int w, int h, unsigned int format, unsigned long planeMask, char *d);
93535c4bbdfSmrg/*
93635c4bbdfSmrg * fbline.c
93735c4bbdfSmrg */
93805b261ecSmrg
9396747b715Smrgextern _X_EXPORT void
94035c4bbdfSmrgfbPolyLine(DrawablePtr pDrawable,
94135c4bbdfSmrg           GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
94205b261ecSmrg
9436747b715Smrgextern _X_EXPORT void
94435c4bbdfSmrg fbFixCoordModePrevious(int npt, DDXPointPtr ppt);
94505b261ecSmrg
9466747b715Smrgextern _X_EXPORT void
94735c4bbdfSmrg fbPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pseg);
94805b261ecSmrg
94905b261ecSmrg#define fbPolyRectangle	miPolyRectangle
95005b261ecSmrg
95105b261ecSmrg/*
95205b261ecSmrg * fbpict.c
95305b261ecSmrg */
95405b261ecSmrg
9556747b715Smrgextern _X_EXPORT Bool
95635c4bbdfSmrg fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
95735c4bbdfSmrg
95835c4bbdfSmrgextern _X_EXPORT void
95935c4bbdfSmrgfbDestroyGlyphCache(void);
96005b261ecSmrg
96105b261ecSmrg/*
96205b261ecSmrg * fbpixmap.c
96305b261ecSmrg */
96405b261ecSmrg
9656747b715Smrgextern _X_EXPORT PixmapPtr
96635c4bbdfSmrgfbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
96735c4bbdfSmrg               unsigned usage_hint);
96805b261ecSmrg
9696747b715Smrgextern _X_EXPORT Bool
97035c4bbdfSmrg fbDestroyPixmap(PixmapPtr pPixmap);
97105b261ecSmrg
9726747b715Smrgextern _X_EXPORT RegionPtr
97335c4bbdfSmrg fbPixmapToRegion(PixmapPtr pPix);
97405b261ecSmrg
97505b261ecSmrg/*
97605b261ecSmrg * fbpoint.c
97705b261ecSmrg */
97805b261ecSmrg
9796747b715Smrgextern _X_EXPORT void
98005b261ecSmrg
98135c4bbdfSmrgfbPolyPoint(DrawablePtr pDrawable,
98235c4bbdfSmrg            GCPtr pGC, int mode, int npt, xPoint * pptInit);
98305b261ecSmrg
98405b261ecSmrg/*
98505b261ecSmrg * fbpush.c
98605b261ecSmrg */
98705b261ecSmrg
9886747b715Smrgextern _X_EXPORT void
98905b261ecSmrg
99035c4bbdfSmrgfbPushImage(DrawablePtr pDrawable,
99135c4bbdfSmrg            GCPtr pGC,
99235c4bbdfSmrg            FbStip * src,
99335c4bbdfSmrg            FbStride srcStride, int srcX, int x, int y, int width, int height);
99405b261ecSmrg
9956747b715Smrgextern _X_EXPORT void
99605b261ecSmrg
99735c4bbdfSmrgfbPushPixels(GCPtr pGC,
99835c4bbdfSmrg             PixmapPtr pBitmap,
99935c4bbdfSmrg             DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg);
100005b261ecSmrg
100105b261ecSmrg/*
100205b261ecSmrg * fbscreen.c
100305b261ecSmrg */
100405b261ecSmrg
10056747b715Smrgextern _X_EXPORT Bool
100635c4bbdfSmrg fbCloseScreen(ScreenPtr pScreen);
100705b261ecSmrg
10086747b715Smrgextern _X_EXPORT Bool
100935c4bbdfSmrg fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
101005b261ecSmrg
10116747b715Smrgextern _X_EXPORT Bool
101235c4bbdfSmrg fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
101305b261ecSmrg
10146747b715Smrgextern _X_EXPORT void
101535c4bbdfSmrg
101635c4bbdfSmrgfbQueryBestSize(int class,
101735c4bbdfSmrg                unsigned short *width, unsigned short *height,
101835c4bbdfSmrg                ScreenPtr pScreen);
101905b261ecSmrg
10206747b715Smrgextern _X_EXPORT PixmapPtr
102135c4bbdfSmrg _fbGetWindowPixmap(WindowPtr pWindow);
102205b261ecSmrg
10236747b715Smrgextern _X_EXPORT void
102435c4bbdfSmrg _fbSetWindowPixmap(WindowPtr pWindow, PixmapPtr pPixmap);
102505b261ecSmrg
10266747b715Smrgextern _X_EXPORT Bool
102735c4bbdfSmrg fbSetupScreen(ScreenPtr pScreen, void *pbits,        /* pointer to screen bitmap */
102835c4bbdfSmrg               int xsize,       /* in pixels */
102935c4bbdfSmrg               int ysize, int dpix,     /* dots per inch */
103035c4bbdfSmrg               int dpiy, int width,     /* pixel width of frame buffer */
103135c4bbdfSmrg               int bpp);        /* bits per pixel of frame buffer */
103205b261ecSmrg
10331b5d61b8Smrg#ifdef FB_ACCESS_WRAPPER
10346747b715Smrgextern _X_EXPORT Bool
103535c4bbdfSmrgwfbFinishScreenInit(ScreenPtr pScreen,
103635c4bbdfSmrg                    void *pbits,
103735c4bbdfSmrg                    int xsize,
103835c4bbdfSmrg                    int ysize,
103935c4bbdfSmrg                    int dpix,
104035c4bbdfSmrg                    int dpiy,
104135c4bbdfSmrg                    int width,
104235c4bbdfSmrg                    int bpp,
104335c4bbdfSmrg                    SetupWrapProcPtr setupWrap, FinishWrapProcPtr finishWrap);
104405b261ecSmrg
10456747b715Smrgextern _X_EXPORT Bool
104635c4bbdfSmrgwfbScreenInit(ScreenPtr pScreen,
104735c4bbdfSmrg              void *pbits,
104835c4bbdfSmrg              int xsize,
104935c4bbdfSmrg              int ysize,
105035c4bbdfSmrg              int dpix,
105135c4bbdfSmrg              int dpiy,
105235c4bbdfSmrg              int width,
105335c4bbdfSmrg              int bpp,
105435c4bbdfSmrg              SetupWrapProcPtr setupWrap, FinishWrapProcPtr finishWrap);
10551b5d61b8Smrg#endif
105605b261ecSmrg
105735c4bbdfSmrgextern _X_EXPORT Bool
105835c4bbdfSmrgfbFinishScreenInit(ScreenPtr pScreen,
105935c4bbdfSmrg                   void *pbits,
106035c4bbdfSmrg                   int xsize,
106135c4bbdfSmrg                   int ysize, int dpix, int dpiy, int width, int bpp);
106205b261ecSmrg
106335c4bbdfSmrgextern _X_EXPORT Bool
106405b261ecSmrg
106535c4bbdfSmrgfbScreenInit(ScreenPtr pScreen,
106635c4bbdfSmrg             void *pbits,
106735c4bbdfSmrg             int xsize, int ysize, int dpix, int dpiy, int width, int bpp);
106805b261ecSmrg
106905b261ecSmrg/*
107035c4bbdfSmrg * fbseg.c
107105b261ecSmrg */
107235c4bbdfSmrgtypedef void FbBres(DrawablePtr pDrawable,
107335c4bbdfSmrg                    GCPtr pGC,
107435c4bbdfSmrg                    int dashOffset,
107535c4bbdfSmrg                    int signdx,
107635c4bbdfSmrg                    int signdy,
107735c4bbdfSmrg                    int axis, int x, int y, int e, int e1, int e3, int len);
107805b261ecSmrg
10796747b715Smrgextern _X_EXPORT void
108035c4bbdfSmrgfbSegment(DrawablePtr pDrawable,
108135c4bbdfSmrg          GCPtr pGC,
108235c4bbdfSmrg          int xa, int ya, int xb, int yb, Bool drawLast, int *dashOffset);
108305b261ecSmrg
108405b261ecSmrg/*
108535c4bbdfSmrg * fbsetsp.c
108605b261ecSmrg */
108705b261ecSmrg
10886747b715Smrgextern _X_EXPORT void
108935c4bbdfSmrgfbSetSpans(DrawablePtr pDrawable,
109035c4bbdfSmrg           GCPtr pGC,
109135c4bbdfSmrg           char *src, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
109205b261ecSmrg
109305b261ecSmrg/*
109435c4bbdfSmrg * fbsolid.c
109505b261ecSmrg */
109605b261ecSmrg
10976747b715Smrgextern _X_EXPORT void
109805b261ecSmrg
109935c4bbdfSmrgfbSolid(FbBits * dst,
110035c4bbdfSmrg        FbStride dstStride,
110135c4bbdfSmrg        int dstX, int bpp, int width, int height, FbBits and, FbBits xor);
110205b261ecSmrg
110305b261ecSmrg/*
110405b261ecSmrg * fbutil.c
110505b261ecSmrg */
110635c4bbdfSmrgextern _X_EXPORT FbBits fbReplicatePixel(Pixel p, int bpp);
110705b261ecSmrg
110805b261ecSmrg#ifdef FB_ACCESS_WRAPPER
11096747b715Smrgextern _X_EXPORT ReadMemoryProcPtr wfbReadMemory;
11106747b715Smrgextern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory;
111105b261ecSmrg#endif
111205b261ecSmrg
1113427d0583Stsutsui/*
1114427d0583Stsutsui * fbtile.c
1115427d0583Stsutsui */
1116427d0583Stsutsui
1117427d0583Stsutsuiextern _X_EXPORT void
1118427d0583Stsutsui
1119427d0583StsutsuifbEvenTile(FbBits * dst,
1120427d0583Stsutsui           FbStride dstStride,
1121427d0583Stsutsui           int dstX,
1122427d0583Stsutsui           int width,
1123427d0583Stsutsui           int height,
1124427d0583Stsutsui           FbBits * tile,
1125427d0583Stsutsui           FbStride tileStride,
1126427d0583Stsutsui           int tileHeight, int alu, FbBits pm, int xRot, int yRot);
1127427d0583Stsutsui
1128427d0583Stsutsuiextern _X_EXPORT void
1129427d0583Stsutsui
1130427d0583StsutsuifbOddTile(FbBits * dst,
1131427d0583Stsutsui          FbStride dstStride,
1132427d0583Stsutsui          int dstX,
1133427d0583Stsutsui          int width,
1134427d0583Stsutsui          int height,
1135427d0583Stsutsui          FbBits * tile,
1136427d0583Stsutsui          FbStride tileStride,
1137427d0583Stsutsui          int tileWidth,
1138427d0583Stsutsui          int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
1139427d0583Stsutsui
1140427d0583Stsutsuiextern _X_EXPORT void
1141427d0583Stsutsui
1142427d0583StsutsuifbTile(FbBits * dst,
1143427d0583Stsutsui       FbStride dstStride,
1144427d0583Stsutsui       int dstX,
1145427d0583Stsutsui       int width,
1146427d0583Stsutsui       int height,
1147427d0583Stsutsui       FbBits * tile,
1148427d0583Stsutsui       FbStride tileStride,
1149427d0583Stsutsui       int tileWidth,
1150427d0583Stsutsui       int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
1151427d0583Stsutsui
115205b261ecSmrg/*
115305b261ecSmrg * fbwindow.c
115405b261ecSmrg */
115505b261ecSmrg
11566747b715Smrgextern _X_EXPORT Bool
115735c4bbdfSmrg fbCreateWindow(WindowPtr pWin);
115805b261ecSmrg
11596747b715Smrgextern _X_EXPORT Bool
116035c4bbdfSmrg fbDestroyWindow(WindowPtr pWin);
116105b261ecSmrg
11626747b715Smrgextern _X_EXPORT Bool
116335c4bbdfSmrg fbRealizeWindow(WindowPtr pWindow);
116405b261ecSmrg
11656747b715Smrgextern _X_EXPORT Bool
116635c4bbdfSmrg fbPositionWindow(WindowPtr pWin, int x, int y);
116705b261ecSmrg
11686747b715Smrgextern _X_EXPORT Bool
116935c4bbdfSmrg fbUnrealizeWindow(WindowPtr pWindow);
117035c4bbdfSmrg
117135c4bbdfSmrgextern _X_EXPORT void
117235c4bbdfSmrg
117335c4bbdfSmrgfbCopyWindowProc(DrawablePtr pSrcDrawable,
117435c4bbdfSmrg                 DrawablePtr pDstDrawable,
117535c4bbdfSmrg                 GCPtr pGC,
117635c4bbdfSmrg                 BoxPtr pbox,
117735c4bbdfSmrg                 int nbox,
117835c4bbdfSmrg                 int dx,
117935c4bbdfSmrg                 int dy,
118035c4bbdfSmrg                 Bool reverse, Bool upsidedown, Pixel bitplane, void *closure);
118135c4bbdfSmrg
118235c4bbdfSmrgextern _X_EXPORT void
118335c4bbdfSmrg fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
118405b261ecSmrg
11856747b715Smrgextern _X_EXPORT Bool
118635c4bbdfSmrg fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
118705b261ecSmrg
11886747b715Smrgextern _X_EXPORT void
118905b261ecSmrg
119035c4bbdfSmrgfbFillRegionSolid(DrawablePtr pDrawable,
119135c4bbdfSmrg                  RegionPtr pRegion, FbBits and, FbBits xor);
11926747b715Smrg
119335c4bbdfSmrgextern _X_EXPORT pixman_image_t *image_from_pict(PicturePtr pict,
119435c4bbdfSmrg                                                 Bool has_clip,
119535c4bbdfSmrg                                                 int *xoff, int *yoff);
119605b261ecSmrg
119735c4bbdfSmrgextern _X_EXPORT void free_pixman_pict(PicturePtr, pixman_image_t *);
119805b261ecSmrg
119935c4bbdfSmrg#endif                          /* _FB_H_ */
1200