Bool XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XAAScreenPtr pScreenPriv; int i; #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif /* Return successfully if no acceleration wanted */ if (!infoRec) return TRUE; if (XAAGeneration != serverGeneration) { if ( ((XAAScreenIndex = AllocateScreenPrivateIndex()) < 0) || ((XAAGCIndex = AllocateGCPrivateIndex()) < 0) || ((XAAPixmapIndex = AllocatePixmapPrivateIndex()) < 0)) return FALSE; XAAGeneration = serverGeneration; } if (!AllocateGCPrivate(pScreen, XAAGCIndex, sizeof(XAAGCRec))) return FALSE; if (!AllocatePixmapPrivate(pScreen, XAAPixmapIndex, sizeof(XAAPixmapRec))) return FALSE; if (!(pScreenPriv = xalloc(sizeof(XAAScreenRec)))) return FALSE; pScreen->devPrivates[XAAScreenIndex].ptr = (pointer)pScreenPriv; if(!xf86FBManagerRunning(pScreen)) infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS); if(!(infoRec->Flags & LINEAR_FRAMEBUFFER)) infoRec->Flags &= ~OFFSCREEN_PIXMAPS; if(!infoRec->FullPlanemask) { /* for backwards compatibility */ infoRec->FullPlanemask = (1 << pScrn->depth) - 1; infoRec->FullPlanemasks[pScrn->depth - 1] = infoRec->FullPlanemask; } for(i = 0; i < 32; i++) { if(!infoRec->FullPlanemasks[i]) /* keep any set by caller */ infoRec->FullPlanemasks[i] = (1 << (i+1)) - 1; } if(!XAAInitAccel(pScreen, infoRec)) return FALSE; pScreenPriv->AccelInfoRec = infoRec; infoRec->ScratchGC.pScreen = pScreen; if(!infoRec->GetImage) infoRec->GetImage = XAAGetImage; if(!infoRec->GetSpans) infoRec->GetSpans = XAAGetSpans; if(!infoRec->PaintWindowBackground) infoRec->PaintWindowBackground = XAAPaintWindow; if(!infoRec->PaintWindowBorder) infoRec->PaintWindowBorder = XAAPaintWindow; if(!infoRec->CopyWindow) infoRec->CopyWindow = XAACopyWindow; if(!infoRec->SaveAreas) infoRec->SaveAreas = XAASaveAreas; if(!infoRec->RestoreAreas) infoRec->RestoreAreas = XAARestoreAreas; pScreenPriv->CreateGC = pScreen->CreateGC; pScreen->CreateGC = XAACreateGC; pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = XAACloseScreen; pScreenPriv->GetImage = pScreen->GetImage; pScreen->GetImage = infoRec->GetImage; pScreenPriv->GetSpans = pScreen->GetSpans; pScreen->GetSpans = infoRec->GetSpans; pScreenPriv->PaintWindowBackground = pScreen->PaintWindowBackground; pScreen->PaintWindowBackground = infoRec->PaintWindowBackground; pScreenPriv->PaintWindowBorder = pScreen->PaintWindowBorder; pScreen->PaintWindowBorder = infoRec->PaintWindowBorder; pScreenPriv->CopyWindow = pScreen->CopyWindow; pScreen->CopyWindow = infoRec->CopyWindow; pScreenPriv->CreatePixmap = pScreen->CreatePixmap; pScreen->CreatePixmap = XAACreatePixmap; pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap; pScreen->DestroyPixmap = XAADestroyPixmap; pScreenPriv->BackingStoreFuncs.RestoreAreas = pScreen->BackingStoreFuncs.RestoreAreas; pScreen->BackingStoreFuncs.RestoreAreas = infoRec->RestoreAreas; pScreenPriv->BackingStoreFuncs.SaveAreas = pScreen->BackingStoreFuncs.SaveAreas; pScreen->BackingStoreFuncs.SaveAreas = infoRec->SaveAreas; pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; pScreen->ChangeWindowAttributes = XAAChangeWindowAttributes; pScreenPriv->EnterVT = pScrn->EnterVT; pScrn->EnterVT = XAAEnterVT; pScreenPriv->LeaveVT = pScrn->LeaveVT; pScrn->LeaveVT = XAALeaveVT; pScreenPriv->SetDGAMode = pScrn->SetDGAMode; pScrn->SetDGAMode = XAASetDGAMode; pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess; pScreenPriv->WindowExposures = pScreen->WindowExposures; #ifdef RENDER if (ps) { pScreenPriv->Composite = ps->Composite; ps->Composite = XAAComposite; pScreenPriv->Glyphs = ps->Glyphs; ps->Glyphs = XAAGlyphs; } #endif if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR) XAASetupOverlay8_32Planar(pScreen); infoRec->PreAllocMem = xalloc(MAX_PREALLOC_MEM); if(infoRec->PreAllocMem) infoRec->PreAllocSize = MAX_PREALLOC_MEM; if(infoRec->Flags & PIXMAP_CACHE) xf86RegisterFreeBoxCallback(pScreen, infoRec->InitPixmapCache, (pointer)infoRec); if(infoRec->Flags & MICROSOFT_ZERO_LINE_BIAS) miSetZeroLineBias(pScreen, OCTANT1 | OCTANT2 | OCTANT3 | OCTANT4); #ifdef COMPOSITE /* Initialize the composite wrapper. This needs to happen after the * wrapping above (so it comes before us), but before all other extensions, * so it doesn't confuse them. (particularly damage). */ miInitializeCompositeWrapper(pScreen); #endif return TRUE; }
Bool miScreenInit(ScreenPtr pScreen, void *pbits, /* pointer to screen bits */ int xsize, int ysize, /* in pixels */ int dpix, int dpiy, /* dots per inch */ int width, /* pixel width of frame buffer */ int rootDepth, /* depth of root window */ int numDepths, /* number of depths supported */ DepthRec * depths, /* supported depths */ VisualID rootVisual, /* root visual */ int numVisuals, /* number of visuals supported */ VisualRec * visuals /* supported visuals */ ) { pScreen->width = xsize; pScreen->height = ysize; pScreen->mmWidth = (xsize * 254 + dpix * 5) / (dpix * 10); pScreen->mmHeight = (ysize * 254 + dpiy * 5) / (dpiy * 10); pScreen->numDepths = numDepths; pScreen->rootDepth = rootDepth; pScreen->allowedDepths = depths; pScreen->rootVisual = rootVisual; /* defColormap */ pScreen->minInstalledCmaps = 1; pScreen->maxInstalledCmaps = 1; pScreen->backingStoreSupport = NotUseful; pScreen->saveUnderSupport = NotUseful; /* whitePixel, blackPixel */ pScreen->ModifyPixmapHeader = miModifyPixmapHeader; pScreen->CreateScreenResources = miCreateScreenResources; pScreen->GetScreenPixmap = miGetScreenPixmap; pScreen->SetScreenPixmap = miSetScreenPixmap; pScreen->numVisuals = numVisuals; pScreen->visuals = visuals; if (width) { #ifdef MITSHM ShmRegisterFbFuncs(pScreen); #endif pScreen->CloseScreen = miCloseScreen; } /* else CloseScreen */ /* QueryBestSize */ pScreen->SaveScreen = miSaveScreen; /* GetImage, GetSpans */ pScreen->SourceValidate = (SourceValidateProcPtr) 0; /* CreateWindow, DestroyWindow, PositionWindow, ChangeWindowAttributes */ /* RealizeWindow, UnrealizeWindow */ pScreen->ValidateTree = miValidateTree; pScreen->PostValidateTree = (PostValidateTreeProcPtr) 0; pScreen->WindowExposures = miWindowExposures; /* CopyWindow */ pScreen->ClearToBackground = miClearToBackground; pScreen->ClipNotify = (ClipNotifyProcPtr) 0; pScreen->RestackWindow = (RestackWindowProcPtr) 0; pScreen->PaintWindow = miPaintWindow; /* CreatePixmap, DestroyPixmap */ /* RealizeFont, UnrealizeFont */ /* CreateGC */ /* CreateColormap, DestroyColormap, InstallColormap, UninstallColormap */ /* ListInstalledColormaps, StoreColors, ResolveColor */ /* BitmapToRegion */ pScreen->BlockHandler = (ScreenBlockHandlerProcPtr) NoopDDA; pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr) NoopDDA; pScreen->MarkWindow = miMarkWindow; pScreen->MarkOverlappedWindows = miMarkOverlappedWindows; pScreen->MoveWindow = miMoveWindow; pScreen->ResizeWindow = miResizeWindow; pScreen->GetLayerWindow = miGetLayerWindow; pScreen->HandleExposures = miHandleValidateExposures; pScreen->ReparentWindow = (ReparentWindowProcPtr) 0; pScreen->ChangeBorderWidth = miChangeBorderWidth; pScreen->SetShape = miSetShape; pScreen->MarkUnrealizedWindow = miMarkUnrealizedWindow; pScreen->XYToWindow = miXYToWindow; miSetZeroLineBias(pScreen, DEFAULTZEROLINEBIAS); return miScreenDevPrivateInit(pScreen, width, pbits); }
vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) #endif { #if XORG < 113 vfbScreenInfoPtr pvfb = &vfbScreens[index]; #else vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; #endif int dpi; int ret; void *pbits; #ifdef RANDR rrScrPrivPtr rp; #endif #if XORG >= 113 if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; #endif /* 96 is the default used by most other systems */ dpi = 96; if (monitorResolution) dpi = monitorResolution; pbits = vfbAllocateFramebufferMemory(&pvfb->fb); if (!pbits) return FALSE; #if XORG < 113 vncFbptr[index] = pbits; vncFbstride[index] = pvfb->fb.paddedWidth; #else vncFbptr[pScreen->myNum] = pbits; vncFbstride[pScreen->myNum] = pvfb->fb.paddedWidth; #endif miSetPixmapDepths(); switch (pvfb->fb.depth) { case 8: miSetVisualTypesAndMasks (8, ((1 << StaticGray) | (1 << GrayScale) | (1 << StaticColor) | (1 << PseudoColor) | (1 << TrueColor) | (1 << DirectColor)), 8, PseudoColor, 0, 0, 0); break; case 16: miSetVisualTypesAndMasks (16, ((1 << TrueColor) | (1 << DirectColor)), 8, TrueColor, 0xf800, 0x07e0, 0x001f); break; case 24: miSetVisualTypesAndMasks (24, ((1 << TrueColor) | (1 << DirectColor)), 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); break; case 32: miSetVisualTypesAndMasks (32, ((1 << TrueColor) | (1 << DirectColor)), 8, TrueColor, 0xff000000, 0x00ff0000, 0x0000ff00); break; default: return FALSE; } ret = fbScreenInit(pScreen, pbits, pvfb->fb.width, pvfb->fb.height, dpi, dpi, pvfb->fb.paddedWidth, pvfb->fb.bitsPerPixel); #ifdef RENDER if (ret && Render) ret = fbPictureInit (pScreen, 0, 0); #endif if (!ret) return FALSE; #if XORG < 110 miInitializeBackingStore(pScreen); #endif /* * Circumvent the backing store that was just initialised. This amounts * to a truely bizarre way of initialising SaveDoomedAreas and friends. */ pScreen->InstallColormap = vfbInstallColormap; pScreen->UninstallColormap = vfbUninstallColormap; pScreen->ListInstalledColormaps = vfbListInstalledColormaps; pScreen->SaveScreen = vfbSaveScreen; miPointerInitialize(pScreen, &vfbPointerSpriteFuncs, &vfbPointerCursorFuncs, FALSE); pScreen->blackPixel = pvfb->blackPixel; pScreen->whitePixel = pvfb->whitePixel; if (!pvfb->pixelFormatDefined) { switch (pvfb->fb.depth) { case 16: pvfb->pixelFormatDefined = TRUE; pvfb->rgbNotBgr = TRUE; pvfb->blueBits = pvfb->redBits = 5; pvfb->greenBits = 6; break; case 24: case 32: pvfb->pixelFormatDefined = TRUE; pvfb->rgbNotBgr = TRUE; pvfb->blueBits = pvfb->redBits = pvfb->greenBits = 8; break; } } if (pvfb->pixelFormatDefined) { VisualPtr vis = pScreen->visuals; for (int i = 0; i < pScreen->numVisuals; i++) { if (pvfb->rgbNotBgr) { vis->offsetBlue = 0; vis->blueMask = (1 << pvfb->blueBits) - 1; vis->offsetGreen = pvfb->blueBits; vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; vis->offsetRed = vis->offsetGreen + pvfb->greenBits; vis->redMask = ((1 << pvfb->redBits) - 1) << vis->offsetRed; } else { vis->offsetRed = 0; vis->redMask = (1 << pvfb->redBits) - 1; vis->offsetGreen = pvfb->redBits; vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; vis->offsetBlue = vis->offsetGreen + pvfb->greenBits; vis->blueMask = ((1 << pvfb->blueBits) - 1) << vis->offsetBlue; } vis++; } } ret = fbCreateDefColormap(pScreen); if (!ret) return FALSE; miSetZeroLineBias(pScreen, pvfb->lineBias); pvfb->closeScreen = pScreen->CloseScreen; pScreen->CloseScreen = vfbCloseScreen; #ifdef RANDR ret = RRScreenInit(pScreen); if (!ret) return FALSE; rp = rrGetScrPriv(pScreen); rp->rrGetInfo = vncRandRGetInfo; rp->rrSetConfig = NULL; rp->rrScreenSetSize = vncRandRScreenSetSize; rp->rrCrtcSet = vncRandRCrtcSet; rp->rrOutputValidateMode = vncRandROutputValidateMode; rp->rrModeDestroy = vncRandRModeDestroy; ret = vncRandRInit(pScreen); if (!ret) return FALSE; #endif return TRUE; } /* end vfbScreenInit */