diff options
Diffstat (limited to 'xc/programs/Xserver/hw/darwin/quartz/fullscreen.c')
-rw-r--r-- | xc/programs/Xserver/hw/darwin/quartz/fullscreen.c | 78 |
1 files changed, 67 insertions, 11 deletions
diff --git a/xc/programs/Xserver/hw/darwin/quartz/fullscreen.c b/xc/programs/Xserver/hw/darwin/quartz/fullscreen.c index 46b562794..e51211559 100644 --- a/xc/programs/Xserver/hw/darwin/quartz/fullscreen.c +++ b/xc/programs/Xserver/hw/darwin/quartz/fullscreen.c @@ -26,13 +26,14 @@ * dealings in this Software without prior written authorization from * Torrey T. Lyons. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/fullscreen.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/fullscreen.c,v 1.3 2002/12/10 00:00:39 torrey Exp $ */ #include "quartzCommon.h" #include "darwin.h" #include "colormapst.h" #include "scrnintstr.h" #include "micmap.h" +#include "shadow.h" // Full screen specific per screen storage structure typedef struct { @@ -41,6 +42,8 @@ typedef struct { CFDictionaryRef aquaDisplayMode; CGDirectPaletteRef xPalette; CGDirectPaletteRef aquaPalette; + unsigned char *framebuffer; + unsigned char *shadowPtr; } QuartzFSScreenRec, *QuartzFSScreenPtr; #define FULLSCREEN_PRIV(pScreen) \ @@ -327,30 +330,76 @@ Bool QuartzFSAddScreen( dfb->height = bounds.size.height; dfb->pitch = CGDisplayBytesPerRow(cgID); dfb->bitsPerPixel = CGDisplayBitsPerPixel(cgID); - dfb->pixelInfo.componentCount = CGDisplaySamplesPerPixel(cgID); if (dfb->bitsPerPixel == 8) { if (CGDisplayCanSetPalette(cgID)) { - dfb->pixelInfo.pixelType = kIOCLUTPixels; + dfb->colorType = PseudoColor; } else { - dfb->pixelInfo.pixelType = kIOFixedCLUTPixels; + dfb->colorType = StaticColor; } - dfb->pixelInfo.bitsPerComponent = 8; + dfb->bitsPerComponent = 8; dfb->colorBitsPerPixel = 8; } else { - dfb->pixelInfo.pixelType = kIORGBDirectPixels; - dfb->pixelInfo.bitsPerComponent = CGDisplayBitsPerSample(cgID); - dfb->colorBitsPerPixel = (dfb->pixelInfo.componentCount * - dfb->pixelInfo.bitsPerComponent); + dfb->colorType = TrueColor; + dfb->bitsPerComponent = CGDisplayBitsPerSample(cgID); + dfb->colorBitsPerPixel = CGDisplaySamplesPerPixel(cgID) * + dfb->bitsPerComponent; } - dfb->framebuffer = CGDisplayBaseAddress(cgID); + fsDisplayInfo->framebuffer = CGDisplayBaseAddress(cgID); + + // allocate shadow framebuffer + fsDisplayInfo->shadowPtr = shadowAlloc(dfb->width, dfb->height, + dfb->bitsPerPixel); + dfb->framebuffer = fsDisplayInfo->shadowPtr; return TRUE; } /* + * QuartzFSShadowUpdate + * Update the damaged regions of the shadow framebuffer on the display. + */ +static void QuartzFSShadowUpdate(ScreenPtr pScreen, + shadowBufPtr pBuf) +{ + DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen); + QuartzFSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen); + RegionPtr damage = &pBuf->damage; + int numBox = REGION_NUM_RECTS(damage); + BoxPtr pBox = REGION_RECTS(damage); + int pitch = dfb->pitch; + int bpp = dfb->bitsPerPixel/8; + + // Don't update if the X server is not visible + if (!quartzServerVisible) + return; + + // Loop through all the damaged boxes + while (numBox--) { + int width, height, offset; + unsigned char *src, *dst; + + width = (pBox->x2 - pBox->x1) * bpp; + height = pBox->y2 - pBox->y1; + offset = (pBox->y1 * pitch) + (pBox->x1 * bpp); + src = fsDisplayInfo->shadowPtr + offset; + dst = fsDisplayInfo->framebuffer + offset; + + while (height--) { + memcpy(dst, src, width); + dst += pitch; + src += pitch; + } + + // Get the next box + pBox++; + } +} + + +/* * QuartzFSSetupScreen * Finalize full screen specific setup of each screen. */ @@ -362,7 +411,14 @@ Bool QuartzFSSetupScreen( QuartzFSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen); CGDirectDisplayID cgID = fsDisplayInfo->displayID; - if (dfb->pixelInfo.pixelType == kIOCLUTPixels) { + // Initialize shadow framebuffer support + if (! shadowInit(pScreen, QuartzFSShadowUpdate, NULL)) { + ErrorF("Failed to initalize shadow framebuffer for screen %i.\n", + index); + return FALSE; + } + + if (dfb->colorType == PseudoColor) { // Initialize colormap handling size_t aquaBpp; |