diff options
author | Peter Åstrand <astrand@cendio.se> | 2005-02-22 21:05:16 +0000 |
---|---|---|
committer | Peter Åstrand <astrand@cendio.se> | 2005-02-22 21:05:16 +0000 |
commit | 8de329f6e0e96d2d3610ee8b800e1893c7838a8e (patch) | |
tree | 4cadaee1b888406287c6d52c983d9e2925817d64 /xc | |
parent | 4efcfe07ba40a37f6c2b82fb07d79f03c8c03fd2 (diff) | |
download | tigervnc-8de329f6e0e96d2d3610ee8b800e1893c7838a8e.tar.gz tigervnc-8de329f6e0e96d2d3610ee8b800e1893c7838a8e.zip |
Synched vfbAllocateFramebufferMemory with modern InitOutput.c.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@220 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'xc')
-rw-r--r-- | xc/programs/Xserver/vnc/Xvnc/xvnc.cc | 85 |
1 files changed, 51 insertions, 34 deletions
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) { |