Bool glamor_font_init(ScreenPtr screen) { if (glamor_font_generation != serverGeneration) { glamor_font_private_index = AllocateFontPrivateIndex(); if (glamor_font_private_index == -1) return FALSE; glamor_font_screen_count = 0; glamor_font_generation = serverGeneration; } if (screen->myNum >= glamor_font_screen_count) glamor_font_screen_count = screen->myNum + 1; screen->RealizeFont = glamor_realize_font; screen->UnrealizeFont = glamor_unrealize_font; return TRUE; }
void XFree86BigfontExtensionInit(void) { if (AddExtension(XF86BIGFONTNAME, XF86BigfontNumberEvents, XF86BigfontNumberErrors, ProcXF86BigfontDispatch, SProcXF86BigfontDispatch, XF86BigfontResetProc, StandardMinorOpcode)) { #ifdef HAS_SHM #ifdef MUST_CHECK_FOR_SHM_SYSCALL /* * Note: Local-clients will not be optimized without shared memory * support. Remote-client optimization does not depend on shared * memory support. Thus, the extension is still registered even * when shared memory support is not functional. */ if (!CheckForShmSyscall()) { ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n"); return; } #endif srand((unsigned int) time(NULL)); signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16) + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ FontShmdescIndex = AllocateFontPrivateIndex(); #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; #else # ifdef _SC_PAGESIZE pagesize = sysconf(_SC_PAGESIZE); # else pagesize = getpagesize(); # endif #endif #endif } }
void XFree86BigfontExtensionInit() { ExtensionEntry* extEntry; if ((extEntry = AddExtension(XF86BIGFONTNAME, XF86BigfontNumberEvents, XF86BigfontNumberErrors, ProcXF86BigfontDispatch, SProcXF86BigfontDispatch, XF86BigfontResetProc, StandardMinorOpcode))) { XF86BigfontReqCode = (unsigned char) extEntry->base; #ifdef HAS_SHM #ifdef MUST_CHECK_FOR_SHM_SYSCALL if (!CheckForShmSyscall()) { ErrorF(XF86BIGFONTNAME " extension disabled due to lack of shared memory support in the kernel\n"); return; } #endif srand((unsigned int) time(NULL)); signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16) + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ FontShmdescIndex = AllocateFontPrivateIndex(); #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; #else # ifdef _SC_PAGESIZE pagesize = sysconf(_SC_PAGESIZE); # else pagesize = getpagesize(); # endif #endif #endif } }
void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) { int i, j; xnestOpenDisplay(argc, argv); screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay); screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay); screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay); screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay); screenInfo->numPixmapFormats = 0; for (i = 0; i < xnestNumPixmapFormats; i++) for (j = 0; j < xnestNumDepths; j++) if ((xnestPixmapFormats[i].depth == 1) || (xnestPixmapFormats[i].depth == xnestDepths[j])) { screenInfo->formats[screenInfo->numPixmapFormats].depth = xnestPixmapFormats[i].depth; screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel = xnestPixmapFormats[i].bits_per_pixel; screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad = xnestPixmapFormats[i].scanline_pad; screenInfo->numPixmapFormats++; break; } xnestWindowPrivateIndex = AllocateWindowPrivateIndex(); xnestGCPrivateIndex = AllocateGCPrivateIndex(); xnestFontPrivateIndex = AllocateFontPrivateIndex(); if (!xnestNumScreens) xnestNumScreens = 1; for (i = 0; i < xnestNumScreens; i++) AddScreen(xnestOpenScreen, argc, argv); xnestNumScreens = screenInfo->numScreens; xnestDoFullGeneration = xnestFullGeneration; }
void XFree86BigfontExtensionInit() { #if 0 ExtensionEntry* extEntry; if ((extEntry = AddExtension(XF86BIGFONTNAME, XF86BigfontNumberEvents, XF86BigfontNumberErrors, ProcXF86BigfontDispatch, SProcXF86BigfontDispatch, XF86BigfontResetProc, StandardMinorOpcode))) { XF86BigfontReqCode = (unsigned char) extEntry->base; #else if (AddExtension(XF86BIGFONTNAME, XF86BigfontNumberEvents, XF86BigfontNumberErrors, ProcXF86BigfontDispatch, SProcXF86BigfontDispatch, XF86BigfontResetProc, StandardMinorOpcode)) { #endif #ifdef HAS_SHM #ifdef MUST_CHECK_FOR_SHM_SYSCALL /* * Note: Local-clients will not be optimized without shared memory * support. Remote-client optimization does not depend on shared * memory support. Thus, the extension is still registered even * when shared memory support is not functional. */ if (!CheckForShmSyscall()) { ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n"); return; } #endif srand((unsigned int) time(NULL)); signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16) + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ FontShmdescIndex = AllocateFontPrivateIndex(); #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; #else # ifdef _SC_PAGESIZE pagesize = sysconf(_SC_PAGESIZE); # else pagesize = getpagesize(); # endif #endif #endif } } /* ========== Management of shared memory segments ========== */ #ifdef HAS_SHM #ifdef __linux__ /* On Linux, shared memory marked as "removed" can still be attached. Nice feature, because the kernel will automatically free the associated storage when the server and all clients are gone. */ #define EARLY_REMOVE #endif typedef struct _ShmDesc { struct _ShmDesc *next; struct _ShmDesc **prev; int shmid; char *attach_addr; } ShmDescRec, *ShmDescPtr; static ShmDescPtr ShmList = (ShmDescPtr) NULL; static ShmDescPtr shmalloc( unsigned int size) { ShmDescPtr pDesc; int shmid; char *addr; #ifdef MUST_CHECK_FOR_SHM_SYSCALL if (pagesize == 0) return (ShmDescPtr) NULL; #endif /* On some older Linux systems, the number of shared memory segments system-wide is 127. In Linux 2.4, it is 4095. Therefore there is a tradeoff to be made between allocating a shared memory segment on one hand, and allocating memory and piping the glyph metrics on the other hand. If the glyph metrics size is small, we prefer the traditional way. */ if (size < 3500) return (ShmDescPtr) NULL; pDesc = (ShmDescRec *) xalloc(sizeof(ShmDescRec)); if (!pDesc) return (ShmDescPtr) NULL; size = (size + pagesize-1) & -pagesize; shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); if (shmid == -1) { ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, errno = %d\n", size, errno); xfree(pDesc); return (ShmDescPtr) NULL; } if ((addr = shmat(shmid, 0, 0)) == (char *)-1) { ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, errno = %d\n", size, errno); shmctl(shmid, IPC_RMID, (void *) 0); xfree(pDesc); return (ShmDescPtr) NULL; } #ifdef EARLY_REMOVE shmctl(shmid, IPC_RMID, (void *) 0); #endif pDesc->shmid = shmid; pDesc->attach_addr = addr; if (ShmList) ShmList->prev = &pDesc->next; pDesc->next = ShmList; pDesc->prev = &ShmList; ShmList = pDesc; return pDesc; }
void LbxDixInit(void) { TagInit(); lbx_font_private = AllocateFontPrivateIndex(); }