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

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

index fc1499aeabfb5f5429aea637b09b0fd9285d44d9..e1ed9baff6acd8a1746879a6e4d89f45cbf0c45d 100644 (file)
@@ -74,6 +74,7 @@ extern "C" {
 #include "gcstruct.h"
 #include "input.h"
 #include "mipointer.h"
+#include "micmap.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
@@ -934,84 +935,94 @@ vfbCloseScreen(int index, ScreenPtr pScreen)
     return pScreen->CloseScreen(index, pScreen);
 }
 
-static Bool vfbScreenInit(int index, ScreenPtr pScreen, int argc, char** argv)
+static Bool
+vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
 {
-  vfbScreenInfoPtr pvfb = &vfbScreens[index];
-  int dpi = 100;
-  int ret;
-  char *pbits;
-
-  if (monitorResolution) dpi = monitorResolution;
-
-  pvfb->paddedBytesWidth = PixmapBytePad(pvfb->width, pvfb->depth);
-  pvfb->bitsPerPixel = vfbBitsPerPixel(pvfb->depth);
-  pvfb->paddedWidth = pvfb->paddedBytesWidth * 8 / pvfb->bitsPerPixel;
-  pbits = vfbAllocateFramebufferMemory(pvfb);
-  if (!pbits) return FALSE;
-  vncFbptr[index] = pbits;
-
-  defaultColorVisualClass
-    = (pvfb->bitsPerPixel > 8) ? TrueColor : PseudoColor;
-
-  ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-                    dpi, dpi, pvfb->paddedWidth, pvfb->bitsPerPixel);
-  
+    vfbScreenInfoPtr pvfb = &vfbScreens[index];
+    int dpix = 100, dpiy = 100;
+    int ret;
+    char *pbits;
+
+    pvfb->paddedBytesWidth = PixmapBytePad(pvfb->width, pvfb->depth);
+    pvfb->bitsPerPixel = vfbBitsPerPixel(pvfb->depth);
+    if (pvfb->bitsPerPixel >= 8 )
+       pvfb->paddedWidth = pvfb->paddedBytesWidth / (pvfb->bitsPerPixel / 8);
+    else
+       pvfb->paddedWidth = pvfb->paddedBytesWidth * 8;
+    pbits = vfbAllocateFramebufferMemory(pvfb);
+    if (!pbits) return FALSE;
+
+    miSetPixmapDepths ();
+
+    switch (pvfb->depth) {
+    case 8:
+       miSetVisualTypesAndMasks (8,
+                                 ((1 << StaticGray) |
+                                  (1 << GrayScale) |
+                                  (1 << StaticColor) |
+                                  (1 << PseudoColor) |
+                                  (1 << TrueColor) |
+                                  (1 << DirectColor)),
+                                 8, PseudoColor, 0x07, 0x38, 0xc0);
+       break;
+    case 15:
+       miSetVisualTypesAndMasks (15,
+                                 ((1 << TrueColor) |
+                                  (1 << DirectColor)),
+                                 8, TrueColor, 0x7c00, 0x03e0, 0x001f);
+       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;
+    }
+       
+    ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+                      dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel);
 #ifdef RENDER
-  if (ret && Render) 
-      fbPictureInit(pScreen, 0, 0); 
+    if (ret && Render) 
+       fbPictureInit (pScreen, 0, 0);
 #endif
 
-  if (!ret) return FALSE;
+    if (!ret) return FALSE;
+
+    /* miInitializeBackingStore(pScreen); */
 
-  pScreen->InstallColormap = vfbInstallColormap;
-  pScreen->UninstallColormap = vfbUninstallColormap;
-  pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
+    /*
+     * Circumvent the backing store that was just initialised.  This amounts
+     * to a truely bizarre way of initialising SaveDoomedAreas and friends.
+     */
 
-  pScreen->SaveScreen = vfbSaveScreen;
-  pScreen->StoreColors = vfbStoreColors;
+    pScreen->InstallColormap = vfbInstallColormap;
+    pScreen->UninstallColormap = vfbUninstallColormap;
+    pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
 
-  miPointerInitialize(pScreen, &vfbPointerSpriteFuncs, &vfbPointerCursorFuncs,
-                      FALSE);
+    pScreen->SaveScreen = vfbSaveScreen;
+    pScreen->StoreColors = vfbStoreColors;
 
-  vfbWriteXWDFileHeader(pScreen);
+    miDCInitialize(pScreen, &vfbPointerCursorFuncs);
 
-  pScreen->blackPixel = pvfb->blackPixel;
-  pScreen->whitePixel = pvfb->whitePixel;
+    vfbWriteXWDFileHeader(pScreen);
 
-  if (!pvfb->pixelFormatDefined && pvfb->depth == 16) {
-    pvfb->pixelFormatDefined = TRUE;
-    pvfb->rgbNotBgr = TRUE;
-    pvfb->blueBits = pvfb->redBits = 5;
-    pvfb->greenBits = 6;
-  }
+    pScreen->blackPixel = pvfb->blackPixel;
+    pScreen->whitePixel = pvfb->whitePixel;
 
-  if (pvfb->pixelFormatDefined) {
-    VisualPtr vis;
-    for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++)
-      ;
-
-    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;
-    }
-  }
+    ret = fbCreateDefColormap(pScreen);
 
-  ret = fbCreateDefColormap(pScreen);
+    miSetZeroLineBias(pScreen, pvfb->lineBias);
 
-  miSetZeroLineBias(pScreen, pvfb->lineBias);
+    pvfb->closeScreen = pScreen->CloseScreen;
+    pScreen->CloseScreen = vfbCloseScreen;
 
-  return ret;
+    return ret;
 
 } /* end vfbScreenInit */