diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:57 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:57 +0000 |
commit | 9508a382f8a9f241dab097d921b6d290c1c3a776 (patch) | |
tree | fa456480bae7040c3f971a70b390f2d091c680b5 /hw/xfree86/xf8_32bpp | |
parent | ded6147bfb5d75ff1e67c858040a628b61bc17d1 (diff) |
Initial revision
Diffstat (limited to 'hw/xfree86/xf8_32bpp')
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfb8_32.h | 226 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfb8_32module.c | 38 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbbstore.c | 102 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbcpyarea.c | 540 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbcpyplane.c | 39 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbgc.c | 663 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbgcmisc.c | 146 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbgcunder.c | 636 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbimage.c | 168 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbpntwin.c | 177 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbscrinit.c | 309 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/cfbwindow.c | 116 | ||||
-rw-r--r-- | hw/xfree86/xf8_32bpp/xf86overlay.c | 1258 |
13 files changed, 4418 insertions, 0 deletions
diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h new file mode 100644 index 000000000..733051ae0 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfb8_32.h @@ -0,0 +1,226 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfb8_32.h,v 1.5 2000/03/02 02:32:52 mvojkovi Exp $ */ + +#ifndef _CFB8_32_H +#define _CFB8_32_H + +#include "gcstruct.h" + +typedef struct { + GCOps *Ops8bpp; + GCOps *Ops32bpp; + unsigned long changes; + Bool OpsAre8bpp; +} cfb8_32GCRec, *cfb8_32GCPtr; + +typedef struct { + unsigned char key; + void (*EnableDisableFBAccess)(int scrnIndex, Bool enable); + pointer visualData; +} cfb8_32ScreenRec, *cfb8_32ScreenPtr; + + +extern int cfb8_32GCPrivateIndex; +extern int cfb8_32ScreenPrivateIndex; + +void +cfb8_32SaveAreas( + PixmapPtr pPixmap, + RegionPtr prgnSave, + int xorg, + int yorg, + WindowPtr pWin +); + +void +cfb8_32RestoreAreas( + PixmapPtr pPixmap, + RegionPtr prgnRestore, + int xorg, + int yorg, + WindowPtr pWin +); + +RegionPtr +cfb8_32CopyArea( + DrawablePtr pSrcDraw, + DrawablePtr pDstDraw, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +); + +void +cfbDoBitblt8To32( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long planemask, + unsigned long bitPlane +); + +void +cfbDoBitblt32To8( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long planemask, + unsigned long bitPlane +); + + +void +cfb8_32ValidateGC8( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +); + +void +cfb8_32ValidateGC32( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +); + +void +cfb32ValidateGC_Underlay( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +); + +Bool cfb8_32CreateGC(GCPtr pGC); + +void +cfb8_32GetSpans( + DrawablePtr pDraw, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pchardstStart +); + +void +cfb8_32PutImage ( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +); + +void +cfb8_32GetImage ( + DrawablePtr pDraw, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planeMask, + char *pdstLine +); + +void +cfb8_32PaintWindow ( + WindowPtr pWin, + RegionPtr pRegion, + int what +); + +Bool +cfb8_32ScreenInit ( + ScreenPtr pScreen, + pointer pbits, + int xsize, int ysize, + int dpix, int dpiy, + int width +); + +void +cfb8_32FillBoxSolid8 ( + DrawablePtr pDraw, + int nbox, + BoxPtr pBox, + unsigned long color +); + + +void +cfb8_32FillBoxSolid32 ( + DrawablePtr pDraw, + int nbox, + BoxPtr pBox, + unsigned long color +); + +RegionPtr +cfb8_32CopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +); + +void +cfbDoBitblt8To8GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm, + unsigned long bitPlane +); + +void +cfbDoBitblt24To24GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm, + unsigned long bitPlane +); + +Bool cfb8_32CreateWindow(WindowPtr pWin); +Bool cfb8_32DestroyWindow(WindowPtr pWin); + +Bool +cfb8_32PositionWindow( + WindowPtr pWin, + int x, int y +); + +void +cfb8_32CopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc +); + +Bool +cfb8_32ChangeWindowAttributes( + WindowPtr pWin, + unsigned long mask +); + + +#define CFB8_32_GET_GC_PRIVATE(pGC)\ + (cfb8_32GCPtr)((pGC)->devPrivates[cfb8_32GCPrivateIndex].ptr) + +#define CFB8_32_GET_SCREEN_PRIVATE(pScreen)\ + (cfb8_32ScreenPtr)((pScreen)->devPrivates[cfb8_32ScreenPrivateIndex].ptr) + +Bool xf86Overlay8Plus32Init (ScreenPtr pScreen); + +#endif /* _CFB8_32_H */ diff --git a/hw/xfree86/xf8_32bpp/cfb8_32module.c b/hw/xfree86/xf8_32bpp/cfb8_32module.c new file mode 100644 index 000000000..9ed6b2018 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfb8_32module.c @@ -0,0 +1,38 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfb8_32module.c,v 1.6 1999/01/26 05:54:20 dawes Exp $ */ + + +#ifdef XFree86LOADER + +#include "xf86Module.h" + +static MODULESETUPPROTO(xf8_32bppSetup); + +static XF86ModuleVersionInfo VersRec = +{ + "xf8_32bpp", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +XF86ModuleData xf8_32bppModuleData = { &VersRec, xf8_32bppSetup, NULL }; + +static pointer +xf8_32bppSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + if (!LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL, + errmaj, errmin)) + return NULL; + if (!LoadSubModule(module, "cfb32", NULL, NULL, NULL, NULL, + errmaj, errmin)) + return NULL; + return (pointer)1; /* non-NULL required to indicate success */ +} + +#endif diff --git a/hw/xfree86/xf8_32bpp/cfbbstore.c b/hw/xfree86/xf8_32bpp/cfbbstore.c new file mode 100644 index 000000000..919fabf5f --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbbstore.c @@ -0,0 +1,102 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbbstore.c,v 1.2 1999/01/31 12:22:17 dawes Exp $ */ + +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "X.h" +#include "mibstore.h" +#include "regionstr.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" + +void +cfb8_32SaveAreas( + PixmapPtr pPixmap, + RegionPtr prgnSave, + int xorg, + int yorg, + WindowPtr pWin +){ + DDXPointPtr pPt; + DDXPointPtr pPtsInit; + BoxPtr pBox; + int i; + ScreenPtr pScreen = pPixmap->drawable.pScreen; + PixmapPtr pScrPix; + + if(pPixmap->drawable.bitsPerPixel == 32) { + cfb32SaveAreas(pPixmap, prgnSave, xorg, yorg, pWin); + return; + } + + i = REGION_NUM_RECTS(prgnSave); + pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec)); + if (!pPtsInit) + return; + + pBox = REGION_RECTS(prgnSave); + pPt = pPtsInit; + while (--i >= 0) { + pPt->x = pBox->x1 + xorg; + pPt->y = pBox->y1 + yorg; + pPt++; + pBox++; + } + + pScrPix = (PixmapPtr) pScreen->devPrivate; + + cfbDoBitblt32To8((DrawablePtr) pScrPix, (DrawablePtr)pPixmap, + GXcopy, prgnSave, pPtsInit, ~0L, 0); + + DEALLOCATE_LOCAL (pPtsInit); +} + + +void +cfb8_32RestoreAreas( + PixmapPtr pPixmap, + RegionPtr prgnRestore, + int xorg, + int yorg, + WindowPtr pWin +){ + DDXPointPtr pPt; + DDXPointPtr pPtsInit; + BoxPtr pBox; + int i; + ScreenPtr pScreen = pPixmap->drawable.pScreen; + PixmapPtr pScrPix; + + i = REGION_NUM_RECTS(prgnRestore); + pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec)); + if (!pPtsInit) + return; + + pBox = REGION_RECTS(prgnRestore); + pPt = pPtsInit; + while (--i >= 0) { + pPt->x = pBox->x1 - xorg; + pPt->y = pBox->y1 - yorg; + pPt++; + pBox++; + } + + pScrPix = (PixmapPtr) pScreen->devPrivate; + + if(pPixmap->drawable.bitsPerPixel == 32) { + if(pWin->drawable.depth == 24) + cfb32DoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix, + GXcopy, prgnRestore, pPtsInit, 0x00ffffff); + else + cfb32DoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix, + GXcopy, prgnRestore, pPtsInit, ~0); + } else { + cfbDoBitblt8To32((DrawablePtr)pPixmap, (DrawablePtr) pScrPix, + GXcopy, prgnRestore, pPtsInit, ~0L, 0); + } + + DEALLOCATE_LOCAL (pPtsInit); +} diff --git a/hw/xfree86/xf8_32bpp/cfbcpyarea.c b/hw/xfree86/xf8_32bpp/cfbcpyarea.c new file mode 100644 index 000000000..752e56db8 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbcpyarea.c @@ -0,0 +1,540 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbcpyarea.c,v 1.5 2000/02/29 00:17:16 mvojkovi Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "servermd.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "resource.h" +#include "colormap.h" +#include "colormapst.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" +#include "mistruct.h" +#include "dix.h" +#include "mibstore.h" + + +RegionPtr +cfb8_32CopyArea( + DrawablePtr pSrcDraw, + DrawablePtr pDstDraw, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + + if(pSrcDraw->bitsPerPixel == 32) { + if(pDstDraw->bitsPerPixel == 32) { + if((pGC->alu == GXcopy) && (pGC->planemask == 0xff000000)) { + return cfb32BitBlt (pSrcDraw, pDstDraw, + pGC, srcx, srcy, width, height, dstx, dsty, + cfbDoBitblt8To8GXcopy, 0L); + } + return(cfb32CopyArea(pSrcDraw, pDstDraw, pGC, srcx, srcy, + width, height, dstx, dsty)); + } else { + /* have to translate 32 -> 8 copies */ + return cfb32BitBlt (pSrcDraw, pDstDraw, + pGC, srcx, srcy, width, height, dstx, dsty, + cfbDoBitblt32To8, 0L); + } + } else { + if(pDstDraw->bitsPerPixel == 32) { + /* have to translate 8 -> 32 copies */ + return cfb32BitBlt (pSrcDraw, pDstDraw, + pGC, srcx, srcy, width, height, dstx, dsty, + cfbDoBitblt8To32, 0L); + } else { + return(cfbCopyArea(pSrcDraw, pDstDraw, pGC, srcx, srcy, + width, height, dstx, dsty)); + } + } +} + + + + +void +cfbDoBitblt8To32( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm, + unsigned long bitPlane +){ + BoxPtr pbox = REGION_RECTS(prgnDst); + int nbox = REGION_NUM_RECTS(prgnDst); + unsigned char *ptr8, *ptr32; + unsigned char *data8, *data32; + int pitch8, pitch32; + int height, width, i; + + cfbGetByteWidthAndPointer(pSrc, pitch8, ptr8); + cfbGetByteWidthAndPointer(pDst, pitch32, ptr32); + ptr32 += 3; /* point to the top byte */ + + pm >>= 24; + + if((pm == 0xff) && (rop == GXcopy)) { + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pptSrc->y * pitch8) + pptSrc->x; + data32 = ptr32 + (pbox->y1 * pitch32) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + for(i = 0; i < width; i++) + data32[i << 2] = data8[i]; + data8 += pitch8; + data32 += pitch32; + } + } + } else { /* it ain't pretty, but hey */ + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pptSrc->y * pitch8) + pptSrc->x; + data32 = ptr32 + (pbox->y1 * pitch32) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + switch(rop) { + case GXcopy: + for(i = 0; i < width; i++) + data32[i<<2] = (data8[i] & pm) | (data32[i<<2] & ~pm); + break; + case GXor: + for(i = 0; i < width; i++) + data32[i<<2] |= data8[i] & pm; + break; + case GXclear: + for(i = 0; i < width; i++) + data32[i<<2] &= ~pm; + break; + case GXand: + for(i = 0; i < width; i++) + data32[i<<2] &= data8[i] | ~pm; + break; + case GXandReverse: + for(i = 0; i < width; i++) + data32[i<<2] = ~data32[i<<2] & (data8[i] | ~pm); + break; + case GXandInverted: + for(i = 0; i < width; i++) + data32[i<<2] &= ~data8[i] | ~pm; + break; + case GXnoop: + return; + case GXxor: + for(i = 0; i < width; i++) + data32[i<<2] ^= data8[i] & pm; + break; + case GXnor: + for(i = 0; i < width; i++) + data32[i<<2] = ~(data32[i<<2] | (data8[i] & pm)); + break; + case GXequiv: + for(i = 0; i < width; i++) + data32[i<<2] = ~(data32[i<<2] ^ (data8[i] & pm)); + break; + case GXinvert: + for(i = 0; i < width; i++) + data32[i<<2] ^= pm; + break; + case GXorReverse: + for(i = 0; i < width; i++) + data32[i<<2] = ~data32[i<<2] | (data8[i] & pm); + break; + case GXcopyInverted: + for(i = 0; i < width; i++) + data32[i<<2] = (~data8[i] & pm) | (data32[i<<2] & ~pm); + break; + case GXorInverted: + for(i = 0; i < width; i++) + data32[i<<2] |= ~data8[i] & pm; + break; + case GXnand: + for(i = 0; i < width; i++) + data32[i<<2] = ~(data32[i<<2] & (data8[i] | ~pm)); + break; + case GXset: + for(i = 0; i < width; i++) + data32[i<<2] |= pm; + break; + } + data8 += pitch8; + data32 += pitch32; + } + } + } +} + + +void +cfbDoBitblt32To8( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm, + unsigned long bitPlane +){ + BoxPtr pbox = REGION_RECTS(prgnDst); + int nbox = REGION_NUM_RECTS(prgnDst); + unsigned char *ptr8, *ptr32; + unsigned char *data8, *data32; + int pitch8, pitch32; + int height, width, i; + + cfbGetByteWidthAndPointer(pDst, pitch8, ptr8); + cfbGetByteWidthAndPointer(pSrc, pitch32, ptr32); + ptr32 += 3; /* point to the top byte */ + + if(((pm & 0xff) == 0xff) && (rop == GXcopy)) { + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pbox->y1 * pitch8) + pbox->x1; + data32 = ptr32 + (pptSrc->y * pitch32) + (pptSrc->x << 2); + + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + for(i = 0; i < width; i++) + data8[i] = data32[i << 2]; + data8 += pitch8; + data32 += pitch32; + } + } + } else { + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pbox->y1 * pitch8) + pbox->x1; + data32 = ptr32 + (pptSrc->y * pitch32) + (pptSrc->x << 2); + + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + switch(rop) { + case GXcopy: + for(i = 0; i < width; i++) + data8[i] = (data32[i<<2] & pm) | (data8[i] & ~pm); + break; + case GXor: + for(i = 0; i < width; i++) + data8[i] |= data32[i<<2] & pm; + break; + case GXclear: + for(i = 0; i < width; i++) + data8[i] &= ~pm; + break; + case GXand: + for(i = 0; i < width; i++) + data8[i] &= data32[i<<2] | ~pm; + break; + case GXandReverse: + for(i = 0; i < width; i++) + data8[i] = ~data8[i] & (data32[i<<2] | ~pm); + break; + case GXandInverted: + for(i = 0; i < width; i++) + data8[i] &= ~data32[i<<2] | ~pm; + break; + case GXnoop: + return; + case GXxor: + for(i = 0; i < width; i++) + data8[i] ^= data32[i<<2] & pm; + break; + case GXnor: + for(i = 0; i < width; i++) + data8[i] = ~(data8[i] | (data32[i<<2] & pm)); + break; + case GXequiv: + for(i = 0; i < width; i++) + data8[i] = ~(data8[i] ^ (data32[i<<2] & pm)); + break; + case GXinvert: + for(i = 0; i < width; i++) + data8[i] ^= pm; + break; + case GXorReverse: + for(i = 0; i < width; i++) + data8[i] = ~data8[i] | (data32[i<<2] & pm); + break; + case GXcopyInverted: + for(i = 0; i < width; i++) + data8[i] = (~data32[i<<2] & pm) | (data8[i] & ~pm); + break; + case GXorInverted: + for(i = 0; i < width; i++) + data8[i] |= ~data32[i<<2] & pm; + break; + case GXnand: + for(i = 0; i < width; i++) + data8[i] = ~(data8[i] & (data32[i<<2] | ~pm)); + break; + case GXset: + for(i = 0; i < width; i++) + data8[i] |= pm; + break; + } + data8 += pitch8; + data32 += pitch32; + } + } + } +} + + + +static void +Do8To8Blt( + unsigned char *SrcPtr, + int SrcPitch, + unsigned char *DstPtr, + int DstPitch, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir +){ + int i, j, width, height, ydir2; + CARD8 *src, *dst; + + SrcPtr += 3; + DstPtr += 3; + xdir *= 4; + ydir2 = ydir * DstPitch; + ydir *= SrcPitch; + + for(;nbox; pbox++, pptSrc++, nbox--) { + src = SrcPtr + (pptSrc->y * SrcPitch) + (pptSrc->x << 2); + dst = DstPtr + (pbox->y1 * DstPitch) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(ydir < 0) { + src += (height - 1) * SrcPitch; + dst += (height - 1) * DstPitch; + } + + if(xdir < 0) { + register int tmp = (width - 1) << 2; + src += tmp; + dst += tmp; + } + + while(height--) { + for(i = width, j = 0; i--; j+=xdir) + dst[j] = src[j]; + src += ydir; + dst += ydir2; + } + } +} + +static void +Do24To24Blt( + unsigned char *SrcPtr, + int SrcPitch, + unsigned char *DstPtr, + int DstPitch, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir +){ + int i, j, width, height, ydir2; + CARD8 *src, *dst; + + xdir *= 4; + ydir2 = ydir * DstPitch; + ydir *= SrcPitch; + + for(;nbox; pbox++, pptSrc++, nbox--) { + src = SrcPtr + (pptSrc->y * SrcPitch) + (pptSrc->x << 2); + dst = DstPtr + (pbox->y1 * DstPitch) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(ydir < 0) { + src += (height - 1) * SrcPitch; + dst += (height - 1) * DstPitch; + } + + if(xdir < 0) { + register int tmp = (width - 1) << 2; + src += tmp; + dst += tmp; + } + + while(height--) { + for(i = width, j = 0; i--; j+=xdir) { + *((CARD16*)(dst + j)) = *((CARD32*)(src + j)); + dst[j + 2] = src[j + 2]; + } + src += ydir; + dst += ydir2; + } + } +} + + +static void +cfb8_32DoBitBlt( + DrawablePtr pSrc, + DrawablePtr pDst, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + void (*DoBlt)() +){ + int nbox, careful, SrcPitch, DstPitch; + BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2; + DDXPointPtr pptTmp, pptNew1, pptNew2; + int xdir, ydir; + unsigned char *SrcPtr, *DstPtr; + + /* XXX we have to err on the side of safety when both are windows, + * because we don't know if IncludeInferiors is being used. + */ + careful = ((pSrc == pDst) || + ((pSrc->type == DRAWABLE_WINDOW) && + (pDst->type == DRAWABLE_WINDOW))); + + pbox = REGION_RECTS(prgnDst); + nbox = REGION_NUM_RECTS(prgnDst); + + pboxNew1 = NULL; + pptNew1 = NULL; + pboxNew2 = NULL; + pptNew2 = NULL; + if (careful && (pptSrc->y < pbox->y1)) { + /* walk source botttom to top */ + ydir = -1; + + if (nbox > 1) { + /* keep ordering in each band, reverse order of bands */ + pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox); + if(!pboxNew1) + return; + pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); + if(!pptNew1) { + DEALLOCATE_LOCAL(pboxNew1); + return; + } + pboxBase = pboxNext = pbox+nbox-1; + while (pboxBase >= pbox) { + while ((pboxNext >= pbox) && + (pboxBase->y1 == pboxNext->y1)) + pboxNext--; + pboxTmp = pboxNext+1; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp <= pboxBase) { + *pboxNew1++ = *pboxTmp++; + *pptNew1++ = *pptTmp++; + } + pboxBase = pboxNext; + } + pboxNew1 -= nbox; + pbox = pboxNew1; + pptNew1 -= nbox; + pptSrc = pptNew1; + } + } else { + /* walk source top to bottom */ + ydir = 1; + } + + if (careful && (pptSrc->x < pbox->x1)) { + /* walk source right to left */ + xdir = -1; + + if (nbox > 1) { + /* reverse order of rects in each band */ + pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox); + pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); + if(!pboxNew2 || !pptNew2) { + if (pptNew2) DEALLOCATE_LOCAL(pptNew2); + if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2); + if (pboxNew1) { + DEALLOCATE_LOCAL(pptNew1); + DEALLOCATE_LOCAL(pboxNew1); + } + return; + } + pboxBase = pboxNext = pbox; + while (pboxBase < pbox+nbox) { + while ((pboxNext < pbox+nbox) && + (pboxNext->y1 == pboxBase->y1)) + pboxNext++; + pboxTmp = pboxNext; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp != pboxBase) { + *pboxNew2++ = *--pboxTmp; + *pptNew2++ = *--pptTmp; + } + pboxBase = pboxNext; + } + pboxNew2 -= nbox; + pbox = pboxNew2; + pptNew2 -= nbox; + pptSrc = pptNew2; + } + } else { + /* walk source left to right */ + xdir = 1; + } + + cfbGetByteWidthAndPointer(pSrc, SrcPitch, SrcPtr); + cfbGetByteWidthAndPointer(pDst, DstPitch, DstPtr); + + (*DoBlt)(SrcPtr,SrcPitch,DstPtr,DstPitch,nbox,pptSrc,pbox,xdir,ydir); + + if (pboxNew2) { + DEALLOCATE_LOCAL(pptNew2); + DEALLOCATE_LOCAL(pboxNew2); + } + if (pboxNew1) { + DEALLOCATE_LOCAL(pptNew1); + DEALLOCATE_LOCAL(pboxNew1); + } + +} + + +/* A couple routines to speed up full planemask copies */ + +void +cfbDoBitblt8To8GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm, + unsigned long bitPlane +){ + cfb8_32DoBitBlt(pSrc, pDst, prgnDst, pptSrc, Do8To8Blt); +} + + +void +cfbDoBitblt24To24GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm, + unsigned long bitPlane +){ + cfb8_32DoBitBlt(pSrc, pDst, prgnDst, pptSrc, Do24To24Blt); +} diff --git a/hw/xfree86/xf8_32bpp/cfbcpyplane.c b/hw/xfree86/xf8_32bpp/cfbcpyplane.c new file mode 100644 index 000000000..248ca0869 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbcpyplane.c @@ -0,0 +1,39 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbcpyplane.c,v 1.1 1999/01/03 03:58:55 dawes Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "Xproto.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "regionstr.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" + + +RegionPtr +cfb8_32CopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + /* There's actually much more to it than this */ + + if((pDst->bitsPerPixel == 8) && (pSrc->bitsPerPixel != 32)){ + return(cfbCopyPlane(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)); + } + + + return(miCopyPlane (pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)); +} diff --git a/hw/xfree86/xf8_32bpp/cfbgc.c b/hw/xfree86/xf8_32bpp/cfbgc.c new file mode 100644 index 000000000..6c13ca721 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbgc.c @@ -0,0 +1,663 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbgc.c,v 1.4 2001/12/14 19:59:52 dawes Exp $ */ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +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. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ + + +/* + +PSZ 8 16 24 32 +PIXEL_ADDR True True True True +NO_ONE_RECT False False False False +WriteBitGroup True True True True +FOUR_BIT_CODE True False False False +LOWMEMFTPT False False False False + +*/ + + +/* This gets built twice. Once for 8bpp and another for 32bpp */ + +#include "X.h" +#include "Xmd.h" +#include "Xproto.h" +#include "cfb.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "region.h" + +#include "mistruct.h" +#include "mibstore.h" +#include "migc.h" +#include "mioverlay.h" + +#include "cfb8_32.h" +#include "cfbmskbits.h" +#include "cfb8bit.h" + + +#if PSZ == 8 +# define useTEGlyphBlt cfbTEGlyphBlt8 +#else +# ifdef WriteBitGroup +# define useTEGlyphBlt cfbImageGlyphBlt8 +# else +# define useTEGlyphBlt cfbTEGlyphBlt +# endif +#endif + +#ifdef WriteBitGroup +# define useImageGlyphBlt cfbImageGlyphBlt8 +# define usePolyGlyphBlt cfbPolyGlyphBlt8 +#else +# define useImageGlyphBlt miImageGlyphBlt +# define usePolyGlyphBlt miPolyGlyphBlt +#endif + +#ifdef FOUR_BIT_CODE +# define usePushPixels cfbPushPixels8 +#else +#ifndef LOWMEMFTPT +# define usePushPixels mfbPushPixels +#else +# define usePushPixels miPushPixels +#endif /* ifndef LOWMEMFTPT */ +#endif + +#ifdef PIXEL_ADDR +# define ZeroPolyArc cfbZeroPolyArcSS8Copy +#else +# define ZeroPolyArc miZeroPolyArc +#endif + + +static GCOps cfb8_32TEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps cfb8_32NonTEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps cfb8_32TEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, + ZeroPolyArc, + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps cfb8_32NonTEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, +#ifdef PIXEL_ADDR + cfbZeroPolyArcSS8Copy, +#else + miZeroPolyArc, +#endif + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps * +cfb8_32MatchCommon (GCPtr pGC, cfbPrivGCPtr devPriv) +{ + if (pGC->lineWidth != 0) + return 0; + if (pGC->lineStyle != LineSolid) + return 0; + if (pGC->fillStyle != FillSolid) + return 0; + if (devPriv->rop != GXcopy) + return 0; + if (pGC->font && + FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 && + FONTMINBOUNDS(pGC->font,characterWidth) >= 0) + { + if (TERMINALFONT(pGC->font) +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) +#ifdef NO_ONE_RECT + return &cfb8_32TEOps1Rect; +#else + if (devPriv->oneRect) + return &cfb8_32TEOps1Rect; + else + return &cfb8_32TEOps; +#endif + else +#ifdef NO_ONE_RECT + return &cfb8_32NonTEOps1Rect; +#else + if (devPriv->oneRect) + return &cfb8_32NonTEOps1Rect; + else + return &cfb8_32NonTEOps; +#endif + } + return 0; +} + + +/* Clipping conventions + if the drawable is a window + CT_REGION ==> pCompositeClip really is the composite + CT_other ==> pCompositeClip is the window clip region + if the drawable is a pixmap + CT_REGION ==> pCompositeClip is the translated client region + clipped to the pixmap boundary + CT_other ==> pCompositeClip is the pixmap bounding box +*/ + +void +#if PSZ == 8 +cfb8_32ValidateGC8( +#else +cfb8_32ValidateGC32( +#endif + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +){ + int mask; /* stateChanges */ + int index; /* used for stepping through bitfields */ + int new_rrop; + int new_line, new_text, new_fillspans, new_fillarea; + /* flags for changing the proc vector */ + cfbPrivGCPtr devPriv; + int oneRect; + + pGC->lastWinOrg.x = pDrawable->x; + pGC->lastWinOrg.y = pDrawable->y; + devPriv = cfbGetGCPrivate(pGC); + + new_rrop = FALSE; + new_line = FALSE; + new_text = FALSE; + new_fillspans = FALSE; + new_fillarea = FALSE; + + /* + * if the client clip is different or moved OR the subwindowMode has + * changed OR the window's clip has changed since the last validation + * we need to recompute the composite clip + */ + + if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || + (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))) + { + miComputeCompositeClip (pGC, pDrawable); +#ifdef NO_ONE_RECT + devPriv->oneRect = FALSE; +#else + oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1; + if (oneRect != devPriv->oneRect) + new_line = TRUE; + devPriv->oneRect = oneRect; +#endif + } + + mask = changes; + while (mask) { + index = lowbit (mask); + mask &= ~index; + + switch (index) { + case GCFunction: + case GCForeground: + new_rrop = TRUE; + break; + case GCPlaneMask: + new_rrop = TRUE; + new_text = TRUE; + break; + case GCBackground: + break; + case GCLineStyle: + case GCLineWidth: + new_line = TRUE; + break; + case GCJoinStyle: + case GCCapStyle: + break; + case GCFillStyle: + new_text = TRUE; + new_fillspans = TRUE; + new_line = TRUE; + new_fillarea = TRUE; + break; + case GCFillRule: + break; + case GCTile: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCStipple: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCTileStipXOrigin: + case GCTileStipYOrigin: + break; + case GCFont: + new_text = TRUE; + break; + case GCSubwindowMode: + case GCGraphicsExposures: + case GCClipXOrigin: + case GCClipYOrigin: + case GCClipMask: + case GCDashOffset: + case GCDashList: + case GCArcMode: + default: + break; + } + } + + /* + * If the drawable has changed, ensure suitable + * entries are in the proc vector. + */ + if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) + new_fillspans = TRUE; /* deal with FillSpans later */ + + if (new_rrop) + { + int old_rrop; + + old_rrop = devPriv->rop; + devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel, + pGC->planemask, + &devPriv->and, &devPriv->xor); + if (old_rrop == devPriv->rop) + new_rrop = FALSE; + else + { +#ifdef PIXEL_ADDR + new_line = TRUE; +#endif +#ifdef WriteBitGroup + new_text = TRUE; +#endif + new_fillspans = TRUE; + new_fillarea = TRUE; + } + } + + if(!pGC->ops) + pGC->ops = & cfb8_32NonTEOps; + + if (new_rrop || new_fillspans || new_text || new_fillarea || new_line) + { + GCOps *newops; + + if ((newops = cfb8_32MatchCommon (pGC, devPriv))) + { + if (pGC->ops->devPrivate.val) + miDestroyGCOps (pGC->ops); + pGC->ops = newops; + new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0; + } + else + { + if (!pGC->ops->devPrivate.val) + { + pGC->ops = miCreateGCOps (pGC->ops); + pGC->ops->devPrivate.val = 1; + } + } + } + + /* deal with the changes we've collected */ + if (new_line) + { + pGC->ops->FillPolygon = miFillPolygon; +#ifdef NO_ONE_RECT + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#else + if (devPriv->oneRect && pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#endif + if (pGC->lineWidth == 0) + { +#ifdef PIXEL_ADDR + if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)) + { + switch (devPriv->rop) + { + case GXxor: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor; + break; + case GXcopy: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy; + break; + default: + pGC->ops->PolyArc = cfbZeroPolyArcSS8General; + break; + } + } + else +#endif + pGC->ops->PolyArc = miZeroPolyArc; + } + else + pGC->ops->PolyArc = miPolyArc; + pGC->ops->PolySegment = miPolySegment; + switch (pGC->lineStyle) + { + case LineSolid: + if(pGC->lineWidth == 0) + { + if (pGC->fillStyle == FillSolid) + { +#if defined(PIXEL_ADDR) && !defined(NO_ONE_RECT) + if (devPriv->oneRect && + ((pDrawable->x >= pGC->pScreen->width - 32768) && + (pDrawable->y >= pGC->pScreen->height - 32768))) + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } else +#endif +#ifdef NO_ONE_RECT + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } +#else + { + pGC->ops->Polylines = cfbLineSS; + pGC->ops->PolySegment = cfbSegmentSS; + } +#endif + } + else + pGC->ops->Polylines = miZeroLine; + } + else + pGC->ops->Polylines = miWideLine; + break; + case LineOnOffDash: + case LineDoubleDash: + if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) + { + pGC->ops->Polylines = cfbLineSD; + pGC->ops->PolySegment = cfbSegmentSD; + } else + pGC->ops->Polylines = miWideDash; + break; + } + } + + if (new_text && (pGC->font)) + { + if (FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 || + FONTMINBOUNDS(pGC->font,characterWidth) < 0) + { + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + else + { +#ifdef WriteBitGroup + if (pGC->fillStyle == FillSolid) + { + if (devPriv->rop == GXcopy) + pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8; + else +#ifdef FOUR_BIT_CODE + pGC->ops->PolyGlyphBlt = cfbPolyGlyphRop8; +#else + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; +#endif + } + else +#endif + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + /* special case ImageGlyphBlt for terminal emulator fonts */ +#if !defined(WriteBitGroup) || PSZ == 8 + if (TERMINALFONT(pGC->font) && + (pGC->planemask & PMSK) == PMSK +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) + { + pGC->ops->ImageGlyphBlt = useTEGlyphBlt; + } + else +#endif + { +#ifdef WriteBitGroup + if (devPriv->rop == GXcopy && + pGC->fillStyle == FillSolid && + (pGC->planemask & PMSK) == PMSK) + pGC->ops->ImageGlyphBlt = cfbImageGlyphBlt8; + else +#endif + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + } + } + + + if (new_fillspans) { + switch (pGC->fillStyle) { + case FillSolid: + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillSpans = cfbSolidSpansCopy; + break; + case GXxor: + pGC->ops->FillSpans = cfbSolidSpansXor; + break; + default: + pGC->ops->FillSpans = cfbSolidSpansGeneral; + break; + } + break; + case FillTiled: + pGC->ops->FillSpans = cfbUnnaturalTileFS; + break; + case FillStippled: + case FillOpaqueStippled: + pGC->ops->FillSpans = cfbUnnaturalStippleFS; + break; + default: + FatalError("cfbValidateGC: illegal fillStyle\n"); + } + } /* end of new_fillspans */ + + if (new_fillarea) { +#ifndef FOUR_BIT_CODE + pGC->ops->PolyFillRect = miPolyFillRect; + if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) + { + pGC->ops->PolyFillRect = cfbPolyFillRect; + } +#endif +#ifdef FOUR_BIT_CODE +#ifndef LOWMEMFTPT + pGC->ops->PushPixels = mfbPushPixels; +#else + pGC->ops->PushPixels = miPushPixels; +#endif /* ifndef LOWMEMFTPT */ + if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy) + pGC->ops->PushPixels = cfbPushPixels8; +#endif + pGC->ops->PolyFillArc = miPolyFillArc; + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) + { + case GXcopy: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy; + break; + default: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidGeneral; + break; + } + } + } +} diff --git a/hw/xfree86/xf8_32bpp/cfbgcmisc.c b/hw/xfree86/xf8_32bpp/cfbgcmisc.c new file mode 100644 index 000000000..d8a6f4608 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbgcmisc.c @@ -0,0 +1,146 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbgcmisc.c,v 1.3 2000/02/29 00:17:16 mvojkovi Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "Xproto.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "region.h" + +#include "mistruct.h" +#include "mibstore.h" +#include "migc.h" + + +static void cfb8_32ValidateGC(GCPtr, unsigned long, DrawablePtr); +static void cfb8_32DestroyGC(GCPtr pGC); +static void cfb32DestroyGC_Underlay(GCPtr pGC); + +static +GCFuncs cfb8_32GCFuncs = { + cfb8_32ValidateGC, + miChangeGC, + miCopyGC, + cfb8_32DestroyGC, + miChangeClip, + miDestroyClip, + miCopyClip, +}; + + +static +GCFuncs cfb32GCFuncs_Underlay = { + cfb32ValidateGC_Underlay, + miChangeGC, + miCopyGC, + cfb32DestroyGC_Underlay, + miChangeClip, + miDestroyClip, + miCopyClip, +}; + +static void +cfb32DestroyGC_Underlay(GCPtr pGC) +{ + if (pGC->freeCompClip) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + + if(pGC->ops) + miDestroyGCOps(pGC->ops); +} + + +static void +cfb8_32DestroyGC(GCPtr pGC) +{ + cfb8_32GCPtr pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC); + + if (pGC->freeCompClip) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + if(pGCPriv->Ops8bpp) + miDestroyGCOps(pGCPriv->Ops8bpp); + if(pGCPriv->Ops32bpp) + miDestroyGCOps(pGCPriv->Ops32bpp); +} + +Bool +cfb8_32CreateGC(GCPtr pGC) +{ + cfb8_32GCPtr pGCPriv; + cfbPrivGC *pPriv; + + if (PixmapWidthPaddingInfo[pGC->depth].padPixelsLog2 == LOG2_BITMAP_PAD) + return (mfbCreateGC(pGC)); + + pGC->clientClip = NULL; + pGC->clientClipType = CT_NONE; + pGC->miTranslate = 1; + pGC->fExpose = TRUE; + pGC->freeCompClip = FALSE; + pGC->pRotatedPixmap = (PixmapPtr) NULL; + + pPriv = cfbGetGCPrivate(pGC); + pPriv->rop = pGC->alu; + pPriv->oneRect = FALSE; + + pGC->ops = NULL; + + if (pGC->depth == 8) { + pGC->funcs = &cfb8_32GCFuncs; + + pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC); + pGCPriv->Ops8bpp = NULL; + pGCPriv->Ops32bpp = NULL; + pGCPriv->OpsAre8bpp = FALSE; + pGCPriv->changes = 0; + } else + pGC->funcs = &cfb32GCFuncs_Underlay; + + return TRUE; +} + + +static void +cfb8_32ValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + cfb8_32GCPtr pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC); + + if(pDraw->bitsPerPixel == 32) { + if(pGCPriv->OpsAre8bpp) { + int origChanges = changes; + pGC->ops = pGCPriv->Ops32bpp; + changes |= pGCPriv->changes; + pGCPriv->changes = origChanges; + pGCPriv->OpsAre8bpp = FALSE; + } else + pGCPriv->changes |= changes; + + cfb8_32ValidateGC32(pGC, changes, pDraw); + pGCPriv->Ops32bpp = pGC->ops; + } else { /* bitsPerPixel == 8 */ + if(!pGCPriv->OpsAre8bpp) { + int origChanges = changes; + pGC->ops = pGCPriv->Ops8bpp; + changes |= pGCPriv->changes; + pGCPriv->changes = origChanges; + pGCPriv->OpsAre8bpp = TRUE; + } else + pGCPriv->changes |= changes; + + cfb8_32ValidateGC8(pGC, changes, pDraw); + pGCPriv->Ops8bpp = pGC->ops; + } +} + diff --git a/hw/xfree86/xf8_32bpp/cfbgcunder.c b/hw/xfree86/xf8_32bpp/cfbgcunder.c new file mode 100644 index 000000000..d263b8b9e --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbgcunder.c @@ -0,0 +1,636 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbgcunder.c,v 1.5 2001/12/14 19:59:52 dawes Exp $ */ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +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. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ +#define PSZ 32 + +#include "X.h" +#include "Xmd.h" +#include "Xproto.h" +#include "cfb.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "region.h" + +#include "mistruct.h" +#include "mibstore.h" +#include "migc.h" +#include "mioverlay.h" + +#include "cfbmskbits.h" +#include "cfb8bit.h" + +#ifdef WriteBitGroup +# define useTEGlyphBlt cfbImageGlyphBlt8 +#else +# define useTEGlyphBlt cfbTEGlyphBlt +#endif + +#ifdef WriteBitGroup +# define useImageGlyphBlt cfbImageGlyphBlt8 +# define usePolyGlyphBlt cfbPolyGlyphBlt8 +#else +# define useImageGlyphBlt miImageGlyphBlt +# define usePolyGlyphBlt miPolyGlyphBlt +#endif + +#ifdef FOUR_BIT_CODE +# define usePushPixels cfbPushPixels8 +#else +#ifndef LOWMEMFTPT +# define usePushPixels mfbPushPixels +#else +# define usePushPixels miPushPixels +#endif /* ifndef LOWMEMFTPT */ +#endif + +#ifdef PIXEL_ADDR +# define ZeroPolyArc cfbZeroPolyArcSS8Copy +#else +# define ZeroPolyArc miZeroPolyArc +#endif + + +static GCOps cfbTEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps cfbNonTEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps cfbTEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, + ZeroPolyArc, + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps cfbNonTEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, +#ifdef PIXEL_ADDR + cfbZeroPolyArcSS8Copy, +#else + miZeroPolyArc, +#endif + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +#ifdef NEED_LINEHELPER + ,NULL +#endif +}; + +static GCOps * +cfb32MatchCommon_Underlay (pGC, devPriv) + GCPtr pGC; + cfbPrivGCPtr devPriv; +{ + if (pGC->lineWidth != 0) + return 0; + if (pGC->lineStyle != LineSolid) + return 0; + if (pGC->fillStyle != FillSolid) + return 0; + if (devPriv->rop != GXcopy) + return 0; + if (pGC->font && + FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 && + FONTMINBOUNDS(pGC->font,characterWidth) >= 0) + { + if (TERMINALFONT(pGC->font) +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) +#ifdef NO_ONE_RECT + return &cfbTEOps1Rect; +#else + if (devPriv->oneRect) + return &cfbTEOps1Rect; + else + return &cfbTEOps; +#endif + else +#ifdef NO_ONE_RECT + return &cfbNonTEOps1Rect; +#else + if (devPriv->oneRect) + return &cfbNonTEOps1Rect; + else + return &cfbNonTEOps; +#endif + } + return 0; +} + + +void +cfb32ValidateGC_Underlay( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +){ + int mask; /* stateChanges */ + int index; /* used for stepping through bitfields */ + int new_rrop; + int new_line, new_text, new_fillspans, new_fillarea; + /* flags for changing the proc vector */ + cfbPrivGCPtr devPriv; + int oneRect; + + pGC->lastWinOrg.x = pDrawable->x; + pGC->lastWinOrg.y = pDrawable->y; + devPriv = cfbGetGCPrivate(pGC); + + new_rrop = FALSE; + new_line = FALSE; + new_text = FALSE; + new_fillspans = FALSE; + new_fillarea = FALSE; + + /* + * if the client clip is different or moved OR the subwindowMode has + * changed OR the window's clip has changed since the last validation + * we need to recompute the composite clip + */ + + if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || + (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) + ) + { + if(pDrawable->type == DRAWABLE_WINDOW) + miOverlayComputeCompositeClip (pGC, (WindowPtr)pDrawable); + else + miComputeCompositeClip (pGC, pDrawable); +#ifdef NO_ONE_RECT + devPriv->oneRect = FALSE; +#else + oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1; + if (oneRect != devPriv->oneRect) + new_line = TRUE; + devPriv->oneRect = oneRect; +#endif + } + + mask = changes; + while (mask) { + index = lowbit (mask); + mask &= ~index; + + switch (index) { + case GCFunction: + case GCForeground: + new_rrop = TRUE; + break; + case GCPlaneMask: + new_rrop = TRUE; + new_text = TRUE; + break; + case GCBackground: + break; + case GCLineStyle: + case GCLineWidth: + new_line = TRUE; + break; + case GCJoinStyle: + case GCCapStyle: + break; + case GCFillStyle: + new_text = TRUE; + new_fillspans = TRUE; + new_line = TRUE; + new_fillarea = TRUE; + break; + case GCFillRule: + break; + case GCTile: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCStipple: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCTileStipXOrigin: + case GCTileStipYOrigin: + break; + case GCFont: + new_text = TRUE; + break; + case GCSubwindowMode: + case GCGraphicsExposures: + case GCClipXOrigin: + case GCClipYOrigin: + case GCClipMask: + case GCDashOffset: + case GCDashList: + case GCArcMode: + default: + break; + } + } + + /* + * If the drawable has changed, ensure suitable + * entries are in the proc vector. + */ + if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) + new_fillspans = TRUE; /* deal with FillSpans later */ + + if (new_rrop) + { + int old_rrop; + + old_rrop = devPriv->rop; + devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel, + pGC->planemask, + &devPriv->and, &devPriv->xor); + if (old_rrop == devPriv->rop) + new_rrop = FALSE; + else + { +#ifdef PIXEL_ADDR + new_line = TRUE; +#endif +#ifdef WriteBitGroup + new_text = TRUE; +#endif + new_fillspans = TRUE; + new_fillarea = TRUE; + } + } + + if(!pGC->ops) + pGC->ops = & cfbNonTEOps; + + + if (new_rrop || new_fillspans || new_text || new_fillarea || new_line) + { + GCOps *newops; + + if ((newops = cfb32MatchCommon_Underlay (pGC, devPriv))) + { + if (pGC->ops->devPrivate.val) + miDestroyGCOps (pGC->ops); + pGC->ops = newops; + new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0; + } + else + { + if (!pGC->ops->devPrivate.val) + { + pGC->ops = miCreateGCOps (pGC->ops); + pGC->ops->devPrivate.val = 1; + } + } + } + + /* deal with the changes we've collected */ + if (new_line) + { + pGC->ops->FillPolygon = miFillPolygon; +#ifdef NO_ONE_RECT + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#else + if (devPriv->oneRect && pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#endif + if (pGC->lineWidth == 0) + { +#ifdef PIXEL_ADDR + if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)) + { + switch (devPriv->rop) + { + case GXxor: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor; + break; + case GXcopy: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy; + break; + default: + pGC->ops->PolyArc = cfbZeroPolyArcSS8General; + break; + } + } + else +#endif + pGC->ops->PolyArc = miZeroPolyArc; + } + else + pGC->ops->PolyArc = miPolyArc; + pGC->ops->PolySegment = miPolySegment; + switch (pGC->lineStyle) + { + case LineSolid: + if(pGC->lineWidth == 0) + { + if (pGC->fillStyle == FillSolid) + { +#if defined(PIXEL_ADDR) && !defined(NO_ONE_RECT) + if (devPriv->oneRect && + ((pDrawable->x >= pGC->pScreen->width - 32768) && + (pDrawable->y >= pGC->pScreen->height - 32768))) + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } else +#endif +#ifdef NO_ONE_RECT + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } +#else + { + pGC->ops->Polylines = cfbLineSS; + pGC->ops->PolySegment = cfbSegmentSS; + } +#endif + } + else + pGC->ops->Polylines = miZeroLine; + } + else + pGC->ops->Polylines = miWideLine; + break; + case LineOnOffDash: + case LineDoubleDash: + if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) + { + pGC->ops->Polylines = cfbLineSD; + pGC->ops->PolySegment = cfbSegmentSD; + } else + pGC->ops->Polylines = miWideDash; + break; + } + } + + if (new_text && (pGC->font)) + { + if (FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 || + FONTMINBOUNDS(pGC->font,characterWidth) < 0) + { + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + else + { +#ifdef WriteBitGroup + if (pGC->fillStyle == FillSolid) + { + if (devPriv->rop == GXcopy) + pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8; + else +#ifdef FOUR_BIT_CODE + pGC->ops->PolyGlyphBlt = cfbPolyGlyphRop8; +#else + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; +#endif + } + else +#endif + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + /* special case ImageGlyphBlt for terminal emulator fonts */ +#if !defined(WriteBitGroup) || PSZ == 8 + if (TERMINALFONT(pGC->font) && + (pGC->planemask & PMSK) == PMSK +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) + { + pGC->ops->ImageGlyphBlt = useTEGlyphBlt; + } + else +#endif + { +#ifdef WriteBitGroup + if (devPriv->rop == GXcopy && + pGC->fillStyle == FillSolid && + (pGC->planemask & PMSK) == PMSK) + pGC->ops->ImageGlyphBlt = cfbImageGlyphBlt8; + else +#endif + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + } + } + + + if (new_fillspans) { + switch (pGC->fillStyle) { + case FillSolid: + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillSpans = cfbSolidSpansCopy; + break; + case GXxor: + pGC->ops->FillSpans = cfbSolidSpansXor; + break; + default: + pGC->ops->FillSpans = cfbSolidSpansGeneral; + break; + } + break; + case FillTiled: + pGC->ops->FillSpans = cfbUnnaturalTileFS; + break; + case FillStippled: + case FillOpaqueStippled: + pGC->ops->FillSpans = cfbUnnaturalStippleFS; + break; + default: + FatalError("cfbValidateGC: illegal fillStyle\n"); + } + } /* end of new_fillspans */ + + if (new_fillarea) { +#ifndef FOUR_BIT_CODE + pGC->ops->PolyFillRect = miPolyFillRect; + if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) + { + pGC->ops->PolyFillRect = cfbPolyFillRect; + } +#endif +#ifdef FOUR_BIT_CODE +#ifndef LOWMEMFTPT + pGC->ops->PushPixels = mfbPushPixels; +#else + pGC->ops->PushPixels = miPushPixels; +#endif /* ifndef LOWMEMFTPT */ + if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy) + pGC->ops->PushPixels = cfbPushPixels8; +#endif + pGC->ops->PolyFillArc = miPolyFillArc; + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) + { + case GXcopy: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy; + break; + default: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidGeneral; + break; + } + } + } +} diff --git a/hw/xfree86/xf8_32bpp/cfbimage.c b/hw/xfree86/xf8_32bpp/cfbimage.c new file mode 100644 index 000000000..1e8550851 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbimage.c @@ -0,0 +1,168 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbimage.c,v 1.2 2000/02/25 00:21:40 mvojkovi Exp $ */ + +#include "X.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "gcstruct.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "servermd.h" +#include "mi.h" + + +void +cfb8_32GetImage ( + DrawablePtr pDraw, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planemask, + char *pdstLine +){ + if(!w || !h) return; + + if (!cfbDrawableEnabled (pDraw)) + return; + + if(pDraw->depth == 24){ + cfb32GetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); + return; + } + + if((pDraw->bitsPerPixel == 8) || (pDraw->bitsPerPixel == 1)){ + cfbGetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); + return; + } + + /* source is depth 8, 32 bpp */ + if(format != ZPixmap) { + miGetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); + return; + } else { + BoxRec box; + DDXPointRec ptSrc; + RegionRec rgnDst; + ScreenPtr pScreen; + PixmapPtr pPixmap; + + pScreen = pDraw->pScreen; + pPixmap = GetScratchPixmapHeader(pScreen, w, h, 8, 8, + PixmapBytePad(w,8), (pointer)pdstLine); + if (!pPixmap) + return; + if ((planemask & 0xff) != 0xff) + bzero((char *)pdstLine, pPixmap->devKind * h); + ptSrc.x = sx + pDraw->x; + ptSrc.y = sy + pDraw->y; + box.x1 = 0; + box.y1 = 0; + box.x2 = w; + box.y2 = h; + REGION_INIT(pScreen, &rgnDst, &box, 1); + cfbDoBitblt32To8(pDraw, (DrawablePtr)pPixmap, GXcopy, &rgnDst, + &ptSrc, planemask, 0); + REGION_UNINIT(pScreen, &rgnDst); + FreeScratchPixmapHeader(pPixmap); + } +} + +void +cfb8_32PutImage ( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + if(!w || !h) return; + + if((pDraw->bitsPerPixel == 8) || (format != XYPixmap)){ + cfbPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage); + return; + } else { /* moving an 8bpp XYPixmap to a 32bpp screen */ + unsigned long oldFg, oldBg; + XID gcv[3]; + unsigned long oldPlanemask; + unsigned long i; + long bytesPer; + + oldPlanemask = pGC->planemask; + oldFg = pGC->fgPixel; + oldBg = pGC->bgPixel; + gcv[0] = ~0L; + gcv[1] = 0; + DoChangeGC(pGC, GCForeground | GCBackground, gcv, 0); + bytesPer = (long)h * BitmapBytePad(w + leftPad); + + for (i = 0x80000000; i & 0xff000000; i >>= 1, pImage += bytesPer) + { + if (i & oldPlanemask) + { + gcv[0] = i; + DoChangeGC(pGC, GCPlaneMask, gcv, 0); + ValidateGC(pDraw, pGC); + (*pGC->ops->PutImage)(pDraw, pGC, 1, x, y, w, h, leftPad, + XYBitmap, pImage); + } + } + gcv[0] = oldPlanemask; + gcv[1] = oldFg; + gcv[2] = oldBg; + DoChangeGC(pGC, GCPlaneMask | GCForeground | GCBackground, gcv, 0); + ValidateGC(pDraw, pGC); + } +} + + + + +void +cfb8_32GetSpans( + DrawablePtr pDraw, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pDst +){ + int pitch, i; + CARD8 *ptr, *ptrBase; + + if (!cfbDrawableEnabled (pDraw)) + return; + + if(pDraw->bitsPerPixel == 1) { + mfbGetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); + return; + } + + if(pDraw->depth == 24) { + cfb32GetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); + return; + } else if(pDraw->bitsPerPixel == 8) { + cfbGetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); + return; + } + + /* gotta get spans from a depth 8 window */ + cfbGetByteWidthAndPointer(pDraw, pitch, ptrBase); + ptrBase += 3; /* point to top byte */ + + while(nspans--) { + ptr = ptrBase + (ppt->y * pitch) + (ppt->x << 2); + + for(i = *pwidth; i--; ptr += 4) + *(pDst++) = *ptr; + + pDst = (char*)((long)(pDst + 3) & ~3L); + + ppt++; pwidth++; + } +} + + diff --git a/hw/xfree86/xf8_32bpp/cfbpntwin.c b/hw/xfree86/xf8_32bpp/cfbpntwin.c new file mode 100644 index 000000000..516decd6c --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbpntwin.c @@ -0,0 +1,177 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbpntwin.c,v 1.5 2001/10/01 13:44:15 eich Exp $ */ + +#include "X.h" + +#include "windowstr.h" +#include "regionstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" + +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" + +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif + +void +cfb8_32PaintWindow( + WindowPtr pWin, + RegionPtr pRegion, + int what +){ + WindowPtr pBgWin; + int xorg, yorg; + + switch (what) { + case PW_BACKGROUND: + switch (pWin->backgroundState) { + case None: + break; + case ParentRelative: + do { + pWin = pWin->parent; + } while (pWin->backgroundState == ParentRelative); + (*pWin->drawable.pScreen->PaintWindowBackground)( + pWin, pRegion, what); + break; + case BackgroundPixmap: + xorg = pWin->drawable.x; + yorg = pWin->drawable.y; +#ifdef PANORAMIX + if(!noPanoramiXExtension) { + int index = pWin->drawable.pScreen->myNum; + if(WindowTable[index] == pWin) { + xorg -= panoramiXdataPtr[index].x; + yorg -= panoramiXdataPtr[index].y; + } + } +#endif + cfb32FillBoxTileOddGeneral ((DrawablePtr)pWin, + (int)REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion), + pWin->background.pixmap, xorg, yorg, GXcopy, + (pWin->drawable.depth == 24) ? 0x00ffffff : 0xff000000); + break; + case BackgroundPixel: + if(pWin->drawable.depth == 24) + cfb8_32FillBoxSolid32 ((DrawablePtr)pWin, + (int)REGION_NUM_RECTS(pRegion), + REGION_RECTS(pRegion), + pWin->background.pixel); + else + cfb8_32FillBoxSolid8 ((DrawablePtr)pWin, + (int)REGION_NUM_RECTS(pRegion), + REGION_RECTS(pRegion), + pWin->background.pixel); + break; + } + break; + case PW_BORDER: + if (pWin->borderIsPixel) { + if(pWin->drawable.depth == 24) { + cfb8_32FillBoxSolid32 ((DrawablePtr)pWin, + (int)REGION_NUM_RECTS(pRegion), + REGION_RECTS(pRegion), + pWin->border.pixel); + } else + cfb8_32FillBoxSolid8 ((DrawablePtr)pWin, + (int)REGION_NUM_RECTS(pRegion), + REGION_RECTS(pRegion), + pWin->border.pixel); + } else { + for (pBgWin = pWin; + pBgWin->backgroundState == ParentRelative; + pBgWin = pBgWin->parent); + + xorg = pBgWin->drawable.x; + yorg = pBgWin->drawable.y; + +#ifdef PANORAMIX + if(!noPanoramiXExtension) { + int index = pWin->drawable.pScreen->myNum; + if(WindowTable[index] == pBgWin) { + xorg -= panoramiXdataPtr[index].x; + yorg -= panoramiXdataPtr[index].y; + } + } +#endif + cfb32FillBoxTileOddGeneral ((DrawablePtr)pWin, + (int)REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion), + pWin->border.pixmap, xorg, yorg, GXcopy, + (pWin->drawable.depth == 24) ? 0x00ffffff : 0xff000000); + } + break; + } + +} + +void +cfb8_32FillBoxSolid8( + DrawablePtr pDraw, + int nbox, + BoxPtr pbox, + unsigned long color +){ + CARD8 *ptr, *data; + int pitch, height, width, i; + CARD8 c = (CARD8)color; + + cfbGetByteWidthAndPointer(pDraw, pitch, ptr); + ptr += 3; /* point to the top byte */ + + while(nbox--) { + data = ptr + (pbox->y1 * pitch) + (pbox->x1 << 2); + width = (pbox->x2 - pbox->x1) << 2; + height = pbox->y2 - pbox->y1; + + while(height--) { + for(i = 0; i < width; i+=4) + data[i] = c; + data += pitch; + } + pbox++; + } +} + + +void +cfb8_32FillBoxSolid32( + DrawablePtr pDraw, + int nbox, + BoxPtr pbox, + unsigned long color +){ + CARD8 *ptr, *data; + CARD16 *ptr2, *data2; + int pitch, pitch2; + int height, width, i; + CARD8 c = (CARD8)(color >> 16); + CARD16 c2 = (CARD16)color; + + cfbGetByteWidthAndPointer(pDraw, pitch, ptr); + cfbGetTypedWidthAndPointer(pDraw, pitch2, ptr2, CARD16, CARD16); + ptr += 2; /* point to the third byte */ + + while(nbox--) { + data = ptr + (pbox->y1 * pitch) + (pbox->x1 << 2); + data2 = ptr2 + (pbox->y1 * pitch2) + (pbox->x1 << 1); + width = (pbox->x2 - pbox->x1) << 1; + height = pbox->y2 - pbox->y1; + + while(height--) { + for(i = 0; i < width; i+=2) { + data[i << 1] = c; + data2[i] = c2; + } + data += pitch; + data2 += pitch2; + } + pbox++; + } +} + diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c new file mode 100644 index 000000000..ce2b8ae8f --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c @@ -0,0 +1,309 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbscrinit.c,v 1.11 2001/04/14 21:17:49 mvojkovi Exp $ */ + + +#include "X.h" +#include "Xmd.h" +#include "misc.h" +#include "servermd.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "resource.h" +#include "colormap.h" +#include "colormapst.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" +#include "micmap.h" +#include "mistruct.h" +#include "dix.h" +#include "mibstore.h" +#include "mioverlay.h" +#include "xf86.h" +#include "xf86str.h" +#include "globals.h" + +/* CAUTION: We require that cfb8 and cfb32 were NOT + compiled with CFB_NEED_SCREEN_PRIVATE */ + +static BSFuncRec cfb8_32BSFuncRec = { + cfb8_32SaveAreas, + cfb8_32RestoreAreas, + (BackingStoreSetClipmaskRgnProcPtr) 0, + (BackingStoreGetImagePixmapProcPtr) 0, + (BackingStoreGetSpansPixmapProcPtr) 0, +}; + + +int cfb8_32GCPrivateIndex; +int cfb8_32ScreenPrivateIndex; +static unsigned long cfb8_32Generation = 0; + +static Bool +cfb8_32AllocatePrivates(ScreenPtr pScreen) +{ + cfb8_32ScreenPtr pScreenPriv; + + if(cfb8_32Generation != serverGeneration) { + if(((cfb8_32GCPrivateIndex = AllocateGCPrivateIndex()) < 0) || + ((cfb8_32ScreenPrivateIndex = AllocateScreenPrivateIndex()) < 0)) + return FALSE; + cfb8_32Generation = serverGeneration; + } + + if (!(pScreenPriv = xalloc(sizeof(cfb8_32ScreenRec)))) + return FALSE; + + pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = (pointer)pScreenPriv; + + + /* All cfb will have the same GC and Window private indicies */ + if(!mfbAllocatePrivates(pScreen,&cfbWindowPrivateIndex, &cfbGCPrivateIndex)) + return FALSE; + + /* The cfb indicies are the mfb indicies. Reallocating them resizes them */ + if(!AllocateWindowPrivate(pScreen,cfbWindowPrivateIndex,sizeof(cfbPrivWin))) + return FALSE; + + if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC))) + return FALSE; + + if(!AllocateGCPrivate(pScreen, cfb8_32GCPrivateIndex, sizeof(cfb8_32GCRec))) + return FALSE; + + return TRUE; +} + +static Bool +cfb8_32SetupScreen( + ScreenPtr pScreen, + pointer pbits, /* pointer to screen bitmap */ + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy, /* dots per inch */ + int width /* pixel width of frame buffer */ +){ + if (!cfb8_32AllocatePrivates(pScreen)) + return FALSE; + pScreen->defColormap = FakeClientID(0); + /* let CreateDefColormap do whatever it wants for pixels */ + pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0; + pScreen->QueryBestSize = mfbQueryBestSize; + /* SaveScreen */ + pScreen->GetImage = cfb8_32GetImage; + pScreen->GetSpans = cfb8_32GetSpans; + pScreen->CreateWindow = cfb8_32CreateWindow; + pScreen->DestroyWindow = cfb8_32DestroyWindow; + pScreen->PositionWindow = cfb8_32PositionWindow; + pScreen->ChangeWindowAttributes = cfb8_32ChangeWindowAttributes; + pScreen->RealizeWindow = cfb32MapWindow; /* OK */ + pScreen->UnrealizeWindow = cfb32UnmapWindow; /* OK */ + pScreen->PaintWindowBackground = cfb8_32PaintWindow; + pScreen->PaintWindowBorder = cfb8_32PaintWindow; + pScreen->CopyWindow = cfb8_32CopyWindow; + pScreen->CreatePixmap = cfb32CreatePixmap; /* OK */ + pScreen->DestroyPixmap = cfb32DestroyPixmap; /* OK */ + pScreen->RealizeFont = mfbRealizeFont; + pScreen->UnrealizeFont = mfbUnrealizeFont; + pScreen->CreateGC = cfb8_32CreateGC; + pScreen->CreateColormap = miInitializeColormap; + pScreen->DestroyColormap = (void (*)())NoopDDA; + pScreen->InstallColormap = miInstallColormap; + pScreen->UninstallColormap = miUninstallColormap; + pScreen->ListInstalledColormaps = miListInstalledColormaps; + pScreen->StoreColors = (void (*)())NoopDDA; + pScreen->ResolveColor = miResolveColor; + pScreen->BitmapToRegion = mfbPixmapToRegion; + + mfbRegisterCopyPlaneProc (pScreen, cfb8_32CopyPlane); + return TRUE; +} + +typedef struct { + pointer pbits; + int width; +} miScreenInitParmsRec, *miScreenInitParmsPtr; + +static Bool +cfb8_32CreateScreenResources(ScreenPtr pScreen) +{ + miScreenInitParmsPtr pScrInitParms; + int pitch; + Bool retval; + + /* get the pitch before mi destroys it */ + pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate; + pitch = pScrInitParms->width << 2; + + if((retval = miCreateScreenResources(pScreen))) { + /* fix the screen pixmap */ + PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate; + pPix->drawable.bitsPerPixel = 32; + pPix->drawable.depth = 8; + pPix->devKind = pitch; + } + + return retval; +} + + +static Bool +cfb8_32CloseScreen (int i, ScreenPtr pScreen) +{ + cfb8_32ScreenPtr pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + if(pScreenPriv->visualData) + xfree(pScreenPriv->visualData); + + xfree((pointer) pScreenPriv); + pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = NULL; + + return(cfb32CloseScreen(i, pScreen)); +} + +static void +cfb8_32TransFunc( + ScreenPtr pScreen, + int nbox, + BoxPtr pbox +){ + cfb8_32FillBoxSolid8(&(WindowTable[pScreen->myNum]->drawable), + nbox, pbox, xf86Screens[pScreen->myNum]->colorKey); +} + +static Bool +cfb8_32InOverlayFunc(WindowPtr pWin) +{ + return (pWin->drawable.depth == 8); +} + +static Bool +cfb8_32FinishScreenInit( + ScreenPtr pScreen, + pointer pbits, /* pointer to screen bitmap */ + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy, /* dots per inch */ + int width /* pixel width of frame buffer */ +){ + VisualPtr visuals; + DepthPtr depths; + int nvisuals; + int ndepths; + int rootdepth; + VisualID defaultVisual; + + rootdepth = 0; + if (!miInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth, + &defaultVisual,((unsigned long)1<<(32-1)), 8, -1)) + return FALSE; + if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, + rootdepth, ndepths, depths, + defaultVisual, nvisuals, visuals)) + return FALSE; + + pScreen->BackingStoreFuncs = cfb8_32BSFuncRec; + pScreen->CreateScreenResources = cfb8_32CreateScreenResources; + pScreen->CloseScreen = cfb8_32CloseScreen; + pScreen->GetScreenPixmap = cfb32GetScreenPixmap; /* OK */ + pScreen->SetScreenPixmap = cfb32SetScreenPixmap; /* OK */ + + if (! miInitOverlay(pScreen, cfb8_32InOverlayFunc, cfb8_32TransFunc)) + return FALSE; + + return TRUE; +} + +static void +cfb8_32EnableDisableFBAccess ( + int index, + Bool enable +){ + ScreenPtr pScreen = screenInfo.screens[index]; + cfb8_32ScreenPtr pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + + miOverlaySetRootClip(pScreen, enable); + + (*pScreenPriv->EnableDisableFBAccess) (index, enable); +} + +static Atom overlayVisualsAtom; + +typedef struct { + CARD32 overlay_visual; + CARD32 transparent_type; + CARD32 value; + CARD32 layer; +} overlayVisualRec; + +static void +cfb8_32SetupVisuals (ScreenPtr pScreen) +{ + cfb8_32ScreenPtr pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + char atomString[] = {"SERVER_OVERLAY_VISUALS"}; + overlayVisualRec *overlayVisuals; + VisualID *visuals = NULL; + int numVisuals = 0; + DepthPtr pDepth = pScreen->allowedDepths; + int numDepths = pScreen->numDepths; + int i; + + /* find depth 8 visuals */ + for(i = 0; i < numDepths; i++, pDepth++) { + if(pDepth->depth == 8) { + numVisuals = pDepth->numVids; + visuals = pDepth->vids; + break; + } + } + + if(!numVisuals || !visuals) { + ErrorF("No overlay visuals found!\n"); + return; + } + + if(!(overlayVisuals = xalloc(numVisuals * sizeof(overlayVisualRec)))) + return; + + for(i = 0; i < numVisuals; i++) { + overlayVisuals[i].overlay_visual = visuals[i]; + overlayVisuals[i].transparent_type = 1; /* transparent pixel */ + overlayVisuals[i].value = pScreenPriv->key; + overlayVisuals[i].layer = 1; + } + + overlayVisualsAtom = MakeAtom(atomString, sizeof(atomString) - 1, TRUE); + xf86RegisterRootWindowProperty(pScreen->myNum, overlayVisualsAtom, + overlayVisualsAtom, 32, numVisuals * 4, overlayVisuals); + pScreenPriv->visualData = (pointer)overlayVisuals; +} + +Bool +cfb8_32ScreenInit( + ScreenPtr pScreen, + pointer pbits, /* pointer to screen bitmap */ + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy, /* dots per inch */ + int w /* pixel width of frame buffer */ +){ + cfb8_32ScreenPtr pScreenPriv; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (!cfb8_32SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, w)) + return FALSE; + + pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + pScreenPriv->key = pScrn->colorKey; + pScreenPriv->visualData = NULL; + + + pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; + pScrn->EnableDisableFBAccess = cfb8_32EnableDisableFBAccess; + + + if(cfb8_32FinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, w)) + { + cfb8_32SetupVisuals(pScreen); + return TRUE; + } + return FALSE; +} diff --git a/hw/xfree86/xf8_32bpp/cfbwindow.c b/hw/xfree86/xf8_32bpp/cfbwindow.c new file mode 100644 index 000000000..518166f41 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/cfbwindow.c @@ -0,0 +1,116 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbwindow.c,v 1.7 2003/02/17 16:08:30 dawes Exp $ */ + + +#include "X.h" +#include "scrnintstr.h" +#include "windowstr.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mistruct.h" +#include "regionstr.h" +#include "cfbmskbits.h" +#include "mioverlay.h" + + +/* We don't bother with cfb's fastBackground/Border so we don't + need to use the Window privates */ + + +Bool +cfb8_32CreateWindow(WindowPtr pWin) +{ + cfbPrivWin *pPrivWin = cfbGetWindowPrivate(pWin); + + pPrivWin->fastBackground = FALSE; + pPrivWin->fastBorder = FALSE; + + pWin->drawable.bitsPerPixel = 32; + return TRUE; +} + + +Bool +cfb8_32DestroyWindow(WindowPtr pWin) +{ + return TRUE; +} + +Bool +cfb8_32PositionWindow( + WindowPtr pWin, + int x, int y +){ + return TRUE; +} + +void +cfb8_32CopyWindow(pWin, ptOldOrg, prgnSrc) + WindowPtr pWin; + DDXPointRec ptOldOrg; + RegionPtr prgnSrc; +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DDXPointPtr ppt, pptSrc; + RegionRec rgnDst; + RegionPtr borderClip = &pWin->borderClip; + BoxPtr pbox; + int dx, dy, i, nbox; + WindowPtr pwinRoot; + Bool doUnderlay = miOverlayCopyUnderlay(pScreen); + Bool freeReg = FALSE; + + pwinRoot = WindowTable[pScreen->myNum]; + + if(doUnderlay) + freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip); + + REGION_INIT(pScreen, &rgnDst, NullBox, 0); + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); + REGION_INTERSECT(pScreen, &rgnDst, borderClip, prgnSrc); + + pbox = REGION_RECTS(&rgnDst); + nbox = REGION_NUM_RECTS(&rgnDst); + if(!nbox || + !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) + { + REGION_UNINIT(pScreen, &rgnDst); + return; + } + ppt = pptSrc; + + for (i = nbox; --i >= 0; ppt++, pbox++) + { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + if(doUnderlay) + cfbDoBitblt24To24GXcopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + GXcopy, &rgnDst, pptSrc, ~0, 0); + else + cfbDoBitblt8To8GXcopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + GXcopy, &rgnDst, pptSrc, ~0, 0); + + DEALLOCATE_LOCAL(pptSrc); + REGION_UNINIT(pScreen, &rgnDst); + if(freeReg) + REGION_DESTROY(pScreen, borderClip); +} + +Bool +cfb8_32ChangeWindowAttributes( + WindowPtr pWin, + unsigned long mask +){ + return TRUE; +} + + + + diff --git a/hw/xfree86/xf8_32bpp/xf86overlay.c b/hw/xfree86/xf8_32bpp/xf86overlay.c new file mode 100644 index 000000000..998503c21 --- /dev/null +++ b/hw/xfree86/xf8_32bpp/xf86overlay.c @@ -0,0 +1,1258 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c,v 1.9 2002/02/11 00:07:25 dawes Exp $ */ + +/* + Copyright (C) 1998. The XFree86 Project Inc. + + Written by Mark Vojkovich (mvojkovi@ucsd.edu) +*/ + +#include "misc.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" + +#include "X.h" +#include "scrnintstr.h" +#include "regionstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "migc.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "colormapst.h" +#include "cfb8_32.h" + +#define IS_DIRTY 1 +#define IS_SHARED 2 + +/** Screen Functions **/ + +static Bool OverlayCloseScreen (int, ScreenPtr); +static Bool OverlayCreateGC(GCPtr pGC); +static Bool OverlayDestroyPixmap(PixmapPtr); +static PixmapPtr OverlayCreatePixmap(ScreenPtr, int, int, int); +static Bool OverlayChangeWindowAttributes(WindowPtr, unsigned long); +static void OverlayPaintWindow(WindowPtr, RegionPtr, int); + +/** Funcs **/ +static void OverlayValidateGC(GCPtr, unsigned long, DrawablePtr); +static void OverlayChangeGC(GCPtr, unsigned long); +static void OverlayCopyGC(GCPtr, unsigned long, GCPtr); +static void OverlayDestroyGC(GCPtr); +static void OverlayChangeClip(GCPtr, int, pointer, int); +static void OverlayDestroyClip(GCPtr); +static void OverlayCopyClip(GCPtr, GCPtr); + + +static PixmapPtr OverlayRefreshPixmap(PixmapPtr); + +static GCFuncs OverlayGCFuncs = { + OverlayValidateGC, OverlayChangeGC, + OverlayCopyGC, OverlayDestroyGC, + OverlayChangeClip, OverlayDestroyClip, + OverlayCopyClip +}; + + +/** Pixmap Ops */ +static void PixmapFillSpans(DrawablePtr, GCPtr, int, DDXPointPtr, int *, + int); +static void PixmapSetSpans(DrawablePtr, GCPtr, char *, DDXPointPtr, + int *, int, int); +static void PixmapPutImage(DrawablePtr, GCPtr, int, int, int, int, int, + int, int, char *); +static void PixmapPushPixels(GCPtr, PixmapPtr, DrawablePtr, int, int, + int, int); +static RegionPtr PixmapCopyArea(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int); +static RegionPtr PixmapCopyPlane(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int, unsigned long); +static void PixmapPolyPoint(DrawablePtr, GCPtr, int, int, xPoint *); +static void PixmapPolylines(DrawablePtr, GCPtr, int, int, DDXPointPtr); +static void PixmapPolySegment(DrawablePtr, GCPtr, int, xSegment *); +static void PixmapPolyRectangle(DrawablePtr, GCPtr, int, xRectangle *); +static void PixmapPolyArc(DrawablePtr, GCPtr, int, xArc *); +static void PixmapFillPolygon(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void PixmapPolyFillRect(DrawablePtr, GCPtr, int, xRectangle *); +static void PixmapPolyFillArc(DrawablePtr, GCPtr, int, xArc *); +static int PixmapPolyText8(DrawablePtr, GCPtr, int, int, int, char *); +static int PixmapPolyText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void PixmapImageText8(DrawablePtr, GCPtr, int, int, int, char *); +static void PixmapImageText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void PixmapImageGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); +static void PixmapPolyGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); + +static GCOps PixmapGCOps = { + PixmapFillSpans, PixmapSetSpans, + PixmapPutImage, PixmapCopyArea, + PixmapCopyPlane, PixmapPolyPoint, + PixmapPolylines, PixmapPolySegment, + PixmapPolyRectangle, PixmapPolyArc, + PixmapFillPolygon, PixmapPolyFillRect, + PixmapPolyFillArc, PixmapPolyText8, + PixmapPolyText16, PixmapImageText8, + PixmapImageText16, PixmapImageGlyphBlt, + PixmapPolyGlyphBlt, PixmapPushPixels, +#ifdef NEED_LINEHELPER + NULL, +#endif + {NULL} /* devPrivate */ +}; + + +/** Window Ops **/ +static void WindowFillSpans(DrawablePtr, GCPtr, int, DDXPointPtr, int *, + int); +static void WindowSetSpans(DrawablePtr, GCPtr, char *, DDXPointPtr, + int *, int, int); +static void WindowPutImage(DrawablePtr, GCPtr, int, int, int, int, int, + int, int, char *); +static void WindowPushPixels(GCPtr, PixmapPtr, DrawablePtr, int, int, + int, int); +static RegionPtr WindowCopyArea(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int); +static RegionPtr WindowCopyPlane(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int, unsigned long); +static void WindowPolyPoint(DrawablePtr, GCPtr, int, int, xPoint *); +static void WindowPolylines(DrawablePtr, GCPtr, int, int, DDXPointPtr); +static void WindowPolySegment(DrawablePtr, GCPtr, int, xSegment *); +static void WindowPolyRectangle(DrawablePtr, GCPtr, int, xRectangle *); +static void WindowPolyArc(DrawablePtr, GCPtr, int, xArc *); +static void WindowFillPolygon(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void WindowPolyFillRect(DrawablePtr, GCPtr, int, xRectangle *); +static void WindowPolyFillArc(DrawablePtr, GCPtr, int, xArc *); +static int WindowPolyText8(DrawablePtr, GCPtr, int, int, int, char *); +static int WindowPolyText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void WindowImageText8(DrawablePtr, GCPtr, int, int, int, char *); +static void WindowImageText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void WindowImageGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); +static void WindowPolyGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); + +static GCOps WindowGCOps = { + WindowFillSpans, WindowSetSpans, + WindowPutImage, WindowCopyArea, + WindowCopyPlane, WindowPolyPoint, + WindowPolylines, WindowPolySegment, + WindowPolyRectangle, WindowPolyArc, + WindowFillPolygon, WindowPolyFillRect, + WindowPolyFillArc, WindowPolyText8, + WindowPolyText16, WindowImageText8, + WindowImageText16, WindowImageGlyphBlt, + WindowPolyGlyphBlt, WindowPushPixels, +#ifdef NEED_LINEHELPER + NULL, +#endif + {NULL} /* devPrivate */ +}; + +/** privates **/ + +typedef struct { + CloseScreenProcPtr CloseScreen; + CreateGCProcPtr CreateGC; + CreatePixmapProcPtr CreatePixmap; + DestroyPixmapProcPtr DestroyPixmap; + ChangeWindowAttributesProcPtr ChangeWindowAttributes; + PaintWindowBackgroundProcPtr PaintWindowBackground; + PaintWindowBorderProcPtr PaintWindowBorder; + int LockPrivate; +} OverlayScreenRec, *OverlayScreenPtr; + +typedef struct { + GCFuncs *wrapFuncs; + GCOps *wrapOps; + GCOps *overlayOps; + unsigned long fg; + unsigned long bg; + unsigned long pm; + PixmapPtr tile; +} OverlayGCRec, *OverlayGCPtr; + +typedef struct { + PixmapPtr pix32; + CARD32 dirty; +} OverlayPixmapRec, *OverlayPixmapPtr; + + +static int OverlayScreenIndex = -1; +static int OverlayGCIndex = -1; +static int OverlayPixmapIndex = -1; +static unsigned long OverlayGeneration = 0; + +/** Macros **/ + +#define TILE_EXISTS(pGC) (!(pGC)->tileIsPixel && (pGC)->tile.pixmap) + +#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) \ + (OverlayPixmapPtr)((pPix)->devPrivates[OverlayPixmapIndex].ptr) + +#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) \ + (OverlayScreenPtr)((pScreen)->devPrivates[OverlayScreenIndex].ptr) + +#define OVERLAY_GET_GC_PRIVATE(pGC) \ + (OverlayGCPtr)((pGC)->devPrivates[OverlayGCIndex].ptr) + +#define OVERLAY_GC_FUNC_PROLOGUE(pGC)\ + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ + (pGC)->funcs = pGCPriv->wrapFuncs;\ + if(pGCPriv->overlayOps) \ + (pGC)->ops = pGCPriv->wrapOps + +#define OVERLAY_GC_FUNC_EPILOGUE(pGC)\ + pGCPriv->wrapFuncs = (pGC)->funcs;\ + (pGC)->funcs = &OverlayGCFuncs;\ + if(pGCPriv->overlayOps) { \ + pGCPriv->wrapOps = (pGC)->ops;\ + (pGC)->ops = pGCPriv->overlayOps;\ + } + +#define WINDOW_GC_OP_PROLOGUE(pGC)\ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE((pGC)->pScreen);\ + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ + unsigned long oldfg = (pGC)->fgPixel;\ + unsigned long oldbg = (pGC)->bgPixel;\ + unsigned long oldpm = (pGC)->planemask;\ + PixmapPtr oldtile = (pGC)->tile.pixmap;\ + (pGC)->fgPixel = pGCPriv->fg;\ + (pGC)->bgPixel = pGCPriv->bg;\ + (pGC)->planemask = pGCPriv->pm;\ + if(pGCPriv->tile) (pGC)->tile.pixmap = pGCPriv->tile;\ + (pGC)->funcs = pGCPriv->wrapFuncs;\ + (pGC)->ops = pGCPriv->wrapOps;\ + pScreenPriv->LockPrivate++ + + +#define WINDOW_GC_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = (pGC)->ops;\ + pGCPriv->wrapFuncs = (pGC)->funcs;\ + (pGC)->fgPixel = oldfg;\ + (pGC)->bgPixel = oldbg;\ + (pGC)->planemask = oldpm;\ + (pGC)->tile.pixmap = oldtile;\ + (pGC)->funcs = &OverlayGCFuncs;\ + (pGC)->ops = &WindowGCOps;\ + pScreenPriv->LockPrivate-- + + +#define PIXMAP_GC_OP_PROLOGUE(pGC)\ + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ + OverlayPixmapPtr pPixPriv = OVERLAY_GET_PIXMAP_PRIVATE((PixmapPtr)pDraw);\ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps + +#define PIXMAP_GC_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = pGC->ops;\ + pGC->funcs = &OverlayGCFuncs;\ + pGC->ops = &PixmapGCOps;\ + pPixPriv->dirty |= IS_DIRTY + + +Bool +xf86Overlay8Plus32Init (ScreenPtr pScreen) +{ + OverlayScreenPtr pScreenPriv; + + if(OverlayGeneration != serverGeneration) { + if(((OverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) || + ((OverlayGCIndex = AllocateGCPrivateIndex()) < 0) || + ((OverlayPixmapIndex = AllocatePixmapPrivateIndex()) < 0)) + return FALSE; + + OverlayGeneration = serverGeneration; + } + + if (!AllocateGCPrivate(pScreen, OverlayGCIndex, sizeof(OverlayGCRec))) + return FALSE; + + if (!AllocatePixmapPrivate(pScreen, OverlayPixmapIndex, + sizeof(OverlayPixmapRec))) + return FALSE; + + if (!(pScreenPriv = xalloc(sizeof(OverlayScreenRec)))) + return FALSE; + + pScreen->devPrivates[OverlayScreenIndex].ptr = (pointer)pScreenPriv; + + pScreenPriv->CreateGC = pScreen->CreateGC; + pScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreenPriv->CreatePixmap = pScreen->CreatePixmap; + pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap; + pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; + pScreenPriv->PaintWindowBackground = pScreen->PaintWindowBackground; + pScreenPriv->PaintWindowBorder = pScreen->PaintWindowBorder; + + pScreen->CreateGC = OverlayCreateGC; + pScreen->CloseScreen = OverlayCloseScreen; + pScreen->CreatePixmap = OverlayCreatePixmap; + pScreen->DestroyPixmap = OverlayDestroyPixmap; + pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes; + pScreen->PaintWindowBackground = OverlayPaintWindow; + pScreen->PaintWindowBorder = OverlayPaintWindow; + + pScreenPriv->LockPrivate = 0; + + /* allocate the key in the default map */ + if(pScreen->defColormap) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ColormapPtr pmap; + xColorItem color; + + pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, RT_COLORMAP); + + pmap->red[pScrn->colorKey].refcnt = AllocPrivate; + pmap->red[pScrn->colorKey].fShared = FALSE; + pmap->freeRed--; + + color.red = color.blue = color.green = 0; + color.pixel = pScrn->colorKey; + color.flags = DoRed | DoGreen | DoBlue; + + StoreColors(pmap, 1, &color); + } + + return TRUE; +} + + +/*********************** Screen Funcs ***********************/ + +Bool +OverlayCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC); + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + Bool ret; + + pScreen->CreateGC = pScreenPriv->CreateGC; + + if((ret = (*pScreen->CreateGC)(pGC)) && (pGC->depth != 1)) { + pGCPriv->wrapFuncs = pGC->funcs; + pGC->funcs = &OverlayGCFuncs; + pGCPriv->wrapOps = NULL; + pGCPriv->overlayOps = NULL; + pGCPriv->tile = NULL; + } + + pScreen->CreateGC = OverlayCreateGC; + + return ret; +} + +static PixmapPtr +OverlayCreatePixmap(ScreenPtr pScreen, int w, int h, int depth) +{ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + PixmapPtr pPix; + + pScreen->CreatePixmap = pScreenPriv->CreatePixmap; + pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth); + pScreen->CreatePixmap = OverlayCreatePixmap; + + /* We initialize all the privates */ + if(pPix) { + OverlayPixmapPtr pPriv = OVERLAY_GET_PIXMAP_PRIVATE(pPix); + pPriv->pix32 = NULL; + pPriv->dirty = IS_DIRTY; + if(!w || !h) + pPriv->dirty |= IS_SHARED; + } + + return pPix; +} + +static Bool +OverlayDestroyPixmap(PixmapPtr pPix) +{ + ScreenPtr pScreen = pPix->drawable.pScreen; + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + Bool result; + + pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap; + + if((pPix->refcnt == 1) && (pPix->drawable.bitsPerPixel == 8)) { + OverlayPixmapPtr pPriv = OVERLAY_GET_PIXMAP_PRIVATE(pPix); + if(pPriv->pix32) { + if(pPriv->pix32->refcnt != 1) + ErrorF("Warning! private pix refcnt = %i\n", pPriv->pix32->refcnt); + (*pScreen->DestroyPixmap)(pPriv->pix32); + } + pPriv->pix32 = NULL; + } + + result = (*pScreen->DestroyPixmap) (pPix); + pScreen->DestroyPixmap = OverlayDestroyPixmap; + + return result; +} + +static Bool +OverlayCloseScreen (int i, ScreenPtr pScreen) +{ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + + pScreen->CreateGC = pScreenPriv->CreateGC; + pScreen->CloseScreen = pScreenPriv->CloseScreen; + pScreen->CreatePixmap = pScreenPriv->CreatePixmap; + pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap; + pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes; + pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground; + pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder; + + xfree ((pointer) pScreenPriv); + + return (*pScreen->CloseScreen) (i, pScreen); +} + + + +static Bool +OverlayChangeWindowAttributes (WindowPtr pWin, unsigned long mask) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + Bool result; + + if(pWin->drawable.depth == 8) { + if((mask & CWBackPixmap) && + (pWin->backgroundState == BackgroundPixmap)) + OverlayRefreshPixmap(pWin->background.pixmap); + + if((mask & CWBorderPixmap) && !pWin->borderIsPixel) + OverlayRefreshPixmap(pWin->border.pixmap); + } + + pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes; + result = (*pScreen->ChangeWindowAttributes) (pWin, mask); + pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes; + + return result; +} + +static void +OverlayPaintWindow( + WindowPtr pWin, + RegionPtr pReg, + int what +){ + ScreenPtr pScreen = pWin->drawable.pScreen; + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + OverlayPixmapPtr pixPriv; + PixmapPtr oldPix = NULL; + + if(what == PW_BACKGROUND) { + if(pWin->drawable.depth == 8) { + if(pWin->backgroundState == ParentRelative) { + do { + pWin = pWin->parent; + } while (pWin->backgroundState == ParentRelative); + } + + if(pWin->backgroundState == BackgroundPixmap) { + oldPix = pWin->background.pixmap; + pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix); + /* have to do this here because alot of applications + incorrectly assume changes to a pixmap that is + a window background go into effect immediatedly */ + if(pixPriv->dirty & IS_DIRTY) + OverlayRefreshPixmap(pWin->background.pixmap); + pWin->background.pixmap = pixPriv->pix32; + } + } + + pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground; + (*pScreen->PaintWindowBackground) (pWin, pReg, what); + pScreen->PaintWindowBackground = OverlayPaintWindow; + + if(oldPix) + pWin->background.pixmap = oldPix; + } else { + if((pWin->drawable.depth == 8) && !pWin->borderIsPixel) { + oldPix = pWin->border.pixmap; + pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix); + if(pixPriv->dirty & IS_DIRTY) + OverlayRefreshPixmap(pWin->border.pixmap); + pWin->border.pixmap = pixPriv->pix32; + } + + pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder; + (*pScreen->PaintWindowBorder) (pWin, pReg, what); + pScreen->PaintWindowBorder = OverlayPaintWindow; + + if(oldPix) + pWin->border.pixmap = oldPix; + } +} + + +/*********************** GC Funcs *****************************/ + + +static PixmapPtr +OverlayRefreshPixmap(PixmapPtr pix8) +{ + OverlayPixmapPtr pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(pix8); + ScreenPtr pScreen = pix8->drawable.pScreen; + + if(!pixPriv->pix32) { + PixmapPtr newPix; + + newPix = (*pScreen->CreatePixmap)(pScreen, pix8->drawable.width, + pix8->drawable.height, 24); + newPix->drawable.depth = 8; /* Bad Mark! Bad Mark! */ + pixPriv->pix32 = newPix; + } + + if(pixPriv->dirty) { + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + GCPtr pGC; + + pGC = GetScratchGC(8, pScreen); + + pScreenPriv->LockPrivate++; /* don't modify this one */ + ValidateGC((DrawablePtr)pixPriv->pix32, pGC); + + (*pGC->ops->CopyArea)((DrawablePtr)pix8, (DrawablePtr)pixPriv->pix32, + pGC, 0, 0, pix8->drawable.width, pix8->drawable.height, 0, 0); + pScreenPriv->LockPrivate--; + FreeScratchGC(pGC); + + pixPriv->dirty &= ~IS_DIRTY; + pixPriv->pix32->drawable.serialNumber = NEXT_SERIAL_NUMBER; + } + + return pixPriv->pix32; +} + + +static void +OverlayValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pGC->pScreen); + OVERLAY_GC_FUNC_PROLOGUE (pGC); + + if(pScreenPriv->LockPrivate < 0) { + ErrorF("Something is wrong in OverlayValidateGC!\n"); + pScreenPriv->LockPrivate = 0; + } + + if(pGC->depth == 24) { + unsigned long oldpm = pGC->planemask; + pGCPriv->overlayOps = NULL; + + if(pDraw->type == DRAWABLE_WINDOW) + pGC->planemask &= 0x00ffffff; + else + pGC->planemask |= 0xff000000; + + if(oldpm != pGC->planemask) changes |= GCPlaneMask; + + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + + } else { /* depth == 8 */ + unsigned long newChanges = 0; + + if(pDraw->bitsPerPixel == 32) { + + if(pGC->fillStyle == FillTiled) + pGCPriv->tile = OverlayRefreshPixmap(pGC->tile.pixmap); + else pGCPriv->tile = NULL; + + if(pGCPriv->overlayOps != &WindowGCOps) { + newChanges = GCForeground | GCBackground | GCPlaneMask; + if(pGCPriv->tile) + newChanges |= GCTile; + } + pGCPriv->overlayOps = &WindowGCOps; + + if(!pScreenPriv->LockPrivate) { + unsigned long oldfg = pGC->fgPixel; + unsigned long oldbg = pGC->bgPixel; + unsigned long oldpm = pGC->planemask; + PixmapPtr oldtile = pGC->tile.pixmap; + + pGC->fgPixel = pGCPriv->fg = oldfg << 24; + pGC->bgPixel = pGCPriv->bg = oldbg << 24; + pGC->planemask = pGCPriv->pm = oldpm << 24; + if(pGCPriv->tile) + pGC->tile.pixmap = pGCPriv->tile; + + (*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw); + + pGC->fgPixel = oldfg; + pGC->bgPixel = oldbg; + pGC->planemask = oldpm; + pGC->tile.pixmap = oldtile; + } else { + pGCPriv->fg = pGC->fgPixel; + pGCPriv->bg = pGC->bgPixel; + pGCPriv->pm = pGC->planemask; + + (*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw); + } + + } else { /* bitsPerPixel == 8 */ + if(pGCPriv->overlayOps == &WindowGCOps) { + newChanges = GCForeground | GCBackground | GCPlaneMask; + if(pGCPriv->tile) + newChanges |= GCTile; + } + pGCPriv->overlayOps = &PixmapGCOps; + + (*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw); + } + } + + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + + +static void +OverlayDestroyGC(GCPtr pGC) +{ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->DestroyGC)(pGC); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + +static void +OverlayChangeGC ( + GCPtr pGC, + unsigned long mask +){ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + +static void +OverlayCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst +){ + OVERLAY_GC_FUNC_PROLOGUE (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + OVERLAY_GC_FUNC_EPILOGUE (pGCDst); +} +static void +OverlayChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects +){ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + +static void +OverlayCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + OVERLAY_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + OVERLAY_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +OverlayDestroyClip(GCPtr pGC) +{ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + + + +/******************* Window GC ops ***********************/ + +static void +WindowFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static RegionPtr +WindowCopyArea( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + RegionPtr ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static RegionPtr +WindowCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + RegionPtr ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +WindowPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static int +WindowPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + int ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static int +WindowPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + int ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +WindowImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + WINDOW_GC_OP_EPILOGUE(pGC); +} + + +/******************* Pixmap GC ops ***********************/ + +static void +PixmapFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static RegionPtr +PixmapCopyArea( + DrawablePtr pSrc, + DrawablePtr pDraw, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + RegionPtr ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyArea)(pSrc, pDraw, + pGC, srcx, srcy, width, height, dstx, dsty); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static RegionPtr +PixmapCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDraw, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + RegionPtr ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyPlane)(pSrc, pDraw, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +PixmapPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static int +PixmapPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + int ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static int +PixmapPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + int ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +PixmapImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + + |