From: Peter Åstrand Date: Tue, 22 Feb 2005 21:05:16 +0000 (+0000) Subject: Synched vfbAllocateFramebufferMemory with modern InitOutput.c. X-Git-Tag: v0.0.90~384^2~615 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8de329f6e0e96d2d3610ee8b800e1893c7838a8e;p=tigervnc.git Synched vfbAllocateFramebufferMemory with modern InitOutput.c. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@220 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/xc/programs/Xserver/vnc/Xvnc/xvnc.cc b/xc/programs/Xserver/vnc/Xvnc/xvnc.cc index 0dd0a034..c11a2f6d 100644 --- a/xc/programs/Xserver/vnc/Xvnc/xvnc.cc +++ b/xc/programs/Xserver/vnc/Xvnc/xvnc.cc @@ -736,49 +736,66 @@ vfbSaveScreen(ScreenPtr pScreen, int on) return TRUE; } -static char* vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb) +static char * +vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb) { - if (pvfb->pfbMemory) return pvfb->pfbMemory; /* already done */ + if (pvfb->pfbMemory) return pvfb->pfbMemory; /* already done */ - pvfb->sizeInBytes = pvfb->paddedBytesWidth * pvfb->height; + pvfb->sizeInBytes = pvfb->paddedBytesWidth * pvfb->height; - /* Calculate how many entries in colormap. This is rather bogus, because - * the visuals haven't even been set up yet, but we need to know because we - * have to allocate space in the file for the colormap. The number 10 - * below comes from the MAX_PSEUDO_DEPTH define in cfbcmap.c. - */ + /* Calculate how many entries in colormap. This is rather bogus, because + * the visuals haven't even been set up yet, but we need to know because we + * have to allocate space in the file for the colormap. The number 10 + * below comes from the MAX_PSEUDO_DEPTH define in cfbcmap.c. + */ - if (pvfb->depth <= 10) - { /* single index colormaps */ - pvfb->ncolors = 1 << pvfb->depth; - } - else - { /* decomposed colormaps */ - int nplanes_per_color_component = pvfb->depth / 3; - if (pvfb->depth % 3) nplanes_per_color_component++; - pvfb->ncolors = 1 << nplanes_per_color_component; - } + if (pvfb->depth <= 10) + { /* single index colormaps */ + pvfb->ncolors = 1 << pvfb->depth; + } + else + { /* decomposed colormaps */ + int nplanes_per_color_component = pvfb->depth / 3; + if (pvfb->depth % 3) nplanes_per_color_component++; + pvfb->ncolors = 1 << nplanes_per_color_component; + } - /* add extra bytes for XWDFileHeader, window name, and colormap */ + /* add extra bytes for XWDFileHeader, window name, and colormap */ - pvfb->sizeInBytes += SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN + - pvfb->ncolors * SIZEOF(XWDColor); + pvfb->sizeInBytes += SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN + + pvfb->ncolors * SIZEOF(XWDColor); - pvfb->pXWDHeader = NULL; - pvfb->pXWDHeader = (XWDFileHeader *)Xalloc(pvfb->sizeInBytes); + pvfb->pXWDHeader = NULL; + switch (fbmemtype) + { +#ifdef HAS_MMAP + case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break; +#else + case MMAPPED_FILE_FB: break; +#endif - if (pvfb->pXWDHeader) - { - pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader - + SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN); - pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors); - memset(pvfb->pfbMemory, 0, pvfb->paddedBytesWidth * pvfb->height); - return pvfb->pfbMemory; - } - else - return NULL; -} +#ifdef HAS_SHM + case SHARED_MEMORY_FB: vfbAllocateSharedMemoryFramebuffer(pvfb); break; +#else + case SHARED_MEMORY_FB: break; +#endif + case NORMAL_MEMORY_FB: + pvfb->pXWDHeader = (XWDFileHeader *)Xalloc(pvfb->sizeInBytes); + break; + } + + if (pvfb->pXWDHeader) + { + pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader + + SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN); + pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors); + + return pvfb->pfbMemory; + } + else + return NULL; +} static void vfbWriteXWDFileHeader(ScreenPtr pScreen) {