From 7777730e7749fe6921e76a4a1738e0e2a0b16376 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 30 Nov 2006 16:03:35 -0500 Subject: Fix shadow support yet again. --- src/vesa.c | 55 ++++++++++++++++++++++++++++++++++++++++++------------- src/vesa.h | 4 ++++ 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/vesa.c b/src/vesa.c index bd4bf42..63e2491 100644 --- a/src/vesa.c +++ b/src/vesa.c @@ -746,6 +746,23 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags) return (TRUE); } +static Bool +vesaCreateScreenResources(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + VESAPtr pVesa = VESAGetRec(pScrn); + Bool ret; + + pScreen->CreateScreenResources = pVesa->CreateScreenResources; + ret = pScreen->CreateScreenResources(pScreen); + pScreen->CreateScreenResources = vesaCreateScreenResources; + + shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen), pVesa->update, + pVesa->window, 0, 0); + + return ret; +} + static Bool VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { @@ -788,6 +805,16 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (pVesa->shadowFB && pScrn->bitsPerPixel == 4) pScrn->bitsPerPixel = 8; + if (pVesa->shadowFB) { + pVesa->shadow = xcalloc(1, pScrn->displayWidth * pScrn->virtualY * + ((pScrn->bitsPerPixel + 7) / 8)); + if (!pVesa->shadow) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to allocate shadow buffer\n"); + return FALSE; + } + } + /* save current video state */ VESASaveRestore(pScrn, MODE_SAVE); pVesa->savedPal = VBESetGetPaletteData(pVesa->pVbe, FALSE, 0, 256, @@ -865,7 +892,7 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) case 24: case 32: if (!fbScreenInit(pScreen, - pVesa->base, + pVesa->shadowFB ? pVesa->shadow : pVesa->base, pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel)) @@ -901,27 +928,26 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) fbPictureInit(pScreen, 0, 0); if (pVesa->shadowFB) { - ShadowUpdateProc update; - ShadowWindowProc window; - if (mode->MemoryModel == 3) { /* Planar */ if (pScrn->bitsPerPixel == 8) - update = shadowUpdatePlanar4x8Weak(); + pVesa->update = shadowUpdatePlanar4x8Weak(); else - update = shadowUpdatePlanar4Weak(); - window = VESAWindowPlanar; + pVesa->update = shadowUpdatePlanar4Weak(); + pVesa->window = VESAWindowPlanar; } else if (pVesa->mapPhys == 0xa0000) { /* Windowed */ - update = shadowUpdatePackedWeak(); - window = VESAWindowWindowed; + pVesa->update = shadowUpdatePackedWeak(); + pVesa->window = VESAWindowWindowed; } else { /* Linear */ - update = shadowUpdatePackedWeak(); - window = VESAWindowLinear; + pVesa->update = shadowUpdatePackedWeak(); + pVesa->window = VESAWindowLinear; } - if (!shadowInit(pScreen, update, window)) - return (FALSE); + if (!shadowSetup(pScreen)) + return FALSE; + pVesa->CreateScreenResources = pScreen->CreateScreenResources; + pScreen->CreateScreenResources = vesaCreateScreenResources; } else if (pVesa->mapPhys == 0xa0000 && mode->MemoryModel != 0x3) { unsigned int bankShift = 0; @@ -1005,6 +1031,8 @@ VESACloseScreen(int scrnIndex, ScreenPtr pScreen) pVesa->savedPal, FALSE, TRUE); VESAUnmapVidMem(pScrn); } + if (pVesa->shadowFB && pVesa->shadow) + xfree(pVesa->shadow); if (pVesa->pDGAMode) { xfree(pVesa->pDGAMode); pVesa->pDGAMode = NULL; @@ -1012,6 +1040,7 @@ VESACloseScreen(int scrnIndex, ScreenPtr pScreen) } pScrn->vtSema = FALSE; + pScreen->CreateScreenResources = pVesa->CreateScreenResources; pScreen->CloseScreen = pVesa->CloseScreen; return pScreen->CloseScreen(scrnIndex, pScreen); } diff --git a/src/vesa.h b/src/vesa.h index 300281d..6110a71 100644 --- a/src/vesa.h +++ b/src/vesa.h @@ -116,9 +116,13 @@ typedef struct _VESARec DGAModePtr pDGAMode; int nDGAMode; CloseScreenProcPtr CloseScreen; + CreateScreenResourcesProcPtr CreateScreenResources; OptionInfoPtr Options; IOADDRESS ioBase; Bool ModeSetClearScreen; + void *shadow; + ShadowUpdateProc update; + ShadowWindowProc window; } VESARec, *VESAPtr; -- cgit v1.2.3