Applied vnc-use-fb.patch from FC3, slightly modified:
Use fb unconditionally. This makes the code simpler, and the old mfb/cfb is buggy and deprecated.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@184 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/xc.patch b/xc.patch
index cc90f16..274c8ee 100644
--- a/xc.patch
+++ b/xc.patch
@@ -1,110 +1,6 @@
-diff -bcr xc.org/programs/Xserver/cfb/cfb8line.c xc/programs/Xserver/cfb/cfb8line.c
-*** xc.org/programs/Xserver/cfb/cfb8line.c	2004-04-23 21:00:12.000000000 +0200
---- xc/programs/Xserver/cfb/cfb8line.c	2005-02-11 16:47:34.000000000 +0100
-***************
-*** 695,716 ****
-  # if PSZ == 24
-  	    y1_or_e1 = xOffset & 3;
-  # else
-! #  if PGSZ == 64 /* PIM value from <cfbmskbits.h> is not it! (for 16/32 PSZ)*/
-! 	    y1_or_e1 = ((long) addrp) & 0x7;
-! 	    addrp = (PixelType *) (((unsigned char *) addrp) - y1_or_e1);
-! #  else
-! 	    y1_or_e1 = ((long) addrp) & PIM;
-! 	    addrp = (PixelType *) (((unsigned char *) addrp) - y1_or_e1);
-! #  endif
-! #if PGSZ == 32
-! #  if PWSH != 2
-! 	    y1_or_e1 >>= (2 - PWSH);
-! #  endif
-! #else /* PGSZ == 64 */
-! #  if PWSH != 3
-! 	    y1_or_e1 >>= (3 - PWSH);
-! #  endif
-! #endif /* PGSZ */
-  # endif /* PSZ == 24 */
-  #if PSZ == 24
-  	    {
---- 695,705 ----
-  # if PSZ == 24
-  	    y1_or_e1 = xOffset & 3;
-  # else
-! 	    /* Round addrp down to the next PixelGroup boundary, and
-! 	     * set y1_or_e1 to the excess (in pixels)
-! 	     * (assumes PGSZB is a power of 2). */
-! 	    y1_or_e1 = (((unsigned long) addrp) & (PGSZB - 1)) / (PSZ / 8);
-! 	    addrp -= y1_or_e1;
-  # endif /* PSZ == 24 */
-  #if PSZ == 24
-  	    {
-diff -bcr xc.org/programs/Xserver/cfb/cfbcppl.c xc/programs/Xserver/cfb/cfbcppl.c
-*** xc.org/programs/Xserver/cfb/cfbcppl.c	2004-04-23 21:00:12.000000000 +0200
---- xc/programs/Xserver/cfb/cfbcppl.c	2005-02-11 16:47:34.000000000 +0100
-***************
-*** 383,389 ****
-  	psrcLine = (unsigned int *)psrcBase + srcy * widthSrc + srcx;
-  #endif
-  	pdstLine = (unsigned int *)pdstBase + dsty * widthDst + (dstx >> 5);
-! 	if (dstx + width <= 32)
-  	{
-  	    mfbmaskpartialbits(dstx, width, startmask);
-  	    nlMiddle = 0;
---- 383,389 ----
-  	psrcLine = (unsigned int *)psrcBase + srcy * widthSrc + srcx;
-  #endif
-  	pdstLine = (unsigned int *)pdstBase + dsty * widthDst + (dstx >> 5);
-! 	if ((dstx & 0x1f) + width <= 32)
-  	{
-  	    mfbmaskpartialbits(dstx, width, startmask);
-  	    nlMiddle = 0;
-diff -bcr xc.org/programs/Xserver/cfb/cfbtile32.c xc/programs/Xserver/cfb/cfbtile32.c
-*** xc.org/programs/Xserver/cfb/cfbtile32.c	2004-04-23 21:00:12.000000000 +0200
---- xc/programs/Xserver/cfb/cfbtile32.c	2005-02-11 16:47:34.000000000 +0100
-***************
-*** 72,78 ****
-                        (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<16)|(srcpix>>8)),*(p))), \
-                        (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<8)|(srcpix>>16)),*(p))))
-  
-! #if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE)
-  # define Expand(left,right) {\
-      int part = nlwMiddle & ((PGSZB*2)-1); \
-      nlwMiddle *= 3; \
---- 72,84 ----
-                        (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<16)|(srcpix>>8)),*(p))), \
-                        (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<8)|(srcpix>>16)),*(p))))
-  
-! 
-! 
-! /* XXX TJR: I doubt that this optimised case works (because the non-24 bit case
-!    was broken), so I've added the #if 0 below.  Someone who knows what they're
-!    doing can re-enable it if they fix it */
-! 
-! #if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE) && 0
-  # define Expand(left,right) {\
-      int part = nlwMiddle & ((PGSZB*2)-1); \
-      nlwMiddle *= 3; \
-***************
-*** 144,151 ****
-  
-  #if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE)
-  # define Expand(left,right) {\
-!     int part = nlwMiddle & ((PGSZB*2)-1); \
-!     nlwMiddle >>= PWSH + 1; \
-      while (h--) { \
-  	srcpix = psrc[srcy]; \
-  	MROP_PREBUILD(srcpix); \
---- 150,157 ----
-  
-  #if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE)
-  # define Expand(left,right) {\
-!     int part = nlwMiddle & 7; \
-!     nlwMiddle >>= 3; \
-      while (h--) { \
-  	srcpix = psrc[srcy]; \
-  	MROP_PREBUILD(srcpix); \
 diff -bcr xc.org/programs/Xserver/Imakefile xc/programs/Xserver/Imakefile
 *** xc.org/programs/Xserver/Imakefile	2004-12-15 20:22:53.000000000 +0100
---- xc/programs/Xserver/Imakefile	2005-02-11 16:50:00.000000000 +0100
+--- xc/programs/Xserver/Imakefile	2005-02-14 14:23:21.000000000 +0100
 ***************
 *** 128,134 ****
          LIBREGEX = RegexLibrary
@@ -124,29 +20,17 @@
   #if BuildXprint
 ***************
 *** 414,419 ****
---- 414,442 ----
+--- 414,430 ----
   #define ServerToInstall Xsun
   #endif
   #endif /* XsunServer */
 + XCOMM
 + XCOMM X VNC server
 + XCOMM
-+ MFBSUBDIR = mfb
-+ CFB8SUBDIR = cfb
-+ CFB16SUBDIR = cfb16
-+ CFB24SUBDIR = cfb24
-+ CFB32SUBDIR = cfb32
 + FBSUBDIR = fb
 + XVNCDDXDIR = vnc/Xvnc
-+ #if VncUseFb
 + XVNCDIRS = $(STDDIRS) $(FBSUBDIR) $(XVNCDDXDIR) $(DEPDIRS)
 + XVNCLIBS = PreFbLibs vnc/Xvnc/LibraryTargetName(xvnc) FbPostFbLibs
-+ #else
-+ XVNCDIRS = $(STDDIRS) $(MFBSUBDIR) \
-+ 	    $(CFB8SUBDIR) $(CFB16SUBDIR) $(CFB24SUBDIR) $(CFB32SUBDIR) \
-+ 	    $(XVNCDDXDIR) $(DEPDIRS)
-+ XVNCLIBS = PreFbLibs vnc/Xvnc/LibraryTargetName(xvnc) CFBLibs PostFbLibs
-+ #endif
 + XVNCOBJS = $(XVNCDDXDIR)/stubs.o $(XVNCDDXDIR)/miinitext.o
 + XVNCSYSLIBS = $(FONTLIBS) $(SYSLIBS)
 + ServerTarget(Xvnc,$(XVNCDIRS),$(XVNCOBJS), \
diff --git a/xc/programs/Xserver/vnc/Xvnc/Imakefile b/xc/programs/Xserver/vnc/Xvnc/Imakefile
index 870a7a2..0e3e677 100644
--- a/xc/programs/Xserver/vnc/Xvnc/Imakefile
+++ b/xc/programs/Xserver/vnc/Xvnc/Imakefile
@@ -27,15 +27,17 @@
 OBJS1 = os2_stubs.o
 #endif
 
+FBINCLUDE = -I../../fb
+
 SRCSA =	xvnc.cc stubs.c $(SRCS1) miinitext.c $(SRCS2)
 
 OBJSA =	xvnc.o stubs.o $(OBJS1) miinitext.o $(OBJS2)
 
 INCLUDES = -I. -I.. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../cfb -I../../mfb -I../../mi -I../../include -I../../os  \
+           $(FBINCLUDE) -I../../mfb -I../../mi -I../../include -I../../os  \
            -I$(EXTINCSRC) -I$(XINCLUDESRC)  -I$(SERVERSRC)/render $(VNCINCLUDE)
 
-DEFINES = $(OS_DEFINES) $(SHMDEF) $(MMAPDEF) \
+DEFINES = $(OS_DEFINES) $(SHMDEF) $(MMAPDEF) $(FB_DEFINES) \
           $(VENDOR_STRING) $(VENDOR_RELEASE) $(STD_DEFINES) ServerOSDefines \
           -UXFree86LOADER
 
diff --git a/xc/programs/Xserver/vnc/Xvnc/xvnc.cc b/xc/programs/Xserver/vnc/Xvnc/xvnc.cc
index 9e8b264..2d2dc78 100644
--- a/xc/programs/Xserver/vnc/Xvnc/xvnc.cc
+++ b/xc/programs/Xserver/vnc/Xvnc/xvnc.cc
@@ -67,8 +67,7 @@
 #include "X11/Xos.h"
 #include "scrnintstr.h"
 #include "servermd.h"
-#define PSZ 8
-#include "cfb.h"
+#include "fb.h"
 #include "mi.h"
 #include "mibstore.h"
 #include "colormapst.h"
@@ -92,16 +91,6 @@
 #undef public
 #undef xor
 #undef and
-  extern Bool cfb16ScreenInit(ScreenPtr, pointer, int, int, int, int, int);
-  extern Bool cfb32ScreenInit(ScreenPtr, pointer, int, int, int, int, int);
-  extern Bool cfb16CreateGC(GCPtr);
-  extern Bool cfb32CreateGC(GCPtr);
-  extern void cfb16GetSpans(DrawablePtr, int, DDXPointPtr, int*, int, char*);
-  extern void cfb32GetSpans(DrawablePtr, int, DDXPointPtr, int*, int, char*);
-  extern void cfb16GetImage(DrawablePtr, int, int, int, int, unsigned int,
-                            unsigned long, char*);
-  extern void cfb32GetImage(DrawablePtr, int, int, int, int, unsigned int,
-                            unsigned long, char*);
 }
 
 #define XVNCVERSION "4.0"
@@ -491,66 +480,6 @@
 }
 #endif
 
-
-static Bool vfbMultiDepthCreateGC(GCPtr   pGC)
-{
-  switch (vfbBitsPerPixel(pGC->depth))
-  {
-  case 1:  return mfbCreateGC (pGC);
-  case 8:  return cfbCreateGC (pGC);
-  case 16: return cfb16CreateGC (pGC);
-  case 32: return cfb32CreateGC (pGC);
-  default: return FALSE;
-  }
-}
-
-static void vfbMultiDepthGetSpans(
-                                  DrawablePtr		pDrawable,	/* drawable from which to get bits */
-                                  int			wMax,		/* largest value of all *pwidths */
-                                  register DDXPointPtr ppt,		/* points to start copying from */
-                                  int			*pwidth,	/* list of number of bits to copy */
-                                  int			nspans,		/* number of scanlines to copy */
-                                  char		*pdstStart)	/* where to put the bits */
-{
-  switch (pDrawable->bitsPerPixel) {
-  case 1:
-    mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-    break;
-  case 8:
-    cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-    break;
-  case 16:
-    cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-    break;
-  case 32:
-    cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-    break;
-  }
-  return;
-}
-
-static void
-vfbMultiDepthGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
-                      unsigned int format, unsigned long planeMask,
-                      char *pdstLine)
-{
-  switch (pDrawable->bitsPerPixel)
-  {
-  case 1:
-    mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
-    break;
-  case 8:
-    cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
-    break;
-  case 16:
-    cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
-    break;
-  case 32:
-    cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
-    break;
-  }
-}
-
 static ColormapPtr InstalledMaps[MAXSCREENS];
 
 static int vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
@@ -820,33 +749,9 @@
   defaultColorVisualClass
     = (pvfb->bitsPerPixel > 8) ? TrueColor : PseudoColor;
 
-  switch (pvfb->bitsPerPixel)
-  {
-  case 1:
-    ret = mfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-                        dpi, dpi, pvfb->paddedWidth);
-    break;
-  case 8:
-    ret = cfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-                        dpi, dpi, pvfb->paddedWidth);
-    break;
-  case 16:
-    ret = cfb16ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-                          dpi, dpi, pvfb->paddedWidth);
-    break;
-  case 32:
-    ret = cfb32ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-                          dpi, dpi, pvfb->paddedWidth);
-    break;
-  default:
-    return FALSE;
-  }
-
-  if (!ret) return FALSE;
-
-  pScreen->CreateGC = vfbMultiDepthCreateGC;
-  pScreen->GetImage = vfbMultiDepthGetImage;
-  pScreen->GetSpans = vfbMultiDepthGetSpans;
+  if (!fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+                    dpi, dpi, pvfb->paddedWidth, pvfb->bitsPerPixel))
+      return FALSE;
 
   pScreen->InstallColormap = vfbInstallColormap;
   pScreen->UninstallColormap = vfbUninstallColormap;
@@ -892,14 +797,7 @@
     }
   }
 
-  if (pvfb->bitsPerPixel == 1)
-  {
-    ret = mfbCreateDefColormap(pScreen);
-  }
-  else
-  {
-    ret = cfbCreateDefColormap(pScreen);
-  }
+  ret = fbCreateDefColormap(pScreen);
 
   miSetZeroLineBias(pScreen, pvfb->lineBias);