fb.h revision deb4998ba50060c48cce222fd18a8eed053918d7
/*
*
* Copyright © 1998 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _FB_H_
#define _FB_H_
#include "scrnintstr.h"
#include "pixmap.h"
#include "pixmapstr.h"
#include "region.h"
#include "gcstruct.h"
#include "colormap.h"
#include "miscstruct.h"
#include "servermd.h"
#include "windowstr.h"
#include "mi.h"
#include "migc.h"
#include "mibstore.h"
#ifdef RENDER
#include "picturestr.h"
#else
#include "picture.h"
#endif
/*
* This single define controls the basic size of data manipulated
* by this software; it must be log2(sizeof (FbBits) * 8)
*/
#ifndef FB_SHIFT
#define FB_SHIFT LOG2_BITMAP_PAD
#endif
#if FB_SHIFT < LOG2_BITMAP_PAD
#endif
#if GLYPHPADBYTES != 4
#error "GLYPHPADBYTES must be 4"
#endif
#if GETLEFTBITS_ALIGNMENT != 1
#error "GETLEFTBITS_ALIGNMENT must be 1"
#endif
/* whether to bother to include 24bpp support */
#ifndef FBNO24BIT
#define FB_24BIT
#endif
/*
* Unless otherwise instructed, fb includes code to advertise 24bpp
* windows with 32bpp image format for application compatibility
*/
#ifdef FB_24BIT
#ifndef FBNO24_32
#define FB_24_32BIT
#endif
#endif
#define FB_STIP_SHIFT LOG2_BITMAP_PAD
#if FB_SHIFT == 6
# ifdef WIN32
# else
defined(__sparc64__) || defined(_LP64) || \
defined(__s390x__) || \
defined (__powerpc64__) || \
typedef unsigned long FbBits;
# else
typedef unsigned long long FbBits;
# endif
# endif
#endif
#if FB_SHIFT == 5
#endif
#if FB_SHIFT == 4
#endif
#if LOG2_BITMAP_PAD == FB_SHIFT
#else
# if LOG2_BITMAP_PAD == 5
# endif
#endif
typedef int FbStride;
#ifdef FB_DEBUG
extern void fbValidateDrawable(DrawablePtr d);
extern void fbInitializeDrawable(DrawablePtr d);
#else
#define fbValidateDrawable(d)
#define fdInitializeDrawable(d)
#endif
#include "fbrop.h"
#if BITMAP_BIT_ORDER == LSBFirst
#define FbScrLeft(x,n) ((x) >> (n))
#define FbScrRight(x,n) ((x) << (n))
/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
#define FbPatternOffsetBits 0
#else
#define FbScrLeft(x,n) ((x) << (n))
#define FbScrRight(x,n) ((x) >> (n))
/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
#define FbStipMoveLsb(x,s,n) (x)
#endif
#include "micoord.h"
#define FbStipLeft(x,n) FbScrLeft(x,n)
#define FbStipRight(x,n) FbScrRight(x,n)
#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
#define FbMaskBits(x,w,l,n,r) { \
n = (w); \
r = FbRightMask((x)+n); \
l = FbLeftMask(x); \
if (l) { \
if (n < 0) { \
n = 0; \
l &= r; \
r = 0; \
} \
} \
n >>= FB_SHIFT; \
}
#ifdef FBNOPIXADDR
}
}
#else
#define FbByteMaskInvalid 0x10
#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
#ifndef FbSelectPart
#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
#endif
n = (w); \
lb = 0; \
rb = 0; \
r = FbRightMask((x)+n); \
if (r) { \
/* compute right byte length */ \
if ((copy) && (((x) + n) & 7) == 0) { \
} else { \
rb = FbByteMaskInvalid; \
} \
} \
l = FbLeftMask(x); \
if (l) { \
/* compute left byte length */ \
if ((copy) && ((x) & 7) == 0) { \
} else { \
lb = FbByteMaskInvalid; \
} \
/* subtract out the portion painted by leftMask */ \
if (n < 0) { \
if (lb != FbByteMaskInvalid) { \
if (rb == FbByteMaskInvalid) { \
lb = FbByteMaskInvalid; \
} else if (rb) { \
rb = 0; \
} \
} \
n = 0; \
l &= r; \
r = 0; \
}\
} \
n >>= FB_SHIFT; \
}
#if FB_SHIFT == 6
break; \
break; \
break; \
break; \
break; \
break; \
case (sizeof (FbBits) - 7): \
break; \
break; \
break; \
break; \
break; \
break; \
case (sizeof (FbBits) - 6): \
break; \
break; \
break; \
break; \
break; \
case (sizeof (FbBits) - 5): \
break; \
break; \
break; \
break; \
case (sizeof (FbBits) - 4): \
break;
case 4: \
break; \
case 5: \
break; \
case 6: \
break; \
case 7: \
break;
#else
#endif
switch (lb) { \
break; \
break; \
break; \
case sizeof (FbBits) - 3: \
case sizeof (FbBits) - 2: \
break; \
case sizeof (FbBits) - 1: \
break; \
default: \
break; \
} \
}
switch (rb) { \
case 1: \
break; \
case 2: \
break; \
case 3: \
break; \
default: \
} \
}
#endif
#define FbMaskStip(x,w,l,n,r) { \
n = (w); \
r = FbRightStipMask((x)+n); \
l = FbLeftStipMask(x); \
if (l) { \
n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
if (n < 0) { \
n = 0; \
l &= r; \
r = 0; \
} \
} \
n >>= FB_STIP_SHIFT; \
}
/*
* These macros are used to transparently stipple
* in copy mode; the expected usage is with 'n' constant
* so all of the conditional parts collapse into a minimal
* sequence of partial word writes
*
* 'n' is the bytemask of which bytes to store, 'a' is the address
* of the FbBits base unit, 'o' is the offset within that unit
*
* The term "lane" comes from the hardware term "byte-lane" which
*/
#define FbLaneCase1(n,a,o) ((n) == 0x01 ? \
fgxor) : 0)
#define FbLaneCase2(n,a,o) ((n) == 0x03 ? \
fgxor) : \
((void)FbLaneCase1((n)&1,a,o), \
#define FbLaneCase4(n,a,o) ((n) == 0x0f ? \
fgxor) : \
((void)FbLaneCase2((n)&3,a,o), \
((void)FbLaneCase4((n)&15,a,o), \
#if FB_SHIFT == 6
#endif
#if FB_SHIFT == 5
#endif
/* Rotate a filled pixel value to the specified alignement */
#if FB_UNIT == 64
#if IMAGE_BYTE_ORDER == MSBFirst
#else
#define FbFirst24Rot(x) ((x) % 24)
#endif
#endif
#if FB_UNIT == 32
#if IMAGE_BYTE_ORDER == MSBFirst
#else
#define FbFirst24Rot(x) ((x) % 24)
#endif
#endif
/* Whether 24-bit specific code is needed for this filled pixel value */
#define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
/* Macros for dealing with dashing */
#define FbDashDeclare \
\
__dash = __firstDash; \
{ \
(dashOffset) -= (dashlen); \
if (++__dash == __lastDash) \
__dash = __firstDash; \
} \
(dashlen) -= (dashOffset); \
}
#define FbDashNext(dashlen) { \
if (++__dash == __lastDash) \
__dash = __firstDash; \
}
/* as numInDashList is always even, this case can skip a test */
#define FbDashNextEven(dashlen) { \
}
if (!--(dashlen)) { \
FbDashNext(dashlen); \
} \
}
/* XXX fb*PrivateIndex should be static, but it breaks the ABI */
extern int fbGCPrivateIndex;
extern int fbGetGCPrivateIndex(void);
#ifndef FB_NO_WINDOW_PIXMAPS
extern int fbWinPrivateIndex;
extern int fbGetWinPrivateIndex(void);
#endif
#ifdef TEKX11
#define FB_OLD_GC
#define FB_OLD_SCREEN
#endif
#ifdef FB_OLD_SCREEN
# define FB_OLD_MISCREENINIT /* miScreenInit requires 14 args, not 13 */
extern WindowPtr *WindowTable;
#endif
#ifdef FB_24_32BIT
#define FB_SCREEN_PRIVATE
#endif
#ifdef FB_SCREEN_PRIVATE
extern int fbScreenPrivateIndex;
extern int fbGetScreenPrivateIndex(void);
/* private field of a screen */
typedef struct {
unsigned char win32bpp; /* window bpp for 32-bpp images */
unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
#endif
/* private field of GC */
typedef struct {
#ifdef FB_OLD_GC
unsigned char pad1;
unsigned char pad2;
unsigned char pad3;
unsigned fExpose:1;
unsigned freeCompClip:1;
#endif
unsigned int dashLength; /* total of all dash elements */
unsigned char oneRect; /* clip list is single rectangle */
unsigned char evenStipple; /* stipple is even */
unsigned char bpp; /* current drawable bpp */
} FbGCPrivRec, *FbGCPrivPtr;
#ifdef FB_OLD_GC
#else
#endif
#ifdef FB_NO_WINDOW_PIXMAPS
#else
#endif
#ifdef ROOTLESS
#else
#define __fbPixDrawableX(pPix) 0
#define __fbPixDrawableY(pPix) 0
#endif
#ifdef COMPOSITE
#else
#endif
} else { \
} \
}
} else { \
} \
}
/*
* XFree86 empties the root BorderClip when the VT is inactive,
* here's a macro which uses that to disable GetImage and GetSpans
*/
#define fbWindowEnabled(pWin) \
#define fbDrawableEnabled(pDrawable) \
#ifdef FB_OLD_SCREEN
#define BitsPerPixel(d) (\
#endif
#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
/*
* Accelerated tiles are power of 2 width <= FB_UNIT
*/
/*
* with dstBpp a power of 2 as well
*/
/*
*/
void
int wMax,
int *pwidth,
int nspans,
char *pchardstStart);
void
char *src,
int *pwidth,
int nspans,
int fSorted);
void
int alu,
int x,
int y,
int width,
int height,
void
int x,
int y,
int w,
int h,
unsigned int format,
unsigned long planeMask,
char *d);
void
int nbox,
int dx,
int dy,
void *closure);
int width,
int height,
int depth,
int bitsPerPixel,
int devKind,
/*
*/
/*
* fbarc.c
*/
void
int narcs,
/*
* fbbits.c
*/
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dstBpp,
int npt,
int xorg,
int yorg,
int xoff,
int yoff,
void
int dstBpp,
int dx,
int dy,
void
int dstBpp,
int height,
int shift);
void
int mode,
int npt,
void
int nseg,
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dstBpp,
int npt,
int xorg,
int yorg,
int xoff,
int yoff,
void
int dstBpp,
int dx,
int dy,
void
int dstBpp,
int height,
int shift);
void
int mode,
int npt,
void
int nseg,
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dstBpp,
int npt,
int xorg,
int yorg,
int xoff,
int yoff,
void
int dstBpp,
int dx,
int dy,
void
int dstBpp,
int height,
int shift);
void
int mode,
int npt,
void
int nseg,
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int dstBpp,
int npt,
int xorg,
int yorg,
int xoff,
int yoff,
void
int dstBpp,
int dx,
int dy,
void
int dstBpp,
int height,
int shift);
void
int mode,
int npt,
void
int nseg,
/*
* fbblt.c
*/
void
int srcX,
int dstX,
int width,
int height,
int alu,
int bpp,
void
int srcX,
int dstX,
int width,
int height,
int alu,
void
int srcX,
int dstX,
int width,
int height,
int alu,
int bpp);
/*
*/
void
int srcX,
int dstX,
int dstBpp,
int width,
int height,
#ifdef FB_24BIT
void
int srcX, /* bit position of source */
int dstX, /* bit position of dest */
int dstBpp, /* bits per destination unit */
int width, /* width in bits of destination */
int height, /* height in scanlines */
#endif
void
int srcX,
int srcBpp,
int dstX,
int width,
int height,
/*
*/
void
int xorg,
int yorg,
void
int xorg,
int yorg,
/*
* fbcmap.c
*/
int
void
void
void
fbResolveColor(unsigned short *pred,
unsigned short *pgreen,
unsigned short *pblue,
int
int ndef,
void
fbClearVisualTypes(void);
int *nvisualp,
int *ndepthp,
int *rootDepthp,
unsigned long sizes,
int bitsPerRGB);
/*
* fbcopy.c
*/
int nbox,
int dx,
int dy,
void *closure);
void
int nbox,
int dx,
int dy,
void *closure);
void
int nbox,
int dx,
int dy,
void *closure);
void
int nbox,
int dx,
int dy,
void *closure);
void
int dx,
int dy,
void *closure);
int xIn,
int yIn,
int widthSrc,
int heightSrc,
int xOut,
int yOut,
void *closure);
int xIn,
int yIn,
int widthSrc,
int heightSrc,
int xOut,
int yOut);
int xIn,
int yIn,
int widthSrc,
int heightSrc,
int xOut,
int yOut,
unsigned long bitplane);
/*
* fbfill.c
*/
void
int x,
int y,
int width,
int height);
void
int xa,
int ya,
int xb,
int yb,
/*
*/
void
int nrectInit,
#define fbPolyFillArc miPolyFillArc
#define fbFillPolygon miFillPolygon
/*
*/
void
int nInit,
int *pwidthInit,
int fSorted);
/*
* fbgc.c
*/
void
void
/*
*/
void
int wMax,
int *pwidth,
int nspans,
char *pchardstStart);
/*
*/
int x,
int y,
int width,
int height);
void
int x,
int y,
unsigned int nglyph,
void
int x,
int y,
unsigned int nglyph,
/*
*/
void
int depth,
int x,
int y,
int w,
int h,
int leftPad,
int format,
char *pImage);
void
int alu,
int x,
int y,
int width,
int height,
void
int alu,
int x,
int y,
int width,
int height,
int srcX);
void
int x,
int y,
int w,
int h,
unsigned int format,
unsigned long planeMask,
char *d);
/*
* fbline.c
*/
void
int mode,
int npt,
void
int nseg,
void
int mode,
int npt,
void
fbFixCoordModePrevious (int npt,
void
int nseg,
#define fbPolyRectangle miPolyRectangle
/*
* fbpict.c
*/
int nformats);
/*
*/
/*
*/
void
int dstBpp,
int npt,
int xorg,
int yorg,
int xoff,
int yoff,
void
int mode,
int npt,
/*
* fbpush.c
*/
void
int srcX,
int x,
int y,
int width,
int height);
void
int srcX,
int x,
int y,
int width,
int height);
void
int nbox,
int dx,
int dy,
void *closure);
void
int srcX,
int x,
int y,
int width,
int height);
void
int dx,
int dy,
int xOrg,
int yOrg);
/*
*/
void
fbQueryBestSize (int class,
#ifndef FB_OLD_SCREEN
void
#endif
int xsize, /* in pixels */
int ysize,
int dpix, /* dots per inch */
int dpiy,
int width, /* pixel width of frame buffer */
int bpp); /* bits per pixel of frame buffer */
int xsize,
int ysize,
int dpix,
int dpiy,
int width,
int bpp);
int xsize,
int ysize,
int dpix,
int dpiy,
int width,
int bpp);
void
/*
* fbseg.c
*/
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
/*
*/
void
char *src,
int *pwidth,
int nspans,
int fSorted);
FbBres *
void
int dashOffset,
int signdx,
int signdy,
int axis,
int x,
int y,
int e,
int e1,
int e3,
int len);
void
int xa,
int ya,
int xb,
int yb,
int *dashOffset);
/*
*/
void
int dstX,
int bpp,
int width,
int height,
#ifdef FB_24BIT
void
int dstX,
int width,
int height,
#endif
/*
*/
void
int n);
void
int dstX,
int dstBpp,
int width,
int height,
int stipHeight,
int xRot,
int yRot);
void
int dstX,
int dstBpp,
int width,
int height,
int stipWidth,
int stipHeight,
int xRot,
int yRot);
void
int dstX,
int dstBpp,
int width,
int height,
int stipWidth,
int stipHeight,
int xRot,
int yRot);
/*
* fbtile.c
*/
void
int dstX,
int width,
int height,
int tileHeight,
int alu,
int xRot,
int yRot);
void
int dstX,
int width,
int height,
int tileWidth,
int tileHeight,
int alu,
int bpp,
int xRot,
int yRot);
void
int dstX,
int width,
int height,
int tileWidth,
int tileHeight,
int alu,
int bpp,
int xRot,
int yRot);
/*
* fbutil.c
*/
void
/*
*/
void
int nbox,
int dx,
int dy,
void *closure);
void
void
void
void
#endif /* _FB_H_ */