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_32wid | |
parent | ded6147bfb5d75ff1e67c858040a628b61bc17d1 (diff) |
Initial revision
Diffstat (limited to 'hw/xfree86/xf8_32wid')
-rw-r--r-- | hw/xfree86/xf8_32wid/cfb8_32wid.h | 93 | ||||
-rw-r--r-- | hw/xfree86/xf8_32wid/cfb8_32widmodule.c | 46 | ||||
-rw-r--r-- | hw/xfree86/xf8_32wid/cfbscrinit.c | 382 | ||||
-rw-r--r-- | hw/xfree86/xf8_32wid/cfbwid.c | 147 | ||||
-rw-r--r-- | hw/xfree86/xf8_32wid/cfbwindow.c | 284 |
5 files changed, 952 insertions, 0 deletions
diff --git a/hw/xfree86/xf8_32wid/cfb8_32wid.h b/hw/xfree86/xf8_32wid/cfb8_32wid.h new file mode 100644 index 000000000..9913c2a6c --- /dev/null +++ b/hw/xfree86/xf8_32wid/cfb8_32wid.h @@ -0,0 +1,93 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32wid.h,v 1.1 2000/05/21 01:02:43 mvojkovi Exp $ */ + +#ifndef _CFB8_32WID_H +#define _CFB8_32WID_H + +#include "regionstr.h" +#include "windowstr.h" + +typedef struct { + unsigned int (*WidGet)(WindowPtr); + Bool (*WidAlloc)(WindowPtr); + void (*WidFree)(WindowPtr); + void (*WidFillBox)(DrawablePtr, DrawablePtr, int, BoxPtr); + void (*WidCopyArea)(DrawablePtr, RegionPtr, DDXPointPtr); +} cfb8_32WidOps; + +typedef struct { + pointer pix8; + int width8; + pointer pix32; + int width32; + + /* WID information */ + pointer pixWid; + int widthWid; + int bitsPerWid; + cfb8_32WidOps *WIDOps; +} cfb8_32WidScreenRec, *cfb8_32WidScreenPtr; + +extern int cfb8_32WidScreenPrivateIndex; + +Bool +cfb8_32WidScreenInit ( + ScreenPtr pScreen, + pointer pbits32, + pointer pbits8, + pointer pbitsWid, + int xsize, int ysize, + int dpix, int dpiy, + int width32, + int width8, + int widthWid, + int bitsPerWid, + cfb8_32WidOps *WIDOps +); + +/* cfbwindow.c */ + +void +cfb8_32WidPaintWindow ( + WindowPtr pWin, + RegionPtr pRegion, + int what +); + +Bool cfb8_32WidCreateWindow(WindowPtr pWin); +Bool cfb8_32WidDestroyWindow(WindowPtr pWin); + +Bool +cfb8_32WidPositionWindow( + WindowPtr pWin, + int x, int y +); + +void +cfb8_32WidCopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc +); + +Bool +cfb8_32WidChangeWindowAttributes( + WindowPtr pWin, + unsigned long mask +); + +void +cfb8_32WidWindowExposures( + WindowPtr pWin, + RegionPtr pReg, + RegionPtr pOtherReg +); + +/* cfbwid.c */ + +Bool +cfb8_32WidGenericOpsInit(cfb8_32WidScreenPtr pScreenPriv); + +#define CFB8_32WID_GET_SCREEN_PRIVATE(pScreen)\ + (cfb8_32WidScreenPtr)((pScreen)->devPrivates[cfb8_32WidScreenPrivateIndex].ptr) + +#endif /* _CFB8_32WID_H */ diff --git a/hw/xfree86/xf8_32wid/cfb8_32widmodule.c b/hw/xfree86/xf8_32wid/cfb8_32widmodule.c new file mode 100644 index 000000000..5a47b9ff5 --- /dev/null +++ b/hw/xfree86/xf8_32wid/cfb8_32widmodule.c @@ -0,0 +1,46 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32widmodule.c,v 1.1 2000/05/21 01:02:43 mvojkovi Exp $ */ + +#ifdef XFree86LOADER + +#include "xf86Module.h" + +static MODULESETUPPROTO(xf8_32widSetup); + +static XF86ModuleVersionInfo VersRec = +{ + "xf8_32wid", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + NULL, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +XF86ModuleData xf8_32widModuleData = { &VersRec, xf8_32widSetup, NULL }; + +static pointer +xf8_32widSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + if (!LoadSubModule(module, "mfb", NULL, NULL, NULL, NULL, + errmaj, errmin)) + return NULL; + if (!LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL, + errmaj, errmin)) + return NULL; + if (!LoadSubModule(module, "cfb16", NULL, NULL, NULL, NULL, + errmaj, errmin)) + return NULL; + if (!LoadSubModule(module, "cfb24", 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_32wid/cfbscrinit.c b/hw/xfree86/xf8_32wid/cfbscrinit.c new file mode 100644 index 000000000..93c15371d --- /dev/null +++ b/hw/xfree86/xf8_32wid/cfbscrinit.c @@ -0,0 +1,382 @@ +/* + Copyright (C) 1999. The XFree86 Project Inc. + + Written by David S. Miller (davem@redhat.com) + + Based largely upon the xf8_16bpp module which is + Mark Vojkovich's work. +*/ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbscrinit.c,v 1.1 2000/05/21 01:02:43 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_32wid.h" +#include "mi.h" +#include "micmap.h" +#include "mistruct.h" +#include "gcstruct.h" +#include "dix.h" +#include "mibstore.h" +#include "xf86str.h" +#include "xf86.h" + +/* CAUTION: We require that cfb8 and cfb32 were NOT + compiled with CFB_NEED_SCREEN_PRIVATE */ + +int cfb8_32WidScreenPrivateIndex; + +static unsigned long cfb8_32WidGeneration = 0; +extern WindowPtr *WindowTable; + +static PixmapPtr cfb8_32WidGetWindowPixmap(WindowPtr pWin); + +static void +cfb8_32WidSaveAreas( + PixmapPtr pPixmap, + RegionPtr prgnSave, + int xorg, + int yorg, + WindowPtr pWin +); + +static void +cfb8_32WidRestoreAreas( + PixmapPtr pPixmap, + RegionPtr prgnRestore, + int xorg, + int yorg, + WindowPtr pWin +); + +static BSFuncRec cfb8_32WidBSFuncRec = { + cfb8_32WidSaveAreas, + cfb8_32WidRestoreAreas, + (BackingStoreSetClipmaskRgnProcPtr) 0, + (BackingStoreGetImagePixmapProcPtr) 0, + (BackingStoreGetSpansPixmapProcPtr) 0, +}; + +static void +cfb8_32WidGetSpans( + DrawablePtr pDraw, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pchardstStart +); + +static void +cfb8_32WidGetImage ( + DrawablePtr pDraw, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planeMask, + char *pdstLine +); + +static Bool cfb8_32WidCreateGC(GCPtr pGC); +static void cfb8_32WidEnableDisableFBAccess(int index, Bool enable); + + +static Bool +cfb8_32WidAllocatePrivates(ScreenPtr pScreen) +{ + cfb8_32WidScreenPtr pScreenPriv; + + if (cfb8_32WidGeneration != serverGeneration) { + if ((cfb8_32WidScreenPrivateIndex = AllocateScreenPrivateIndex()) < 0) + return FALSE; + cfb8_32WidGeneration = serverGeneration; + } + + if (!(pScreenPriv = xalloc(sizeof(cfb8_32WidScreenRec)))) + return FALSE; + + pScreen->devPrivates[cfb8_32WidScreenPrivateIndex].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; + + return TRUE; +} + +static Bool +cfb8_32WidSetupScreen( + ScreenPtr pScreen, + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy +){ + if (!cfb8_32WidAllocatePrivates(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_32WidGetImage; + pScreen->GetSpans = cfb8_32WidGetSpans; + pScreen->CreateWindow = cfb8_32WidCreateWindow; + pScreen->DestroyWindow = cfb8_32WidDestroyWindow; + pScreen->PositionWindow = cfb8_32WidPositionWindow; + pScreen->ChangeWindowAttributes = cfb8_32WidChangeWindowAttributes; + pScreen->RealizeWindow = cfb32MapWindow; /* OK */ + pScreen->UnrealizeWindow = cfb32UnmapWindow; /* OK */ + pScreen->PaintWindowBackground = cfb8_32WidPaintWindow; + pScreen->PaintWindowBorder = cfb8_32WidPaintWindow; + pScreen->CopyWindow = cfb8_32WidCopyWindow; + pScreen->CreatePixmap = cfb32CreatePixmap; /* OK */ + pScreen->DestroyPixmap = cfb32DestroyPixmap; /* OK */ + pScreen->RealizeFont = mfbRealizeFont; + pScreen->UnrealizeFont = mfbUnrealizeFont; + pScreen->CreateGC = cfb8_32WidCreateGC; + 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, cfbCopyPlane); + return TRUE; +} + +static Bool +cfb8_32WidCreateScreenResources(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + cfb8_32WidScreenPtr pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + PixmapPtr pix8, pix32, pixWid; + + xfree(pScreen->devPrivate); /* freeing miScreenInitParmsRec */ + + pix8 = (*pScreen->CreatePixmap)(pScreen, 0, 0, 8); + pix32 = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScrn->depth); + pixWid = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreenPriv->bitsPerWid); + if (!pix32 || !pix8 || !pixWid) + return FALSE; + + pix8->drawable.width = pScreen->width; + pix8->drawable.height = pScreen->height; + pix8->devKind = pScreenPriv->width8; + pix8->devPrivate.ptr = pScreenPriv->pix8; + + pix32->drawable.width = pScreen->width; + pix32->drawable.height = pScreen->height; + pix32->devKind = pScreenPriv->width32 * 4; + pix32->devPrivate.ptr = pScreenPriv->pix32; + + pixWid->drawable.width = pScreen->width; + pixWid->drawable.height = pScreen->height; + pixWid->devKind = (pScreenPriv->widthWid * pScreenPriv->bitsPerWid) / 8; + pixWid->devPrivate.ptr = pScreenPriv->pixWid; + + pScreenPriv->pix8 = (pointer) pix8; + pScreenPriv->pix32 = (pointer) pix32; + pScreenPriv->pixWid = (pointer) pixWid; + + pScreen->devPrivate = (pointer) pix32; + + return TRUE; +} + + +static Bool +cfb8_32WidCloseScreen (int i, ScreenPtr pScreen) +{ + cfb8_32WidScreenPtr pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + + xfree((pointer) pScreenPriv); + + return cfb32CloseScreen(i, pScreen); +} + +static Bool +cfb8_32WidFinishScreenInit( + ScreenPtr pScreen, + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy /* dots per inch */ +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + 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, NULL, xsize, ysize, dpix, dpiy, 0, + rootdepth, ndepths, depths, + defaultVisual, nvisuals, visuals)) + return FALSE; + + pScreen->BackingStoreFuncs = cfb8_32WidBSFuncRec; + pScreen->CreateScreenResources = cfb8_32WidCreateScreenResources; + pScreen->CloseScreen = cfb8_32WidCloseScreen; + pScreen->GetWindowPixmap = cfb8_32WidGetWindowPixmap; + pScreen->WindowExposures = cfb8_32WidWindowExposures; + + pScrn->EnableDisableFBAccess = cfb8_32WidEnableDisableFBAccess; + + return TRUE; +} + +Bool +cfb8_32WidScreenInit( + ScreenPtr pScreen, + pointer pbits32, /* pointer to screen bitmap */ + pointer pbits8, + pointer pbitsWid, /* pointer to WID bitmap */ + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy, /* dots per inch */ + int width32, /* pixel width of frame buffer */ + int width8, + int widthWid, + int bitsPerWid, + cfb8_32WidOps *WIDOps +){ + cfb8_32WidScreenPtr pScreenPriv; + + if (!WIDOps || !WIDOps->WidGet || !WIDOps->WidAlloc || !WIDOps->WidFree) + return FALSE; + + if (!cfb8_32WidSetupScreen(pScreen, xsize, ysize, dpix, dpiy)) + return FALSE; + + pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + pScreenPriv->pix8 = pbits8; + pScreenPriv->pix32 = pbits32; + pScreenPriv->pixWid = pbitsWid; + pScreenPriv->width8 = width8; + pScreenPriv->width32 = width32; + pScreenPriv->widthWid = widthWid; + pScreenPriv->bitsPerWid = bitsPerWid; + + pScreenPriv->WIDOps = xalloc(sizeof(cfb8_32WidOps)); + if (!pScreenPriv->WIDOps) + return FALSE; + + *(pScreenPriv->WIDOps) = *WIDOps; + + if (!WIDOps->WidFillBox || !WIDOps->WidCopyArea) + cfb8_32WidGenericOpsInit(pScreenPriv); + + return cfb8_32WidFinishScreenInit(pScreen, xsize, ysize, dpix, dpiy); +} + +static PixmapPtr +cfb8_32WidGetWindowPixmap(WindowPtr pWin) +{ + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen); + + return ((pWin->drawable.bitsPerPixel == 8) ? + (PixmapPtr) pScreenPriv->pix8 : (PixmapPtr) pScreenPriv->pix32); +} + +static void +cfb8_32WidGetImage (DrawablePtr pDraw, int sx, int sy, int w, int h, + unsigned int format, unsigned long planemask, char *pdstLine) +{ + if (!w || !h) + return; + + if (pDraw->bitsPerPixel == 8) + cfbGetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); + else + cfb32GetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); +} + +static void +cfb8_32WidGetSpans(DrawablePtr pDraw, int wMax, DDXPointPtr ppt, int *pwidth, int nspans, char *pDst) +{ + if (pDraw->bitsPerPixel == 8) + cfbGetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); + else + cfb32GetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); +} + +static void +cfb8_32WidSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin) +{ + if (pWin->drawable.bitsPerPixel == 8) + cfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin); + else + cfb32SaveAreas(pPixmap, prgnSave, xorg, yorg, pWin); +} + +static void +cfb8_32WidRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin) +{ + if (pWin->drawable.bitsPerPixel == 8) + cfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin); + else + cfb32RestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin); +} + + +static Bool +cfb8_32WidCreateGC(GCPtr pGC) +{ + if (pGC->depth == 8) + return cfbCreateGC(pGC); + else + return cfb32CreateGC(pGC); +} + +static void +cfb8_32WidEnableDisableFBAccess(int index, Bool enable) +{ + ScreenPtr pScreen = xf86Screens[index]->pScreen; + cfb8_32WidScreenPtr pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + static DevUnion devPrivates8[MAXSCREENS]; + static DevUnion devPrivates32[MAXSCREENS]; + PixmapPtr pix8, pix32; + + pix8 = (PixmapPtr) pScreenPriv->pix8; + pix32 = (PixmapPtr) pScreenPriv->pix32; + + if (enable) { + pix8->devPrivate = devPrivates8[index]; + pix32->devPrivate = devPrivates32[index]; + } + + xf86EnableDisableFBAccess (index, enable); + + if (!enable) { + devPrivates8[index] = pix8->devPrivate; + pix8->devPrivate.ptr = 0; + devPrivates32[index] = pix32->devPrivate; + pix32->devPrivate.ptr = 0; + } +} diff --git a/hw/xfree86/xf8_32wid/cfbwid.c b/hw/xfree86/xf8_32wid/cfbwid.c new file mode 100644 index 000000000..0aa894176 --- /dev/null +++ b/hw/xfree86/xf8_32wid/cfbwid.c @@ -0,0 +1,147 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwid.c,v 1.1 2000/05/21 01:02:44 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" + +#include "mfb.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" +#include "cfb32.h" + +#include "cfb8_32wid.h" + +static void +WidFillBox1(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox) +{ + WindowPtr pWin = (WindowPtr) pWinDraw; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen); + unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin); + + if (wid & 1) + mfbSolidWhiteArea((DrawablePtr)pWin, nbox, pBox, GXset, NullPixmap); + else + mfbSolidBlackArea((DrawablePtr)pWin, nbox, pBox, GXset, NullPixmap); +} + +static void +WidCopyArea1(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc) +{ + mfbDoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc); +} + +static void +WidFillBox8(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox) +{ + WindowPtr pWin = (WindowPtr) pWinDraw; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen); + unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin); + + cfbFillBoxSolid(pixWid, nbox, pBox, wid); +} + +static void +WidCopyArea8(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc) +{ + cfbDoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L); +} + +static void +WidFillBox16(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox) +{ + WindowPtr pWin = (WindowPtr) pWinDraw; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen); + unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin); + + cfb16FillBoxSolid(pixWid, nbox, pBox, wid); +} + +static void +WidCopyArea16(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc) +{ + cfb16DoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L); +} + +static void +WidFillBox24(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox) +{ + WindowPtr pWin = (WindowPtr) pWinDraw; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen); + unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin); + + cfb24FillBoxSolid(pixWid, nbox, pBox, wid); +} + +static void +WidCopyArea24(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc) +{ + cfb24DoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L); +} + +static void +WidFillBox32(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox) +{ + WindowPtr pWin = (WindowPtr) pWinDraw; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen); + unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin); + + cfb32FillBoxSolid(pixWid, nbox, pBox, wid); +} + +static void +WidCopyArea32(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc) +{ + cfb32DoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L); +} + +Bool +cfb8_32WidGenericOpsInit(cfb8_32WidScreenPtr pScreenPriv) +{ + cfb8_32WidOps *WIDOps = pScreenPriv->WIDOps; + + switch (pScreenPriv->bitsPerWid) { + case 1: + WIDOps->WidFillBox = WidFillBox1; + WIDOps->WidCopyArea = WidCopyArea1; + break; + + case 8: + WIDOps->WidFillBox = WidFillBox8; + WIDOps->WidCopyArea = WidCopyArea8; + break; + + case 16: + WIDOps->WidFillBox = WidFillBox16; + WIDOps->WidCopyArea = WidCopyArea16; + break; + + case 24: + WIDOps->WidFillBox = WidFillBox24; + WIDOps->WidCopyArea = WidCopyArea24; + break; + + case 32: + WIDOps->WidFillBox = WidFillBox32; + WIDOps->WidCopyArea = WidCopyArea32; + break; + + default: + return FALSE; + }; + + return TRUE; +} diff --git a/hw/xfree86/xf8_32wid/cfbwindow.c b/hw/xfree86/xf8_32wid/cfbwindow.c new file mode 100644 index 000000000..74db57649 --- /dev/null +++ b/hw/xfree86/xf8_32wid/cfbwindow.c @@ -0,0 +1,284 @@ +/* + Copyright (C) 1999. The XFree86 Project Inc. + + Written by David S. Miller (davem@redhat.com) + + Based largely upon the xf8_16bpp module which is + Mark Vojkovich's work. +*/ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwindow.c,v 1.2 2001/10/28 03:34:09 tsi Exp $ */ + +#include "X.h" +#include "scrnintstr.h" +#include "windowstr.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32wid.h" +#include "mistruct.h" +#include "regionstr.h" +#include "cfbmskbits.h" +#include "xf86.h" + +/* We don't bother with cfb's fastBackground/Border so we don't + need to use the Window privates */ + +Bool +cfb8_32WidCreateWindow(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + cfbPrivWin *pPrivWin = cfbGetWindowPrivate(pWin); + + pPrivWin->fastBackground = FALSE; + pPrivWin->fastBorder = FALSE; + + if (!pScreenPriv->WIDOps->WidAlloc(pWin)) + return FALSE; + + return TRUE; +} + + +Bool +cfb8_32WidDestroyWindow(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + + pScreenPriv->WIDOps->WidFree(pWin); + return TRUE; +} + +Bool +cfb8_32WidPositionWindow(WindowPtr pWin, int x, int y) +{ + return TRUE; +} + +static void +SegregateChildrenBpp(WindowPtr pWin, RegionPtr pReg, int subtract, int bpp, int other_bpp) +{ + WindowPtr pChild; + + for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { + if (pChild->drawable.bitsPerPixel == bpp) { + if (subtract) { + REGION_SUBTRACT(pWin->drawable.pScreen, pReg, + pReg, &pChild->borderClip); + } else { + REGION_UNION(pWin->drawable.pScreen, pReg, + pReg, &pChild->borderClip); + } + if (pChild->firstChild) + SegregateChildrenBpp(pChild, pReg, + !subtract, other_bpp, bpp); + } else { + if (pChild->firstChild) + SegregateChildrenBpp(pChild, pReg, + subtract, bpp, other_bpp); + } + } +} + +void +cfb8_32WidCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + PixmapPtr pPixChildren; + DDXPointPtr ppt, pptSrc; + RegionRec rgnDst, rgnOther, rgnPixmap; + BoxPtr pbox; + int i, nbox, dx, dy, other_bpp; + + 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, &pWin->borderClip, prgnSrc); + + if ((nbox = REGION_NUM_RECTS(&rgnDst)) == 0) { + /* Nothing to render. */ + REGION_UNINIT(pScreen, &rgnDst); + return; + } + + /* First, copy the WID plane for the whole area. */ + pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)); + if(pptSrc) { + pbox = REGION_RECTS(&rgnDst); + for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + pScreenPriv->WIDOps->WidCopyArea((DrawablePtr)pScreenPriv->pixWid, + &rgnDst, pptSrc); + + DEALLOCATE_LOCAL(pptSrc); + } + + /* Next, we copy children which have a different + * bpp than pWin into a temporary pixmap. We will + * toss this pixmap back onto the framebuffer before + * we return. + */ + if (pWin->drawable.bitsPerPixel == 8) + other_bpp = pScrn->bitsPerPixel; + else + other_bpp = 8; + + REGION_INIT(pScreen, &rgnOther, NullBox, 0); + SegregateChildrenBpp(pWin, &rgnOther, 0, + other_bpp, pWin->drawable.bitsPerPixel); + pPixChildren = NULL; + if (REGION_NOTEMPTY(pScreen, &rgnOther)) { + REGION_INTERSECT(pScreen, &rgnOther, &rgnOther, prgnSrc); + nbox = REGION_NUM_RECTS(&rgnOther); + if (nbox) { + int width = rgnOther.extents.x2 - rgnOther.extents.x1; + int height = rgnOther.extents.y2 - rgnOther.extents.y1; + int depth = (other_bpp == 8) ? 8 : pScrn->depth; + + if (other_bpp == 8) + pPixChildren = cfbCreatePixmap(pScreen, width, height, depth); + else + pPixChildren = cfb32CreatePixmap(pScreen, width, height, depth); + } + if (nbox && + pPixChildren && + (pptSrc = (DDXPointPtr) ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) { + pbox = REGION_RECTS(&rgnOther); + for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + REGION_INIT(pScreen, &rgnPixmap, NullBox, 0); + REGION_COPY(pScreen, &rgnPixmap, &rgnOther); + REGION_TRANSLATE(pScreen, &rgnPixmap, -(rgnOther.extents.x1), -(rgnOther.extents.y1)); + + if (other_bpp == 8) + cfbDoBitbltCopy((DrawablePtr)pScreenPriv->pix8, + (DrawablePtr)pPixChildren, + GXcopy, &rgnPixmap, pptSrc, ~0L); + else + cfb32DoBitbltCopy((DrawablePtr)pScreenPriv->pix32, + (DrawablePtr)pPixChildren, + GXcopy, &rgnPixmap, pptSrc, ~0L); + + REGION_UNINIT(pScreen, &rgnPixmap); + + DEALLOCATE_LOCAL(pptSrc); + } + + REGION_SUBTRACT(pScreen, &rgnDst, &rgnDst, &rgnOther); + } + + /* Now copy the parent along with all child windows using the same depth. */ + nbox = REGION_NUM_RECTS(&rgnDst); + if(nbox && + (pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) { + pbox = REGION_RECTS(&rgnDst); + for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + if (pWin->drawable.bitsPerPixel == 8) + cfbDoBitbltCopy((DrawablePtr)pScreenPriv->pix8, + (DrawablePtr)pScreenPriv->pix8, + GXcopy, &rgnDst, pptSrc, ~0L); + else + cfb32DoBitbltCopy((DrawablePtr)pScreenPriv->pix32, + (DrawablePtr)pScreenPriv->pix32, + GXcopy, &rgnDst, pptSrc, ~0L); + + DEALLOCATE_LOCAL(pptSrc); + } + + REGION_UNINIT(pScreen, &rgnDst); + + if (pPixChildren) { + nbox = REGION_NUM_RECTS(&rgnOther); + pptSrc = (DDXPointPtr) ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)); + if (pptSrc) { + pbox = REGION_RECTS(&rgnOther); + for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { + ppt->x = pbox->x1 - rgnOther.extents.x1; + ppt->y = pbox->y1 - rgnOther.extents.y1; + } + + if (other_bpp == 8) + cfbDoBitbltCopy((DrawablePtr)pPixChildren, + (DrawablePtr)pScreenPriv->pix8, + GXcopy, &rgnOther, pptSrc, ~0L); + else + cfb32DoBitbltCopy((DrawablePtr)pPixChildren, + (DrawablePtr)pScreenPriv->pix32, + GXcopy, &rgnOther, pptSrc, ~0L); + + DEALLOCATE_LOCAL(pptSrc); + } + + if (other_bpp == 8) + cfbDestroyPixmap(pPixChildren); + else + cfb32DestroyPixmap(pPixChildren); + } + REGION_UNINIT(pScreen, &rgnOther); +} + +Bool +cfb8_32WidChangeWindowAttributes(WindowPtr pWin, unsigned long mask) +{ + return TRUE; +} + +void +cfb8_32WidWindowExposures(WindowPtr pWin, RegionPtr pReg, RegionPtr pOtherReg) +{ + /* Fill in the WID channel before rendering of + * the exposed window area. + */ + if (REGION_NUM_RECTS(pReg)) { + ScreenPtr pScreen = pWin->drawable.pScreen; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + + pScreenPriv->WIDOps->WidFillBox((DrawablePtr)pScreenPriv->pixWid, + (DrawablePtr)pWin, + REGION_NUM_RECTS(pReg), REGION_RECTS(pReg)); + } + + miWindowExposures(pWin, pReg, pOtherReg); +} + +void +cfb8_32WidPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) +{ + if (what == PW_BORDER) { + ScreenPtr pScreen = pWin->drawable.pScreen; + cfb8_32WidScreenPtr pScreenPriv = + CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); + + pScreenPriv->WIDOps->WidFillBox((DrawablePtr)pScreenPriv->pixWid, + (DrawablePtr)pWin, + REGION_NUM_RECTS(pRegion), + REGION_RECTS(pRegion)); + } + + if (pWin->drawable.bitsPerPixel == 8) + cfbPaintWindow(pWin, pRegion, what); + else + cfb32PaintWindow(pWin, pRegion, what); +} + |