Synched vfbScreenInit with modern InitOutput.c.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@224 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/xc/programs/Xserver/vnc/Xvnc/xvnc.cc b/xc/programs/Xserver/vnc/Xvnc/xvnc.cc
index fc1499a..e1ed9ba 100644
--- a/xc/programs/Xserver/vnc/Xvnc/xvnc.cc
+++ b/xc/programs/Xserver/vnc/Xvnc/xvnc.cc
@@ -74,6 +74,7 @@
#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 @@
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;
+ vfbScreenInfoPtr pvfb = &vfbScreens[index];
+ int dpix = 100, dpiy = 100;
+ int ret;
+ char *pbits;
- if (monitorResolution) dpi = monitorResolution;
+ 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;
- 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;
+ miSetPixmapDepths ();
- defaultColorVisualClass
- = (pvfb->bitsPerPixel > 8) ? TrueColor : PseudoColor;
-
- ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
- dpi, dpi, pvfb->paddedWidth, pvfb->bitsPerPixel);
-
+ 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;
- pScreen->InstallColormap = vfbInstallColormap;
- pScreen->UninstallColormap = vfbUninstallColormap;
- pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
+ /* miInitializeBackingStore(pScreen); */
- pScreen->SaveScreen = vfbSaveScreen;
- pScreen->StoreColors = vfbStoreColors;
+ /*
+ * Circumvent the backing store that was just initialised. This amounts
+ * to a truely bizarre way of initialising SaveDoomedAreas and friends.
+ */
- miPointerInitialize(pScreen, &vfbPointerSpriteFuncs, &vfbPointerCursorFuncs,
- FALSE);
+ pScreen->InstallColormap = vfbInstallColormap;
+ pScreen->UninstallColormap = vfbUninstallColormap;
+ pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
- vfbWriteXWDFileHeader(pScreen);
+ pScreen->SaveScreen = vfbSaveScreen;
+ pScreen->StoreColors = vfbStoreColors;
- pScreen->blackPixel = pvfb->blackPixel;
- pScreen->whitePixel = pvfb->whitePixel;
+ miDCInitialize(pScreen, &vfbPointerCursorFuncs);
- if (!pvfb->pixelFormatDefined && pvfb->depth == 16) {
- pvfb->pixelFormatDefined = TRUE;
- pvfb->rgbNotBgr = TRUE;
- pvfb->blueBits = pvfb->redBits = 5;
- pvfb->greenBits = 6;
- }
+ vfbWriteXWDFileHeader(pScreen);
- if (pvfb->pixelFormatDefined) {
- VisualPtr vis;
- for (vis = pScreen->visuals; vis->vid != pScreen->rootVisual; vis++)
- ;
+ pScreen->blackPixel = pvfb->blackPixel;
+ pScreen->whitePixel = pvfb->whitePixel;
- 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 */