]> source.dussan.org Git - tigervnc.git/commitdiff
Synched vfbAllocateFramebufferMemory with modern InitOutput.c.
authorPeter Åstrand <astrand@cendio.se>
Tue, 22 Feb 2005 21:05:16 +0000 (21:05 +0000)
committerPeter Åstrand <astrand@cendio.se>
Tue, 22 Feb 2005 21:05:16 +0000 (21:05 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@220 3789f03b-4d11-0410-bbf8-ca57d06f2519

xc/programs/Xserver/vnc/Xvnc/xvnc.cc

index 0dd0a03418e493fe34c921562021aeca41486fd9..c11a2f6d4e5a07e98ac96f8e957f679ff7ff96e6 100644 (file)
@@ -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)
 {