diff options
author | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
commit | 3562e78743202e43aec8727005182a2558117eca (patch) | |
tree | 8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xorg-server/hw/xfree86/xaa/xaaBitmap.c | |
download | vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2 vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip |
Checked in the following released items:
xkeyboard-config-1.4.tar.gz
ttf-bitstream-vera-1.10.tar.gz
font-alias-1.0.1.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sony-misc-1.0.0.tar.gz
font-schumacher-misc-1.0.0.tar.gz
font-mutt-misc-1.0.0.tar.gz
font-misc-misc-1.0.0.tar.gz
font-misc-meltho-1.0.0.tar.gz
font-micro-misc-1.0.0.tar.gz
font-jis-misc-1.0.0.tar.gz
font-isas-misc-1.0.0.tar.gz
font-dec-misc-1.0.0.tar.gz
font-daewoo-misc-1.0.0.tar.gz
font-cursor-misc-1.0.0.tar.gz
font-arabic-misc-1.0.0.tar.gz
font-winitzki-cyrillic-1.0.0.tar.gz
font-misc-cyrillic-1.0.0.tar.gz
font-cronyx-cyrillic-1.0.0.tar.gz
font-screen-cyrillic-1.0.1.tar.gz
font-xfree86-type1-1.0.1.tar.gz
font-adobe-utopia-type1-1.0.1.tar.gz
font-ibm-type1-1.0.0.tar.gz
font-bitstream-type1-1.0.0.tar.gz
font-bitstream-speedo-1.0.0.tar.gz
font-bh-ttf-1.0.0.tar.gz
font-bh-type1-1.0.0.tar.gz
font-bitstream-100dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz
font-bh-100dpi-1.0.0.tar.gz
font-adobe-utopia-100dpi-1.0.1.tar.gz
font-adobe-100dpi-1.0.0.tar.gz
font-util-1.0.1.tar.gz
font-bitstream-75dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz
font-adobe-utopia-75dpi-1.0.1.tar.gz
font-bh-75dpi-1.0.0.tar.gz
bdftopcf-1.0.1.tar.gz
font-adobe-75dpi-1.0.0.tar.gz
mkfontscale-1.0.6.tar.gz
openssl-0.9.8k.tar.gz
bigreqsproto-1.0.2.tar.gz
xtrans-1.2.2.tar.gz
resourceproto-1.0.2.tar.gz
inputproto-1.4.4.tar.gz
compositeproto-0.4.tar.gz
damageproto-1.1.0.tar.gz
zlib-1.2.3.tar.gz
xkbcomp-1.0.5.tar.gz
freetype-2.3.9.tar.gz
pthreads-w32-2-8-0-release.tar.gz
pixman-0.12.0.tar.gz
kbproto-1.0.3.tar.gz
evieext-1.0.2.tar.gz
fixesproto-4.0.tar.gz
recordproto-1.13.2.tar.gz
randrproto-1.2.2.tar.gz
scrnsaverproto-1.1.0.tar.gz
renderproto-0.9.3.tar.gz
xcmiscproto-1.1.2.tar.gz
fontsproto-2.0.2.tar.gz
xextproto-7.0.3.tar.gz
xproto-7.0.14.tar.gz
libXdmcp-1.0.2.tar.gz
libxkbfile-1.0.5.tar.gz
libfontenc-1.0.4.tar.gz
libXfont-1.3.4.tar.gz
libX11-1.1.5.tar.gz
libXau-1.0.4.tar.gz
libxcb-1.1.tar.gz
xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xorg-server/hw/xfree86/xaa/xaaBitmap.c')
-rw-r--r-- | xorg-server/hw/xfree86/xaa/xaaBitmap.c | 476 |
1 files changed, 476 insertions, 0 deletions
diff --git a/xorg-server/hw/xfree86/xaa/xaaBitmap.c b/xorg-server/hw/xfree86/xaa/xaaBitmap.c new file mode 100644 index 000000000..f7ae78d3f --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaBitmap.c @@ -0,0 +1,476 @@ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xaa.h" +#include "xaalocal.h" +#include "xaacexp.h" +#include "xf86.h" + + +/********** byte swapping ***************/ + + +#ifdef FIXEDBASE +# define DEST(i) *dest +# define RETURN(i) return(dest) +#else +# define DEST(i) dest[i] +# define RETURN(i) return(dest + i) +#endif + +#ifdef MSBFIRST +# define SOURCE(i) SWAP_BITS_IN_BYTES(src[i]) +#else +# define SOURCE(i) src[i] +#endif + + +typedef CARD32 *(* BitmapScanlineProcPtr)(CARD32 *, CARD32 *, int, int); + +#ifdef TRIPLE_BITS +static CARD32* +BitmapScanline( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = *src; + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = *src; + WRITE_BITS2(bits); + } else if (count == 1) { + bits = *src; + WRITE_BITS1(bits); + } + + return base; +} + +static CARD32* +BitmapScanline_Inverted( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = ~(*src); + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = ~(*src); + WRITE_BITS2(bits); + } else if (count == 1) { + bits = ~(*src); + WRITE_BITS1(bits); + } + + return base; +} + + +static CARD32* +BitmapScanline_Shifted( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)); + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)); + WRITE_BITS2(bits); + } else if (count == 1) { + bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)); + WRITE_BITS1(bits); + } + + return base; +} + +static CARD32* +BitmapScanline_Shifted_Inverted( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft))); + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft))); + WRITE_BITS2(bits); + } else if (count == 1) { + bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft))); + WRITE_BITS1(bits); + } + + return base; +} + +#define BitmapScanline_Shifted_Careful BitmapScanline_Shifted +#define BitmapScanline_Shifted_Inverted_Careful BitmapScanline_Shifted_Inverted + +#else +static CARD32* +BitmapScanline( + CARD32 *src, CARD32 *dest, + int count, int skipleft ) +{ + while(count >= 4) { + DEST(0) = SOURCE(0); + DEST(1) = SOURCE(1); + DEST(2) = SOURCE(2); + DEST(3) = SOURCE(3); + count -= 4; + src += 4; +#ifndef FIXEDBASE + dest += 4; +#endif + } + + if(!count) return dest; + DEST(0) = SOURCE(0); + if(count == 1) RETURN(1); + DEST(1) = SOURCE(1); + if(count == 2) RETURN(2); + DEST(2) = SOURCE(2); + RETURN(3); +} + +static CARD32* +BitmapScanline_Inverted( + CARD32 *src, CARD32 *dest, + int count, int skipleft ) +{ + while(count >= 4) { + DEST(0) = ~SOURCE(0); + DEST(1) = ~SOURCE(1); + DEST(2) = ~SOURCE(2); + DEST(3) = ~SOURCE(3); + count -= 4; + src += 4; +#ifndef FIXEDBASE + dest += 4; +#endif + } + + if(!count) return dest; + DEST(0) = ~SOURCE(0); + if(count == 1) RETURN(1); + DEST(1) = ~SOURCE(1); + if(count == 2) RETURN(2); + DEST(2) = ~SOURCE(2); + RETURN(3); +} + + +static CARD32* +BitmapScanline_Shifted( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + while(count--) { + register CARD32 tmp = SHIFT_R(*bits,skipleft) | + SHIFT_L(*(bits + 1),(32 - skipleft)); + WRITE_BITS(tmp); + bits++; + } + return base; +} + +static CARD32* +BitmapScanline_Shifted_Inverted( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + while(count--) { + register CARD32 tmp = ~(SHIFT_R(*bits,skipleft) | + SHIFT_L(*(bits + 1),(32 - skipleft))); + WRITE_BITS(tmp); + bits++; + } + return base; +} + +static CARD32* +BitmapScanline_Shifted_Careful( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + register CARD32 tmp; + while(--count) { + tmp = SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft)); + WRITE_BITS(tmp); + bits++; + } + tmp = SHIFT_R(*bits,skipleft); + WRITE_BITS(tmp); + + return base; +} + +static CARD32* +BitmapScanline_Shifted_Inverted_Careful( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + register CARD32 tmp; + while(--count) { + tmp = ~(SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft))); + WRITE_BITS(tmp); + bits++; + } + tmp = ~(SHIFT_R(*bits,skipleft)); + WRITE_BITS(tmp); + return base; +} + +#endif + +/* + When the accelerator is TRANSPARENCY_ONLY, WriteBitmap can do + the fill in two passes, inverting the source on the second pass. + For GXcopy we can fill the backing rectangle as a solid rect and + avoid the invert. +*/ + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAWriteBitmapColorExpand3)( +#else +EXPNAME(XAAWriteBitmapColorExpand)( +#endif + ScrnInfoPtr pScrn, + int x, int y, int w, int H, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32* base; + unsigned char *srcp = src; + int SecondPassColor = -1; + int shift = 0, dwords; + BitmapScanlineProcPtr firstFunc; + BitmapScanlineProcPtr secondFunc; + int flag; + int h = H; + +#ifdef TRIPLE_BITS + if((bg != -1) && + ((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) || + ((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) && + (!CHECK_RGB_EQUAL(bg))))) { +#else + if((bg != -1) && + (infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) { +#endif + if((rop == GXcopy) && infoRec->SetupForSolidFill) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + } else SecondPassColor = bg; + bg = -1; + } + +#ifdef TRIPLE_BITS + if(skipleft) { +#else + if(skipleft && + (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) || + (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) && + (skipleft > x)))) { +#endif + if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) { + /* don't read past the end */ + firstFunc = BitmapScanline_Shifted_Careful; + secondFunc = BitmapScanline_Shifted_Inverted_Careful; + } else { + firstFunc = BitmapScanline_Shifted; + secondFunc = BitmapScanline_Shifted_Inverted; + } + shift = skipleft; + skipleft = 0; + } else { + firstFunc = BitmapScanline; + secondFunc = BitmapScanline_Inverted; + w += skipleft; + x -= skipleft; + } + +#ifdef TRIPLE_BITS + dwords = (3 * w + 31) >> 5; +#else + dwords = (w + 31) >> 5; +#endif + +SECOND_PASS: + + flag = (infoRec->CPUToScreenColorExpandFillFlags + & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01); + (*infoRec->SetupForCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + (*infoRec->SubsequentCPUToScreenColorExpandFill)( + pScrn, x, y, w, h, skipleft); + + base = (CARD32*)infoRec->ColorExpandBase; + +#ifndef FIXEDBASE + if((dwords * h) <= infoRec->ColorExpandRange) + while(h--) { + base = (*firstFunc)((CARD32*)srcp, base, dwords, shift); + srcp += srcwidth; + } + else +#endif + while(h--) { + (*firstFunc)((CARD32*)srcp, base, dwords, shift); + srcp += srcwidth; + } + + if(flag){ + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + + if(SecondPassColor != -1) { + h = H; /* Reset height */ + fg = SecondPassColor; + SecondPassColor = -1; + firstFunc = secondFunc; + srcp = src; + goto SECOND_PASS; + } + + if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + +#ifndef FIXEDBASE + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAWriteBitmapScanlineColorExpand3)( +#else +EXPNAME(XAAWriteBitmapScanlineColorExpand)( +#endif + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32* base; + unsigned char *srcp = src; + int SecondPassColor = -1; + int shift = 0, dwords, bufferNo; + BitmapScanlineProcPtr firstFunc; + BitmapScanlineProcPtr secondFunc; + +#ifdef TRIPLE_BITS + if((bg != -1) && + ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) + || ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) && + (!CHECK_RGB_EQUAL(bg))))) { +#else + if((bg != -1) && + (infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)){ +#endif + if((rop == GXcopy) && infoRec->SetupForSolidFill) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + } else SecondPassColor = bg; + bg = -1; + } + +#ifdef TRIPLE_BITS + if(skipleft) { +#else + if(skipleft && + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + LEFT_EDGE_CLIPPING) || + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) { +#endif + if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) { + /* don't read past the end */ + firstFunc = BitmapScanline_Shifted_Careful; + secondFunc = BitmapScanline_Shifted_Inverted_Careful; + } else { + firstFunc = BitmapScanline_Shifted; + secondFunc = BitmapScanline_Shifted_Inverted; + } + shift = skipleft; + skipleft = 0; + } else { + firstFunc = BitmapScanline; + secondFunc = BitmapScanline_Inverted; + w += skipleft; + x -= skipleft; + } + +#ifdef TRIPLE_BITS + dwords = (3 * w + 31) >> 5; +#else + dwords = (w + 31) >> 5; +#endif + +SECOND_PASS: + + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask); + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, x, y, w, h, skipleft); + + bufferNo = 0; + + while(h--) { + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + (*firstFunc)((CARD32*)srcp, base, dwords, shift); + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + srcp += srcwidth; + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + } + + if(SecondPassColor != -1) { + fg = SecondPassColor; + SecondPassColor = -1; + firstFunc = secondFunc; + srcp = src; + goto SECOND_PASS; + } + + SET_SYNC_FLAG(infoRec); +} + +#endif |