xserver: Branch 'pci-rework' - 252 commits

Ian Romanick idr at kemper.freedesktop.org
Mon Jun 18 17:15:58 PDT 2007


 GL/glx/Makefile.am                          |    3 
 GL/glx/glxcmds.c                            |   34 
 GL/glx/glxcontext.h                         |    3 
 GL/glx/glxdrawable.h                        |    9 
 GL/glx/glxdri.c                             |  296 +-
 GL/glx/glxext.c                             |   35 
 GL/glx/glxext.h                             |    2 
 GL/glx/glxglcore.c                          |   17 
 GL/glx/glxscreens.h                         |    3 
 GL/glx/glxserver.h                          |    8 
 GL/glx/indirect_dispatch.h                  |   14 
 GL/glx/indirect_size_get.c                  |    8 
 GL/glx/indirect_table.c                     |   19 
 GL/mesa/.gitignore                          |    2 
 GL/mesa/X/Makefile.am                       |    5 
 GL/mesa/X/xf86glx_util.c                    |  149 -
 GL/mesa/X/xf86glx_util.h                    |  105 
 GL/mesa/main/Makefile.am                    |    2 
 GL/mesa/shader/slang/Makefile.am            |    1 
 GL/mesa/tnl/Makefile.am                     |    2 
 GL/symlink-mesa.sh                          |    5 
 Xext/Makefile.am                            |    1 
 Xext/sync.c                                 |  121 
 Xext/xcmisc.c                               |   13 
 Xext/xvmain.c                               |    8 
 Xext/xvmc.c                                 |    2 
 Xi/stubs.c                                  |   14 
 composite/compext.c                         |    2 
 config/config.c                             |  135 -
 config/dbus-api                             |   22 
 configure.ac                                |   93 
 dix/atom.c                                  |    6 
 dix/devices.c                               |   73 
 dix/dispatch.c                              |   18 
 dix/dixfonts.c                              |    4 
 dix/dixutils.c                              |    6 
 dix/events.c                                |  473 +++
 dix/extension.c                             |    2 
 dix/getevents.c                             |   24 
 dix/initatoms.c                             |    2 
 dix/main.c                                  |    3 
 dix/privates.c                              |   28 
 dix/resource.c                              |    4 
 dix/tables.c                                |   15 
 exa/exa.c                                   |   28 
 exa/exa.h                                   |   24 
 exa/exa_accel.c                             |  465 +--
 exa/exa_migration.c                         |   21 
 exa/exa_offscreen.c                         |    8 
 exa/exa_priv.h                              |   11 
 exa/exa_render.c                            |  178 -
 exa/exa_unaccel.c                           |   36 
 fb/Makefile.am                              |   28 
 fb/fb.h                                     |    6 
 fb/fbcmap.c                                 |   91 
 fb/fbcmap_mi.c                              |  123 
 fb/fbcompose.c                              | 3687 ----------------------------
 fb/fbcopy.c                                 |   25 
 fb/fbedge.c                                 |  314 --
 fb/fbedgeimp.h                              |  145 -
 fb/fbfill.c                                 |   28 
 fb/fbmmx.c                                  | 2412 ------------------
 fb/fbmmx.h                                  |  232 -
 fb/fbpict.c                                 | 1759 ++-----------
 fb/fbpict.h                                 |  248 -
 fb/fbtrap.c                                 |  102 
 fb/fbwindow.c                               |   43 
 fb/wfbrename.h                              |    2 
 hw/darwin/Makefile.am                       |    6 
 hw/dmx/Makefile.am                          |    5 
 hw/dmx/dmx-config.h                         |    2 
 hw/dmx/dmxcursor.c                          |    2 
 hw/dmx/dmxinput.h                           |    2 
 hw/dmx/glxProxy/glxext.h                    |    2 
 hw/dmx/input/dmxbackend.c                   |   33 
 hw/dmx/input/dmxcommon.c                    |   16 
 hw/dmx/input/dmxconsole.c                   |    9 
 hw/dmx/input/dmxdummy.c                     |    2 
 hw/dmx/input/dmxevents.c                    |  321 +-
 hw/dmx/input/dmxinputinit.c                 |   22 
 hw/kdrive/Makefile.am                       |   12 
 hw/kdrive/ati/Makefile.am                   |    3 
 hw/kdrive/ati/ati_dma.c                     |    2 
 hw/kdrive/chips/Makefile.am                 |    3 
 hw/kdrive/ephyr/Makefile.am                 |    3 
 hw/kdrive/epson/Makefile.am                 |    3 
 hw/kdrive/fake/Makefile.am                  |    3 
 hw/kdrive/fbdev/Makefile.am                 |    3 
 hw/kdrive/i810/Makefile.am                  |    3 
 hw/kdrive/linux/agp.c                       |    2 
 hw/kdrive/mach64/Makefile.am                |    3 
 hw/kdrive/mga/Makefile.am                   |    3 
 hw/kdrive/neomagic/Makefile.am              |    3 
 hw/kdrive/nvidia/Makefile.am                |    3 
 hw/kdrive/pm2/Makefile.am                   |    3 
 hw/kdrive/r128/Makefile.am                  |    3 
 hw/kdrive/sdl/Makefile.am                   |    3 
 hw/kdrive/sis300/Makefile.am                |    3 
 hw/kdrive/smi/Makefile.am                   |    3 
 hw/kdrive/src/kinput.c                      |   13 
 hw/kdrive/vesa/Makefile.am                  |    3 
 hw/kdrive/via/Makefile.am                   |    3 
 hw/vfb/Makefile.am                          |    4 
 hw/xfree86/common/compiler.h                |    2 
 hw/xfree86/common/xf86AutoConfig.c          |    2 
 hw/xfree86/common/xf86Build.h.in            |    1 
 hw/xfree86/common/xf86Bus.c                 |    2 
 hw/xfree86/common/xf86Config.c              |  196 -
 hw/xfree86/common/xf86Config.h              |   19 
 hw/xfree86/common/xf86Configure.c           |   15 
 hw/xfree86/common/xf86DGA.c                 |    3 
 hw/xfree86/common/xf86Events.c              |   28 
 hw/xfree86/common/xf86Helper.c              |    3 
 hw/xfree86/common/xf86Init.c                |    8 
 hw/xfree86/common/xf86Mode.c                |    2 
 hw/xfree86/common/xf86Module.h              |    4 
 hw/xfree86/common/xf86Option.c              |    4 
 hw/xfree86/common/xf86Privstr.h             |    2 
 hw/xfree86/common/xf86Xinput.c              |  199 +
 hw/xfree86/common/xf86Xinput.h              |    5 
 hw/xfree86/common/xf86pciBus.c              |    1 
 hw/xfree86/common/xf86xv.c                  |   42 
 hw/xfree86/ddc/Makefile.am                  |    4 
 hw/xfree86/ddc/ddcProperty.c                |   11 
 hw/xfree86/ddc/edid.h                       |    4 
 hw/xfree86/ddc/edid_modes.c                 |  361 --
 hw/xfree86/ddc/interpret_vdif.c             |  132 -
 hw/xfree86/ddc/print_vdif.c                 |  225 -
 hw/xfree86/ddc/vdif.h                       |  174 -
 hw/xfree86/ddc/xf86DDC.c                    |   41 
 hw/xfree86/ddc/xf86DDC.h                    |    8 
 hw/xfree86/dixmods/Makefile.am              |   11 
 hw/xfree86/dixmods/afbmodule.c              |    1 
 hw/xfree86/dixmods/cfb32module.c            |    3 
 hw/xfree86/dixmods/cfbmodule.c              |    3 
 hw/xfree86/doc/man/xorg.conf.man.pre        | 1313 +++++----
 hw/xfree86/dri/dri.c                        |  550 ++--
 hw/xfree86/dri/dri.h                        |   27 
 hw/xfree86/dri/drimodule.c                  |    2 
 hw/xfree86/dri/dristruct.h                  |   24 
 hw/xfree86/dri/sarea.h                      |    5 
 hw/xfree86/dri/xf86dri.c                    |   34 
 hw/xfree86/loader/loadmod.c                 |    2 
 hw/xfree86/loader/xf86sym.c                 |   53 
 hw/xfree86/modes/xf86Crtc.c                 |  178 +
 hw/xfree86/modes/xf86Crtc.h                 |   23 
 hw/xfree86/modes/xf86EdidModes.c            |   16 
 hw/xfree86/modes/xf86RandR12.c              |   27 
 hw/xfree86/modes/xf86RandR12.h              |    4 
 hw/xfree86/modes/xf86Rename.h               |    9 
 hw/xfree86/modes/xf86Rotate.c               |   64 
 hw/xfree86/os-support/bsd/Makefile.am       |    3 
 hw/xfree86/os-support/bsd/bsd_bell.c        |    4 
 hw/xfree86/os-support/bsd/i386_video.c      |    5 
 hw/xfree86/os-support/bsd/ppc_video.c       |   33 
 hw/xfree86/os-support/bus/Pci.h             |    2 
 hw/xfree86/os-support/hurd/hurd_video.c     |   44 
 hw/xfree86/os-support/linux/lnx_init.c      |   14 
 hw/xfree86/os-support/linux/lnx_video.c     |   67 
 hw/xfree86/os-support/misc/SlowBcopy.c      |    3 
 hw/xfree86/parser/Flags.c                   |   28 
 hw/xfree86/parser/Module.c                  |   17 
 hw/xfree86/parser/write.c                   |   20 
 hw/xfree86/parser/xf86Parser.h              |    2 
 hw/xfree86/parser/xf86tokens.h              |    1 
 hw/xfree86/utils/xorgcfg/text-mode.c        |    4 
 hw/xfree86/xaa/xaaWideLine.c                |    4 
 hw/xgl/xglcompose.c                         |    2 
 hw/xnest/Display.c                          |    2 
 hw/xnest/Events.c                           |    8 
 hw/xnest/Makefile.am                        |    4 
 hw/xnest/Xnest.man.pre                      |  604 ++--
 hw/xprint/Makefile.am                       |    8 
 hw/xprint/ddxInit.c                         |    6 
 hw/xwin/winmouse.c                          |    5 
 hw/xwin/winmultiwindowclass.c               |    2 
 hw/xwin/winmultiwindowwm.c                  |    5 
 hw/xwin/winmultiwindowwndproc.c             |    9 
 hw/xwin/winwin32rootlesswndproc.c           |    5 
 hw/xwin/winwndproc.c                        |    5 
 include/dix-config.h.in                     |    3 
 include/dixstruct.h                         |    4 
 include/input.h                             |    5 
 include/misc.h                              |    2 
 include/miscstruct.h                        |    5 
 include/regionstr.h                         |   15 
 include/servermd.h                          |   10 
 mi/Makefile.am                              |   10 
 mi/cbrt.c                                   |   46 
 mi/miarc.c                                  |   44 
 mi/micmap.c                                 |    4 
 mi/mieq.c                                   |   28 
 mi/mifpoly.h                                |   13 
 mi/mifpolycon.c                             |    4 
 mi/miregion.c                               |  747 -----
 mi/miwideline.c                             |    4 
 miext/cw/cw_ops.c                           |   37 
 miext/rootless/safeAlpha/safeAlphaPicture.c |  526 ---
 os/Makefile.am                              |    3 
 os/access.c                                 |   31 
 os/auth.c                                   |   12 
 os/k5auth.c                                 |  799 ------
 os/log.c                                    |    4 
 os/oscolor.c                                |    2 
 os/osdep.h                                  |   23 
 os/utils.c                                  |   20 
 randr/Makefile.am                           |   10 
 randr/randr.c                               |    3 
 randr/rrcrtc.c                              |    6 
 randr/rrscreen.c                            |   31 
 randr/rrxinerama.c                          |    8 
 render/glyph.c                              |    4 
 render/mipict.c                             |   58 
 render/mipict.h                             |    6 
 render/picture.c                            |  140 -
 render/picture.h                            |  172 -
 render/picturestr.h                         |   62 
 render/render.c                             |    2 
 render/renderedge.c                         |  118 
 render/renderedge.h                         |   15 
 220 files changed, 5399 insertions(+), 14716 deletions(-)

New commits:
diff-tree ab7a6d860d4a275a810a64b1ba7b13726ed10575 (from parents)
Merge: e9130b8bac73a0843d5ff6b2216eccfb3e094a48 2e7fef7d0837939e822c40b6ac77e7f0e66d57bd
Author: Ian Romanick <idr at us.ibm.com>
Date:   Mon Jun 18 16:51:13 2007 -0700

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into pci-rework
    
    Conflicts:
    
    	hw/xfree86/os-support/bus/Pci.c
    	hw/xfree86/os-support/bus/linuxPci.c

diff --cc hw/xfree86/common/xf86AutoConfig.c
index 89e2afa,4f6a98a..d2d1c6f
@@@ -215,9 -215,8 +215,9 @@@
  {
      const char **p;
      char buf[1024];
 -    pciVideoPtr *pciptr, info = NULL;
 -    char *driver = NULL;
 +    struct pci_device_iterator *iter;
 +    struct pci_device * info = NULL;
-     char *driver = NULL;
++    const char *driver = NULL;
      ConfigStatus ret;
  
      /* Find the primary device, and get some information about it. */
diff --cc hw/xfree86/common/xf86Bus.c
index 686e1ee,cd309a5..537ddf7
@@@ -2998,12 -2997,14 +2998,12 @@@
  	    bus = "";
  	    loc[0] = '\0';
  	}
 -	
 +
  	xf86MsgVerb(X_INFO, 2, "Primary Device is: %s%s\n",bus,loc);
 -	xfree(loc);
      }
 -    
  }
  
- #if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__)
+ #if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__arm__)
  #include "vgaHW.h"
  #include "compiler.h"
  #endif
diff --cc hw/xfree86/common/xf86Config.c
index 9862445,8e58bef..6369d6d
@@@ -703,7 -752,7 +753,7 @@@
    }
  #endif
  
--  return TRUE;
++  return;
  }
  
  typedef enum {
diff --cc hw/xfree86/common/xf86pciBus.c
index 21a57ae,ae33568..13e13e9
@@@ -532,36 -2678,31 +532,35 @@@
  void
  initPciBusState(void)
  {
 +    static const struct pci_id_match bridge_match = {
 +	PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
 +	(PCI_CLASS_BRIDGE << 16), 0x0000ff0000, 0
 +    };
 +    struct pci_device *dev;
 +    struct pci_device_iterator *iter;
      BusAccPtr pbap, pbap_tmp;
-     pciBusInfo_t *pBusInfo;
 -    PciBusPtr pbp = xf86PciBus;
 -    pciBusInfo_t *pBusInfo;
  
 -    while (pbp) {
 +    iter = pci_id_match_iterator_create(& bridge_match);
 +    while((dev = pci_device_next(iter)) != NULL) {
 +	const uint8_t subclass = (dev->device_class >> 8) & 0x0ff;
 +	int primary;
 +	int secondary;
 +	int subordinate;
 +
 +
 +	pci_device_get_bridge_buses(dev, &primary, &secondary, &subordinate);
 +
  	pbap = xnfcalloc(1,sizeof(BusAccRec));
 -	pbap->busdep.pci.bus = pbp->secondary;
 -	pbap->busdep.pci.primary_bus = pbp->primary;
 +	pbap->busdep.pci.bus = secondary;
 +	pbap->busdep.pci.primary_bus = primary;
  	pbap->busdep_type = BUS_PCI;
 -	pbap->busdep.pci.acc = PCITAG_SPECIAL;
 +	pbap->busdep.pci.dev = dev;
  
 -	if ((pbp->secondary >= 0) && (pbp->secondary < pciNumBuses) &&
 -	    (pBusInfo = pciBusInfo[pbp->secondary]) &&
 -	    pBusInfo->funcs->pciControlBridge) {
 -	    pbap->type = BUS_PCI;
 -	    pbap->save_f = savePciDrvBusState;
 -	    pbap->restore_f = restorePciDrvBusState;
 -	    pbap->set_f = pciSetBusAccess;
 -	    pbap->enable_f = pciDrvBusAccessEnable;
 -	    pbap->disable_f = pciDrvBusAccessDisable;
 -	    savePciDrvBusState(pbap);
 -	} else switch (pbp->subclass) {
 +	pbap->set_f = pciSetBusAccess;
 +	
 +	switch (subclass) {
  	case PCI_SUBCLASS_BRIDGE_HOST:
  	    pbap->type = BUS_PCI;
 -	    pbap->set_f = pciSetBusAccess;
  	    break;
  	case PCI_SUBCLASS_BRIDGE_PCI:
  	case PCI_SUBCLASS_BRIDGE_CARDBUS:
diff --cc hw/xfree86/os-support/bus/Pci.h
index 9eb536d,f0cb916..a9b9cf7
@@@ -259,13 -318,16 +259,13 @@@
  #elif defined(__sparc__) || defined(sparc)
  # if defined(linux)
  #  define ARCH_PCI_INIT linuxPciInit
 -#  define INCLUDE_XF86_MAP_PCI_MEM
  # elif defined(sun)
  #  define ARCH_PCI_INIT sparcPciInit
 -#  define INCLUDE_XF86_MAP_PCI_MEM
  # elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__)
  #  define  ARCH_PCI_INIT freebsdPciInit
 -#  define INCLUDE_XF86_MAP_PCI_MEM
  #  define INCLUDE_XF86_NO_DOMAIN
  # endif
- # if !defined(__FreeBSD__)
+ # if !defined(__FreeBSD__) && !defined(linux)
  #  define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
  # endif
  #elif defined(__amd64__) || defined(__amd64)
diff-tree 2e7fef7d0837939e822c40b6ac77e7f0e66d57bd (from 831d3b7f8d053aba649c8d04af3bef96376bdc3a)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Jun 18 12:08:39 2007 -0400

    Make xf86{En,Dis}ableInterrupts no-ops on Linux.

diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index a816560..0bc99b0 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -604,73 +604,21 @@ xf86DisableIO(void)
 	return;
 }
 
-
-/***************************************************************************/
-/* Interrupt Handling section                                              */
-/***************************************************************************/
-
-/* XXX The #ifdefs should be made simpler. */
+/*
+ * Don't use these two functions.  They can't possibly work.  If you actually
+ * need interrupts off for something, you ought to be doing it in the kernel
+ * anyway.
+ */
 
 _X_EXPORT Bool
 xf86DisableInterrupts()
 {
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__)
-	if (!ExtendedEnabled)
-	    if (iopl(3) || ioperm(0, 1024, 1))
-			return (FALSE);
-#endif
-#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__) || defined(__s390__)
-#else
-# ifdef __GNUC__
-#  if defined(__ia64__)
-#   if 0
-	__asm__ __volatile__ (";; rsm psr.i;; srlz.d" ::: "memory");
-#   endif
-#  else
-      __asm__ __volatile__("cli");
-#  endif
-# else
-	asm("cli");
-# endif
-#endif
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__)
-	if (!ExtendedEnabled) {
-	    iopl(0);
-	    ioperm(0, 1024, 0);
-	}
-	
-#endif
 	return (TRUE);
 }
 
 _X_EXPORT void
 xf86EnableInterrupts()
 {
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__)
-	if (!ExtendedEnabled)
-	    if (iopl(3) || ioperm(0, 1024, 1))
-			return;
-#endif
-#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__) || defined(__s390__)
-#else
-# ifdef __GNUC__
-#  if defined(__ia64__)
-#   if 0
-	__asm__ __volatile__ (";; ssm psr.i;; srlz.d" ::: "memory");
-#   endif
-#  else
-      __asm__ __volatile__("sti");
-#  endif
-# else
-	asm("sti");
-# endif
-#endif
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__)
-	if (!ExtendedEnabled) {
-	    iopl(0);
-	    ioperm(0, 1024, 0);
-	}
-#endif
 	return;
 }
 
diff-tree 831d3b7f8d053aba649c8d04af3bef96376bdc3a (from 562ca3f2f9005e7c5ed0a24b0759051ded2173e9)
Author: Lennart Buytenhek <buytenh at wantstofly.org>
Date:   Mon Jun 18 12:05:55 2007 -0400

    Compile fixes for Linux ARM platforms.

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 9740b07..cd309a5 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -3004,7 +3004,7 @@ xf86FindPrimaryDevice()
     
 }
 
-#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__)
+#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__arm__)
 #include "vgaHW.h"
 #include "compiler.h"
 #endif
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 02a1310..a816560 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -62,7 +62,8 @@ static Bool ExtendedEnabled = FALSE;
 #elif !defined(__powerpc__) && \
       !defined(__mc68000__) && \
       !defined(__sparc__) && \
-      !defined(__mips__)
+      !defined(__mips__) && \
+      !defined(__arm__)
 
 /*
  * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
@@ -567,7 +568,7 @@ xf86EnableIO(void)
 #endif
 	}
 	close(fd);
-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__)
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__)
         if (ioperm(0, 1024, 1) || iopl(3)) {
                 if (errno == ENODEV)
                         ErrorF("xf86EnableIOPorts: no I/O ports found\n");
diff --git a/hw/xfree86/os-support/misc/SlowBcopy.c b/hw/xfree86/os-support/misc/SlowBcopy.c
index 1fda7fc..f0ad611 100644
--- a/hw/xfree86/os-support/misc/SlowBcopy.c
+++ b/hw/xfree86/os-support/misc/SlowBcopy.c
@@ -35,7 +35,8 @@ xf86SlowBcopy(unsigned char *src, unsign
 #if !defined(__sparc__) && \
     !defined(__powerpc__) && \
     !defined(__mips__) && \
-    !defined(__ia64__)
+    !defined(__ia64__) && \
+    !defined(__arm__)
 	outb(0x80, 0x00);
 #endif
     }
diff-tree 562ca3f2f9005e7c5ed0a24b0759051ded2173e9 (from 42c2e14b254f6f882b3e79444360ab855db43e27)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Mon Jun 18 12:00:49 2007 -0400

    In NewInputDeviceRequest, only call EnableDevice if xf86Screens[0]->vtSema is
    true, preventing unwanted behavior in the case where a device is added while
    the user is in a different VT.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 5430020..c08b15f 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -408,7 +408,7 @@ NewInputDeviceRequest (InputOption *opti
 
     dev = pInfo->dev;
     ActivateDevice(dev);
-    if (dev->inited && dev->startup)
+    if (dev->inited && dev->startup && xf86Screens[0]->vtSema)
         EnableDevice(dev);
 
     *pdev = dev;
diff-tree 42c2e14b254f6f882b3e79444360ab855db43e27 (from 78179ae827bb5d19abb1340084362bc51ad5c1e5)
Author: Matthieu Herrb <matthieu at deville.herrb.com>
Date:   Fri Jun 15 00:14:02 2007 +0200

    swap xOrigin and yOrigin in SProcRenderSetPictureClipRectangles.
    
    Fixes Xrender clipping rectangles when X server and client are of
    different endianness, shown by xterm 225 among others.

diff --git a/render/render.c b/render/render.c
index 348d4c6..caaa278 100644
--- a/render/render.c
+++ b/render/render.c
@@ -2074,6 +2074,8 @@ SProcRenderSetPictureClipRectangles (Cli
     REQUEST(xRenderSetPictureClipRectanglesReq);
     swaps(&stuff->length, n);
     swapl(&stuff->picture, n);
+    swaps(&stuff->xOrigin, n);
+    swaps(&stuff->yOrigin, n);
     SwapRestS(stuff);
     return (*ProcRenderVector[stuff->renderReqType]) (client);
 }
diff-tree 78179ae827bb5d19abb1340084362bc51ad5c1e5 (from eb2d7fe02f9cbca57b462bba05498e2d59316fbc)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 22:46:42 2007 -0400

    Remove fbmmx.[ch] files

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
deleted file mode 100644
index f962b66..0000000
--- a/fb/fbmmx.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright © 2004, 2005 Red Hat, Inc.
- * Copyright © 2004 Nicholas Miell
- * Copyright © 2005 Trolltech AS
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Red Hat not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  Red Hat makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author:  Søren Sandmann (sandmann at redhat.com)
- * Minor Improvements: Nicholas Miell (nmiell at gmail.com)
- * MMX code paths for fbcompose.c by Lars Knoll (lars at trolltech.com) 
- *
- * Based on work by Owen Taylor
- */
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef USE_MMX
-
-#if defined(__amd64__) || defined(__x86_64__)
-#define USE_SSE
-#endif
-
-#include <mmintrin.h>
-#ifdef USE_SSE
-#include <xmmintrin.h> /* for _mm_shuffle_pi16 and _MM_SHUFFLE */
-#endif
-
-#ifdef RENDER
-
-#include "fb.h"
-#include "fbmmx.h"
-
-#include "picturestr.h"
-#include "mipict.h"
-#include "fbpict.h"
-
-#define noVERBOSE
-
-#ifdef VERBOSE
-#define CHECKPOINT() ErrorF ("at %s %d\n", __FUNCTION__, __LINE__)
-#else
-#define CHECKPOINT()
-#endif
-
-
-typedef unsigned long long ullong;
-
-#ifdef __GNUC__
-typedef ullong mmxdatafield;
-#endif
-#ifdef _MSC_VER
-typedef unsigned __int64 ullong;
-typedef __m64 mmxdatafield;
-#endif
-
-#endif /* RENDER */
-#endif /* USE_MMX */
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
deleted file mode 100644
index 06b079c..0000000
--- a/fb/fbmmx.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright © 2004 Red Hat, Inc.
- * Copyright © 2005 Trolltech AS
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Red Hat not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  Red Hat makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author:  Søren Sandmann (sandmann at redhat.com)
- *          Lars Knoll (lars at trolltech.com)
- * 
- * Based on work by Owen Taylor
- */
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef USE_MMX
-
-#if !defined(__amd64__) && !defined(__x86_64__)
-Bool fbHaveMMX(void);
-#else
-#define fbHaveMMX() TRUE
-#endif
-
-#else
-#define fbHaveMMX() FALSE
-#endif
-
diff-tree eb2d7fe02f9cbca57b462bba05498e2d59316fbc (from f52ae237d3eec79ccd64cdd77271aeacc37af70c)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 22:43:01 2007 -0400

    Replace fbFillmmx() with pixman_fill() and remove fbmmx.[ch]

diff --git a/configure.ac b/configure.ac
index 9890b9a..4406474 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,19 +362,6 @@ case $host_os in
 esac
 AM_CONDITIONAL(KDRIVE_HW, test "x$KDRIVE_HW" = xyes)
 
-AC_MSG_CHECKING(for MMX capable platform)
-if test "x$use_x86_asm" = xyes && test "x$GCC" = xyes ; then
-	AC_PREPROC_IFELSE([
-#if (!defined (__GNUC__) || __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
-    #error Not supported
-#endif
-], mmx_capable=yes, mmx_capable=no)
-else
-	mmx_capable=no
-fi
-AC_MSG_RESULT([$mmx_capable])
-AM_CONDITIONAL(MMX_CAPABLE, [test "x$mmx_capable" = xyes])
-
 DEFAULT_VENDOR_NAME="The X.Org Foundation"
 DEFAULT_VENDOR_NAME_SHORT="X.Org"
 DEFAULT_VERSION_MAJOR=7
diff --git a/fb/Makefile.am b/fb/Makefile.am
index 28c0cc7..75861a3 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -1,4 +1,4 @@
-noinst_LTLIBRARIES = libfb.la libwfb.la libfbmmx.la
+noinst_LTLIBRARIES = libfb.la libwfb.la
 
 INCLUDES = \
 	-I$(top_srcdir)/hw/xfree86/os-support \
@@ -12,25 +12,8 @@ endif
 
 libfb_la_CFLAGS = $(AM_CFLAGS)
 
-if MMX_CAPABLE
-libfb_la_CFLAGS += -DUSE_MMX
-
-libfbmmx_la_CFLAGS =				\
-	$(DIX_CFLAGS)				\
-	-DUSE_MMX				\
-	-mmmx					\
-	-msse					\
-	-Winline				\
-	--param inline-unit-growth=10000	\
-        --param large-function-growth=10000
-endif
-
 libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
 
-libfbmmx_la_SOURCES =	\
-	fbmmx.c		\
-	fbmmx.h
-
 libfb_la_SOURCES = 	\
 	fb.h		\
 	fb24_32.c	\
@@ -73,6 +56,4 @@ libfb_la_SOURCES = 	\
 
 libwfb_la_SOURCES = $(libfb_la_SOURCES)
 
-libfb_la_LIBADD = libfbmmx.la
-
 EXTRA_DIST = fbcmap.c fbcmap_mi.c
diff --git a/fb/fbcopy.c b/fb/fbcopy.c
index a430203..84053e7 100644
--- a/fb/fbcopy.c
+++ b/fb/fbcopy.c
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 
 #include "fb.h"
-#include "fbmmx.h"
 
 void
 fbCopyNtoN (DrawablePtr	pSrcDrawable,
diff --git a/fb/fbfill.c b/fb/fbfill.c
index 4f13a02..0d624fd 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -27,7 +27,6 @@
 #endif
 
 #include "fb.h"
-#include "fbmmx.h"
 
 void
 fbFill (DrawablePtr pDrawable,
@@ -47,10 +46,10 @@ fbFill (DrawablePtr pDrawable,
 
     switch (pGC->fillStyle) {
     case FillSolid:
-#ifdef USE_MMX
-	if (!pPriv->and && fbHaveMMX())
+#ifndef FB_ACCESS_WRAPPER
+	if (!pPriv->and)
 	{
-	    if (fbFillmmx (dst, dstStride, dstBpp, x + dstXoff, y + dstYoff, width, height, pPriv->xor))
+	    if (pixman_fill (dst, dstStride, dstBpp, x + dstXoff, y + dstYoff, width, height, pPriv->xor))
 	    {
 		fbFinishAccess (pDrawable);
 		return;
@@ -218,12 +217,12 @@ fbSolidBoxClipped (DrawablePtr	pDrawable
 	if (partY2 <= partY1)
 	    continue;
 
-#ifdef USE_MMX
-	if (!and && fbHaveMMX())
+#ifndef FB_ACCESS_WRAPPER
+	if (!and)
 	{
-	    if (fbFillmmx (dst, dstStride, dstBpp,
-			   partX1 + dstXoff, partX2 + dstYoff, (partX2 - partX1), (partY2 - partY1),
-			   xor))
+	    if (pixman_fill (dst, dstStride, dstBpp,
+			     partX1 + dstXoff, partX2 + dstYoff, (partX2 - partX1), (partY2 - partY1),
+			     xor))
 	    {
 		fbFinishAccess (pDrawable);
 		return;
diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 452769d..f962b66 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -73,133 +73,5 @@ typedef unsigned __int64 ullong;
 typedef __m64 mmxdatafield;
 #endif
 
-Bool
-fbFillmmx (FbBits *bits,
-	   FbStride stride,
-	   int bpp,
-	   int x,
-	   int y,
-	   int width,
-	   int height,
-	   FbBits xor)
-{
-    ullong	fill;
-    __m64	vfill;
-    CARD32	byte_width;
-    CARD8	*byte_line;
-#ifdef __GNUC__
-    __m64	v1, v2, v3, v4, v5, v6, v7;
-#endif
-    
-    if (bpp == 16 && (xor >> 16 != (xor & 0xffff)))
-	return FALSE;
-    
-    if (bpp != 16 && bpp != 32)
-	return FALSE;
-    
-    if (bpp == 16)
-    {
-	stride = stride * sizeof (FbBits) / 2;
-	byte_line = (CARD8 *)(((CARD16 *)bits) + stride * y + x);
-	byte_width = 2 * width;
-	stride *= 2;
-    }
-    else
-    {
-	stride = stride * sizeof (FbBits) / 4;
-	byte_line = (CARD8 *)(((CARD32 *)bits) + stride * y + x);
-	byte_width = 4 * width;
-	stride *= 4;
-    }
-    
-    fill = ((ullong)xor << 32) | xor;
-    vfill = (__m64)fill;
-    
-#ifdef __GNUC__
-    __asm__ (
-	"movq		%7,	%0\n"
-	"movq		%7,	%1\n"
-	"movq		%7,	%2\n"
-	"movq		%7,	%3\n"
-	"movq		%7,	%4\n"
-	"movq		%7,	%5\n"
-	"movq		%7,	%6\n"
-	: "=y" (v1), "=y" (v2), "=y" (v3),
-	  "=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
-	: "y" (vfill));
-#endif
-    
-    while (height--)
-    {
-	int w;
-	CARD8 *d = byte_line;
-	byte_line += stride;
-	w = byte_width;
-	
-	while (w >= 2 && ((unsigned long)d & 3))
-	{
-	    *(CARD16 *)d = xor;
-	    w -= 2;
-	    d += 2;
-	}
-	
-	while (w >= 4 && ((unsigned long)d & 7))
-	{
-	    *(CARD32 *)d = xor;
-	    
-	    w -= 4;
-	    d += 4;
-	}
-
-	while (w >= 64)
-	{
-#ifdef __GNUC__
-	    __asm__ (
-		"movq	%1,	  (%0)\n"
-		"movq	%2,	 8(%0)\n"
-		"movq	%3,	16(%0)\n"
-		"movq	%4,	24(%0)\n"
-		"movq	%5,	32(%0)\n"
-		"movq	%6,	40(%0)\n"
-		"movq	%7,	48(%0)\n"
-		"movq	%8,	56(%0)\n"
-		:
-		: "r" (d),
-		  "y" (vfill), "y" (v1), "y" (v2), "y" (v3),
-		  "y" (v4), "y" (v5), "y" (v6), "y" (v7)
-		: "memory");
-#else
-	    *(__m64*) (d +  0) = vfill;
-	    *(__m64*) (d +  8) = vfill;
-	    *(__m64*) (d + 16) = vfill;
-	    *(__m64*) (d + 24) = vfill;
-	    *(__m64*) (d + 32) = vfill;
-	    *(__m64*) (d + 40) = vfill;
-	    *(__m64*) (d + 48) = vfill;
-	    *(__m64*) (d + 56) = vfill;
-#endif    
-	    w -= 64;
-	    d += 64;
-	}
-	
-	while (w >= 4)
-	{
-	    *(CARD32 *)d = xor;
-	    
-	    w -= 4;
-	    d += 4;
-	}
-	if (w >= 2)
-	{
-	    *(CARD16 *)d = xor;
-	    w -= 2;
-	    d += 2;
-	}
-    }
-    
-    _mm_empty();
-    return TRUE;
-}
-
 #endif /* RENDER */
 #endif /* USE_MMX */
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index cd685ce..06b079c 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -42,14 +42,3 @@ Bool fbHaveMMX(void);
 #define fbHaveMMX() FALSE
 #endif
 
-#ifdef USE_MMX
-
-Bool fbFillmmx (FbBits *bits,
-		FbStride stride,
-		int bpp,
-		int x,
-		int y,
-		int width,
-		int height,
-		FbBits xor);
-#endif /* USE_MMX */
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 0a42f12..ead84d7 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -36,7 +36,6 @@
 #include "picturestr.h"
 #include "mipict.h"
 #include "fbpict.h"
-#include "fbmmx.h"
 
 #define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
@@ -468,203 +467,3 @@ fbPictureInit (ScreenPtr pScreen, PictFo
 
     return TRUE;
 }
-
-#ifdef USE_MMX
-/* The CPU detection code needs to be in a file not compiled with
- * "-mmmx -msse", as gcc would generate CMOV instructions otherwise
- * that would lead to SIGILL instructions on old CPUs that don't have
- * it.
- */
-#if !defined(__amd64__) && !defined(__x86_64__)
-
-#ifdef HAVE_GETISAX
-#include <sys/auxv.h>
-#endif
-
-enum CPUFeatures {
-    NoFeatures = 0,
-    MMX = 0x1,
-    MMX_Extensions = 0x2, 
-    SSE = 0x6,
-    SSE2 = 0x8,
-    CMOV = 0x10
-};
-
-static unsigned int detectCPUFeatures(void) {
-    unsigned int features = 0;
-    unsigned int result = 0;
-
-#ifdef HAVE_GETISAX
-    if (getisax(&result, 1)) {
-        if (result & AV_386_CMOV)
-            features |= CMOV;
-        if (result & AV_386_MMX)
-            features |= MMX;
-        if (result & AV_386_AMD_MMX)
-            features |= MMX_Extensions;
-        if (result & AV_386_SSE)
-            features |= SSE;
-        if (result & AV_386_SSE2)
-            features |= SSE2;
-    }
-#else
-    char vendor[13];
-#ifdef _MSC_VER
-    int vendor0 = 0, vendor1, vendor2;
-#endif
-    vendor[0] = 0;
-    vendor[12] = 0;
-
-#ifdef __GNUC__
-    /* see p. 118 of amd64 instruction set manual Vol3 */
-    /* We need to be careful about the handling of %ebx and
-     * %esp here. We can't declare either one as clobbered
-     * since they are special registers (%ebx is the "PIC
-     * register" holding an offset to global data, %esp the
-     * stack pointer), so we need to make sure they have their
-     * original values when we access the output operands.
-     */
-    __asm__ ("pushf\n"
-             "pop %%eax\n"
-             "mov %%eax, %%ecx\n"
-             "xor $0x00200000, %%eax\n"
-             "push %%eax\n"
-             "popf\n"
-             "pushf\n"
-             "pop %%eax\n"
-             "mov $0x0, %%edx\n"
-             "xor %%ecx, %%eax\n"
-             "jz 1f\n"
-
-             "mov $0x00000000, %%eax\n"
-	     "push %%ebx\n"
-             "cpuid\n"
-             "mov %%ebx, %%eax\n"
-	     "pop %%ebx\n"
-	     "mov %%eax, %1\n"
-             "mov %%edx, %2\n"
-             "mov %%ecx, %3\n"
-             "mov $0x00000001, %%eax\n"
-	     "push %%ebx\n"
-             "cpuid\n"
-	     "pop %%ebx\n"
-             "1:\n"
-             "mov %%edx, %0\n"
-             : "=r" (result), 
-               "=m" (vendor[0]), 
-               "=m" (vendor[4]), 
-               "=m" (vendor[8])
-             :
-             : "%eax", "%ecx", "%edx"
-        );
-
-#elif defined (_MSC_VER)
-
-    _asm {
-      pushfd
-      pop eax
-      mov ecx, eax
-      xor eax, 00200000h
-      push eax
-      popfd
-      pushfd
-      pop eax
-      mov edx, 0
-      xor eax, ecx
-      jz nocpuid
-
-      mov eax, 0
-      push ebx
-      cpuid
-      mov eax, ebx
-      pop ebx
-      mov vendor0, eax
-      mov vendor1, edx
-      mov vendor2, ecx
-      mov eax, 1
-      push ebx
-      cpuid
-      pop ebx
-    nocpuid:
-      mov result, edx
-    }
-    memmove (vendor+0, &vendor0, 4);
-    memmove (vendor+4, &vendor1, 4);
-    memmove (vendor+8, &vendor2, 4);
-
-#else
-#   error unsupported compiler
-#endif
-    
-    features = 0;
-    if (result) {
-        /* result now contains the standard feature bits */
-        if (result & (1 << 15))
-            features |= CMOV;
-        if (result & (1 << 23))
-            features |= MMX;
-        if (result & (1 << 25))
-            features |= SSE;
-        if (result & (1 << 26))
-            features |= SSE2;
-        if ((features & MMX) && !(features & SSE) &&
-            (strcmp(vendor, "AuthenticAMD") == 0 ||
-             strcmp(vendor, "Geode by NSC") == 0)) {
-            /* check for AMD MMX extensions */
-#ifdef __GNUC__
-            __asm__("push %%ebx\n"
-                    "mov $0x80000000, %%eax\n"
-                    "cpuid\n"
-                    "xor %%edx, %%edx\n"
-                    "cmp $0x1, %%eax\n"
-                    "jge 2f\n"
-                    "mov $0x80000001, %%eax\n"
-                    "cpuid\n"
-                    "2:\n"
-                    "pop %%ebx\n"
-                    "mov %%edx, %0\n"
-                    : "=r" (result)
-                    :
-                    : "%eax", "%ecx", "%edx"
-                );
-#elif defined _MSC_VER
-            _asm {
-              push ebx
-              mov eax, 80000000h
-              cpuid
-              xor edx, edx
-              cmp eax, 1
-              jge notamd
-              mov eax, 80000001h
-              cpuid
-            notamd:
-              pop ebx
-              mov result, edx
-            }
-#endif
-            if (result & (1<<22))
-                features |= MMX_Extensions;
-        }
-    }
-#endif /* HAVE_GETISAX */
-
-    return features;
-}
-
-Bool
-fbHaveMMX (void)
-{
-    static Bool initialized = FALSE;
-    static Bool mmx_present;
-
-    if (!initialized)
-    {
-        unsigned int features = detectCPUFeatures();
-	mmx_present = (features & (MMX|MMX_Extensions)) == (MMX|MMX_Extensions);
-        initialized = TRUE;
-    }
-    
-    return mmx_present;
-}
-#endif /* __amd64__ */
-#endif
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 5b3f446..fc036d3 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -30,10 +30,6 @@
 
 #include "fb.h"
 
-#ifdef USE_MMX
-#include "fbmmx.h"
-#endif
-
 Bool
 fbCreateWindow(WindowPtr pWin)
 {
@@ -222,22 +218,22 @@ fbFillRegionSolid (DrawablePtr	pDrawable
     int		n = REGION_NUM_RECTS(pRegion);
     BoxPtr	pbox = REGION_RECTS(pRegion);
 
-#ifdef USE_MMX
-    int has_mmx = 0;
-    if (!and && fbHaveMMX())
-        has_mmx = 1;
+#ifndef FB_ACCESS_WRAPPER
+    int try_mmx = 0;
+    if (!and)
+        try_mmx = 1;
 #endif
 
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     
     while (n--)
     {
-#ifdef USE_MMX
-	if (!has_mmx || !fbFillmmx (dst, dstStride, dstBpp,
-				    pbox->x1 + dstXoff, pbox->y1 + dstYoff,
-				    (pbox->x2 - pbox->x1),
-				    (pbox->y2 - pbox->y1),
-				    xor))
+#ifndef FB_ACCESS_WRAPPER
+	if (!try_mmx || !pixman_fill (dst, dstStride, dstBpp,
+				      pbox->x1 + dstXoff, pbox->y1 + dstYoff,
+				      (pbox->x2 - pbox->x1),
+				      (pbox->y2 - pbox->y1),
+				      xor))
 	{
 #endif
 	    fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
@@ -247,7 +243,7 @@ fbFillRegionSolid (DrawablePtr	pDrawable
 		     (pbox->x2 - pbox->x1) * dstBpp,
 		     pbox->y2 - pbox->y1,
 		     and, xor);
-#ifdef USE_MMX
+#ifndef FB_ACCESS_WRAPPER
 	}
 #endif
 	fbValidateDrawable (pDrawable);
diff-tree f52ae237d3eec79ccd64cdd77271aeacc37af70c (from d1d85c04e248f46b1cf1b1d25fdd56aa69b8f0ee)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 22:02:39 2007 -0400

    Require pixman 0.9.2

diff --git a/configure.ac b/configure.ac
index a5160a2..9890b9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -626,7 +626,7 @@ XEXT_INC='-I$(top_srcdir)/Xext'
 XEXT_LIB='$(top_builddir)/Xext/libXext.la'
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
-PIXMAN="[pixman >= 0.9.1]"
+PIXMAN="[pixman >= 0.9.2]"
 
 dnl Core modules for most extensions, et al.
 REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
diff-tree d1d85c04e248f46b1cf1b1d25fdd56aa69b8f0ee (from 3f9adb18f127318d054f30a57e3a77176e14c692)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 21:25:42 2007 -0400

    Delete fbBltmmx().

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 3522a00..452769d 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -201,141 +201,5 @@ fbFillmmx (FbBits *bits,
     return TRUE;
 }
 
-Bool
-fbBltmmx (FbBits *src_bits,
-	  FbBits *dst_bits,
-	  FbStride src_stride,
-	  FbStride dst_stride,
-	  int src_bpp,
-	  int dst_bpp,
-	  int src_x, int src_y,
-	  int dst_x, int dst_y,
-	  int width, int height)
-{
-    CARD8 *	src_bytes;
-    CARD8 *	dst_bytes;
-    int		byte_width;
-    
-    if (src_bpp != dst_bpp)
-	return FALSE;
-    
-    if (src_bpp == 16)
-    {
-	src_stride = src_stride * sizeof (FbBits) / 2;
-	dst_stride = dst_stride * sizeof (FbBits) / 2;
-	src_bytes = (CARD8 *)(((CARD16 *)src_bits) + src_stride * (src_y) + (src_x));
-	dst_bytes = (CARD8 *)(((CARD16 *)dst_bits) + dst_stride * (dst_y) + (dst_x));
-	byte_width = 2 * width;
-	src_stride *= 2;
-	dst_stride *= 2;
-    } else if (src_bpp == 32) {
-	src_stride = src_stride * sizeof (FbBits) / 4;
-	dst_stride = dst_stride * sizeof (FbBits) / 4;
-	src_bytes = (CARD8 *)(((CARD32 *)src_bits) + src_stride * (src_y) + (src_x));
-	dst_bytes = (CARD8 *)(((CARD32 *)dst_bits) + dst_stride * (dst_y) + (dst_x));
-	byte_width = 4 * width;
-	src_stride *= 4;
-	dst_stride *= 4;
-    } else {
-	return FALSE;
-    }
-
-    while (height--)
-    {
-	int w;
-	CARD8 *s = src_bytes;
-	CARD8 *d = dst_bytes;
-	src_bytes += src_stride;
-	dst_bytes += dst_stride;
-	w = byte_width;
-	
-	while (w >= 2 && ((unsigned long)d & 3))
-	{
-	    *(CARD16 *)d = *(CARD16 *)s;
-	    w -= 2;
-	    s += 2;
-	    d += 2;
-	}
-	
-	while (w >= 4 && ((unsigned long)d & 7))
-	{
-	    *(CARD32 *)d = *(CARD32 *)s;
-	    
-	    w -= 4;
-	    s += 4;
-	    d += 4;
-	}
-	
-	while (w >= 64)
-	{
-#ifdef __GNUC__
-	    __asm__ (
-		"movq	  (%1),	  %%mm0\n"
-		"movq	 8(%1),	  %%mm1\n"
-		"movq	16(%1),	  %%mm2\n"
-		"movq	24(%1),	  %%mm3\n"
-		"movq	32(%1),	  %%mm4\n"
-		"movq	40(%1),	  %%mm5\n"
-		"movq	48(%1),	  %%mm6\n"
-		"movq	56(%1),	  %%mm7\n"
-
-		"movq	%%mm0,	  (%0)\n"
-		"movq	%%mm1,	 8(%0)\n"
-		"movq	%%mm2,	16(%0)\n"
-		"movq	%%mm3,	24(%0)\n"
-		"movq	%%mm4,	32(%0)\n"
-		"movq	%%mm5,	40(%0)\n"
-		"movq	%%mm6,	48(%0)\n"
-		"movq	%%mm7,	56(%0)\n"
-		:
-		: "r" (d), "r" (s)
-		: "memory",
-		  "%mm0", "%mm1", "%mm2", "%mm3",
-		  "%mm4", "%mm5", "%mm6", "%mm7");
-#else
-	    __m64 v0 = *(__m64 *)(s + 0);
-	    __m64 v1 = *(__m64 *)(s + 8);
-	    __m64 v2 = *(__m64 *)(s + 16);
-	    __m64 v3 = *(__m64 *)(s + 24);
-	    __m64 v4 = *(__m64 *)(s + 32);
-	    __m64 v5 = *(__m64 *)(s + 40);
-	    __m64 v6 = *(__m64 *)(s + 48);
-	    __m64 v7 = *(__m64 *)(s + 56);
-	    *(__m64 *)(d + 0)  = v0;
-	    *(__m64 *)(d + 8)  = v1;
-	    *(__m64 *)(d + 16) = v2;
-	    *(__m64 *)(d + 24) = v3;
-	    *(__m64 *)(d + 32) = v4;
-	    *(__m64 *)(d + 40) = v5;
-	    *(__m64 *)(d + 48) = v6;
-	    *(__m64 *)(d + 56) = v7;
-#endif	    
-	    
-	    w -= 64;
-	    s += 64;
-	    d += 64;
-	}
-	while (w >= 4)
-	{
-	    *(CARD32 *)d = *(CARD32 *)s;
-
-	    w -= 4;
-	    s += 4;
-	    d += 4;
-	}
-	if (w >= 2)
-	{
-	    *(CARD16 *)d = *(CARD16 *)s;
-	    w -= 2;
-	    s += 2;
-	    d += 2;
-	}
-    }
-    
-    _mm_empty();
-
-    return TRUE;
-}
-
 #endif /* RENDER */
 #endif /* USE_MMX */
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index 7d32a38..cd685ce 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -44,15 +44,6 @@ Bool fbHaveMMX(void);
 
 #ifdef USE_MMX
 
-Bool fbBltmmx (FbBits *src_bits,
-	       FbBits *dst_bits,
-	       FbStride src_stride,
-	       FbStride dst_stride,
-	       int src_bpp,
-	       int dst_bpp,
-	       int src_x, int src_y,
-	       int dst_x, int dst_y,
-	       int width, int height);
 Bool fbFillmmx (FbBits *bits,
 		FbStride stride,
 		int bpp,
diff-tree 3f9adb18f127318d054f30a57e3a77176e14c692 (from d06099b38e8445e6e31f5178ffefcc31a71080ef)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 15:19:27 2007 -0400

    Port a few forgotten fbSolidFillmmx()'es to fbFillmmx(). Use pixman_blt() instead of fbBltmmx()
    in fbCopyNToN().

diff --git a/fb/fbcopy.c b/fb/fbcopy.c
index 74ff358..a430203 100644
--- a/fb/fbcopy.c
+++ b/fb/fbcopy.c
@@ -60,17 +60,17 @@ fbCopyNtoN (DrawablePtr	pSrcDrawable,
 
     while (nbox--)
     {
-#ifdef USE_MMX
+#ifndef FB_ACCESS_WRAPPER /* pixman_blt() doesn't support accessors yet */
 	if (pm == FB_ALLONES && alu == GXcopy && !reverse &&
-	    !upsidedown && fbHaveMMX())
+	    !upsidedown)
 	{
-	    if (!fbBltmmx (src, dst, srcStride, dstStride, srcBpp, dstBpp,
-			   (pbox->x1 + dx + srcXoff),
-			   (pbox->y1 + dy + srcYoff),
-			   (pbox->x1 + srcXoff),
-			   (pbox->y1 + srcYoff),
-			   (pbox->x2 - pbox->x1),
-			   (pbox->y2 - pbox->y1)))
+	    if (!pixman_blt ((uint32_t *)src, (uint32_t *)dst, srcStride, dstStride, srcBpp, dstBpp,
+			     (pbox->x1 + dx + srcXoff),
+			     (pbox->y1 + dy + srcYoff),
+			     (pbox->x1 + srcXoff),
+			     (pbox->y1 + srcYoff),
+			     (pbox->x2 - pbox->x1),
+			     (pbox->y2 - pbox->y1)))
 		goto fallback;
 	    else
 		goto next;
@@ -94,7 +94,7 @@ fbCopyNtoN (DrawablePtr	pSrcDrawable,
 	       
 	       reverse,
 	       upsidedown);
-#ifdef USE_MMX
+#ifndef FB_ACCESS_WRAPPER
     next:
 #endif
 	pbox++;
diff --git a/fb/fbfill.c b/fb/fbfill.c
index 35e4427..4f13a02 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -221,13 +221,13 @@ fbSolidBoxClipped (DrawablePtr	pDrawable
 #ifdef USE_MMX
 	if (!and && fbHaveMMX())
 	{
-		if (fbSolidFillmmx (pDrawable,
-		                    partX1, partY1,
-				    (partX2 - partX1), (partY2 - partY1),
-				    xor)) {
-			fbFinishAccess (pDrawable);
-			return;
-		}
+	    if (fbFillmmx (dst, dstStride, dstBpp,
+			   partX1 + dstXoff, partX2 + dstYoff, (partX2 - partX1), (partY2 - partY1),
+			   xor))
+	    {
+		fbFinishAccess (pDrawable);
+		return;
+	    }
 	}
 #endif
 	fbSolid (dst + (partY1 + dstYoff) * dstStride,
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index cac662c..5b3f446 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -233,26 +233,27 @@ fbFillRegionSolid (DrawablePtr	pDrawable
     while (n--)
     {
 #ifdef USE_MMX
-        if (!has_mmx || !fbSolidFillmmx (pDrawable,
-	                                pbox->x1,
-					pbox->y1,
-					(pbox->x2 - pbox->x1),
-					(pbox->y2 - pbox->y1), xor)) {
+	if (!has_mmx || !fbFillmmx (dst, dstStride, dstBpp,
+				    pbox->x1 + dstXoff, pbox->y1 + dstYoff,
+				    (pbox->x2 - pbox->x1),
+				    (pbox->y2 - pbox->y1),
+				    xor))
+	{
 #endif
-	fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
-		 dstStride,
-		 (pbox->x1 + dstXoff) * dstBpp,
-		 dstBpp,
-		 (pbox->x2 - pbox->x1) * dstBpp,
-		 pbox->y2 - pbox->y1,
-		 and, xor);
+	    fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
+		     dstStride,
+		     (pbox->x1 + dstXoff) * dstBpp,
+		     dstBpp,
+		     (pbox->x2 - pbox->x1) * dstBpp,
+		     pbox->y2 - pbox->y1,
+		     and, xor);
 #ifdef USE_MMX
 	}
 #endif
 	fbValidateDrawable (pDrawable);
 	pbox++;
     }
-
+    
     fbFinishAccess (pDrawable);
 }
 
diff-tree d06099b38e8445e6e31f5178ffefcc31a71080ef (from d4a034370c8ae71b2cc4fe824ceee58b19624f35)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 13:28:24 2007 -0400

    Remove fbCopyAreammx() and fbSolidFillmmx()

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 6a593ff..3522a00 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -202,26 +202,6 @@ fbFillmmx (FbBits *bits,
 }
 
 Bool
-fbSolidFillmmx (DrawablePtr	pDraw,
-		int		x,
-		int		y,
-		int		width,
-		int		height,
-		FbBits		xor)
-{ 
-    FbStride	stride;
-    int		bpp;
-    FbBits      *bits;
-    int		xoff, yoff;
-    
-    CHECKPOINT();
-    
-    fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
-
-    return fbFillmmx (bits, stride, bpp, x + xoff, y + yoff, width, height, xor);
-}
-
-Bool
 fbBltmmx (FbBits *src_bits,
 	  FbBits *dst_bits,
 	  FbStride src_stride,
@@ -357,36 +337,5 @@ fbBltmmx (FbBits *src_bits,
     return TRUE;
 }
 
-Bool
-fbCopyAreammx (DrawablePtr	pSrc,
-	       DrawablePtr	pDst,
-	       int		src_x,
-	       int		src_y,
-	       int		dst_x,
-	       int		dst_y,
-	       int		width,
-	       int		height)
-{
-    FbBits *	src_bits;
-    FbStride	src_stride;
-    int		src_bpp;
-    int		src_xoff;
-    int		src_yoff;
-
-    FbBits *	dst_bits;
-    FbStride	dst_stride;
-    int		dst_bpp;
-    int		dst_xoff;
-    int		dst_yoff;
-    
-    fbGetDrawable(pSrc, src_bits, src_stride, src_bpp, src_xoff, src_yoff);
-    fbGetDrawable(pDst, dst_bits, dst_stride, dst_bpp, dst_xoff, dst_yoff);
-
-    return fbBltmmx (src_bits, dst_bits, src_stride, dst_stride, src_bpp, dst_bpp,
-		     src_x + src_xoff, src_y + src_yoff,
-		     dst_x + dst_xoff, dst_y + dst_yoff,
-		     width, height);
-}
-
 #endif /* RENDER */
 #endif /* USE_MMX */
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index dda395a..7d32a38 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -53,14 +53,6 @@ Bool fbBltmmx (FbBits *src_bits,
 	       int src_x, int src_y,
 	       int dst_x, int dst_y,
 	       int width, int height);
-Bool fbCopyAreammx (DrawablePtr	pSrc,
-		    DrawablePtr	pDst,
-		    int		src_x,
-		    int		src_y,
-		    int		dst_x,
-		    int		dst_y,
-		    int		width,
-		    int		height);
 Bool fbFillmmx (FbBits *bits,
 		FbStride stride,
 		int bpp,
@@ -69,11 +61,4 @@ Bool fbFillmmx (FbBits *bits,
 		int width,
 		int height,
 		FbBits xor);
-Bool fbSolidFillmmx (DrawablePtr	pDraw,
-		     int		x,
-		     int		y,
-		     int		width,
-		     int		height,
-		     FbBits		xor);
-
 #endif /* USE_MMX */
diff-tree d4a034370c8ae71b2cc4fe824ceee58b19624f35 (from 3210902a7334f3d8d6c18a34a3cb3f55803b0043)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 13:26:24 2007 -0400

    Split fbSolidFillmmx() into a new FbFillmmx() function. Call that from fbFill().

diff --git a/fb/fbfill.c b/fb/fbfill.c
index 7ef3a70..35e4427 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -49,10 +49,13 @@ fbFill (DrawablePtr pDrawable,
     case FillSolid:
 #ifdef USE_MMX
 	if (!pPriv->and && fbHaveMMX())
-	    if (fbSolidFillmmx (pDrawable, x, y, width, height, pPriv->xor)) {
+	{
+	    if (fbFillmmx (dst, dstStride, dstBpp, x + dstXoff, y + dstYoff, width, height, pPriv->xor))
+	    {
 		fbFinishAccess (pDrawable);
 		return;
 	    }
+	}
 #endif	    
 	fbSolid (dst + (y + dstYoff) * dstStride, 
 		 dstStride, 
diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 7fb4b15..6a593ff 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -74,29 +74,23 @@ typedef __m64 mmxdatafield;
 #endif
 
 Bool
-fbSolidFillmmx (DrawablePtr	pDraw,
-		int		x,
-		int		y,
-		int		width,
-		int		height,
-		FbBits		xor)
-{ 
-    FbStride	stride;
-    int		bpp;
+fbFillmmx (FbBits *bits,
+	   FbStride stride,
+	   int bpp,
+	   int x,
+	   int y,
+	   int width,
+	   int height,
+	   FbBits xor)
+{
     ullong	fill;
     __m64	vfill;
     CARD32	byte_width;
     CARD8	*byte_line;
-    FbBits      *bits;
-    int		xoff, yoff;
 #ifdef __GNUC__
     __m64	v1, v2, v3, v4, v5, v6, v7;
 #endif
     
-    CHECKPOINT();
-    
-    fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
-    
     if (bpp == 16 && (xor >> 16 != (xor & 0xffff)))
 	return FALSE;
     
@@ -106,14 +100,14 @@ fbSolidFillmmx (DrawablePtr	pDraw,
     if (bpp == 16)
     {
 	stride = stride * sizeof (FbBits) / 2;
-	byte_line = (CARD8 *)(((CARD16 *)bits) + stride * (y + yoff) + (x + xoff));
+	byte_line = (CARD8 *)(((CARD16 *)bits) + stride * y + x);
 	byte_width = 2 * width;
 	stride *= 2;
     }
     else
     {
 	stride = stride * sizeof (FbBits) / 4;
-	byte_line = (CARD8 *)(((CARD32 *)bits) + stride * (y + yoff) + (x + xoff));
+	byte_line = (CARD8 *)(((CARD32 *)bits) + stride * y + x);
 	byte_width = 4 * width;
 	stride *= 4;
     }
@@ -208,6 +202,26 @@ fbSolidFillmmx (DrawablePtr	pDraw,
 }
 
 Bool
+fbSolidFillmmx (DrawablePtr	pDraw,
+		int		x,
+		int		y,
+		int		width,
+		int		height,
+		FbBits		xor)
+{ 
+    FbStride	stride;
+    int		bpp;
+    FbBits      *bits;
+    int		xoff, yoff;
+    
+    CHECKPOINT();
+    
+    fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
+
+    return fbFillmmx (bits, stride, bpp, x + xoff, y + yoff, width, height, xor);
+}
+
+Bool
 fbBltmmx (FbBits *src_bits,
 	  FbBits *dst_bits,
 	  FbStride src_stride,
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index a529526..dda395a 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -61,6 +61,14 @@ Bool fbCopyAreammx (DrawablePtr	pSrc,
 		    int		dst_y,
 		    int		width,
 		    int		height);
+Bool fbFillmmx (FbBits *bits,
+		FbStride stride,
+		int bpp,
+		int x,
+		int y,
+		int width,
+		int height,
+		FbBits xor);
 Bool fbSolidFillmmx (DrawablePtr	pDraw,
 		     int		x,
 		     int		y,
diff-tree 3210902a7334f3d8d6c18a34a3cb3f55803b0043 (from 8d5f4368eac1b259db3e61f877a4cc10f04efa2f)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 13:14:50 2007 -0400

    Split fbCopyAreammx() into a new fbBltmmx() function; call this
    
    function from fbCopyNToN().

diff --git a/fb/fbcopy.c b/fb/fbcopy.c
index 164cd3d..74ff358 100644
--- a/fb/fbcopy.c
+++ b/fb/fbcopy.c
@@ -64,17 +64,13 @@ fbCopyNtoN (DrawablePtr	pSrcDrawable,
 	if (pm == FB_ALLONES && alu == GXcopy && !reverse &&
 	    !upsidedown && fbHaveMMX())
 	{
-	    if (!fbCopyAreammx (pSrcDrawable,
-				pDstDrawable,
-				
-				(pbox->x1 + dx),
-				(pbox->y1 + dy),
-				
-				(pbox->x1),
-				(pbox->y1),
-				
-				(pbox->x2 - pbox->x1),
-				(pbox->y2 - pbox->y1)))
+	    if (!fbBltmmx (src, dst, srcStride, dstStride, srcBpp, dstBpp,
+			   (pbox->x1 + dx + srcXoff),
+			   (pbox->y1 + dy + srcYoff),
+			   (pbox->x1 + srcXoff),
+			   (pbox->y1 + srcYoff),
+			   (pbox->x2 - pbox->x1),
+			   (pbox->y2 - pbox->y1)))
 		goto fallback;
 	    else
 		goto next;
diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index b2fe94b..7fb4b15 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -208,34 +208,20 @@ fbSolidFillmmx (DrawablePtr	pDraw,
 }
 
 Bool
-fbCopyAreammx (DrawablePtr	pSrc,
-	       DrawablePtr	pDst,
-	       int		src_x,
-	       int		src_y,
-	       int		dst_x,
-	       int		dst_y,
-	       int		width,
-	       int		height)
+fbBltmmx (FbBits *src_bits,
+	  FbBits *dst_bits,
+	  FbStride src_stride,
+	  FbStride dst_stride,
+	  int src_bpp,
+	  int dst_bpp,
+	  int src_x, int src_y,
+	  int dst_x, int dst_y,
+	  int width, int height)
 {
-    FbBits *	src_bits;
-    FbStride	src_stride;
-    int		src_bpp;
-    int		src_xoff;
-    int		src_yoff;
-
-    FbBits *	dst_bits;
-    FbStride	dst_stride;
-    int		dst_bpp;
-    int		dst_xoff;
-    int		dst_yoff;
-
     CARD8 *	src_bytes;
     CARD8 *	dst_bytes;
     int		byte_width;
     
-    fbGetDrawable(pSrc, src_bits, src_stride, src_bpp, src_xoff, src_yoff);
-    fbGetDrawable(pDst, dst_bits, dst_stride, dst_bpp, dst_xoff, dst_yoff);
-
     if (src_bpp != dst_bpp)
 	return FALSE;
     
@@ -243,16 +229,16 @@ fbCopyAreammx (DrawablePtr	pSrc,
     {
 	src_stride = src_stride * sizeof (FbBits) / 2;
 	dst_stride = dst_stride * sizeof (FbBits) / 2;
-	src_bytes = (CARD8 *)(((CARD16 *)src_bits) + src_stride * (src_y + src_yoff) + (src_x + src_xoff));
-	dst_bytes = (CARD8 *)(((CARD16 *)dst_bits) + dst_stride * (dst_y + dst_yoff) + (dst_x + dst_xoff));
+	src_bytes = (CARD8 *)(((CARD16 *)src_bits) + src_stride * (src_y) + (src_x));
+	dst_bytes = (CARD8 *)(((CARD16 *)dst_bits) + dst_stride * (dst_y) + (dst_x));
 	byte_width = 2 * width;
 	src_stride *= 2;
 	dst_stride *= 2;
     } else if (src_bpp == 32) {
 	src_stride = src_stride * sizeof (FbBits) / 4;
 	dst_stride = dst_stride * sizeof (FbBits) / 4;
-	src_bytes = (CARD8 *)(((CARD32 *)src_bits) + src_stride * (src_y + src_yoff) + (src_x + src_xoff));
-	dst_bytes = (CARD8 *)(((CARD32 *)dst_bits) + dst_stride * (dst_y + dst_yoff) + (dst_x + dst_xoff));
+	src_bytes = (CARD8 *)(((CARD32 *)src_bits) + src_stride * (src_y) + (src_x));
+	dst_bytes = (CARD8 *)(((CARD32 *)dst_bits) + dst_stride * (dst_y) + (dst_x));
 	byte_width = 4 * width;
 	src_stride *= 4;
 	dst_stride *= 4;
@@ -353,8 +339,40 @@ fbCopyAreammx (DrawablePtr	pSrc,
     }
     
     _mm_empty();
+
     return TRUE;
 }
 
+Bool
+fbCopyAreammx (DrawablePtr	pSrc,
+	       DrawablePtr	pDst,
+	       int		src_x,
+	       int		src_y,
+	       int		dst_x,
+	       int		dst_y,
+	       int		width,
+	       int		height)
+{
+    FbBits *	src_bits;
+    FbStride	src_stride;
+    int		src_bpp;
+    int		src_xoff;
+    int		src_yoff;
+
+    FbBits *	dst_bits;
+    FbStride	dst_stride;
+    int		dst_bpp;
+    int		dst_xoff;
+    int		dst_yoff;
+    
+    fbGetDrawable(pSrc, src_bits, src_stride, src_bpp, src_xoff, src_yoff);
+    fbGetDrawable(pDst, dst_bits, dst_stride, dst_bpp, dst_xoff, dst_yoff);
+
+    return fbBltmmx (src_bits, dst_bits, src_stride, dst_stride, src_bpp, dst_bpp,
+		     src_x + src_xoff, src_y + src_yoff,
+		     dst_x + dst_xoff, dst_y + dst_yoff,
+		     width, height);
+}
+
 #endif /* RENDER */
 #endif /* USE_MMX */
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index 4796438..a529526 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -44,6 +44,15 @@ Bool fbHaveMMX(void);
 
 #ifdef USE_MMX
 
+Bool fbBltmmx (FbBits *src_bits,
+	       FbBits *dst_bits,
+	       FbStride src_stride,
+	       FbStride dst_stride,
+	       int src_bpp,
+	       int dst_bpp,
+	       int src_x, int src_y,
+	       int dst_x, int dst_y,
+	       int width, int height);
 Bool fbCopyAreammx (DrawablePtr	pSrc,
 		    DrawablePtr	pDst,
 		    int		src_x,
diff-tree 8d5f4368eac1b259db3e61f877a4cc10f04efa2f (from 54e023cec07aa7e392da36e11d0a4667b8341370)
Author: Clark Rawlins <clark.rawlins at escient.com>
Date:   Mon Jun 11 16:53:38 2007 +0200

    Really make sure BUILD_TIME doesn't have a leading zero.
    
    date +'%k%M%S' still gives a leading zero in the hour after midnight...
    
    Add a leading 1 and remove it in xf86PrintBanner().

diff --git a/configure.ac b/configure.ac
index f7f2e6e..a5160a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1948,7 +1948,7 @@ AM_CONDITIONAL(SUN_KBD_MODE, [test x$KBD
 
 BUILD_DATE="$(date +'%Y%m%d')"
 AC_SUBST([BUILD_DATE])
-BUILD_TIME="$(date +'%k%M%S')"
+BUILD_TIME="$(date +'1%H%M%S')"
 AC_SUBST([BUILD_TIME])
 
 DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 8423fca..16162b7 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1733,7 +1733,7 @@ xf86PrintBanner()
 #if defined(BUILD_TIME)
     t.tm_sec = BUILD_TIME % 100;
     t.tm_min = (BUILD_TIME / 100) % 100;
-    t.tm_hour = (BUILD_TIME / 10000);
+    t.tm_hour = (BUILD_TIME / 10000) % 100;
     if (strftime(buf, sizeof(buf), "%d %B %Y  %I:%M:%s%p", &t))
        ErrorF("Build Date: %s\n", buf);
 #else
diff-tree 54e023cec07aa7e392da36e11d0a4667b8341370 (from 5cbec267b6426960c90f6bcff1d051af5084538c)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon Jun 11 09:16:46 2007 -0400

    Don't pass regions to pixman_image_composite() anymore.

diff --git a/configure.ac b/configure.ac
index 0fd473a..f7f2e6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -626,7 +626,7 @@ XEXT_INC='-I$(top_srcdir)/Xext'
 XEXT_LIB='$(top_builddir)/Xext/libXext.la'
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
-PIXMAN="[pixman >= 0.9.0]"
+PIXMAN="[pixman >= 0.9.1]"
 
 dnl Core modules for most extensions, et al.
 REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 68c0e63..0a42f12 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -38,122 +38,6 @@
 #include "fbpict.h"
 #include "fbmmx.h"
 
-static pixman_image_t *
-create_solid_fill_image (PicturePtr pict)
-{
-    PictSolidFill *solid = &pict->pSourcePict->solidFill;
-    pixman_color_t color;
-    CARD32 a, r, g, b;
-    
-    a = (solid->color & 0xff000000) >> 24;
-    r = (solid->color & 0x00ff0000) >> 16;
-    g = (solid->color & 0x0000ff00) >>  8;
-    b = (solid->color & 0x000000ff) >>  0;
-    
-    color.alpha = (a << 8) | a;
-    color.red =   (r << 8) | r;
-    color.green = (g << 8) | g;
-    color.blue =  (b << 8) | b;
-    
-    return pixman_image_create_solid_fill (&color);
-}
-
-static pixman_image_t *
-create_linear_gradient_image (PictGradient *gradient)
-{
-    PictLinearGradient *linear = (PictLinearGradient *)gradient;
-    pixman_point_fixed_t p1;
-    pixman_point_fixed_t p2;
-    
-    p1.x = linear->p1.x;
-    p1.y = linear->p1.y;
-    p2.x = linear->p2.x;
-    p2.y = linear->p2.y;
-    
-    return pixman_image_create_linear_gradient (
-	&p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
-}
-
-static pixman_image_t *
-create_radial_gradient_image (PictGradient *gradient)
-{
-    PictRadialGradient *radial = (PictRadialGradient *)gradient;
-    pixman_point_fixed_t c1;
-    pixman_point_fixed_t c2;
-    
-    c1.x = radial->c1.x;
-    c1.y = radial->c1.y;
-    c2.x = radial->c2.x;
-    c2.y = radial->c2.y;
-    
-    return pixman_image_create_radial_gradient (
-	&c1, &c2, radial->c1.radius,
-	radial->c2.radius,
-	(pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
-}
-
-static pixman_image_t *
-create_conical_gradient_image (PictGradient *gradient)
-{
-    PictConicalGradient *conical = (PictConicalGradient *)gradient;
-    pixman_point_fixed_t center;
-    
-    center.x = conical->center.x;
-    center.y = conical->center.y;
-    
-    return pixman_image_create_conical_gradient (
-	&center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
-	gradient->nstops);
-}
-
-static pixman_image_t *
-create_bits_picture (PicturePtr pict,
-		     Bool       has_clip)
-{
-    FbBits *bits;
-    FbStride stride;
-    int bpp, xoff, yoff;
-    pixman_image_t *image;
-    
-    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
-    
-    bits += yoff * stride + xoff;
-    
-    image = pixman_image_create_bits (
-	pict->format,
-	pict->pDrawable->width, pict->pDrawable->height,
-	(uint32_t *)bits, stride * sizeof (FbStride));
-    
-    
-#ifdef FB_ACCESS_WRAPPER
-#if FB_SHIFT==5
-    
-    pixman_image_set_accessors (image,
-				(pixman_read_memory_func_t)wfbReadMemory,
-				(pixman_write_memory_func_t)wfbWriteMemory);
-    
-#else
-    
-#error The pixman library only works when FbBits is 32 bits wide
-    
-#endif
-#endif
-    
-    /* pCompositeClip is undefined for source pictures, so
-     * only set the clip region for pictures with drawables
-     */
-    if (has_clip)
-	pixman_image_set_clip_region (image, pict->pCompositeClip);
-    
-    /* Indexed table */
-    if (pict->pFormat->index.devPrivate)
-	pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
-    
-    fbFinishAccess (pict->pDrawable);
-
-    return image;
-}
-
 #define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
 void
@@ -274,7 +158,6 @@ fbComposite (CARD8      op,
 	     CARD16     width,
 	     CARD16     height)
 {
-    pixman_region16_t region;
     pixman_image_t *src, *mask, *dest;
     
     xDst += pDst->pDrawable->x;
@@ -290,10 +173,10 @@ fbComposite (CARD8      op,
 	yMask += pMask->pDrawable->y;
     }
 
-    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc, ySrc,
-				   xMask, yMask, xDst, yDst, width, height))
-        return;
-
+    miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height);
+    if (pMask)
+	miCompositeSourceValidate (pMask, xMask, yMask, width, height);
+    
     src = image_from_pict (pSrc, TRUE);
     mask = image_from_pict (pMask, TRUE);
     dest = image_from_pict (pDst, TRUE);
@@ -302,11 +185,10 @@ fbComposite (CARD8      op,
     {
 	pixman_image_composite (op, src, mask, dest,
 				xSrc, ySrc, xMask, yMask, xDst, yDst,
-				width, height, &region);
+				width, height);
+	    
     }
     
-    pixman_region_fini (&region);
-    
     if (src)
 	pixman_image_unref (src);
     if (mask)
@@ -336,27 +218,125 @@ fbCompositeGeneral (CARD8	op,
 
 #endif /* RENDER */
 
-Bool
-fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+static pixman_image_t *
+create_solid_fill_image (PicturePtr pict)
 {
+    PictSolidFill *solid = &pict->pSourcePict->solidFill;
+    pixman_color_t color;
+    CARD32 a, r, g, b;
+    
+    a = (solid->color & 0xff000000) >> 24;
+    r = (solid->color & 0x00ff0000) >> 16;
+    g = (solid->color & 0x0000ff00) >>  8;
+    b = (solid->color & 0x000000ff) >>  0;
+    
+    color.alpha = (a << 8) | a;
+    color.red =   (r << 8) | r;
+    color.green = (g << 8) | g;
+    color.blue =  (b << 8) | b;
+    
+    return pixman_image_create_solid_fill (&color);
+}
 
-#ifdef RENDER
+static pixman_image_t *
+create_linear_gradient_image (PictGradient *gradient)
+{
+    PictLinearGradient *linear = (PictLinearGradient *)gradient;
+    pixman_point_fixed_t p1;
+    pixman_point_fixed_t p2;
+    
+    p1.x = linear->p1.x;
+    p1.y = linear->p1.y;
+    p2.x = linear->p2.x;
+    p2.y = linear->p2.y;
+    
+    return pixman_image_create_linear_gradient (
+	&p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
 
-    PictureScreenPtr    ps;
+static pixman_image_t *
+create_radial_gradient_image (PictGradient *gradient)
+{
+    PictRadialGradient *radial = (PictRadialGradient *)gradient;
+    pixman_point_fixed_t c1;
+    pixman_point_fixed_t c2;
+    
+    c1.x = radial->c1.x;
+    c1.y = radial->c1.y;
+    c2.x = radial->c2.x;
+    c2.y = radial->c2.y;
+    
+    return pixman_image_create_radial_gradient (
+	&c1, &c2, radial->c1.radius,
+	radial->c2.radius,
+	(pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
 
-    if (!miPictureInit (pScreen, formats, nformats))
-	return FALSE;
-    ps = GetPictureScreen(pScreen);
-    ps->Composite = fbComposite;
-    ps->Glyphs = miGlyphs;
-    ps->CompositeRects = miCompositeRects;
-    ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
-    ps->AddTraps = fbAddTraps;
-    ps->AddTriangles = fbAddTriangles;
+static pixman_image_t *
+create_conical_gradient_image (PictGradient *gradient)
+{
+    PictConicalGradient *conical = (PictConicalGradient *)gradient;
+    pixman_point_fixed_t center;
+    
+    center.x = conical->center.x;
+    center.y = conical->center.y;
+    
+    return pixman_image_create_conical_gradient (
+	&center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
+	gradient->nstops);
+}
 
-#endif /* RENDER */
+static pixman_image_t *
+create_bits_picture (PicturePtr pict,
+		     Bool       has_clip)
+{
+    FbBits *bits;
+    FbStride stride;
+    int bpp, xoff, yoff;
+    pixman_image_t *image;
+    
+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+    
+    bits += yoff * stride + xoff;
+    
+    image = pixman_image_create_bits (
+	pict->format,
+	pict->pDrawable->width, pict->pDrawable->height,
+	(uint32_t *)bits, stride * sizeof (FbStride));
+    
+    
+#ifdef FB_ACCESS_WRAPPER
+#if FB_SHIFT==5
+    
+    pixman_image_set_accessors (image,
+				(pixman_read_memory_func_t)wfbReadMemory,
+				(pixman_write_memory_func_t)wfbWriteMemory);
+    
+#else
+    
+#error The pixman library only works when FbBits is 32 bits wide
+    
+#endif
+#endif
+    
+    /* pCompositeClip is undefined for source pictures, so
+     * only set the clip region for pictures with drawables
+     */
+    if (has_clip)
+    {
+	if (pict->clientClipType != CT_NONE)
+	    pixman_image_set_has_client_clip (image, TRUE);
+	
+	pixman_image_set_clip_region (image, pict->pCompositeClip);
+    }
+    
+    /* Indexed table */
+    if (pict->pFormat->index.devPrivate)
+	pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
+    
+    fbFinishAccess (pict->pDrawable);
 
-    return TRUE;
+    return image;
 }
 
 static void
@@ -428,7 +408,7 @@ set_image_properties (pixman_image_t *im
 
 pixman_image_t *
 image_from_pict (PicturePtr pict,
-		 Bool       has_clip)
+		 Bool has_clip)
 {
     pixman_image_t *image = NULL;
 
@@ -466,8 +446,28 @@ image_from_pict (PicturePtr pict,
     return image;
 }
 
+Bool
+fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
 
+#ifdef RENDER
 
+    PictureScreenPtr    ps;
+
+    if (!miPictureInit (pScreen, formats, nformats))
+	return FALSE;
+    ps = GetPictureScreen(pScreen);
+    ps->Composite = fbComposite;
+    ps->Glyphs = miGlyphs;
+    ps->CompositeRects = miCompositeRects;
+    ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
+    ps->AddTraps = fbAddTraps;
+    ps->AddTriangles = fbAddTriangles;
+
+#endif /* RENDER */
+
+    return TRUE;
+}
 
 #ifdef USE_MMX
 /* The CPU detection code needs to be in a file not compiled with
diff --git a/render/mipict.c b/render/mipict.c
index dff7f5e..87dccbb 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -266,19 +266,19 @@ miChangePictureFilter (PicturePtr pPictu
 
 #define BOUND(v)	(INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
 
-static __inline Bool
-miClipPictureReg (RegionPtr	pRegion,
-		  RegionPtr	pClip,
+static inline pixman_bool_t
+miClipPictureReg (pixman_region16_t *	pRegion,
+		  pixman_region16_t *	pClip,
 		  int		dx,
 		  int		dy)
 {
-    if (REGION_NUM_RECTS(pRegion) == 1 &&
-	REGION_NUM_RECTS(pClip) == 1)
+    if (pixman_region_n_rects(pRegion) == 1 &&
+	pixman_region_n_rects(pClip) == 1)
     {
-	BoxPtr  pRbox = REGION_RECTS(pRegion);
-	BoxPtr  pCbox = REGION_RECTS(pClip);
+	pixman_box16_t *  pRbox = pixman_region_rectangles(pRegion, NULL);
+	pixman_box16_t *  pCbox = pixman_region_rectangles(pClip, NULL);
 	int	v;
-
+	
 	if (pRbox->x1 < (v = pCbox->x1 + dx))
 	    pRbox->x1 = BOUND(v);
 	if (pRbox->x2 > (v = pCbox->x2 + dx))
@@ -290,23 +290,23 @@ miClipPictureReg (RegionPtr	pRegion,
 	if (pRbox->x1 >= pRbox->x2 ||
 	    pRbox->y1 >= pRbox->y2)
 	{
-	    REGION_EMPTY(pScreen, pRegion);
+	    pixman_region_init (pRegion);
 	}
     }
-    else if (!REGION_NOTEMPTY (pScreen, pClip))
+    else if (!pixman_region_not_empty (pClip))
 	return FALSE;
     else
     {
 	if (dx || dy)
-	    REGION_TRANSLATE(pScreen, pRegion, -dx, -dy);
-	if (!REGION_INTERSECT (pScreen, pRegion, pRegion, pClip))
+	    pixman_region_translate (pRegion, -dx, -dy);
+	if (!pixman_region_intersect (pRegion, pRegion, pClip))
 	    return FALSE;
 	if (dx || dy)
-	    REGION_TRANSLATE(pScreen, pRegion, dx, dy);
+	    pixman_region_translate(pRegion, dx, dy);
     }
-    return REGION_NOTEMPTY(pScreen, pRegion);
+    return pixman_region_not_empty(pRegion);
 }
-		  
+
 static __inline Bool
 miClipPictureSrc (RegionPtr	pRegion,
 		  PicturePtr	pPicture,
@@ -320,13 +320,13 @@ miClipPictureSrc (RegionPtr	pRegion,
     {
 	if (pPicture->clientClipType != CT_NONE)
 	{
-	    REGION_TRANSLATE(pScreen, pRegion, 
+	    pixman_region_translate ( pRegion, 
 			     dx - pPicture->clipOrigin.x,
 			     dy - pPicture->clipOrigin.y);
 	    if (!REGION_INTERSECT (pScreen, pRegion, pRegion, 
-				   (RegionPtr) pPicture->clientClip))
+				   (RegionPtr) pPicture->pCompositeClip)) // clientClip))
 		return FALSE;
-	    REGION_TRANSLATE(pScreen, pRegion, 
+	    pixman_region_translate ( pRegion, 
 			     - (dx - pPicture->clipOrigin.x),
 			     - (dy - pPicture->clipOrigin.y));
 	}
@@ -341,7 +341,7 @@ miClipPictureSrc (RegionPtr	pRegion,
     }
 }
 
-static void
+void
 miCompositeSourceValidate (PicturePtr	pPicture,
 			   INT16	x,
 			   INT16	y,
@@ -417,6 +417,7 @@ miComputeCompositeRegion (RegionPtr	pReg
 			  CARD16	width,
 			  CARD16	height)
 {
+    
     int		v;
 
     pRegion->extents.x1 = xDst;
@@ -430,13 +431,13 @@ miComputeCompositeRegion (RegionPtr	pReg
     if (pRegion->extents.x1 >= pRegion->extents.x2 ||
 	pRegion->extents.y1 >= pRegion->extents.y2)
     {
-	REGION_EMPTY (pDst->pDrawable->pScreen, pRegion);
+	pixman_region_init (pRegion);
 	return FALSE;
     }
     /* clip against dst */
     if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0))
     {
-	REGION_UNINIT (pScreen, pRegion);
+	pixman_region_fini (pRegion);
 	return FALSE;
     }
     if (pDst->alphaMap)
@@ -445,14 +446,14 @@ miComputeCompositeRegion (RegionPtr	pReg
 			       -pDst->alphaOrigin.x,
 			       -pDst->alphaOrigin.y))
 	{
-	    REGION_UNINIT (pScreen, pRegion);
+	    pixman_region_fini (pRegion);
 	    return FALSE;
 	}
     }
     /* clip against src */
     if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc))
     {
-	REGION_UNINIT (pScreen, pRegion);
+	pixman_region_fini (pRegion);
 	return FALSE;
     }
     if (pSrc->alphaMap)
@@ -461,7 +462,7 @@ miComputeCompositeRegion (RegionPtr	pReg
 			       xDst - (xSrc + pSrc->alphaOrigin.x),
 			       yDst - (ySrc + pSrc->alphaOrigin.y)))
 	{
-	    REGION_UNINIT (pScreen, pRegion);
+	    pixman_region_fini (pRegion);
 	    return FALSE;
 	}
     }
@@ -470,7 +471,7 @@ miComputeCompositeRegion (RegionPtr	pReg
     {
 	if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask))
 	{
-	    REGION_UNINIT (pScreen, pRegion);
+	    pixman_region_fini (pRegion);
 	    return FALSE;
 	}	
 	if (pMask->alphaMap)
@@ -479,14 +480,17 @@ miComputeCompositeRegion (RegionPtr	pReg
 				   xDst - (xMask + pMask->alphaOrigin.x),
 				   yDst - (yMask + pMask->alphaOrigin.y)))
 	    {
-		REGION_UNINIT (pScreen, pRegion);
+		pixman_region_fini (pRegion);
 		return FALSE;
 	    }
 	}
     }
+
+    
     miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height);
     if (pMask)
 	miCompositeSourceValidate (pMask, xMask, yMask, width, height);
+
     return TRUE;
 }
 
diff --git a/render/mipict.h b/render/mipict.h
index eef155f..bd7c23f 100644
--- a/render/mipict.h
+++ b/render/mipict.h
@@ -88,6 +88,12 @@ miClipPicture (RegionPtr    pRegion,
 	       INT16	    xPict,
 	       INT16	    yPict);
 
+void
+miCompositeSourceValidate (PicturePtr	pPicture,
+			   INT16	x,
+			   INT16	y,
+			   CARD16	width,
+			   CARD16	height);
 Bool
 miComputeCompositeRegion (RegionPtr	pRegion,
 			  PicturePtr	pSrc,
diff --git a/render/picturestr.h b/render/picturestr.h
index 9c41fc1..06530e2 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -661,6 +661,10 @@ AddTraps (PicturePtr	pPicture,
 	  int		ntraps,
 	  xTrap		*traps);
 
+pixman_image_t *
+PixmanImageFromPicture (PicturePtr pPict,
+			Bool hasClip);
+
 PicturePtr
 CreateSolidPicture (Picture pid,
                     xRenderColor *color,
diff-tree 5cbec267b6426960c90f6bcff1d051af5084538c (from 1aceec61ff203848576c47a1eab13f90a67d7176)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Jun 11 12:38:41 2007 +0200

    Make sure BUILD_TIME doesn't have a leading zero.
    
    It causes the compiler to treat it as an octal constant instead of decimal as
    intended, which could even cause a build failure in the cases of 08 and 09.
    
    Thanks to Clark Rawlins for pointing out the problem.

diff --git a/configure.ac b/configure.ac
index ad934a2..0fd473a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1948,7 +1948,7 @@ AM_CONDITIONAL(SUN_KBD_MODE, [test x$KBD
 
 BUILD_DATE="$(date +'%Y%m%d')"
 AC_SUBST([BUILD_DATE])
-BUILD_TIME="$(date +'%H%M%S')"
+BUILD_TIME="$(date +'%k%M%S')"
 AC_SUBST([BUILD_TIME])
 
 DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
diff-tree 1aceec61ff203848576c47a1eab13f90a67d7176 (from 5d896e43fd056d935935b4eb66562791edc247a1)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Jun 11 09:23:19 2007 +0200

    DRI: Clip cliprects obtained from DRIGetDrawableInfo to screen dimensions.
    
    This is to avoid issues with redirected windows which are located partly or
    fully outside of a screen edge, resulting in unusual cliprects which the 3D
    drivers generally can't handle. The symptoms in such cases would be incorrect
    rendering or even crashes or hangs.

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index 156e846..efa02f8 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -886,8 +886,32 @@ getDrawableInfo(__DRInativeDisplay *dpy,
     if (*numClipRects > 0) {
 	size = sizeof (drm_clip_rect_t) * *numClipRects;
 	*ppClipRects = xalloc (size);
-	if (*ppClipRects != NULL)
-	    memcpy (*ppClipRects, pClipRects, size);
+
+	/* Clip cliprects to screen dimensions (redirected windows) */
+	if (*ppClipRects != NULL) {
+	    ScreenPtr pScreen = screenInfo.screens[screen];
+	    int i, j;
+
+	    for (i = 0, j = 0; i < *numClipRects; i++) {
+	        (*ppClipRects)[j].x1 = max(pClipRects[i].x1, 0);
+		(*ppClipRects)[j].y1 = max(pClipRects[i].y1, 0);
+		(*ppClipRects)[j].x2 = min(pClipRects[i].x2, pScreen->width);
+		(*ppClipRects)[j].y2 = min(pClipRects[i].y2, pScreen->height);
+
+		if ((*ppClipRects)[j].x1 < (*ppClipRects)[j].x2 &&
+		    (*ppClipRects)[j].y1 < (*ppClipRects)[j].y2) {
+		    j++;
+		}
+	    }
+
+	    if (*numClipRects != j) {
+		*numClipRects = j;
+		*ppClipRects = xrealloc (*ppClipRects,
+					 sizeof (drm_clip_rect_t) *
+					 *numClipRects);
+	    }
+	} else
+	    *numClipRects = 0;
     }
     else {
       *ppClipRects = NULL;
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index d153c09..dbc1690 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1518,13 +1518,18 @@ DRIGetDrawableInfo(ScreenPtr pScreen,
 	       if (x1 > pScreen->width) x1 = pScreen->width;
 	       if (y1 > pScreen->height) y1 = pScreen->height;
 
-	       pDRIPriv->private_buffer_rect.x1 = x0;
-	       pDRIPriv->private_buffer_rect.y1 = y0;
-	       pDRIPriv->private_buffer_rect.x2 = x1;
-	       pDRIPriv->private_buffer_rect.y2 = y1;
-
-	       *numBackClipRects = 1;
-	       *pBackClipRects = &(pDRIPriv->private_buffer_rect);
+	       if (y0 >= y1 || x0 >= x1) {
+		    *numBackClipRects = 0;
+		    *pBackClipRects = NULL;
+	       } else {
+		    pDRIPriv->private_buffer_rect.x1 = x0;
+		    pDRIPriv->private_buffer_rect.y1 = y0;
+		    pDRIPriv->private_buffer_rect.x2 = x1;
+		    pDRIPriv->private_buffer_rect.y2 = y1;
+
+		    *numBackClipRects = 1;
+		    *pBackClipRects = &(pDRIPriv->private_buffer_rect);
+	       }
 	    } else {
 	       /* Use the frontbuffer cliprects for back buffers.  */
 	       *numBackClipRects = 0;
diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
index 933cd3e..9690e88 100644
--- a/hw/xfree86/dri/xf86dri.c
+++ b/hw/xfree86/dri/xf86dri.c
@@ -452,7 +452,7 @@ ProcXF86DRIGetDrawableInfo(
     xXF86DRIGetDrawableInfoReply	rep;
     DrawablePtr pDrawable;
     int X, Y, W, H;
-    drm_clip_rect_t * pClipRects;
+    drm_clip_rect_t * pClipRects, *pClippedRects;
     drm_clip_rect_t * pBackClipRects;
     int backX, backY, rc;
 
@@ -502,8 +502,35 @@ ProcXF86DRIGetDrawableInfo(
     if (rep.numBackClipRects) 
        rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;    
 
-    if (rep.numClipRects) 
+    pClippedRects = pClipRects;
+
+    if (rep.numClipRects) {
+       /* Clip cliprects to screen dimensions (redirected windows) */
+       pClippedRects = xalloc(rep.numClipRects * sizeof(drm_clip_rect_t));
+
+       if (pClippedRects) {
+	    ScreenPtr pScreen = screenInfo.screens[stuff->screen];
+	    int i, j;
+
+	    for (i = 0, j = 0; i < rep.numClipRects; i++) {
+		pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
+		pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
+		pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
+		pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
+
+		if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
+		    pClippedRects[j].y1 < pClippedRects[j].y2) {
+		    j++;
+		}
+	    }
+
+	    rep.numClipRects = j;
+       } else {
+	    rep.numClipRects = 0;
+       }
+
        rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
+    }
     
     rep.length = ((rep.length + 3) & ~3) >> 2;
 
@@ -512,7 +539,8 @@ ProcXF86DRIGetDrawableInfo(
     if (rep.numClipRects) {
 	WriteToClient(client,  
 		      sizeof(drm_clip_rect_t) * rep.numClipRects,
-		      (char *)pClipRects);
+		      (char *)pClippedRects);
+	xfree(pClippedRects);
     }
 
     if (rep.numBackClipRects) {
diff-tree 5d896e43fd056d935935b4eb66562791edc247a1 (from 0fb44c6f9a0415184818ba8357a21ff920e907dc)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Jun 11 09:23:19 2007 +0200

    DRITreeTraversal: Stop walking tree when we've seen all DRI windows.

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index fae0b43..d153c09 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1863,11 +1863,15 @@ DRITreeTraversal(WindowPtr pWin, pointer
     if(pDRIDrawablePriv) {
         ScreenPtr pScreen = pWin->drawable.pScreen;
         DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-        RegionPtr reg = (RegionPtr)data;
 
-        REGION_UNION(pScreen, reg, reg, &(pWin->clipList));
+	if(REGION_NUM_RECTS(&(pWin->clipList)) > 0) {
+	   RegionPtr reg = (RegionPtr)data;
 
-        if(pDRIPriv->nrWindows == 1)
+	   REGION_UNION(pScreen, reg, reg, &(pWin->clipList));
+	   pDRIPriv->nrWalked++;
+	}
+
+	if(pDRIPriv->nrWindows == pDRIPriv->nrWalked)
 	   return WT_STOPWALKING;
     }
     return WT_WALKCHILDREN;
@@ -1885,6 +1889,7 @@ DRICopyWindow(WindowPtr pWin, DDXPointRe
        RegionRec reg;
 
        REGION_NULL(pScreen, &reg);
+       pDRIPriv->nrWalked = 0;
        TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
 
        if(REGION_NOTEMPTY(pScreen, &reg)) {
diff-tree 0fb44c6f9a0415184818ba8357a21ff920e907dc (from 644f7ddc0cb029e2ebca43742fd8a46a1a3f4c9f)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Jun 11 09:23:19 2007 +0200

    DRI: Fix build warning.

diff --git a/hw/xfree86/dri/drimodule.c b/hw/xfree86/dri/drimodule.c
index 0e3d84e..3aa9245 100644
--- a/hw/xfree86/dri/drimodule.c
+++ b/hw/xfree86/dri/drimodule.c
@@ -88,6 +88,6 @@ driSetup(pointer module, pointer opts, i
     drmSetServerInfo(&DRIDRMServerInfo);
 
     /* Need a non-NULL return value to indicate success */
-    return 1;
+    return (pointer)1;
 }
 
diff-tree 644f7ddc0cb029e2ebca43742fd8a46a1a3f4c9f (from 30a3297fed9af3a594aba0875a8f58a0a38b33fc)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Jun 11 09:23:18 2007 +0200

    dixLookupClient: Use access parameter.

diff --git a/dix/dixutils.c b/dix/dixutils.c
index 30327d3..c1e30ff 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -265,7 +265,7 @@ _X_EXPORT int
 dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
 {
     pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,
-						    DixReadAccess);
+						    access);
     int clientIndex = CLIENT_ID(rid);
     client->errorValue = rid;
 
diff-tree 30a3297fed9af3a594aba0875a8f58a0a38b33fc (from c1a49a9269f14b6975a1a2c751bb179757373f11)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Jun 11 09:23:18 2007 +0200

    mieq queue handling cleanups.
    
    In particular, fix handling of wraparounds in mieqEnqueue.

diff --git a/mi/mieq.c b/mi/mieq.c
index a03fff1..f64e540 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -108,7 +108,8 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e
     HWEventQueueType       oldtail = miEventQueue.tail, newtail;
     int                    isMotion = 0;
     deviceValuator         *v = (deviceValuator *) e;
-    EventPtr               laste = &miEventQueue.events[oldtail - 1];
+    EventPtr               laste = &miEventQueue.events[(oldtail - 1) %
+							QUEUE_SIZE];
     deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *)
                                       &laste->event[0];
 
@@ -139,14 +140,10 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e
 
     if (isMotion && isMotion == miEventQueue.lastMotion &&
         oldtail != miEventQueue.head) {
-	if (oldtail == 0)
-	    oldtail = QUEUE_SIZE;
-	oldtail = oldtail - 1;
+	oldtail = (oldtail - 1) % QUEUE_SIZE;
     }
     else {
-    	newtail = oldtail + 1;
-    	if (newtail == QUEUE_SIZE)
-	    newtail = 0;
+    	newtail = (oldtail + 1) % QUEUE_SIZE;
     	/* Toss events which come in late.  Usually this means your server's
          * stuck in an infinite loop somewhere, but SIGIO is still getting
          * handled. */
@@ -214,22 +211,15 @@ mieqProcessInputEvents(void)
 
         e = &miEventQueue.events[miEventQueue.head];
         /* Assumption - screen switching can only occur on motion events. */
+        miEventQueue.head = (miEventQueue.head + 1) % QUEUE_SIZE;
+
         if (e->pScreen != miEventQueue.pDequeueScreen) {
             miEventQueue.pDequeueScreen = e->pScreen;
             x = e->event[0].u.keyButtonPointer.rootX;
             y = e->event[0].u.keyButtonPointer.rootY;
-            if (miEventQueue.head == QUEUE_SIZE - 1)
-                miEventQueue.head = 0;
-            else
-                ++miEventQueue.head;
             NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
         }
         else {
-            if (miEventQueue.head == QUEUE_SIZE - 1)
-                miEventQueue.head = 0;
-            else
-                ++miEventQueue.head;
-
             /* If someone's registered a custom event handler, let them
              * steal it. */
             if (miEventQueue.handlers[e->event->u.u.type]) {
diff-tree c1a49a9269f14b6975a1a2c751bb179757373f11 (from 67a0a4da1a225ee3bd6bbd1846f8141fe333c884)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Jun 10 22:14:57 2007 -0400

    GNU is wrong and ` is not left-quote.

diff --git a/configure.ac b/configure.ac
index 979615f..ad934a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,20 +165,20 @@ AC_CHECK_FUNCS([geteuid getuid link memm
 AC_FUNC_ALLOCA
 dnl Old HAS_* names used in os/*.c.
 AC_CHECK_FUNC([getdtablesize],
-	AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the `getdtablesize' function.]))
+	AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the 'getdtablesize' function.]))
 AC_CHECK_FUNC([getifaddrs],
-	AC_DEFINE(HAS_GETIFADDRS, 1, [Have the `getifaddrs' function.]))
+	AC_DEFINE(HAS_GETIFADDRS, 1, [Have the 'getifaddrs' function.]))
 AC_CHECK_FUNC([getpeereid],
-	AC_DEFINE(HAS_GETPEEREID, 1, [Have the `getpeereid' function.]))
+	AC_DEFINE(HAS_GETPEEREID, 1, [Have the 'getpeereid' function.]))
 AC_CHECK_FUNC([getpeerucred],
-	AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the `getpeerucred' function.]))
+	AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
 AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
 AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])	
 
 AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
 
 dnl Check for mmap support for Xvfb
-AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the `mmap' function.]))
+AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the 'mmap' function.]))
 
 dnl Find the math libary
 AC_CHECK_LIB(m, sqrt)
@@ -878,7 +878,7 @@ XKB_LIB='$(top_builddir)/xkb/libxkb.la'
 XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la'
 
 AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
-                                        [Do not have `strcasecmp'.]))
+                                        [Do not have 'strcasecmp'.]))
 
 if test "x$NULL_ROOT_CURSOR" = xyes; then
         AC_DEFINE(NULL_ROOT_CURSOR, 1, [Use an empty root cursor])
diff-tree 67a0a4da1a225ee3bd6bbd1846f8141fe333c884 (from c079cce9d884ab03f305b3fba4a4e1247c023480)
Author: Dave Airlie <airlied at linux.ie>
Date:   Mon Jun 11 11:55:11 2007 +1000

    update xproto dependency to at least 7.0.9

diff --git a/configure.ac b/configure.ac
index 1f94556..979615f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -629,7 +629,7 @@ XEXTXORG_LIB='$(top_builddir)/Xext/libXe
 PIXMAN="[pixman >= 0.9.0]"
 
 dnl Core modules for most extensions, et al.
-REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
+REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
 REQUIRED_LIBS="xfont xau fontenc $PIXMAN"
 
 if test "x$DBUS" = xauto; then
diff-tree c079cce9d884ab03f305b3fba4a4e1247c023480 (from 9c47b86bd9a4633fda5fd305a09ac8623187efa0)
Author: Daniel Ciocea <daniel.ciocea at eosystems.ro>
Date:   Fri Jun 8 18:12:21 2007 -0700

    Fix sync polarity on Samsung SyncMaster 205BW monitor.
    
    need to use standard VESA sync polarity instead of the
    EDID provided -hsync -vsync values.

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 46cb6c4..a9f9ddc 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -71,7 +71,11 @@ static Bool quirk_dt_sync_hm_vp (int scr
     if (memcmp (DDC->vendor.name, "VSC", 4) == 0 &&
 	DDC->vendor.prod_id == 58653)
 	return TRUE;
-
+    /* Samsung SyncMaster 205BW */
+    if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
+	DDC->vendor.prod_id == 541)
+	return TRUE;
+     
     return FALSE;
 }
 
diff-tree 9c47b86bd9a4633fda5fd305a09ac8623187efa0 (from 567b5bf765254a4ae9cc7711bb6acfa89a9fd61c)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Jun 7 13:57:12 2007 -0700

    Add new fb symbols to wfbrename.h.
    
    Avoids crashes when wfbComposite calls the wrong image_from_pict.

diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 8f875c8..952512e 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -184,9 +184,11 @@
 #define fbUnmapWindow wfbUnmapWindow
 #define fbUnrealizeFont wfbUnrealizeFont
 #define fbValidateGC wfbValidateGC
+#define fbWalkCompositeRegion wfbWalkCompositeRegion
 #define fbWinPrivateIndex wfbWinPrivateIndex
 #define fbZeroLine wfbZeroLine
 #define fbZeroSegment wfbZeroSegment
+#define image_from_pict wfb_image_from_pict
 #define xxScrPrivateIndex wfbxxScrPrivateIndex
 #define xxGCPrivateIndex wfbxxGCPrivateIndex
 #define xxColormapPrivateIndex wfbxxColormapPrivateIndex
diff-tree 567b5bf765254a4ae9cc7711bb6acfa89a9fd61c (from 49ed31c0b323dd8c5887a803c199875e6f2330d8)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Tue Jun 5 20:26:49 2007 -0400

    Delete fbCompositeCopyAreammx()

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 2e240c1..b2fe94b 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -356,29 +356,5 @@ fbCopyAreammx (DrawablePtr	pSrc,
     return TRUE;
 }
 
-void
-fbCompositeCopyAreammx (CARD8		op,
-			PicturePtr	pSrc,
-			PicturePtr	pMask,
-			PicturePtr	pDst,
-			INT16		xSrc,
-			INT16		ySrc,
-			INT16		xMask,
-			INT16		yMask,
-			INT16		xDst,
-			INT16		yDst,
-			CARD16		width,
-			CARD16		height)
-{
-    fbCopyAreammx (pSrc->pDrawable,
-		   pDst->pDrawable,
-		   xSrc, ySrc,
-		   xDst, yDst,
-		   width, height);
-}
-
-
-
-
 #endif /* RENDER */
 #endif /* USE_MMX */
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index 43079e9..4796438 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -52,18 +52,6 @@ Bool fbCopyAreammx (DrawablePtr	pSrc,
 		    int		dst_y,
 		    int		width,
 		    int		height);
-void fbCompositeCopyAreammx (CARD8	op,
-			     PicturePtr	pSrc,
-			     PicturePtr	pMask,
-			     PicturePtr	pDst,
-			     INT16	xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height);
 Bool fbSolidFillmmx (DrawablePtr	pDraw,
 		     int		x,
 		     int		y,
diff-tree 49ed31c0b323dd8c5887a803c199875e6f2330d8 (from dfbe32b5b828cc4e3da36a0e2e6ad641164eaa5e)
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Tue Jun 5 17:44:21 2007 -0400

    Remove most of the fast-path MMX operations from fbmmx. fbCopyAreammx
    
    and fbSolidFillmmx are still needed by other code.

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 53459a0..2e240c1 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -62,2663 +62,149 @@
 #define CHECKPOINT()
 #endif
 
-/* Notes about writing mmx code
- *
- * give memory operands as the second operand. If you give it as the
- * first, gcc will first load it into a register, then use that
- * register
- *
- *   ie. use
- *
- *         _mm_mullo_pi16 (x, mmx_constant);
- *
- *   not
- *
- *         _mm_mullo_pi16 (mmx_constant, x);
- *
- * Also try to minimize dependencies. i.e. when you need a value, try
- * to calculate it from a value that was calculated as early as
- * possible.
- */
 
-/* --------------- MMX primitivess ------------------------------------ */
-
-typedef unsigned long long ullong;
-
-#ifdef __GNUC__
-typedef ullong mmxdatafield;
-#endif
-#ifdef _MSC_VER
-typedef unsigned __int64 ullong;
-typedef __m64 mmxdatafield;
-#endif
-
-typedef struct
-{
-    mmxdatafield mmx_4x00ff;
-    mmxdatafield mmx_4x0080;
-    mmxdatafield mmx_565_rgb;
-    mmxdatafield mmx_565_unpack_multiplier;
-    mmxdatafield mmx_565_r;
-    mmxdatafield mmx_565_g;
-    mmxdatafield mmx_565_b;
-    mmxdatafield mmx_mask_0;
-    mmxdatafield mmx_mask_1;
-    mmxdatafield mmx_mask_2;
-    mmxdatafield mmx_mask_3;
-    mmxdatafield mmx_full_alpha;
-    mmxdatafield mmx_ffff0000ffff0000;
-    mmxdatafield mmx_0000ffff00000000;
-    mmxdatafield mmx_000000000000ffff;
-} MMXData;
-
-static const MMXData c =
-{
-#ifdef __GNUC__
-    .mmx_4x00ff =			0x00ff00ff00ff00ffULL,
-    .mmx_4x0080 =			0x0080008000800080ULL,
-    .mmx_565_rgb =			0x000001f0003f001fULL,
-    .mmx_565_unpack_multiplier =	0x0000008404100840ULL,
-    .mmx_565_r =			0x000000f800000000ULL,
-    .mmx_565_g =			0x0000000000fc0000ULL,
-    .mmx_565_b =			0x00000000000000f8ULL,
-    .mmx_mask_0 =			0xffffffffffff0000ULL,
-    .mmx_mask_1 =			0xffffffff0000ffffULL,
-    .mmx_mask_2 =			0xffff0000ffffffffULL,
-    .mmx_mask_3 =			0x0000ffffffffffffULL,
-    .mmx_full_alpha =			0x00ff000000000000ULL,
-    .mmx_ffff0000ffff0000 =		0xffff0000ffff0000ULL,
-    .mmx_0000ffff00000000 =		0x0000ffff00000000ULL,
-    .mmx_000000000000ffff =		0x000000000000ffffULL,
-#endif
-#ifdef _MSC_VER
-    { 0x00ff00ff00ff00ffUI64 },
-    { 0x0080008000800080UI64 },
-    { 0x000001f0003f001fUI64 },
-    { 0x0000008404100840UI64 },
-    { 0x000000f800000000UI64 },
-    { 0x0000000000fc0000UI64 },
-    { 0x00000000000000f8UI64 },
-    { 0xffffffffffff0000UI64 },
-    { 0xffffffff0000ffffUI64 },
-    { 0xffff0000ffffffffUI64 },
-    { 0x0000ffffffffffffUI64 },
-    { 0x00ff000000000000UI64 },
-    { 0xffff0000ffff0000UI64 },
-    { 0x0000ffff00000000UI64 },
-    { 0x000000000000ffffUI64 },
-#endif
-};
-
-#ifdef _MSC_VER
-#undef inline
-#define inline __forceinline
-#endif
-
-#ifdef __GNUC__
-#define MC(x) ((__m64) c.mmx_##x)
-#endif
-#ifdef _MSC_VER
-#define MC(x) c.mmx_##x
-#endif
-
-static inline __m64
-shift (__m64 v, int s)
-{
-    if (s > 0)
-	return _mm_slli_si64 (v, s);
-    else if (s < 0)
-	return _mm_srli_si64 (v, -s);
-    else
-	return v;
-}
-
-static inline __m64
-negate (__m64 mask)
-{
-    return _mm_xor_si64 (mask, MC(4x00ff));
-}
-
-static inline __m64
-pix_multiply (__m64 a, __m64 b)
-{
-    __m64 res;
-    
-    res = _mm_mullo_pi16 (a, b);
-    res = _mm_adds_pu16 (res, MC(4x0080));
-    res = _mm_adds_pu16 (res, _mm_srli_pi16 (res, 8));
-    res = _mm_srli_pi16 (res, 8);
-    
-    return res;
-}
-
-static inline __m64
-pix_add (__m64 a, __m64 b)
-{
-    return  _mm_adds_pu8 (a, b);
-}
-
-#ifdef USE_SSE
-
-static inline __m64
-expand_alpha (__m64 pixel)
-{
-    return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 3, 3, 3));
-}
-
-static inline __m64
-expand_alpha_rev (__m64 pixel)
-{
-    return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(0, 0, 0, 0));
-}    
-
-static inline __m64
-invert_colors (__m64 pixel)
-{
-    return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 0, 1, 2));
-}
-
-#else
-
-static inline __m64
-expand_alpha (__m64 pixel)
-{
-    __m64 t1, t2;
-    
-    t1 = shift (pixel, -48);
-    t2 = shift (t1, 16);
-    t1 = _mm_or_si64 (t1, t2);
-    t2 = shift (t1, 32);
-    t1 = _mm_or_si64 (t1, t2);
-
-    return t1;
-}
-
-static inline __m64
-expand_alpha_rev (__m64 pixel)
-{
-    __m64 t1, t2;
-
-    /* move alpha to low 16 bits and zero the rest */
-    t1 = shift (pixel,  48);
-    t1 = shift (t1, -48);
-
-    t2 = shift (t1, 16);
-    t1 = _mm_or_si64 (t1, t2);
-    t2 = shift (t1, 32);
-    t1 = _mm_or_si64 (t1, t2);
-
-    return t1;
-}
-
-static inline __m64
-invert_colors (__m64 pixel)
-{
-    __m64 x, y, z;
-
-    x = y = z = pixel;
-
-    x = _mm_and_si64 (x, MC(ffff0000ffff0000));
-    y = _mm_and_si64 (y, MC(000000000000ffff));
-    z = _mm_and_si64 (z, MC(0000ffff00000000));
-
-    y = shift (y, 32);
-    z = shift (z, -32);
-
-    x = _mm_or_si64 (x, y);
-    x = _mm_or_si64 (x, z);
-
-    return x;
-}
-
-#endif
-
-static inline __m64
-over (__m64 src, __m64 srca, __m64 dest)
-{
-    return  _mm_adds_pu8 (src, pix_multiply(dest, negate(srca)));
-}
-
-static inline __m64
-over_rev_non_pre (__m64 src, __m64 dest)
-{
-    __m64 srca = expand_alpha (src);
-    __m64 srcfaaa = _mm_or_si64 (srca, MC(full_alpha));
-    
-    return over(pix_multiply(invert_colors(src), srcfaaa), srca, dest);
-}
-
-static inline __m64
-in (__m64 src,
-    __m64 mask)
-{
-    return pix_multiply (src, mask);
-}
-
-static inline __m64
-in_over_full_src_alpha (__m64 src, __m64 mask, __m64 dest)
-{
-    src = _mm_or_si64 (src, MC(full_alpha));
-
-    return over(in (src, mask), mask, dest);
-}
-
-#ifndef _MSC_VER
-static inline __m64
-in_over (__m64 src,
-	 __m64 srca,
-	 __m64 mask,
-	 __m64 dest)
-{
-    return over(in(src, mask), pix_multiply(srca, mask), dest);
-}
-#else
-#define in_over(src, srca, mask, dest) over(in(src, mask), pix_multiply(srca, mask), dest)
-#endif
-
-static inline __m64
-load8888 (CARD32 v)
-{
-    return _mm_unpacklo_pi8 (_mm_cvtsi32_si64 (v), _mm_setzero_si64());
-}
-
-static inline __m64
-pack8888 (__m64 lo, __m64 hi)
-{
-    return _mm_packs_pu16 (lo, hi);
-}
-
-static inline CARD32
-store8888 (__m64 v)
-{
-    return _mm_cvtsi64_si32(pack8888(v, _mm_setzero_si64()));
-}
-
-/* Expand 16 bits positioned at @pos (0-3) of a mmx register into
- *
- *    00RR00GG00BB
- * 
- * --- Expanding 565 in the low word ---
- * 
- * m = (m << (32 - 3)) | (m << (16 - 5)) | m;
- * m = m & (01f0003f001f);
- * m = m * (008404100840);
- * m = m >> 8;
- * 
- * Note the trick here - the top word is shifted by another nibble to
- * avoid it bumping into the middle word
- */
-static inline __m64
-expand565 (__m64 pixel, int pos)
-{
-    __m64 p = pixel;
-    __m64 t1, t2;
-    
-    /* move pixel to low 16 bit and zero the rest */
-    p = shift (shift (p, (3 - pos) * 16), -48); 
-    
-    t1 = shift (p, 36 - 11);
-    t2 = shift (p, 16 - 5);
-    
-    p = _mm_or_si64 (t1, p);
-    p = _mm_or_si64 (t2, p);
-    p = _mm_and_si64 (p, MC(565_rgb));
-    
-    pixel = _mm_mullo_pi16 (p, MC(565_unpack_multiplier));
-    return _mm_srli_pi16 (pixel, 8);
-}
-
-static inline __m64
-expand8888 (__m64 in, int pos)
-{
-    if (pos == 0)
-	return _mm_unpacklo_pi8 (in, _mm_setzero_si64());
-    else
-	return _mm_unpackhi_pi8 (in, _mm_setzero_si64());
-}
-
-static inline __m64
-pack565 (__m64 pixel, __m64 target, int pos)
-{
-    __m64 p = pixel;
-    __m64 t = target;
-    __m64 r, g, b;
-    
-    r = _mm_and_si64 (p, MC(565_r));
-    g = _mm_and_si64 (p, MC(565_g));
-    b = _mm_and_si64 (p, MC(565_b));
-    
-    r = shift (r, - (32 - 8) + pos * 16);
-    g = shift (g, - (16 - 3) + pos * 16);
-    b = shift (b, - (0  + 3) + pos * 16);
-    
-    if (pos == 0)
-	t = _mm_and_si64 (t, MC(mask_0));
-    else if (pos == 1)
-	t = _mm_and_si64 (t, MC(mask_1));
-    else if (pos == 2)
-	t = _mm_and_si64 (t, MC(mask_2));
-    else if (pos == 3)
-	t = _mm_and_si64 (t, MC(mask_3));
-    
-    p = _mm_or_si64 (r, t);
-    p = _mm_or_si64 (g, p);
-    
-    return _mm_or_si64 (b, p);
-}
-
-#ifndef _MSC_VER
-static inline __m64
-pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b)
-{
-    x = _mm_mullo_pi16 (x, a);
-    y = _mm_mullo_pi16 (y, b);
-    x = _mm_adds_pu16 (x, MC(4x0080));
-    x = _mm_adds_pu16 (x, y);
-    x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8));
-    x = _mm_srli_pi16 (x, 8);
-
-    return x;
-}
-#else
-#define pix_add_mul(x, a, y, b) \
-( x = _mm_mullo_pi16 (x, a), \
-  y = _mm_mullo_pi16 (y, b), \
-  x = _mm_adds_pu16 (x, MC(4x0080)), \
-  x = _mm_adds_pu16 (x, y), \
-  x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)), \
-  _mm_srli_pi16 (x, 8) )
-#endif
-
-/* --------------- MMX code patch for fbcompose.c --------------------- */
-
-static FASTCALL void
-mmxCombineMaskU (CARD32 *src, const CARD32 *mask, int width)
-{
-    const CARD32 *end = mask + width;
-    while (mask < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        a = expand_alpha(a);
-        s = pix_multiply(s, a);
-        *src = store8888(s);
-        ++src;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-
-static FASTCALL void
-mmxCombineOverU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-        __m64 s, sa;
-	s = load8888(*src);
-	sa = expand_alpha(s);
-	*dest = store8888(over(s, sa, load8888(*dest)));
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineOverReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-	__m64 d, da;
-	d = load8888(*dest);
-	da = expand_alpha(d);
-	*dest = store8888(over (d, da, load8888(*src)));
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineInU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-        __m64 x, a;
-        x = load8888(*src);
-        a = load8888(*dest);
-        a = expand_alpha(a);
-        x = pix_multiply(x, a);
-        *dest = store8888(x);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineInReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-        __m64 x, a;
-        x = load8888(*dest);
-        a = load8888(*src);
-        a = expand_alpha(a);
-        x = pix_multiply(x, a);
-        *dest = store8888(x);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineOutU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-        __m64 x, a;
-        x = load8888(*src);
-        a = load8888(*dest);
-        a = expand_alpha(a);
-        a = negate(a);
-        x = pix_multiply(x, a);
-        *dest = store8888(x);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineOutReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-        __m64 x, a;
-        x = load8888(*dest);
-        a = load8888(*src);
-        a = expand_alpha(a);
-        a = negate(a);
-        x = pix_multiply(x, a);
-        *dest = store8888(x);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineAtopU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-        __m64 s, da, d, sia;
-        s = load8888(*src);
-        d = load8888(*dest);
-        sia = expand_alpha(s);
-        sia = negate(sia);
-        da = expand_alpha(d);
-        s = pix_add_mul (s, da, d, sia);
-        *dest = store8888(s);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end;
-
-    end = dest + width;
-
-    while (dest < end) {
-        __m64 s, dia, d, sa;
-        s = load8888(*src);
-        d = load8888(*dest);
-        sa = expand_alpha(s);
-        dia = expand_alpha(d);
-        dia = negate(dia);
-	s = pix_add_mul (s, dia, d, sa);
-        *dest = store8888(s);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineXorU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-
-    while (dest < end) {
-        __m64 s, dia, d, sia;
-        s = load8888(*src);
-        d = load8888(*dest);
-        sia = expand_alpha(s);
-        dia = expand_alpha(d);
-        sia = negate(sia);
-        dia = negate(dia);
-	s = pix_add_mul (s, dia, d, sia);
-        *dest = store8888(s);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineAddU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-    while (dest < end) {
-        __m64 s, d;
-        s = load8888(*src);
-        d = load8888(*dest);
-        s = pix_add(s, d);
-        *dest = store8888(s);
-        ++dest;
-        ++src;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineSaturateU (CARD32 *dest, const CARD32 *src, int width)
-{
-    const CARD32 *end = dest + width;
-    while (dest < end) {
-        CARD32 s = *src;
-        CARD32 d = *dest;
-        __m64 ms = load8888(s);
-        __m64 md = load8888(d);
-        CARD32 sa = s >> 24;
-        CARD32 da = ~d >> 24;
-
-        if (sa > da) {
-            __m64 msa = load8888(FbIntDiv(da, sa) << 24);
-            msa = expand_alpha(msa);
-            ms = pix_multiply(ms, msa);
-        }
-        md = pix_add(md, ms);
-        *dest = store8888(md);
-        ++src;
-        ++dest;
-    }
-    _mm_empty();
-}
-
-
-static FASTCALL void
-mmxCombineSrcC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        s = pix_multiply(s, a);
-        *dest = store8888(s);
-        ++src;
-        ++mask;
-        ++dest;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 sa = expand_alpha(s);
-	
-	*dest = store8888(in_over (s, sa, a, d));
-	
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 da = expand_alpha(d);
-
-	*dest = store8888(over (d, da, in (s, a)));
-	
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-
-static FASTCALL void
-mmxCombineInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 da = expand_alpha(d);
-        s = pix_multiply(s, a);
-        s = pix_multiply(s, da);
-        *dest = store8888(s);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 sa = expand_alpha(s);
-        a = pix_multiply(a, sa);
-        d = pix_multiply(d, a);
-        *dest = store8888(d);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 da = expand_alpha(d);
-        da = negate(da);
-        s = pix_multiply(s, a);
-        s = pix_multiply(s, da);
-        *dest = store8888(s);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 sa = expand_alpha(s);
-        a = pix_multiply(a, sa);
-        a = negate(a);
-        d = pix_multiply(d, a);
-        *dest = store8888(d);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 da = expand_alpha(d);
-        __m64 sa = expand_alpha(s); 
-        s = pix_multiply(s, a);
-        a = pix_multiply(a, sa);
-        a = negate(a);
-	d = pix_add_mul (d, a, s, da);
-        *dest = store8888(d);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 da = expand_alpha(d);
-        __m64 sa = expand_alpha(s);
-        s = pix_multiply(s, a);
-        a = pix_multiply(a, sa);
-        da = negate(da);
-	d = pix_add_mul (d, a, s, da);
-        *dest = store8888(d);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        __m64 da = expand_alpha(d);
-        __m64 sa = expand_alpha(s);
-        s = pix_multiply(s, a);
-        a = pix_multiply(a, sa);
-        da = negate(da);
-        a = negate(a);
-	d = pix_add_mul (d, a, s, da);
-        *dest = store8888(d);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-static FASTCALL void
-mmxCombineAddC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    const CARD32 *end = src + width;
-    while (src < end) {
-        __m64 a = load8888(*mask);
-        __m64 s = load8888(*src);
-        __m64 d = load8888(*dest);
-        s = pix_multiply(s, a);
-        d = pix_add(s, d);
-        *dest = store8888(d);
-        ++src;
-        ++dest;
-        ++mask;
-    }
-    _mm_empty();
-}
-
-#if 0
-/* FIXME: this should be reinstated after adding fbmmx to pixman */
-extern FbComposeFunctions composeFunctions;
-#endif
-
-void fbComposeSetupMMX(void)
-{
-#if 0
-/* FIXME: this should be reinstated after adding fbmmx to pixman */
-    /* check if we have MMX support and initialize accordingly */
-    if (fbHaveMMX()) {
-        composeFunctions.combineU[PictOpOver] = mmxCombineOverU;
-        composeFunctions.combineU[PictOpOverReverse] = mmxCombineOverReverseU;
-        composeFunctions.combineU[PictOpIn] = mmxCombineInU;
-        composeFunctions.combineU[PictOpInReverse] = mmxCombineInReverseU;
-        composeFunctions.combineU[PictOpOut] = mmxCombineOutU;
-        composeFunctions.combineU[PictOpOutReverse] = mmxCombineOutReverseU;
-        composeFunctions.combineU[PictOpAtop] = mmxCombineAtopU;
-        composeFunctions.combineU[PictOpAtopReverse] = mmxCombineAtopReverseU;
-        composeFunctions.combineU[PictOpXor] = mmxCombineXorU;
-        composeFunctions.combineU[PictOpAdd] = mmxCombineAddU;
-        composeFunctions.combineU[PictOpSaturate] = mmxCombineSaturateU;
-
-        composeFunctions.combineC[PictOpSrc] = mmxCombineSrcC;
-        composeFunctions.combineC[PictOpOver] = mmxCombineOverC;
-        composeFunctions.combineC[PictOpOverReverse] = mmxCombineOverReverseC;
-        composeFunctions.combineC[PictOpIn] = mmxCombineInC;
-        composeFunctions.combineC[PictOpInReverse] = mmxCombineInReverseC;
-        composeFunctions.combineC[PictOpOut] = mmxCombineOutC;
-        composeFunctions.combineC[PictOpOutReverse] = mmxCombineOutReverseC;
-        composeFunctions.combineC[PictOpAtop] = mmxCombineAtopC;
-        composeFunctions.combineC[PictOpAtopReverse] = mmxCombineAtopReverseC;
-        composeFunctions.combineC[PictOpXor] = mmxCombineXorC;
-        composeFunctions.combineC[PictOpAdd] = mmxCombineAddC;
-
-        composeFunctions.combineMaskU = mmxCombineMaskU;
-    } 
-#endif
-}
-
-
-/* ------------------ MMX code paths called from fbpict.c ----------------------- */
-
-void
-fbCompositeSolid_nx8888mmx (CARD8	op,
-			    PicturePtr pSrc,
-			    PicturePtr pMask,
-			    PicturePtr pDst,
-			    INT16	xSrc,
-			    INT16	ySrc,
-			    INT16	xMask,
-			    INT16	yMask,
-			    INT16	xDst,
-			    INT16	yDst,
-			    CARD16	width,
-			    CARD16	height)
-{
-    CARD32	src;
-    CARD32	*dstLine, *dst;
-    CARD16	w;
-    FbStride	dstStride;
-    __m64	vsrc, vsrca;
-    
-    CHECKPOINT();
-    
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    
-    if (src >> 24 == 0)
-	return;
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    
-    vsrc = load8888 (src);
-    vsrca = expand_alpha (vsrc);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	w = width;
-	
-	CHECKPOINT();
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    *dst = store8888(over(vsrc, vsrca, load8888(*dst)));
-	    
-	    w--;
-	    dst++;
-	}
-	
-	while (w >= 2)
-	{
-	    __m64 vdest;
-	    __m64 dest0, dest1;
-	    
-	    vdest = *(__m64 *)dst;
-	    
-	    dest0 = over(vsrc, vsrca, expand8888(vdest, 0));
-	    dest1 = over(vsrc, vsrca, expand8888(vdest, 1));
-	    
-	    *(__m64 *)dst = pack8888(dest0, dest1);
-	    
-	    dst += 2;
-	    w -= 2;
-	}
-	
-	CHECKPOINT();
-	
-	while (w)
-	{
-	    *dst = store8888(over(vsrc, vsrca, load8888(*dst)));
-	    
-	    w--;
-	    dst++;
-	}
-    }
-    
-    _mm_empty();
-}
-
-void
-fbCompositeSolid_nx0565mmx (CARD8	op,
-			    PicturePtr pSrc,
-			    PicturePtr pMask,
-			    PicturePtr pDst,
-			    INT16	xSrc,
-			    INT16	ySrc,
-			    INT16	xMask,
-			    INT16	yMask,
-			    INT16	xDst,
-			    INT16	yDst,
-			    CARD16	width,
-			    CARD16	height)
-{
-    CARD32	src;
-    CARD16	*dstLine, *dst;
-    CARD16	w;
-    FbStride	dstStride;
-    __m64	vsrc, vsrca;
-    
-    CHECKPOINT();
-    
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    
-    if (src >> 24 == 0)
-	return;
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    
-    vsrc = load8888 (src);
-    vsrca = expand_alpha (vsrc);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	w = width;
-	
-	CHECKPOINT();
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    ullong d = *dst;
-	    __m64 vdest = expand565 ((__m64)d, 0);
-	    vdest = pack565(over(vsrc, vsrca, vdest), vdest, 0);
-	    *dst = (ullong)vdest;
-	    
-	    w--;
-	    dst++;
-	}
-	
-	while (w >= 4)
-	{
-	    __m64 vdest;
-	    
-	    vdest = *(__m64 *)dst;
-	    
-	    vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 0)), vdest, 0);
-	    vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 1)), vdest, 1);
-	    vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 2)), vdest, 2);
-	    vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 3)), vdest, 3);
-	    
-	    *(__m64 *)dst = vdest;
-	    
-	    dst += 4;
-	    w -= 4;
-	}
-	
-	CHECKPOINT();
-	
-	while (w)
-	{
-	    ullong d = *dst;
-	    __m64 vdest = expand565 ((__m64)d, 0);
-	    vdest = pack565(over(vsrc, vsrca, vdest), vdest, 0);
-	    *dst = (ullong)vdest;
-	    
-	    w--;
-	    dst++;
-	}
-    }
-    
-    _mm_empty();
-}
-
-void
-fbCompositeSolidMask_nx8888x8888Cmmx (CARD8	op,
-				      PicturePtr pSrc,
-				      PicturePtr pMask,
-				      PicturePtr pDst,
-				      INT16	xSrc,
-				      INT16	ySrc,
-				      INT16	xMask,
-				      INT16	yMask,
-				      INT16	xDst,
-				      INT16	yDst,
-				      CARD16	width,
-				      CARD16	height)
-{
-    CARD32	src, srca;
-    CARD32	*dstLine;
-    CARD32	*maskLine;
-    FbStride	dstStride, maskStride;
-    __m64	vsrc, vsrca;
-    
-    CHECKPOINT();
-    
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    
-    srca = src >> 24;
-    if (srca == 0)
-	return;
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
-    
-    vsrc = load8888(src);
-    vsrca = expand_alpha(vsrc);
-    
-    while (height--)
-    {
-	int twidth = width;
-	CARD32 *p = (CARD32 *)maskLine;
-	CARD32 *q = (CARD32 *)dstLine;
-	
-	while (twidth && (unsigned long)q & 7)
-	{
-	    CARD32 m = *(CARD32 *)p;
-	    
-	    if (m)
-	    {
-		__m64 vdest = load8888(*q);
-		vdest = in_over(vsrc, vsrca, load8888(m), vdest);
-		*q = store8888(vdest);
-	    }
-	    
-	    twidth--;
-	    p++;
-	    q++;
-	}
-	
-	while (twidth >= 2)
-	{
-	    CARD32 m0, m1;
-	    m0 = *p;
-	    m1 = *(p + 1);
-	    
-	    if (m0 | m1)
-	    {
-		__m64 dest0, dest1;
-		__m64 vdest = *(__m64 *)q;
-		
-		dest0 = in_over(vsrc, vsrca, load8888(m0),
-				expand8888 (vdest, 0));
-		dest1 = in_over(vsrc, vsrca, load8888(m1),
-				expand8888 (vdest, 1));
-		
-		*(__m64 *)q = pack8888(dest0, dest1);
-	    }
-	    
-	    p += 2;
-	    q += 2;
-	    twidth -= 2;
-	}
-	
-	while (twidth)
-	{
-	    CARD32 m = *(CARD32 *)p;
-	    
-	    if (m)
-	    {
-		__m64 vdest = load8888(*q);
-		vdest = in_over(vsrc, vsrca, load8888(m), vdest);
-		*q = store8888(vdest);
-	    }
-	    
-	    twidth--;
-	    p++;
-	    q++;
-	}
-	
-	dstLine += dstStride;
-	maskLine += maskStride;
-    }
-    
-    _mm_empty();
-}
-
-void
-fbCompositeSrc_8888x8x8888mmx (CARD8	op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16	xSrc,
-			       INT16	ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height)
-{
-    CARD32	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    CARD32	mask;
-    __m64	vmask;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    __m64  srca;
-
-    CHECKPOINT();
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-
-    fbComposeGetSolid (pMask, mask, pDst->format);
-    mask = mask | mask >> 8 | mask >> 16 | mask >> 24;
-    vmask = load8888 (mask);
-    srca = MC(4x00ff);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w && (unsigned long)dst & 7)
-	{
-	    __m64 s = load8888 (*src);
-	    __m64 d = load8888 (*dst);
-
-	    *dst = store8888 (in_over (s, expand_alpha (s), vmask, d));
-
-	    w--;
-	    dst++;
-	    src++;
-	}
-
-	while (w >= 2)
-	{
-	    __m64 vs = *(__m64 *)src;
-	    __m64 vd = *(__m64 *)dst;
-	    __m64 vsrc0 = expand8888 (vs, 0);
-	    __m64 vsrc1 = expand8888 (vs, 1);
-
-	    *(__m64 *)dst = pack8888 (
-		in_over (vsrc0, expand_alpha (vsrc0), vmask, expand8888 (vd, 0)),
-		in_over (vsrc1, expand_alpha (vsrc1), vmask, expand8888 (vd, 1)));
-
-	    w -= 2;
-	    dst += 2;
-	    src += 2;
-	}
-
-	while (w)
-	{
-	    __m64 s = load8888 (*src);
-	    __m64 d = load8888 (*dst);
-
-	    *dst = store8888 (in_over (s, expand_alpha (s), vmask, d));
-
-	    w--;
-	    dst++;
-	    src++;
-	}
-    }
-
-    _mm_empty();
-}
-
-void
-fbCompositeSrc_x888x8x8888mmx (CARD8	op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16	xSrc,
-			       INT16	ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height)
-{
-    CARD32	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    CARD32	mask;
-    __m64	vmask;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    __m64  srca;
-
-    CHECKPOINT();
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    fbComposeGetSolid (pMask, mask, pDst->format);
-
-    mask = mask | mask >> 8 | mask >> 16 | mask >> 24;
-    vmask = load8888 (mask);
-    srca = MC(4x00ff);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w && (unsigned long)dst & 7)
-	{
-	    __m64 s = load8888 (*src | 0xff000000);
-	    __m64 d = load8888 (*dst);
-
-	    *dst = store8888 (in_over (s, srca, vmask, d));
-
-	    w--;
-	    dst++;
-	    src++;
-	}
-
-	while (w >= 2)
-	{
-	    
-	    __m64 vd0 = *(__m64 *)(dst);
-	    __m64 vs0 = *(__m64 *)(src);
-
-	    vd0 = pack8888 (
-		in_over_full_src_alpha (expand8888 (vs0, 0), vmask, expand8888 (vd0, 0)),
-		in_over_full_src_alpha (expand8888 (vs0, 1), vmask, expand8888 (vd0, 1)));
-
-	    *(__m64 *)(dst) = vd0;
-
-	    w -= 2;
-	    dst += 2;
-	    src += 2;
-	}
-
-	while (w)
-	{
-	    __m64 s = load8888 (*src | 0xff000000);
-	    __m64 d = load8888 (*dst);
-
-	    *dst = store8888 (in_over (s, srca, vmask, d));
-
-	    w--;
-	    dst++;
-	    src++;
-	}
-    }
-
-    _mm_empty();
-}
-
-void
-fbCompositeSrc_8888x8888mmx (CARD8	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16	xSrc,
-			     INT16	ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height)
-{
-    CARD32	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    __m64  srca;
-    
-    CHECKPOINT();
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-
-    srca = MC (4x00ff);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w && (unsigned long)dst & 7)
-	{
-	    __m64 s = load8888 (*src);
-	    __m64 d = load8888 (*dst);
-	    
-	    *dst = store8888 (over (s, expand_alpha (s), d));
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-
-	while (w >= 2)
-	{
-	    __m64 vd = *(__m64 *)(dst + 0);
-	    __m64 vs = *(__m64 *)(src + 0);
-	    __m64 vs0 = expand8888 (vs, 0);
-	    __m64 vs1 = expand8888 (vs, 1);
-
-	    *(__m64 *)dst = (__m64)pack8888 (
-		over (vs0, expand_alpha (vs0), expand8888 (vd, 0)),
-		over (vs1, expand_alpha (vs1), expand8888 (vd, 1)));
-	    
-	    w -= 2;
-	    dst += 2;
-	    src += 2;
-	}
-	
-	while (w)
-	{
-	    __m64 s = load8888 (*src);
-	    __m64 d = load8888 (*dst);
-	    
-	    *dst = store8888 (over (s, expand_alpha (s), d));
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-    }
-
-    _mm_empty(); 
-}
-
-void
-fbCompositeSrc_8888x0565mmx (CARD8      op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height)
-{
-    CARD16	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    
-    CHECKPOINT();
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    
-    assert (pSrc->pDrawable == pMask->pDrawable);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-	
-	CHECKPOINT();
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    __m64 vsrc = load8888 (*src);
-	    ullong d = *dst;
-	    __m64 vdest = expand565 ((__m64)d, 0);
-	    
-	    vdest = pack565(over(vsrc, expand_alpha(vsrc), vdest), vdest, 0);
-	    
-	    *dst = (ullong)vdest;
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-	
-	CHECKPOINT();
-	
-	while (w >= 4)
-	{
-	    __m64 vsrc0, vsrc1, vsrc2, vsrc3;
-	    __m64 vdest;
-
-	    vsrc0 = load8888(*(src + 0));
-	    vsrc1 = load8888(*(src + 1));
-	    vsrc2 = load8888(*(src + 2));
-	    vsrc3 = load8888(*(src + 3));
-
-	    vdest = *(__m64 *)dst;
-	    
-	    vdest = pack565(over(vsrc0, expand_alpha(vsrc0), expand565(vdest, 0)), vdest, 0);
-	    vdest = pack565(over(vsrc1, expand_alpha(vsrc1), expand565(vdest, 1)), vdest, 1);
-	    vdest = pack565(over(vsrc2, expand_alpha(vsrc2), expand565(vdest, 2)), vdest, 2);
-	    vdest = pack565(over(vsrc3, expand_alpha(vsrc3), expand565(vdest, 3)), vdest, 3);
-	    
-	    *(__m64 *)dst = vdest;
-
-	    w -= 4;
-	    dst += 4;
-	    src += 4;
-	}
-
-	CHECKPOINT();
-	
-	while (w)
-	{
-	    __m64 vsrc = load8888 (*src);
-	    ullong d = *dst;
-	    __m64 vdest = expand565 ((__m64)d, 0);
-	    
-	    vdest = pack565(over(vsrc, expand_alpha(vsrc), vdest), vdest, 0);
-	    
-	    *dst = (ullong)vdest;
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-    }
-    
-    _mm_empty();
-}
-
-void
-fbCompositeSolidMask_nx8x8888mmx (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height)
-{
-    CARD32	src, srca;
-    CARD32	*dstLine, *dst;
-    CARD8	*maskLine, *mask;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    __m64	vsrc, vsrca;
-    ullong	srcsrc;
-    
-    CHECKPOINT();
-    
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    
-    srca = src >> 24;
-    if (srca == 0)
-	return;
-    
-    srcsrc = (unsigned long long)src << 32 | src;
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-    
-    vsrc = load8888 (src);
-    vsrca = expand_alpha (vsrc);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-	
-	CHECKPOINT();
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    ullong m = *mask;
-	    
-	    if (m)
-	    {
-		__m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), load8888(*dst));
-		*dst = store8888(vdest);
-	    }
-	    
-	    w--;
-	    mask++;
-	    dst++;
-	}
-	
-	CHECKPOINT();
-	
-	while (w >= 2)
-	{
-	    ullong m0, m1;
-	    m0 = *mask;
-	    m1 = *(mask + 1);
-	    
-	    if (srca == 0xff && (m0 & m1) == 0xff)
-	    {
-		*(unsigned long long *)dst = srcsrc;
-	    }
-	    else if (m0 | m1)
-	    {
-		__m64 vdest;
-		__m64 dest0, dest1;
-		
-		vdest = *(__m64 *)dst;
-		
-		dest0 = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m0), expand8888(vdest, 0));
-		dest1 = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m1), expand8888(vdest, 1));
-		
-		*(__m64 *)dst = pack8888(dest0, dest1);
-	    }
-	    
-	    mask += 2;
-	    dst += 2;
-	    w -= 2;
-	}
-	
-	CHECKPOINT();
-	
-	while (w)
-	{
-	    ullong m = *mask;
-	    
-	    if (m)
-	    {
-		__m64 vdest = load8888(*dst);
-		vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), vdest);
-		*dst = store8888(vdest);
-	    }
-	    
-	    w--;
-	    mask++;
-	    dst++;
-	}
-    }
-    
-    _mm_empty();
-}
-
-
-Bool
-fbSolidFillmmx (DrawablePtr	pDraw,
-		int		x,
-		int		y,
-		int		width,
-		int		height,
-		FbBits		xor)
-{ 
-    FbStride	stride;
-    int		bpp;
-    ullong	fill;
-    __m64	vfill;
-    CARD32	byte_width;
-    CARD8	*byte_line;
-    FbBits      *bits;
-    int		xoff, yoff;
-#ifdef __GNUC__
-    __m64	v1, v2, v3, v4, v5, v6, v7;
-#endif
-    
-    CHECKPOINT();
-    
-    fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
-    
-    if (bpp == 16 && (xor >> 16 != (xor & 0xffff)))
-	return FALSE;
-    
-    if (bpp != 16 && bpp != 32)
-	return FALSE;
-    
-    if (bpp == 16)
-    {
-	stride = stride * sizeof (FbBits) / 2;
-	byte_line = (CARD8 *)(((CARD16 *)bits) + stride * (y + yoff) + (x + xoff));
-	byte_width = 2 * width;
-	stride *= 2;
-    }
-    else
-    {
-	stride = stride * sizeof (FbBits) / 4;
-	byte_line = (CARD8 *)(((CARD32 *)bits) + stride * (y + yoff) + (x + xoff));
-	byte_width = 4 * width;
-	stride *= 4;
-    }
-    
-    fill = ((ullong)xor << 32) | xor;
-    vfill = (__m64)fill;
-    
-#ifdef __GNUC__
-    __asm__ (
-	"movq		%7,	%0\n"
-	"movq		%7,	%1\n"
-	"movq		%7,	%2\n"
-	"movq		%7,	%3\n"
-	"movq		%7,	%4\n"
-	"movq		%7,	%5\n"
-	"movq		%7,	%6\n"
-	: "=y" (v1), "=y" (v2), "=y" (v3),
-	  "=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
-	: "y" (vfill));
-#endif
-    
-    while (height--)
-    {
-	int w;
-	CARD8 *d = byte_line;
-	byte_line += stride;
-	w = byte_width;
-	
-	while (w >= 2 && ((unsigned long)d & 3))
-	{
-	    *(CARD16 *)d = xor;
-	    w -= 2;
-	    d += 2;
-	}
-	
-	while (w >= 4 && ((unsigned long)d & 7))
-	{
-	    *(CARD32 *)d = xor;
-	    
-	    w -= 4;
-	    d += 4;
-	}
-
-	while (w >= 64)
-	{
-#ifdef __GNUC__
-	    __asm__ (
-		"movq	%1,	  (%0)\n"
-		"movq	%2,	 8(%0)\n"
-		"movq	%3,	16(%0)\n"
-		"movq	%4,	24(%0)\n"
-		"movq	%5,	32(%0)\n"
-		"movq	%6,	40(%0)\n"
-		"movq	%7,	48(%0)\n"
-		"movq	%8,	56(%0)\n"
-		:
-		: "r" (d),
-		  "y" (vfill), "y" (v1), "y" (v2), "y" (v3),
-		  "y" (v4), "y" (v5), "y" (v6), "y" (v7)
-		: "memory");
-#else
-	    *(__m64*) (d +  0) = vfill;
-	    *(__m64*) (d +  8) = vfill;
-	    *(__m64*) (d + 16) = vfill;
-	    *(__m64*) (d + 24) = vfill;
-	    *(__m64*) (d + 32) = vfill;
-	    *(__m64*) (d + 40) = vfill;
-	    *(__m64*) (d + 48) = vfill;
-	    *(__m64*) (d + 56) = vfill;
-#endif    
-	    w -= 64;
-	    d += 64;
-	}
-	
-	while (w >= 4)
-	{
-	    *(CARD32 *)d = xor;
-	    
-	    w -= 4;
-	    d += 4;
-	}
-	if (w >= 2)
-	{
-	    *(CARD16 *)d = xor;
-	    w -= 2;
-	    d += 2;
-	}
-    }
-    
-    _mm_empty();
-    return TRUE;
-}
-
-void
-fbCompositeSolidMaskSrc_nx8x8888mmx (CARD8      op,
-				     PicturePtr pSrc,
-				     PicturePtr pMask,
-				     PicturePtr pDst,
-				     INT16      xSrc,
-				     INT16      ySrc,
-				     INT16      xMask,
-				     INT16      yMask,
-				     INT16      xDst,
-				     INT16      yDst,
-				     CARD16     width,
-				     CARD16     height)
-{
-    CARD32	src, srca;
-    CARD32	*dstLine, *dst;
-    CARD8	*maskLine, *mask;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    __m64	vsrc, vsrca;
-    ullong	srcsrc;
-
-    CHECKPOINT();
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    srca = src >> 24;
-    if (srca == 0)
-    {
-	fbSolidFillmmx (pDst->pDrawable, xDst, yDst, width, height, 0);
-	return;
-    }
-
-    srcsrc = (ullong)src << 32 | src;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    vsrc = load8888 (src);
-    vsrca = expand_alpha (vsrc);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	CHECKPOINT();
-
-	while (w && (unsigned long)dst & 7)
-	{
-	    ullong m = *mask;
-
-	    if (m)
-	    {
-		__m64 vdest = in(vsrc, expand_alpha_rev ((__m64)m));
-		*dst = store8888(vdest);
-	    }
-	    else
-	    {
-		*dst = 0;
-	    }
-
-	    w--;
-	    mask++;
-	    dst++;
-	}
-
-	CHECKPOINT();
-
-	while (w >= 2)
-	{
-	    ullong m0, m1;
-	    m0 = *mask;
-	    m1 = *(mask + 1);
-
-	    if (srca == 0xff && (m0 & m1) == 0xff)
-	    {
-		*(ullong *)dst = srcsrc;
-	    }
-	    else if (m0 | m1)
-	    {
-		__m64 vdest;
-		__m64 dest0, dest1;
-
-		vdest = *(__m64 *)dst;
-
-		dest0 = in(vsrc, expand_alpha_rev ((__m64)m0));
-		dest1 = in(vsrc, expand_alpha_rev ((__m64)m1));
-
-		*(__m64 *)dst = pack8888(dest0, dest1);
-	    }
-	    else
-	    {
-		*(ullong *)dst = 0;
-	    }
-
-	    mask += 2;
-	    dst += 2;
-	    w -= 2;
-	}
-
-	CHECKPOINT();
-
-	while (w)
-	{
-	    ullong m = *mask;
-
-	    if (m)
-	    {
-		__m64 vdest = load8888(*dst);
-		vdest = in(vsrc, expand_alpha_rev ((__m64)m));
-		*dst = store8888(vdest);
-	    }
-	    else
-	    {
-		*dst = 0;
-	    }
-
-	    w--;
-	    mask++;
-	    dst++;
-	}
-    }
-
-    _mm_empty();
-}
-
-void
-fbCompositeSolidMask_nx8x0565mmx (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height)
-{
-    CARD32	src, srca;
-    CARD16	*dstLine, *dst;
-    CARD8	*maskLine, *mask;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    __m64	vsrc, vsrca;
-    unsigned long long srcsrcsrcsrc, src16;
-    
-    CHECKPOINT();
-    
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    
-    srca = src >> 24;
-    if (srca == 0)
-	return;
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-    
-    vsrc = load8888 (src);
-    vsrca = expand_alpha (vsrc);
-    
-    src16 = (ullong)pack565(vsrc, _mm_setzero_si64(), 0);
-    
-    srcsrcsrcsrc = (ullong)src16 << 48 | (ullong)src16 << 32 |
-	(ullong)src16 << 16 | (ullong)src16;
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-	
-	CHECKPOINT();
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    ullong m = *mask;
-	    
-	    if (m)
-	    {
-		ullong d = *dst;
-		__m64 vd = (__m64)d;
-		__m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), expand565(vd, 0));
-		*dst = (ullong)pack565(vdest, _mm_setzero_si64(), 0);
-	    }
-	    
-	    w--;
-	    mask++;
-	    dst++;
-	}
-	
-	CHECKPOINT();
-	
-	while (w >= 4)
-	{
-	    ullong m0, m1, m2, m3;
-	    m0 = *mask;
-	    m1 = *(mask + 1);
-	    m2 = *(mask + 2);
-	    m3 = *(mask + 3);
-	    
-	    if (srca == 0xff && (m0 & m1 & m2 & m3) == 0xff)
-	    {
-		*(unsigned long long *)dst = srcsrcsrcsrc;
-	    }
-	    else if (m0 | m1 | m2 | m3)
-	    {
-		__m64 vdest;
-		__m64 vm0, vm1, vm2, vm3;
-		
-		vdest = *(__m64 *)dst;
-		
-		vm0 = (__m64)m0;
-		vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm0), expand565(vdest, 0)), vdest, 0);
-		vm1 = (__m64)m1;
-		vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm1), expand565(vdest, 1)), vdest, 1);
-		vm2 = (__m64)m2;
-		vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm2), expand565(vdest, 2)), vdest, 2);
-		vm3 = (__m64)m3;
-		vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm3), expand565(vdest, 3)), vdest, 3);
-		
-		*(__m64 *)dst = vdest;
-	    }
-	    
-	    w -= 4;
-	    mask += 4;
-	    dst += 4;
-	}
-	
-	CHECKPOINT();
-	
-	while (w)
-	{
-	    ullong m = *mask;
-	    
-	    if (m)
-	    {
-		ullong d = *dst;
-		__m64 vd = (__m64)d;
-		__m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), expand565(vd, 0));
-		*dst = (ullong)pack565(vdest, _mm_setzero_si64(), 0);
-	    }
-	    
-	    w--;
-	    mask++;
-	    dst++;
-	}
-    }
-    
-    _mm_empty();
-}
-
-void
-fbCompositeSrc_8888RevNPx0565mmx (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height)
-{
-    CARD16	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    
-    CHECKPOINT();
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    
-    assert (pSrc->pDrawable == pMask->pDrawable);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-	
-	CHECKPOINT();
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    __m64 vsrc = load8888 (*src);
-	    ullong d = *dst;
-	    __m64 vdest = expand565 ((__m64)d, 0);
-	    
-	    vdest = pack565(over_rev_non_pre(vsrc, vdest), vdest, 0);
-	    
-	    *dst = (ullong)vdest;
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-	
-	CHECKPOINT();
-	
-	while (w >= 4)
-	{
-	    CARD32 s0, s1, s2, s3;
-	    unsigned char a0, a1, a2, a3;
-	    
-	    s0 = *src;
-	    s1 = *(src + 1);
-	    s2 = *(src + 2);
-	    s3 = *(src + 3);
-	    
-	    a0 = (s0 >> 24);
-	    a1 = (s1 >> 24);
-	    a2 = (s2 >> 24);
-	    a3 = (s3 >> 24);
-	    
-	    if ((a0 & a1 & a2 & a3) == 0xFF)
-	    {
-		__m64 vdest;
-		vdest = pack565(invert_colors(load8888(s0)), _mm_setzero_si64(), 0);
-		vdest = pack565(invert_colors(load8888(s1)), vdest, 1);
-		vdest = pack565(invert_colors(load8888(s2)), vdest, 2);
-		vdest = pack565(invert_colors(load8888(s3)), vdest, 3);
-		
-		*(__m64 *)dst = vdest;
-	    }
-	    else if (a0 | a1 | a2 | a3)
-	    {
-		__m64 vdest = *(__m64 *)dst;
-		
-		vdest = pack565(over_rev_non_pre(load8888(s0), expand565(vdest, 0)), vdest, 0);
-	        vdest = pack565(over_rev_non_pre(load8888(s1), expand565(vdest, 1)), vdest, 1);
-		vdest = pack565(over_rev_non_pre(load8888(s2), expand565(vdest, 2)), vdest, 2);
-		vdest = pack565(over_rev_non_pre(load8888(s3), expand565(vdest, 3)), vdest, 3);
-		
-		*(__m64 *)dst = vdest;
-	    }
-	    
-	    w -= 4;
-	    dst += 4;
-	    src += 4;
-	}
-	
-	CHECKPOINT();
-	
-	while (w)
-	{
-	    __m64 vsrc = load8888 (*src);
-	    ullong d = *dst;
-	    __m64 vdest = expand565 ((__m64)d, 0);
-	    
-	    vdest = pack565(over_rev_non_pre(vsrc, vdest), vdest, 0);
-	    
-	    *dst = (ullong)vdest;
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-    }
-    
-    _mm_empty();
-}
-
-/* "8888RevNP" is GdkPixbuf's format: ABGR, non premultiplied */
+typedef unsigned long long ullong;
 
-void
-fbCompositeSrc_8888RevNPx8888mmx (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height)
-{
-    CARD32	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    
-    CHECKPOINT();
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    
-    assert (pSrc->pDrawable == pMask->pDrawable);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    __m64 s = load8888 (*src);
-	    __m64 d = load8888 (*dst);
-	    
-	    *dst = store8888 (over_rev_non_pre (s, d));
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-	
-	while (w >= 2)
-	{
-	    ullong s0, s1;
-	    unsigned char a0, a1;
-	    __m64 d0, d1;
-	    
-	    s0 = *src;
-	    s1 = *(src + 1);
-	    
-	    a0 = (s0 >> 24);
-	    a1 = (s1 >> 24);
-	    
-	    if ((a0 & a1) == 0xFF)
-	    {
-		d0 = invert_colors(load8888(s0));
-		d1 = invert_colors(load8888(s1));
-		
-		*(__m64 *)dst = pack8888 (d0, d1);
-	    }
-	    else if (a0 | a1)
-	    {
-		__m64 vdest = *(__m64 *)dst;
-		
-		d0 = over_rev_non_pre (load8888(s0), expand8888 (vdest, 0));
-		d1 = over_rev_non_pre (load8888(s1), expand8888 (vdest, 1));
-		
-		*(__m64 *)dst = pack8888 (d0, d1);
-	    }
-	    
-	    w -= 2;
-	    dst += 2;
-	    src += 2;
-	}
-	
-	while (w)
-	{
-	    __m64 s = load8888 (*src);
-	    __m64 d = load8888 (*dst);
-	    
-	    *dst = store8888 (over_rev_non_pre (s, d));
-	    
-	    w--;
-	    dst++;
-	    src++;
-	}
-    }
-    
-    _mm_empty();
-}
+#ifdef __GNUC__
+typedef ullong mmxdatafield;
+#endif
+#ifdef _MSC_VER
+typedef unsigned __int64 ullong;
+typedef __m64 mmxdatafield;
+#endif
 
-void
-fbCompositeSolidMask_nx8888x0565Cmmx (CARD8      op,
-				      PicturePtr pSrc,
-				      PicturePtr pMask,
-				      PicturePtr pDst,
-				      INT16      xSrc,
-				      INT16      ySrc,
-				      INT16      xMask,
-				      INT16      yMask,
-				      INT16      xDst,
-				      INT16      yDst,
-				      CARD16     width,
-				      CARD16     height)
-{
-    CARD32	src, srca;
-    CARD16	*dstLine;
-    CARD32	*maskLine;
-    FbStride	dstStride, maskStride;
-    __m64  vsrc, vsrca;
+Bool
+fbSolidFillmmx (DrawablePtr	pDraw,
+		int		x,
+		int		y,
+		int		width,
+		int		height,
+		FbBits		xor)
+{ 
+    FbStride	stride;
+    int		bpp;
+    ullong	fill;
+    __m64	vfill;
+    CARD32	byte_width;
+    CARD8	*byte_line;
+    FbBits      *bits;
+    int		xoff, yoff;
+#ifdef __GNUC__
+    __m64	v1, v2, v3, v4, v5, v6, v7;
+#endif
     
     CHECKPOINT();
     
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    
-    srca = src >> 24;
-    if (srca == 0)
-	return;
-    
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+    fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
     
-    vsrc = load8888 (src);
-    vsrca = expand_alpha (vsrc);
+    if (bpp == 16 && (xor >> 16 != (xor & 0xffff)))
+	return FALSE;
     
-    while (height--)
-    {
-	int twidth = width;
-	CARD32 *p = (CARD32 *)maskLine;
-	CARD16 *q = (CARD16 *)dstLine;
-	
-	while (twidth && ((unsigned long)q & 7))
-	{
-	    CARD32 m = *(CARD32 *)p;
-	    
-	    if (m)
-	    {
-		ullong d = *q;
-		__m64 vdest = expand565 ((__m64)d, 0);
-		vdest = pack565 (in_over (vsrc, vsrca, load8888 (m), vdest), vdest, 0);
-		*q = (ullong)vdest;
-	    }
-	    
-	    twidth--;
-	    p++;
-	    q++;
-	}
-	
-	while (twidth >= 4)
-	{
-	    CARD32 m0, m1, m2, m3;
-	    
-	    m0 = *p;
-	    m1 = *(p + 1);
-	    m2 = *(p + 2);
-	    m3 = *(p + 3);
-	    
-	    if ((m0 | m1 | m2 | m3))
-	    {
-		__m64 vdest = *(__m64 *)q;
-		
-		vdest = pack565(in_over(vsrc, vsrca, load8888(m0), expand565(vdest, 0)), vdest, 0);
-		vdest = pack565(in_over(vsrc, vsrca, load8888(m1), expand565(vdest, 1)), vdest, 1);
-		vdest = pack565(in_over(vsrc, vsrca, load8888(m2), expand565(vdest, 2)), vdest, 2);
-		vdest = pack565(in_over(vsrc, vsrca, load8888(m3), expand565(vdest, 3)), vdest, 3);
-		
-		*(__m64 *)q = vdest;
-	    }
-	    twidth -= 4;
-	    p += 4;
-	    q += 4;
-	}
-	
-	while (twidth)
-	{
-	    CARD32 m;
-	    
-	    m = *(CARD32 *)p;
-	    if (m)
-	    {
-		ullong d = *q;
-		__m64 vdest = expand565((__m64)d, 0);
-		vdest = pack565 (in_over(vsrc, vsrca, load8888(m), vdest), vdest, 0);
-		*q = (ullong)vdest;
-	    }
-	    
-	    twidth--;
-	    p++;
-	    q++;
-	}
-	
-	maskLine += maskStride;
-	dstLine += dstStride;
-    }
+    if (bpp != 16 && bpp != 32)
+	return FALSE;
     
-    _mm_empty ();
-}
-
-void
-fbCompositeIn_nx8x8mmx (CARD8	op,
-			PicturePtr pSrc,
-			PicturePtr pMask,
-			PicturePtr pDst,
-			INT16      xSrc,
-			INT16      ySrc,
-			INT16      xMask,
-			INT16      yMask,
-			INT16      xDst,
-			INT16      yDst,
-			CARD16     width,
-			CARD16     height)
-{
-    CARD8	*dstLine, *dst;
-    CARD8	*maskLine, *mask;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    CARD32	src;
-    CARD8	sa;
-    __m64	vsrc, vsrca;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    sa = src >> 24;
-    if (sa == 0)
-	return;
-
-    vsrc = load8888(src);
-    vsrca = expand_alpha(vsrc);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	if ((((unsigned long)pDst & 3) == 0) &&
-	    (((unsigned long)pSrc & 3) == 0))
-	{
-	    while (w >= 4)
-	    {
-		CARD32 m;
-		__m64 vmask;
-		__m64 vdest;
-
-		m = 0;
-
-		vmask = load8888 (*(CARD32 *)mask);
-		vdest = load8888 (*(CARD32 *)dst);
-
-		*(CARD32 *)dst = store8888 (in (in (vsrca, vmask), vdest));
-
-		dst += 4;
-		mask += 4;
-		w -= 4;
-	    }
-	}
-
-	while (w--)
-	{
-	    CARD16	tmp;
-	    CARD8	a;
-	    CARD32	m, d;
-	    CARD32	r;
-
-	    a = *mask++;
-	    d = *dst;
-
-	    m = FbInU (sa, 0, a, tmp);
-	    r = FbInU (m, 0, d, tmp);
-
-	    *dst++ = r;
-	}
-    }
-
-    _mm_empty();
-}
-
-void
-fbCompositeIn_8x8mmx (CARD8	op,
-		      PicturePtr pSrc,
-		      PicturePtr pMask,
-		      PicturePtr pDst,
-		      INT16      xSrc,
-		      INT16      ySrc,
-		      INT16      xMask,
-		      INT16      yMask,
-		      INT16      xDst,
-		      INT16      yDst,
-		      CARD16     width,
-		      CARD16     height)
-{
-    CARD8	*dstLine, *dst;
-    CARD8	*srcLine, *src;
-    FbStride	srcStride, dstStride;
-    CARD16	w;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
-
-    while (height--)
+    if (bpp == 16)
     {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	if ((((unsigned long)pDst & 3) == 0) &&
-	    (((unsigned long)pSrc & 3) == 0))
-	{
-	    while (w >= 4)
-	    {
-		CARD32 *s = (CARD32 *)src;
-		CARD32 *d = (CARD32 *)dst;
-
-		*d = store8888 (in (load8888 (*s), load8888 (*d)));
-
-		w -= 4;
-		dst += 4;
-		src += 4;
-	    }
-	}
-
-	while (w--)
-	{
-	    CARD8 s, d;
-	    CARD16 tmp;
-
-	    s = *src;
-	    d = *dst;
-
-	    *dst = FbInU (s, 0, d, tmp);
-
-	    src++;
-	    dst++;
-	}
+	stride = stride * sizeof (FbBits) / 2;
+	byte_line = (CARD8 *)(((CARD16 *)bits) + stride * (y + yoff) + (x + xoff));
+	byte_width = 2 * width;
+	stride *= 2;
     }
-
-    _mm_empty ();
-}
-
-void
-fbCompositeSrcAdd_8888x8x8mmx (CARD8   op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16      xSrc,
-			       INT16      ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height)
-{
-    CARD8	*dstLine, *dst;
-    CARD8	*maskLine, *mask;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    CARD32	src;
-    CARD8	sa;
-    __m64	vsrc, vsrca;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    sa = src >> 24;
-    if (sa == 0)
-	return;
-
-    vsrc = load8888(src);
-    vsrca = expand_alpha(vsrc);
-
-    while (height--)
+    else
     {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	if ((((unsigned long)pMask & 3) == 0) &&
-	    (((unsigned long)pDst  & 3) == 0))
-	{
-	    while (w >= 4)
-	    {
-		__m64 vmask = load8888 (*(CARD32 *)mask);
-		__m64 vdest = load8888 (*(CARD32 *)dst);
-
-		*(CARD32 *)dst = store8888 (_mm_adds_pu8 (in (vsrca, vmask), vdest));
-
-		w -= 4;
-		dst += 4;
-		mask += 4;
-	    }
-	}
-
-	while (w--)
-	{
-	    CARD16	tmp;
-	    CARD16	a;
-	    CARD32	m, d;
-	    CARD32	r;
-
-	    a = *mask++;
-	    d = *dst;
-
-	    m = FbInU (sa, 0, a, tmp);
-	    r = FbAdd (m, d, 0, tmp);
-
-	    *dst++ = r;
-	}
+	stride = stride * sizeof (FbBits) / 4;
+	byte_line = (CARD8 *)(((CARD32 *)bits) + stride * (y + yoff) + (x + xoff));
+	byte_width = 4 * width;
+	stride *= 4;
     }
-
-    _mm_empty();
-}
-
-void
-fbCompositeSrcAdd_8000x8000mmx (CARD8	op,
-				PicturePtr pSrc,
-				PicturePtr pMask,
-				PicturePtr pDst,
-				INT16      xSrc,
-				INT16      ySrc,
-				INT16      xMask,
-				INT16      yMask,
-				INT16      xDst,
-				INT16      yDst,
-				CARD16     width,
-				CARD16     height)
-{
-    CARD8	*dstLine, *dst;
-    CARD8	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    CARD8	s, d;
-    CARD16	t;
     
-    CHECKPOINT();
+    fill = ((ullong)xor << 32) | xor;
+    vfill = (__m64)fill;
     
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
+#ifdef __GNUC__
+    __asm__ (
+	"movq		%7,	%0\n"
+	"movq		%7,	%1\n"
+	"movq		%7,	%2\n"
+	"movq		%7,	%3\n"
+	"movq		%7,	%4\n"
+	"movq		%7,	%5\n"
+	"movq		%7,	%6\n"
+	: "=y" (v1), "=y" (v2), "=y" (v3),
+	  "=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
+	: "y" (vfill));
+#endif
     
     while (height--)
     {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-	
-	while (w && (unsigned long)dst & 7)
-	{
-	    s = *src;
-	    d = *dst;
-	    t = d + s;
-	    s = t | (0 - (t >> 8));
-	    *dst = s;
-	    
-	    dst++;
-	    src++;
-	    w--;
-	}
+	int w;
+	CARD8 *d = byte_line;
+	byte_line += stride;
+	w = byte_width;
 	
-	while (w >= 8)
+	while (w >= 2 && ((unsigned long)d & 3))
 	{
-	    *(__m64*)dst = _mm_adds_pu8(*(__m64*)src, *(__m64*)dst);
-	    dst += 8;
-	    src += 8;
-	    w -= 8;
+	    *(CARD16 *)d = xor;
+	    w -= 2;
+	    d += 2;
 	}
 	
-	while (w)
+	while (w >= 4 && ((unsigned long)d & 7))
 	{
-	    s = *src;
-	    d = *dst;
-	    t = d + s;
-	    s = t | (0 - (t >> 8));
-	    *dst = s;
+	    *(CARD32 *)d = xor;
 	    
-	    dst++;
-	    src++;
-	    w--;
+	    w -= 4;
+	    d += 4;
 	}
-    }
-    
-    _mm_empty();
-}
 
-void
-fbCompositeSrcAdd_8888x8888mmx (CARD8		op,
-				PicturePtr	pSrc,
-				PicturePtr	pMask,
-				PicturePtr	 pDst,
-				INT16		 xSrc,
-				INT16      ySrc,
-				INT16      xMask,
-				INT16      yMask,
-				INT16      xDst,
-				INT16      yDst,
-				CARD16     width,
-				CARD16     height)
-{
-    CARD32	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    
-    CHECKPOINT();
-    
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-	
-	while (w && (unsigned long)dst & 7)
+	while (w >= 64)
 	{
-	    *dst = _mm_cvtsi64_si32(_mm_adds_pu8(_mm_cvtsi32_si64(*src),
-						 _mm_cvtsi32_si64(*dst)));
-	    dst++;
-	    src++;
-	    w--;
+#ifdef __GNUC__
+	    __asm__ (
+		"movq	%1,	  (%0)\n"
+		"movq	%2,	 8(%0)\n"
+		"movq	%3,	16(%0)\n"
+		"movq	%4,	24(%0)\n"
+		"movq	%5,	32(%0)\n"
+		"movq	%6,	40(%0)\n"
+		"movq	%7,	48(%0)\n"
+		"movq	%8,	56(%0)\n"
+		:
+		: "r" (d),
+		  "y" (vfill), "y" (v1), "y" (v2), "y" (v3),
+		  "y" (v4), "y" (v5), "y" (v6), "y" (v7)
+		: "memory");
+#else
+	    *(__m64*) (d +  0) = vfill;
+	    *(__m64*) (d +  8) = vfill;
+	    *(__m64*) (d + 16) = vfill;
+	    *(__m64*) (d + 24) = vfill;
+	    *(__m64*) (d + 32) = vfill;
+	    *(__m64*) (d + 40) = vfill;
+	    *(__m64*) (d + 48) = vfill;
+	    *(__m64*) (d + 56) = vfill;
+#endif    
+	    w -= 64;
+	    d += 64;
 	}
 	
-	while (w >= 2)
+	while (w >= 4)
 	{
-	    *(ullong*)dst = (ullong) _mm_adds_pu8(*(__m64*)src, *(__m64*)dst);
-	    dst += 2;
-	    src += 2;
-	    w -= 2;
+	    *(CARD32 *)d = xor;
+	    
+	    w -= 4;
+	    d += 4;
 	}
-	
-	if (w)
+	if (w >= 2)
 	{
-	    *dst = _mm_cvtsi64_si32(_mm_adds_pu8(_mm_cvtsi32_si64(*src),
-						 _mm_cvtsi32_si64(*dst)));
-	    
+	    *(CARD16 *)d = xor;
+	    w -= 2;
+	    d += 2;
 	}
     }
     
     _mm_empty();
+    return TRUE;
 }
 
 Bool
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index ca9c7e7..43079e9 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -44,226 +44,6 @@ Bool fbHaveMMX(void);
 
 #ifdef USE_MMX
 
-void fbComposeSetupMMX(void);
-
-void fbCompositeSolidMask_nx8888x0565Cmmx (CARD8      op,
-					   PicturePtr pSrc,
-					   PicturePtr pMask,
-					   PicturePtr pDst,
-					   INT16      xSrc,
-					   INT16      ySrc,
-					   INT16      xMask,
-					   INT16      yMask,
-					   INT16      xDst,
-					   INT16      yDst,
-					   CARD16     width,
-					   CARD16     height);
-void fbCompositeSrcAdd_8888x8888mmx (CARD8	op,
-				     PicturePtr	pSrc,
-				     PicturePtr	pMask,
-				     PicturePtr	pDst,
-				     INT16	xSrc,
-				     INT16      ySrc,
-				     INT16      xMask,
-				     INT16      yMask,
-				     INT16      xDst,
-				     INT16      yDst,
-				     CARD16     width,
-				     CARD16     height);
-void fbCompositeSrc_8888x8888mmx (CARD8		op,
-				  PicturePtr	pSrc,
-				  PicturePtr	pMask,
-				  PicturePtr	pDst,
-				  INT16		xSrc,
-				  INT16		ySrc,
-				  INT16		xMask,
-				  INT16		yMask,
-				  INT16		xDst,
-				  INT16		yDst,
-				  CARD16	width,
-				  CARD16	height);
-void
-fbCompositeSolidMaskSrc_nx8x8888mmx (CARD8      op,
-				     PicturePtr pSrc,
-				     PicturePtr pMask,
-				     PicturePtr pDst,
-				     INT16      xSrc,
-				     INT16      ySrc,
-				     INT16      xMask,
-				     INT16      yMask,
-				     INT16      xDst,
-				     INT16      yDst,
-				     CARD16     width,
-				     CARD16     height);
-void
-fbCompositeSrc_x888x8x8888mmx (CARD8	op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16	xSrc,
-			       INT16	ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height);
-void fbCompositeSolidMask_nx8888x8888Cmmx (CARD8	op,
-					   PicturePtr	pSrc,
-					   PicturePtr	pMask,
-					   PicturePtr	pDst,
-					   INT16	xSrc,
-					   INT16	ySrc,
-					   INT16	xMask,
-					   INT16	yMask,
-					   INT16	xDst,
-					   INT16	yDst,
-					   CARD16	width,
-					   CARD16	height);
-void fbCompositeSolidMask_nx8x8888mmx (CARD8      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
-void fbCompositeIn_nx8x8mmx (CARD8	op,
-			PicturePtr pSrc,
-			PicturePtr pMask,
-			PicturePtr pDst,
-			INT16      xSrc,
-			INT16      ySrc,
-			INT16      xMask,
-			INT16      yMask,
-			INT16      xDst,
-			INT16      yDst,
-			CARD16     width,
-			CARD16     height);
-void fbCompositeIn_8x8mmx (CARD8	op,
-		      PicturePtr pSrc,
-		      PicturePtr pMask,
-		      PicturePtr pDst,
-		      INT16      xSrc,
-		      INT16      ySrc,
-		      INT16      xMask,
-		      INT16      yMask,
-		      INT16      xDst,
-		      INT16      yDst,
-		      CARD16     width,
-		      CARD16     height);
-void fbCompositeSrcAdd_8888x8x8mmx (CARD8   op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16      xSrc,
-			       INT16      ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height);
-void fbCompositeSrcAdd_8000x8000mmx (CARD8	op,
-				     PicturePtr pSrc,
-				     PicturePtr pMask,
-				     PicturePtr pDst,
-				     INT16      xSrc,
-				     INT16      ySrc,
-				     INT16      xMask,
-				     INT16      yMask,
-				     INT16      xDst,
-				     INT16      yDst,
-				     CARD16     width,
-				     CARD16     height);
-void fbCompositeSrc_8888RevNPx8888mmx (CARD8      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
-void fbCompositeSrc_8888x0565mmx (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height);
-void fbCompositeSrc_8888RevNPx0565mmx (CARD8      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
-void fbCompositeSolid_nx8888mmx (CARD8		op,
-				 PicturePtr	pSrc,
-				 PicturePtr	pMask,
-				 PicturePtr	pDst,
-				 INT16		xSrc,
-				 INT16		ySrc,
-				 INT16		xMask,
-				 INT16		yMask,
-				 INT16		xDst,
-				 INT16		yDst,
-				 CARD16		width,
-				 CARD16		height);
-void fbCompositeSolid_nx0565mmx (CARD8		op,
-				 PicturePtr	pSrc,
-				 PicturePtr	pMask,
-				 PicturePtr	pDst,
-				 INT16		xSrc,
-				 INT16		ySrc,
-				 INT16		xMask,
-				 INT16		yMask,
-				 INT16		xDst,
-				 INT16		yDst,
-				 CARD16		width,
-				 CARD16		height);
-void fbCompositeSolidMask_nx8x0565mmx (CARD8      op,
-				       PicturePtr pSrc,
-				       PicturePtr pMask,
-				       PicturePtr pDst,
-				       INT16      xSrc,
-				       INT16      ySrc,
-				       INT16      xMask,
-				       INT16      yMask,
-				       INT16      xDst,
-				       INT16      yDst,
-				       CARD16     width,
-				       CARD16     height);
-void fbCompositeSrc_8888x8x8888mmx (CARD8	op,
-				    PicturePtr  pSrc,
-				    PicturePtr  pMask,
-				    PicturePtr  pDst,
-				    INT16	xSrc,
-				    INT16	ySrc,
-				    INT16       xMask,
-				    INT16       yMask,
-				    INT16       xDst,
-				    INT16       yDst,
-				    CARD16      width,
-				    CARD16      height);
 Bool fbCopyAreammx (DrawablePtr	pSrc,
 		    DrawablePtr	pDst,
 		    int		src_x,
diff --git a/render/mipict.c b/render/mipict.c
index 3d6c1ae..dff7f5e 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -1,4 +1,4 @@
- /*
+/*
  *
  * Copyright © 1999 Keith Packard
  *
diff-tree dfbe32b5b828cc4e3da36a0e2e6ad641164eaa5e (from 75dece08fb72803d5116e6776e9f1534ff20e37b)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Jun 4 18:07:00 2007 -0400

    Remove the old Kerberos 5 authentication code.
    
    Before you complain, this code hasn't seen material change since at least
    X11R6.  It certainly does not build with any modern version of Kerberos.
    Anybody wanting krb5 auth to their X server should probably be using
    GSSAPI instead of internal krb5 API anyway.

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 6aba9db..c313796 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -996,10 +996,6 @@ ProcGetAtomName(ClientPtr client)
     }
 }
 
-#ifdef K5AUTH
-extern int k5_bad();
-#endif
-
 int
 ProcSetSelectionOwner(ClientPtr client)
 {
@@ -3541,12 +3537,6 @@ InitProcVectors(void)
             ProcVector[i] = SwappedProcVector[i] = ProcBadRequest;
 	    ReplySwapVector[i] = ReplyNotSwappd;
 	}
-#ifdef K5AUTH
-	if (!k5_Vector[i])
-	{
-	    k5_Vector[i] = k5_bad;
-	}
-#endif
     }
     for(i = LASTEvent; i < 128; i++)
     {
diff --git a/dix/tables.c b/dix/tables.c
index 258ac03..2200e3c 100644
--- a/dix/tables.c
+++ b/dix/tables.c
@@ -61,11 +61,6 @@ SOFTWARE.
 #include "swaprep.h"
 #include "swapreq.h"
 
-#ifdef K5AUTH
-extern int
-    k5_stage1(), k5_stage2(), k5_stage3(), k5_bad();
-#endif
-
 int (* InitialVector[3]) (
 	ClientPtr /* client */
     ) =
@@ -515,13 +510,3 @@ _X_EXPORT ReplySwapPtr ReplySwapVector[2
     ReplyNotSwappd,				/* NoOperation */
     ReplyNotSwappd
 };
-
-#ifdef K5AUTH
-int (*k5_Vector[256])() =
-{
-    k5_bad,
-    k5_stage1,
-    k5_bad,
-    k5_stage3
-};
-#endif
diff --git a/include/dixstruct.h b/include/dixstruct.h
index b5ffcca..dd6347f 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -207,10 +207,6 @@ extern int (* ProcVector[256]) (ClientPt
 
 extern int (* SwappedProcVector[256]) (ClientPtr /*client*/);
 
-#ifdef K5AUTH
-extern int (*k5_Vector[256])(ClientPtr /*client*/);
-#endif
-
 extern ReplySwapPtr ReplySwapVector[256];
 
 extern int ProcBadRequest(ClientPtr /*client*/);
diff --git a/os/Makefile.am b/os/Makefile.am
index d8d1405..c5e7b03 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -3,7 +3,6 @@ noinst_LTLIBRARIES = libos.la libcwrappe
 AM_CFLAGS = $(DIX_CFLAGS)
 
 # FIXME: Add support for these in configure.ac
-K5AUTH_SRCS = k5auth.c
 SECURERPC_SRCS = rpcauth.c
 INTERNALMALLOC_SRCS = xalloc.c
 
@@ -48,7 +47,7 @@ libcwrapper_la_CFLAGS = \
 	-I$(top_srcdir)/hw/xfree86/os-support \
 	$(AM_CFLAGS)
 
-EXTRA_DIST = $(K5AUTH_SRCS) $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \
+EXTRA_DIST = $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \
      $(XCSECURITY_SRCS) $(XDMCP_SRCS) $(STRLCAT_SRCS)
 
 if XSERVER_DTRACE
diff --git a/os/access.c b/os/access.c
index 221b8cb..2de0ead 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1169,10 +1169,6 @@ ResetHosts (char *display)
     struct nodeent 	*np;
     struct dn_naddr 	dnaddr, *dnaddrp, *dnet_addr();
 #endif
-#ifdef K5AUTH
-    krb5_principal      princ;
-    krb5_data		kbuf;
-#endif
     int			family = 0;
     pointer		addr;
     int 		len;
@@ -1252,13 +1248,6 @@ ResetHosts (char *display)
 	    hostname = ohostname + 4;
 	}
 #endif
-#ifdef K5AUTH
-	else if (!strncmp("krb:", lhostname, 4))
-	{
-	    family = FamilyKrb5Principal;
-	    hostname = ohostname + 4;
-	}
-#endif
 	else if (!strncmp("si:", lhostname, 3))
 	{
 	    family = FamilyServerInterpreted;
@@ -1301,16 +1290,6 @@ ResetHosts (char *display)
     	}
 	else
 #endif /* DNETCONN */
-#ifdef K5AUTH
-	if (family == FamilyKrb5Principal)
-	{
-            krb5_parse_name(hostname, &princ);
-	    XauKrb5Encode(princ, &kbuf);
-	    (void) NewHost(FamilyKrb5Principal, kbuf.data, kbuf.length, FALSE);
-	    krb5_free_principal(princ);
-        }
-	else
-#endif
 #ifdef SECURE_RPC
 	if ((family == FamilyNetname) || (strchr(hostname, '@')))
 	{
@@ -1552,11 +1531,6 @@ AddHost (ClientPtr	client,
 	len = length;
 	LocalHostEnabled = TRUE;
 	break;
-#ifdef K5AUTH
-    case FamilyKrb5Principal:
-        len = length;
-        break;
-#endif
 #ifdef SECURE_RPC
     case FamilyNetname:
 	len = length;
@@ -1655,11 +1629,6 @@ RemoveHost (
 	len = length;
 	LocalHostEnabled = FALSE;
 	break;
-#ifdef K5AUTH
-    case FamilyKrb5Principal:
-        len = length;
-	break;
-#endif
 #ifdef SECURE_RPC
     case FamilyNetname:
 	len = length;
diff --git a/os/auth.c b/os/auth.c
index b06333e..b2a145f 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -35,9 +35,6 @@ from The Open Group.
 #include <dix-config.h>
 #endif
 
-#ifdef K5AUTH
-# include   <krb5/krb5.h>
-#endif
 # include   <X11/X.h>
 # include   <X11/Xauth.h>
 # include   "misc.h"
@@ -92,15 +89,6 @@ static struct protocol   protocols[] = {
 #endif
 },
 #endif
-#ifdef K5AUTH
-{   (unsigned short) 14, "MIT-KERBEROS-5",
-		K5Add, K5Check, K5Reset,
-		K5ToID, K5FromID, K5Remove,
-#ifdef XCSECURITY
-		NULL
-#endif
-},
-#endif
 #ifdef XCSECURITY
 {   (unsigned short) XSecurityAuthorizationNameLen,
 	XSecurityAuthorizationName,
diff --git a/os/k5auth.c b/os/k5auth.c
deleted file mode 100644
index 7bc0ce8..0000000
--- a/os/k5auth.c
+++ /dev/null
@@ -1,799 +0,0 @@
-/*
-
-Copyright 1993, 1994, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-
-*/
-
-/*
- * Kerberos V5 authentication scheme
- * Author: Tom Yu <tlyu at MIT.EDU>
- *
- * Mostly snarfed wholesale from the user_user demo in the
- * krb5 distribution. (At least the checking part)
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#ifdef TCPCONN
-#include <netinet/in.h>
-#endif
-#ifdef DNETCONN
-#include <netdnet/dn.h>
-#endif
-#include <arpa/inet.h>
-#include <krb5/krb5.h>
-/* 9/93: krb5.h leaks some symbols */
-#undef BITS32
-#undef xfree
-#include <krb5/los-proto.h>
-#include <X11/X.h>
-#include "os.h"
-#include "osdep.h"
-#include <X11/Xproto.h>
-#include <X11/Xfuncs.h>
-#include "dixstruct.h"
-#include <com_err.h>
-#include "Xauth.h"
-
-extern int (*k5_Vector[256])();
-extern int SendConnSetup();
-extern char *display;		/* need this to generate rcache name */
-
-static XID krb5_id = ~0L;
-static krb5_principal srvname = NULL; /* service name */
-static char *ccname = NULL;
-static char *ktname = NULL;	/* key table name */
-static char kerror[256];
-
-/*
- * tgt_keyproc:
- *
- * extract session key from a credentials struct
- */
-krb5_error_code tgt_keyproc(keyprocarg, principal, vno, key)
-    krb5_pointer keyprocarg;
-    krb5_principal principal;
-    krb5_kvno vno;
-    krb5_keyblock **key;
-{
-    krb5_creds *creds = (krb5_creds *)keyprocarg;
-    
-    return krb5_copy_keyblock(&creds->keyblock, key);
-}
-
-/*
- * k5_cmpenc:
- *
- * compare "encoded" principals
- */
-Bool k5_cmpenc(pname, plen, buf)
-    unsigned char *pname;
-    short plen;
-    krb5_data *buf;
-{
-    return (plen == buf->length &&
-	    memcmp(pname, buf->data, plen) == 0);
-}
-
-/*
- * K5Check:
- *
- * This is stage 0 of the krb5 authentication protocol.  It
- * goes through the current credentials cache and extracts the
- * primary principal and tgt to send to the client, or as
- * appropriate, extracts from a keytab.
- *
- * The packet sent to the client has the following format:
- *
- * CARD8	reqType	= 2
- * CARD8	data	= 0
- * CARD16	length	= total length of packet (in 32 bit units)
- * CARD16	plen	= length of encoded principal following
- * STRING8	princ	= encoded principal
- * STRING8	ticket	= server tgt
- *
- * For client-server authentication, the packet is as follows:
- *
- * CARD8	reqType	= 3
- * CARD8	data	= 0
- * CARD16	length	= total length
- * STRING8	princ	= encoded principal of server
- */
-XID K5Check(data_length, data, client, reason)
-    unsigned short data_length;
-    char *data;
-    ClientPtr client;
-    char **reason;
-{
-    krb5_error_code retval;
-    CARD16 tlen;
-    krb5_principal sprinc, cprinc;
-    krb5_ccache cc;
-    krb5_creds *creds;
-    char *outbuf, *cp;
-    krb5_data princ;
-    register char n;
-    xReq prefix;
-
-    if (krb5_id == ~0L)
-	return ~0L;
-    if (!ccname && !srvname)
-	return ~0L;
-    if (ccname)
-    {
-	if ((creds = (krb5_creds *)malloc(sizeof(krb5_creds))) == NULL)
-	    return ~0L;
-	if (retval = krb5_cc_resolve(ccname, &cc))
-	    return ~0L;
-	bzero((char*)creds, sizeof (krb5_creds));
-	if (retval = krb5_cc_get_principal(cc, &cprinc))
-	{
-	    krb5_free_creds(creds);
-	    krb5_cc_close(cc);
-	    return ~0L;
-	}
-	creds->client = cprinc;
-	if (retval =
-	    krb5_build_principal_ext(&sprinc, 
-				     krb5_princ_realm(creds->client)->length,
-				     krb5_princ_realm(creds->client)->data,
-				     6, "krbtgt",
-				     krb5_princ_realm(creds->client)->length,
-				     krb5_princ_realm(creds->client)->data,
-				     0))
-	{
-	    krb5_free_creds(creds);
-	    krb5_cc_close(cc);
-	    return ~0L;
-	}
-	creds->server = sprinc;
-	retval = krb5_get_credentials(KRB5_GC_CACHED, cc, creds);
-	krb5_cc_close(cc);
-	if (retval)
-	{
-	    krb5_free_creds(creds);
-	    return ~0L;
-	}
-	if (retval = XauKrb5Encode(cprinc, &princ))
-	{
-	    krb5_free_creds(creds);
-	    return ~0L;
-	}
-	tlen = sz_xReq + 2 + princ.length + creds->ticket.length;
-	prefix.reqType = 2;	/* opcode = authenticate user-to-user */
-    }
-    else if (srvname)
-    {
-	if (retval = XauKrb5Encode(srvname, &princ))
-	{
-	    return ~0L;
-	}
-	tlen = sz_xReq + princ.length;
-	prefix.reqType = 3;	/* opcode = authenticate client-server */
-    }
-    prefix.data = 0;		/* stage = 0 */
-    prefix.length = (tlen + 3) >> 2; /* round up to nearest multiple
-					of 4 bytes */
-    if (client->swapped)
-    {
-	swaps(&prefix.length, n);
-    }
-    if ((cp = outbuf = (char *)malloc(tlen)) == NULL)
-    {
-	if (ccname)
-	{
-	    krb5_free_creds(creds);
-	}
-	free(princ.data);
-	return ~0L;
-    }
-    memcpy(cp, &prefix, sz_xReq);
-    cp += sz_xReq;
-    if (ccname)
-    {
-	memcpy(cp, &princ.length, 2);
-	if (client->swapped)
-	{
-	    swaps((CARD16 *)cp, n);
-	}
-	cp += 2;
-    }
-    memcpy(cp, princ.data, princ.length);
-    cp += princ.length;
-    free(princ.data);		/* we don't need that anymore */
-    if (ccname)
-	memcpy(cp, creds->ticket.data, creds->ticket.length);
-    WriteToClient(client, tlen, outbuf);
-    free(outbuf);
-    client->requestVector = k5_Vector; /* hack in our dispatch vector */
-    client->clientState = ClientStateAuthenticating;
-    if (ccname)
-    {
-	((OsCommPtr)client->osPrivate)->authstate.srvcreds = (pointer)creds; /* save tgt creds */
-	((OsCommPtr)client->osPrivate)->authstate.ktname = NULL;
-	((OsCommPtr)client->osPrivate)->authstate.srvname = NULL;
-    }
-    if (srvname)
-    {
-	((OsCommPtr)client->osPrivate)->authstate.srvcreds = NULL;
-	((OsCommPtr)client->osPrivate)->authstate.ktname = (pointer)ktname;
-	((OsCommPtr)client->osPrivate)->authstate.srvname = (pointer)srvname;
-    }
-    ((OsCommPtr)client->osPrivate)->authstate.stageno = 1; /* next stage is 1 */
-    return krb5_id;
-}
-
-/*
- * k5_stage1:
- *
- * This gets called out of the dispatcher after K5Check frobs with the
- * client->requestVector.  It accepts the ap_req from the client and verifies
- * it.  In addition, if the client has set AP_OPTS_MUTUAL_REQUIRED, it then
- * sends an ap_rep to the client to achieve mutual authentication.
- *
- * client stage1 packet format is as follows:
- *
- * CARD8	reqType	= 1
- * CARD8	data	= ignored
- * CARD16	length	= total length
- * STRING8	data	= the actual ap_req
- *
- * stage2 packet sent back to client for mutual authentication:
- *
- * CARD8	reqType	= 2
- * CARD8	data	= 2
- * CARD16	length	= total length
- * STRING8	data	= the ap_rep
- */
-int k5_stage1(client)
-    register ClientPtr client;
-{
-    long addrlen;
-    krb5_error_code retval, retval2;
-    register char n;
-    struct sockaddr cli_net_addr;
-    xReq prefix;
-    krb5_principal cprinc;
-    krb5_data buf;
-    krb5_creds *creds = (krb5_creds *)((OsCommPtr)client->osPrivate)->authstate.srvcreds;
-    krb5_keyblock *skey;
-    krb5_address cli_addr, **localaddrs = NULL;
-    krb5_tkt_authent *authdat;
-    krb5_ap_rep_enc_part rep;
-    krb5_int32 ctime, cusec;
-    krb5_rcache rcache = NULL;
-    char *cachename = NULL, *rc_type = NULL, *rc_base = "rcX", *kt = NULL;
-    REQUEST(xReq);
-
-    if (((OsCommPtr)client->osPrivate)->authstate.stageno != 1)
-    {
-	if (creds)
-	    krb5_free_creds(creds);
-	return(SendConnSetup(client, "expected Krb5 stage1 packet"));
-    }
-    addrlen = sizeof (cli_net_addr);
-    if (getpeername(((OsCommPtr)client->osPrivate)->fd,
-		    &cli_net_addr, &addrlen) == -1)
-    {
-	if (creds)
-	    krb5_free_creds(creds);
-	return(SendConnSetup(client, "Krb5 stage1: getpeername failed"));
-    }
-    if (cli_net_addr.sa_family == AF_UNSPEC
-#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
-	|| cli_net_addr.sa_family == AF_UNIX
-#endif
-	)			/* assume local host */
-    {
-	krb5_os_localaddr(&localaddrs);
-	if (!localaddrs || !localaddrs[0])
-	{
-	    if (creds)
-		krb5_free_creds(creds);
-	    return(SendConnSetup(client, "Krb5 failed to get localaddrs"));
-	}
-	cli_addr.addrtype = localaddrs[0]->addrtype;
-	cli_addr.length = localaddrs[0]->length;
-	cli_addr.contents = localaddrs[0]->contents;
-    }
-    else
-    {
-	cli_addr.addrtype = cli_net_addr.sa_family; /* the values
-						       are compatible */
-	switch (cli_net_addr.sa_family)
-	{
-#ifdef TCPCONN
-	case AF_INET:
-	    cli_addr.length = sizeof (struct in_addr);
-	    cli_addr.contents =
-		(krb5_octet *)&((struct sockaddr_in *)&cli_net_addr)->sin_addr;
-	    break;
-#endif
-#ifdef DNETCONN
-	case AF_DECnet:
-	    cli_addr.length = sizeof (struct dn_naddr);
-	    cli_addr.contents =
-		(krb5_octet *)&((struct sockaddr_dn *)&cli_net_addr)->sdn_add;
-	    break;
-#endif
-	default:
-	    if (localaddrs)
-		krb5_free_addresses(localaddrs);
-	    if (creds)
-		krb5_free_creds(creds);
-	    sprintf(kerror, "Krb5 stage1: unknown address family %d from getpeername",
-		    cli_net_addr.sa_family);    
-	    return(SendConnSetup(client, kerror));
-	}
-    }
-    if ((rcache = (krb5_rcache)malloc(sizeof(*rcache))) == NULL)
-    {
-	if (localaddrs)
-	    krb5_free_addresses(localaddrs);
-	if (creds)
-	    krb5_free_creds(creds);
-	return(SendConnSetup(client, "malloc bombed for krb5_rcache"));
-    }
-    if ((rc_type = krb5_rc_default_type()) == NULL)
-	rc_type = "dfl";
-    if (retval = krb5_rc_resolve_type(&rcache, rc_type))
-    {
-	if (localaddrs)
-	    krb5_free_addresses(localaddrs);
-	if (creds)
-	    krb5_free_creds(creds);
-	free(rcache);
-	strcpy(kerror, "krb5_rc_resolve_type failed: ");
-	strncat(kerror, error_message(retval), 231);
-	return(SendConnSetup(client, kerror));
-    }
-    if ((cachename = (char *)malloc(strlen(rc_base) + strlen(display) + 1))
-	== NULL)
-    {
-	if (localaddrs)
-	    krb5_free_addresses(localaddrs);
-	if (creds)
-	    krb5_free_creds(creds);
-	free(rcache);
-	return(SendConnSetup(client, "Krb5: malloc bombed for cachename"));
-    }
-    strcpy(cachename, rc_base);
-    strcat(cachename, display);
-    if (retval = krb5_rc_resolve(rcache, cachename))
-    {
-	if (localaddrs)
-	    krb5_free_addresses(localaddrs);
-	if (creds)
-	    krb5_free_creds(creds);
-	free(rcache);
-	free(cachename);
-	strcpy(kerror, "krb5_rc_resolve failed: ");
-	strncat(kerror, error_message(retval), 236);
-	return(SendConnSetup(client, kerror));
-    }
-    free(cachename);
-    if (krb5_rc_recover(rcache))
-    {
-	extern krb5_deltat krb5_clockskew;
-	if (retval = krb5_rc_initialize(rcache, krb5_clockskew))
-	{
-	    if (localaddrs)
-		krb5_free_addresses(localaddrs);
-	    if (creds)
-		krb5_free_creds(creds);
-	    if (retval2 = krb5_rc_close(rcache))
-	    {
-		strcpy(kerror, "krb5_rc_close failed: ");
-		strncat(kerror, error_message(retval2), 238);
-		return(SendConnSetup(client, kerror));
-	    }
-	    free(rcache);
-	    strcpy(kerror, "krb5_rc_initialize failed: ");
-	    strncat(kerror, error_message(retval), 233);
-	    return(SendConnSetup(client, kerror));
-	}
-    }
-    buf.length = (stuff->length << 2) - sz_xReq;
-    buf.data = (char *)stuff + sz_xReq;
-    if (creds)
-    {
-	retval = krb5_rd_req(&buf,
-			     NULL, /* don't bother with server name */
-			     &cli_addr,
-			     NULL, /* no fetchfrom */
-			     tgt_keyproc,
-			     creds, /* credentials as arg to
-				       keyproc */
-			     rcache,
-			     &authdat);
-	krb5_free_creds(creds);
-    }
-    else if (kt = (char *)((OsCommPtr)client->osPrivate)->authstate.ktname)
-    {
-	retval = krb5_rd_req(&buf, srvname, &cli_addr, kt, NULL, NULL,
-			     rcache, &authdat);
-	((OsCommPtr)client->osPrivate)->authstate.ktname = NULL;
-    }
-    else
-    {
-	if (localaddrs)
-	    krb5_free_addresses(localaddrs);
-	return(SendConnSetup(client, "Krb5: neither srvcreds nor ktname set"));
-    }
-    if (localaddrs)
-	krb5_free_addresses(localaddrs);
-    if (rcache)
-    {
-	if (retval2 = krb5_rc_close(rcache))
-	{
-	    strcpy(kerror, "krb5_rc_close failed (2): ");
-	    strncat(kerror, error_message(retval2), 230);
-	    return(SendConnSetup(client, kerror));
-	}
-	free(rcache);
-    }
-    if (retval)
-    {
-	strcpy(kerror, "Krb5: Bad application request: ");
-	strncat(kerror, error_message(retval), 224);
-	return(SendConnSetup(client, kerror));
-    }
-    cprinc = authdat->ticket->enc_part2->client;
-    skey = authdat->ticket->enc_part2->session;
-    if (XauKrb5Encode(cprinc, &buf))
-    {
-	krb5_free_tkt_authent(authdat);
-	return(SendConnSetup(client, "XauKrb5Encode bombed"));
-    }
-    /*
-     * Now check to see if the principal we got is one that we want to let in
-     */
-    if (ForEachHostInFamily(FamilyKrb5Principal, k5_cmpenc, (pointer)&buf))
-    {
-	free(buf.data);
-	/*
-	 * The following deals with sending an ap_rep to the client to
-	 * achieve mutual authentication.  The client sends back a stage 3
-	 * packet if all is ok.
-	 */
-	if (authdat->ap_options | AP_OPTS_MUTUAL_REQUIRED)
-	{
-	    /*
-	     * stage 2: send ap_rep to client
-	     */
-	    if (retval = krb5_us_timeofday(&ctime, &cusec))
-	    {
-		krb5_free_tkt_authent(authdat);
-		strcpy(kerror, "error in krb5_us_timeofday: ");
-		strncat(kerror, error_message(retval), 234);
-		return(SendConnSetup(client, kerror));
-	    }
-	    rep.ctime = ctime;
-	    rep.cusec = cusec;
-	    rep.subkey = NULL;
-	    rep.seq_number = 0;
-	    if (retval = krb5_mk_rep(&rep, skey, &buf))
-	    {
-		krb5_free_tkt_authent(authdat);
-		strcpy(kerror, "error in krb5_mk_rep: ");
-		strncat(kerror, error_message(retval), 238);
-		return(SendConnSetup(client, kerror));
-	    }
-	    prefix.reqType = 2;	/* opcode = authenticate */
-	    prefix.data = 2;	/* stage = 2 */
-	    prefix.length = (buf.length + sz_xReq + 3) >> 2;
-	    if (client->swapped)
-	    {
-		swaps(&prefix.length, n);
-	    }
-	    WriteToClient(client, sz_xReq, (char *)&prefix);
-	    WriteToClient(client, buf.length, buf.data);
-	    free(buf.data);
-	    krb5_free_tkt_authent(authdat);
-	    ((OsCommPtr)client->osPrivate)->authstate.stageno = 3; /* expect stage3 packet */
-	    return(Success);
-	}
-	else
-	{
-	    free(buf.data);
-	    krb5_free_tkt_authent(authdat);
-	    return(SendConnSetup(client, NULL)); /* success! */
-	}
-    }
-    else
-    {
-	char *kname;
-	
-	krb5_free_tkt_authent(authdat);
-	free(buf.data);
-	retval = krb5_unparse_name(cprinc, &kname);
-	if (retval == 0)
-	{
-	    sprintf(kerror, "Principal \"%s\" is not authorized to connect",
-		    kname);
-	    if (kname)
-		free(kname);
-	    return(SendConnSetup(client, kerror));
-	}
-	else
-	    return(SendConnSetup(client,"Principal is not authorized to connect to Server"));
-    }
-}
-
-/*
- * k5_stage3:
- *
- * Get the short ack packet from the client.  This packet can conceivably
- * be expanded to allow for switching on end-to-end encryption.
- *
- * stage3 packet format:
- *
- * CARD8	reqType	= 3
- * CARD8	data	= ignored (for now)
- * CARD16	length	= should be zero
- */
-int k5_stage3(client)
-    register ClientPtr client;
-{
-    REQUEST(xReq);
-
-    if (((OsCommPtr)client->osPrivate)->authstate.stageno != 3)
-    {
-	return(SendConnSetup(client, "expected Krb5 stage3 packet"));
-    }
-    else
-	return(SendConnSetup(client, NULL)); /* success! */
-}
-
-k5_bad(client)
-    register ClientPtr client;
-{
-    if (((OsCommPtr)client->osPrivate)->authstate.srvcreds)
-	krb5_free_creds((krb5_creds *)((OsCommPtr)client->osPrivate)->authstate.srvcreds);
-    sprintf(kerror, "unrecognized Krb5 auth packet %d, expecting %d",
-	    ((xReq *)client->requestBuffer)->reqType,
-	    ((OsCommPtr)client->osPrivate)->authstate.stageno);
-    return(SendConnSetup(client, kerror));
-}
-
-/*
- * K5Add:
- *
- * Takes the name of a credentials cache and resolves it.  Also adds the
- * primary principal of the ccache to the acl.
- *
- * Now will also take a service name.
- */
-int K5Add(data_length, data, id)
-    unsigned short data_length;
-    char *data;
-    XID id;
-{
-    krb5_principal princ;
-    krb5_error_code retval;
-    krb5_keytab_entry tmp_entry;
-    krb5_keytab keytab;
-    krb5_kvno kvno = 0;
-    krb5_ccache cc;
-    char *nbuf, *cp;
-    krb5_data kbuf;
-    int i, ktlen;
-    
-    krb5_init_ets();		/* can't think of a better place to put it */
-    krb5_id = ~0L;
-    if (data_length < 3)
-	return 0;
-    if ((nbuf = (char *)malloc(data_length - 2)) == NULL)
-	return 0;
-    memcpy(nbuf, data + 3, data_length - 3);
-    nbuf[data_length - 3] = '\0';
-    if (ccname)
-    {
-	free(ccname);
-	ccname = NULL;
-    }
-    if (srvname)
-    {
-	krb5_free_principal(srvname);
-	srvname = NULL;
-    }
-    if (ktname)
-    {
-	free(ktname);
-	ktname = NULL;
-    }
-    if (!strncmp(data, "UU:", 3))
-    {
-	if (retval = krb5_cc_resolve(nbuf, &cc))
-	{
-	    ErrorF("K5Add: krb5_cc_resolve of \"%s\" failed: %s\n",
-		   nbuf, error_message(retval));
-	    free(nbuf);
-	    return 0;
-	}
-	if (cc && !(retval = krb5_cc_get_principal(cc, &princ)))
-	{
-	    if (XauKrb5Encode(princ, &kbuf))
-	    {
-		free(nbuf);
-		krb5_free_principal(princ);
-		krb5_cc_close(cc);
-		return 0;
-	    }
-	    if (krb5_cc_close(cc))
-		return 0;
-	    AddHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
-	    krb5_free_principal(princ);
-	    free(kbuf.data);
-	    ccname = nbuf;
-	    krb5_id = id;
-	    return 1;
-	}
-	else
-	{
-	    ErrorF("K5Add: getting principal from cache \"%s\" failed: %s\n",
-		   nbuf, error_message(retval));
-	}
-    }
-    else if (!strncmp(data, "CS:", 3))
-    {
-	if ((cp = strchr(nbuf, ',')) == NULL)
-	{
-	    free(nbuf);
-	    return 0;
-	}
-	*cp = '\0';		/* gross but it works :-) */
-	ktlen = strlen(cp + 1);
-	if ((ktname = (char *)malloc(ktlen + 1)) == NULL)
-	{
-	    free(nbuf);
-	    return 0;
-	}
-	strcpy(ktname, cp + 1);
-	retval = krb5_sname_to_principal(NULL, /* NULL for hostname uses
-						  local host name*/
-					 nbuf, KRB5_NT_SRV_HST,
-					 &srvname);
-	free(nbuf);
-	if (retval)
-	{
-	    free(ktname);
-	    ktname = NULL;
-	    return 0;
-	}
-	if (retval = krb5_kt_resolve(ktname, &keytab))
-	{
-	    free(ktname);
-	    ktname = NULL;
-	    krb5_free_principal(srvname);
-	    srvname = NULL;
-	    return 0;
-	}
-	retval = krb5_kt_get_entry(keytab, srvname, kvno, &tmp_entry);
-	krb5_kt_free_entry(&tmp_entry);
-	if (retval)
-	{
-	    free(ktname);
-	    ktname = NULL;
-	    krb5_free_principal(srvname);
-	    srvname = NULL;
-	    return 0;
-	}
-	if (XauKrb5Encode(srvname, &kbuf))
-	{
-	    free(ktname);
-	    ktname = NULL;
-	    krb5_free_principal(srvname);
-	    srvname = NULL;
-	    return 0;
-	}
-	AddHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
-	krb5_id = id;
-	return 1;
-    }
-    else
-    {
-	ErrorF("K5Add: credentials cache name \"%.*s\" in auth file: unknown type\n",
-	       data_length, data);
-    }
-    return 0;
-}
-
-/*
- * K5Reset:
- *
- * Reset krb5_id, also nuke the current principal from the acl.
- */
-int K5Reset()
-{
-    krb5_principal princ;
-    krb5_error_code retval;
-    krb5_ccache cc;
-    krb5_data kbuf;
-    int i;
-    
-    if (ccname)
-    {
-	if (retval = krb5_cc_resolve(ccname, &cc))
-	{
-	    free(ccname);
-	    ccname = NULL;
-	}
-	if (cc && !(retval = krb5_cc_get_principal(cc, &princ)))
-	{
-	    if (XauKrb5Encode(princ, &kbuf))
-		return 1;
-	    RemoveHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
-	    krb5_free_principal(princ);
-	    free(kbuf.data);
-	    if (krb5_cc_close(cc))
-		return 1;
-	    free(ccname);
-	    ccname = NULL;
-	}
-    }
-    if (srvname)
-    {
-	if (XauKrb5Encode(srvname, &kbuf))
-	    return 1;
-	RemoveHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
-	krb5_free_principal(srvname);
-	free(kbuf.data);
-	srvname = NULL;
-    }
-    if (ktname)
-    {
-	free(ktname);
-	ktname = NULL;
-    }
-    krb5_id = ~0L;
-    return 0;
-}
-
-XID K5ToID(data_length, data)
-    unsigned short data_length;
-    char *data;
-{
-    return krb5_id;
-}
-
-int K5FromID(id, data_lenp, datap)
-    XID id;
-    unsigned short *data_lenp;
-    char **datap;
-{
-    return 0;
-}
-
-int K5Remove(data_length, data)
-    unsigned short data_length;
-    char *data;
-{
-    return 0;
-}
diff --git a/os/osdep.h b/os/osdep.h
index 0984d51..04e88ea 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -145,16 +145,6 @@ typedef struct _connectionOutput {
     int count;
 } ConnectionOutput, *ConnectionOutputPtr;
 
-#ifdef K5AUTH
-typedef struct _k5_state {
-    int		stageno;	/* current stage of auth protocol */
-    pointer	srvcreds;	/* server credentials */
-    pointer	srvname;	/* server principal name */
-    pointer	ktname;		/* key table: principal-key pairs */
-    pointer	skey;		/* session key */
-}           k5_state;
-#endif
-
 struct _osComm;
 
 #define AuthInitArgs void
@@ -190,9 +180,6 @@ typedef struct _osComm {
     ConnectionInputPtr input;
     ConnectionOutputPtr output;
     XID	auth_id;		/* authorization id */
-#ifdef K5AUTH
-    k5_state	authstate;	/* state of setup auth conversation */
-#endif
     CARD32 conn_time;		/* timestamp if not established, else 0  */
     struct _XtransConnInfo *trans_conn; /* transport connection object */
 } OsCommRec, *OsCommPtr;
@@ -273,16 +260,6 @@ extern int  SecureRPCRemove   (AuthRemCA
 extern int  SecureRPCReset    (AuthRstCArgs);
 #endif
 
-/* in k5auth.c */
-#ifdef K5AUTH
-extern XID  K5Check           (AuthCheckArgs);
-extern XID  K5ToID            (AuthToIDArgs);
-extern int  K5Add             (AuthAddCArgs);
-extern int  K5FromID          (AuthFromIDArgs);
-extern int  K5Remove          (AuthRemCArgs);
-extern int  K5Reset           (AuthRstCArgs);
-#endif
-
 /* in secauth.c */
 extern XID AuthSecurityCheck (AuthCheckArgs);
 
diff-tree 75dece08fb72803d5116e6776e9f1534ff20e37b (from fbb9b203950e9d0e82574cde5b3e006b0e6b404f)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Mon Jun 4 09:09:20 2007 -0400

    xf86PostMotionEvents[P] calls xf86SendDragEvents, xf86SendDragEvents
    unconditionally checks device->button->buttonsDown.
    
    Let's make it possible to have a device with motion, but no buttons.
    
    Without segfaulting.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 207e792..5430020 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -101,7 +101,7 @@ xf86SendDragEvents(DeviceIntPtr	device)
 {
     LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
     
-    if (device->button->buttonsDown > 0)
+    if (device->button && device->button->buttonsDown > 0)
         return (local->flags & XI86_SEND_DRAG_EVENTS);
     else
         return (TRUE);
diff-tree fbb9b203950e9d0e82574cde5b3e006b0e6b404f (from 3f4295e643ca56c40f33af7966e8efd367ef8749)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Mon Jun 4 06:59:42 2007 -0400

    Let's not do a calloc and a free on every call to xf86PostMotionEvents.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 91e5fec..207e792 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -463,9 +463,18 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 {
     va_list var;
     int i = 0;
-    int *valuators = NULL;
-    
-    valuators = xcalloc(sizeof(int), num_valuators);
+    static int *valuators = NULL;
+    static int n_valuators = 0;
+
+    if (num_valuators > n_valuators) {
+	xfree (valuators);
+	valuators = NULL;
+    }
+
+    if (!valuators) {
+	valuators = xcalloc(sizeof(int), num_valuators);
+	n_valuators = num_valuators;
+    }
 
     va_start(var, num_valuators);
     for (i = 0; i < num_valuators; i++)
@@ -473,7 +482,6 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     va_end(var);
 
     xf86PostMotionEventP(device, is_absolute, first_valuator, num_valuators, valuators);
-    xfree(valuators);
 }
 
 _X_EXPORT void
diff-tree 3f4295e643ca56c40f33af7966e8efd367ef8749 (from a4f3473c88370b8411e016ebab619cffd33e58f9)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Mon Jun 4 06:48:06 2007 -0400

    Add xf86PostMotionEventP, takes a pointer instead of a variable number of
    arguments.
    
    Bump input ABI to 1.1 since we export this.

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 8e644c4..cdf3d1b 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -85,7 +85,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(2, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(1, 0)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(1, 1)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 5)
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 7a47276..91e5fec 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -462,25 +462,38 @@ xf86PostMotionEvent(DeviceIntPtr	device,
                     ...)
 {
     va_list var;
+    int i = 0;
+    int *valuators = NULL;
+    
+    valuators = xcalloc(sizeof(int), num_valuators);
+
+    va_start(var, num_valuators);
+    for (i = 0; i < num_valuators; i++)
+        valuators[i] = va_arg(var, int);
+    va_end(var);
+
+    xf86PostMotionEventP(device, is_absolute, first_valuator, num_valuators, valuators);
+    xfree(valuators);
+}
+
+_X_EXPORT void
+xf86PostMotionEventP(DeviceIntPtr	device,
+                    int			is_absolute,
+                    int			first_valuator,
+                    int			num_valuators,
+                    int			*valuators)
+{
     int i = 0, nevents = 0;
     int dx, dy;
     Bool drag = xf86SendDragEvents(device);
-    int *valuators = NULL;
-    int flags = 0;
     xEvent *xE = NULL;
     int index;
+    int flags = 0;
 
     if (is_absolute)
         flags = POINTER_ABSOLUTE;
     else
         flags = POINTER_RELATIVE | POINTER_ACCELERATE;
-    
-    valuators = xcalloc(sizeof(int), num_valuators);
-
-    va_start(var, num_valuators);
-    for (i = 0; i < num_valuators; i++)
-        valuators[i] = va_arg(var, int);
-    va_end(var);
 
 #if XFreeXDGA
     if (first_valuator == 0 && num_valuators >= 2) {
@@ -495,7 +508,7 @@ xf86PostMotionEvent(DeviceIntPtr	device,
                 dy = valuators[1];
             }
             if (DGAStealMotionEvent(index, dx, dy))
-                goto out;
+                return;
         }
     }
 #endif
@@ -517,9 +530,6 @@ xf86PostMotionEvent(DeviceIntPtr	device,
             mieqEnqueue(device, xf86Events + i);
         }
     }
-
-out:
-    xfree(valuators);
 }
 
 _X_EXPORT void
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 7ef28ed..f882b26 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -163,6 +163,8 @@ extern InputInfoPtr xf86InputDevs;
 void InitExtInput(void);
 void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute,
 			 int first_valuator, int num_valuators, ...);
+void xf86PostMotionEventP(DeviceIntPtr device, int is_absolute,
+			 int first_valuator, int num_valuators, int *valuators);
 void xf86PostProximityEvent(DeviceIntPtr device, int is_in,
 			    int first_valuator, int num_valuators, ...);
 void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute, int button,
diff-tree a4f3473c88370b8411e016ebab619cffd33e58f9 (from 0cbc3a4da2ddb6e4f30f60d2bc7f405d31aa554a)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Mon Jun 4 06:39:02 2007 -0400

    Fully init the AbsoluteClassRec in InitAbsoluteClassDeviceStruct.
    (Specificly, we were missing the screen field.)

diff --git a/dix/devices.c b/dix/devices.c
index da6e590..6c69454 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -901,6 +901,7 @@ InitAbsoluteClassDeviceStruct(DeviceIntP
     abs->width = -1;
     abs->height = -1;
     abs->following = 0;
+    abs->screen = 0;
 
     dev->absolute = abs;
 
diff-tree 0cbc3a4da2ddb6e4f30f60d2bc7f405d31aa554a (from 9a7aaeb3f6ff79af60fde91cd0575a54ba0b9587)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Mon Jun 4 02:03:44 2007 -0400

    Print the build time as well as the date if we can.

diff --git a/configure.ac b/configure.ac
index 350245e..1f94556 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1948,6 +1948,8 @@ AM_CONDITIONAL(SUN_KBD_MODE, [test x$KBD
 
 BUILD_DATE="$(date +'%Y%m%d')"
 AC_SUBST([BUILD_DATE])
+BUILD_TIME="$(date +'%H%M%S')"
+AC_SUBST([BUILD_TIME])
 
 DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
 
diff --git a/hw/xfree86/common/xf86Build.h.in b/hw/xfree86/common/xf86Build.h.in
index 3f25413..a4f56b0 100644
--- a/hw/xfree86/common/xf86Build.h.in
+++ b/hw/xfree86/common/xf86Build.h.in
@@ -1 +1,2 @@
 #define BUILD_DATE @BUILD_DATE@
+#define BUILD_TIME @BUILD_TIME@
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 221ab9a..8423fca 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1730,8 +1730,16 @@ xf86PrintBanner()
     t.tm_mday = BUILD_DATE % 100;
     t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
     t.tm_year = BUILD_DATE / 10000 - 1900;
+#if defined(BUILD_TIME)
+    t.tm_sec = BUILD_TIME % 100;
+    t.tm_min = (BUILD_TIME / 100) % 100;
+    t.tm_hour = (BUILD_TIME / 10000);
+    if (strftime(buf, sizeof(buf), "%d %B %Y  %I:%M:%s%p", &t))
+       ErrorF("Build Date: %s\n", buf);
+#else
     if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
        ErrorF("Build Date: %s\n", buf);
+#endif
   }
 #endif
 #if defined(CLOG_DATE) && (CLOG_DATE > 19000000)
diff-tree 9a7aaeb3f6ff79af60fde91cd0575a54ba0b9587 (from 94361cbba7f866144691f6f5e9251a550e0e0cb8)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon May 28 13:54:16 2007 +0300

    XFree86: Input: Assume core events per default
    
    Assume that a device will be sending core events, unless explicitly
    specified otherwise.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 5eede08..7a47276 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -119,10 +119,12 @@ _X_EXPORT void
 xf86ProcessCommonOptions(LocalDevicePtr local,
                          pointer	list)
 {
-    if (!xf86SetBoolOption(list, "AlwaysCore", 0) ||
-        xf86SetBoolOption(list, "SendCoreEvents", 0) ||
-        xf86SetBoolOption(list, "CorePointer", 0) ||
-        xf86SetBoolOption(list, "CoreKeyboard", 0)) {
+    if (xf86SetBoolOption(list, "AlwaysCore", 0) ||
+        !xf86SetBoolOption(list, "SendCoreEvents", 1) ||
+        !xf86SetBoolOption(list, "CorePointer", 1) ||
+        !xf86SetBoolOption(list, "CoreKeyboard", 1)) {
+        xf86Msg(X_CONFIG, "%s: doesn't report core events\n", local->name);
+    } else {
         local->flags |= XI86_ALWAYS_CORE;
         xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name);
     }
diff-tree 94361cbba7f866144691f6f5e9251a550e0e0cb8 (from e5ce982381c4092252d6b55fcefcc9a3cd21e656)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon May 28 13:54:47 2007 +0300

    XFree86: Input: Perform case-insensitive comparisons on option names

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 2d0a376..5eede08 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -329,7 +329,7 @@ NewInputDeviceRequest (InputOption *opti
         return BadAlloc;
 
     for (option = options; option; option = option->next) {
-        if (strcmp(option->key, "driver") == 0) {
+        if (strcasecmp(option->key, "driver") == 0) {
             if (idev->driver) {
                 rval = BadRequest;
                 goto unwind;
@@ -352,8 +352,8 @@ NewInputDeviceRequest (InputOption *opti
                 goto unwind;
             }
         }
-        if (strcmp(option->key, "name") == 0 ||
-            strcmp(option->key, "identifier") == 0) {
+        if (strcasecmp(option->key, "name") == 0 ||
+            strcasecmp(option->key, "identifier") == 0) {
             if (idev->identifier) {
                 rval = BadRequest;
                 goto unwind;
diff-tree e5ce982381c4092252d6b55fcefcc9a3cd21e656 (from 90eb22656c34d2d08a8dccaf05e6d081c56bd7f3)
Author: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Date:   Sun Jun 3 09:40:37 2007 +1000

    Include pixman.h from fb.h or compile of some files will fail
    
    Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

diff --git a/fb/fb.h b/fb/fb.h
index 7d94886..655d5ae 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -26,6 +26,8 @@
 #define _FB_H_
 
 #include <X11/X.h>
+#include <pixman/pixman.h>
+
 #include "scrnintstr.h"
 #include "pixmap.h"
 #include "pixmapstr.h"
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 00dde61..68c0e63 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -30,7 +30,6 @@
 #include <string.h>
 
 #include "fb.h"
-#include <pixman/pixman.h>
 
 #ifdef RENDER
 
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index 07b4fbb..8313068 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -30,8 +30,6 @@
 
 #ifdef RENDER
 
-#include <pixman/pixman.h>
-
 #include "picturestr.h"
 #include "mipict.h"
 #include "renderedge.h"
diff-tree 90eb22656c34d2d08a8dccaf05e6d081c56bd7f3 (from f6a983533bdc84752562ef0be25b320678bf08a1)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sat Jun 2 16:49:26 2007 -0400

    Minor cleanup/robustification to config parsing.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 877ea62..8e58bef 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -131,9 +131,9 @@ static Bool configInput(IDevPtr inputp, 
 static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
 static Bool addDefaultModes(MonPtr monitorp);
 #ifdef XF86DRI
-static Bool configDRI(XF86ConfDRIPtr drip);
+static void configDRI(XF86ConfDRIPtr drip);
 #endif
-static Bool configExtensions(XF86ConfExtensionsPtr conf_ext);
+static void configExtensions(XF86ConfExtensionsPtr conf_ext);
 
 /*
  * xf86GetPathElem --
@@ -598,7 +598,7 @@ xf86ConfigError(char *msg, ...)
     return;
 }
 
-static Bool
+static void
 configFiles(XF86ConfFilesPtr fileconf)
 {
   MessageType pathFrom = X_DEFAULT;
@@ -2228,7 +2228,7 @@ configDevice(GDevPtr devicep, XF86ConfDe
 }
 
 #ifdef XF86DRI
-static Bool
+static void
 configDRI(XF86ConfDRIPtr drip)
 {
     int                count = 0;
@@ -2269,12 +2269,10 @@ configDRI(XF86ConfDRIPtr drip)
 	    xf86ConfigDRI.bufs[i].flags = 0;
 	}
     }
-
-    return TRUE;
 }
 #endif
 
-static Bool
+static void
 configExtensions(XF86ConfExtensionsPtr conf_ext)
 {
     XF86OptionPtr o;
@@ -2309,11 +2307,9 @@ configExtensions(XF86ConfExtensionsPtr c
 		       xf86NameCmp(val, "false") == 0) {
 		enable = !enable;
 	    } else {
-		xf86Msg(X_ERROR,
-			"%s is not a valid value for the Extension option\n",
-			val);
+		xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
 		xfree(n);
-		return FALSE;
+		continue;
 	    }
 
 	    if (EnableDisableExtension(name, enable)) {
@@ -2326,8 +2322,6 @@ configExtensions(XF86ConfExtensionsPtr c
 	    xfree(n);
 	}
     }
-
-    return TRUE;
 }
 
 static Bool
@@ -2510,19 +2504,17 @@ xf86HandleConfigFile(Bool autoconfig)
     }
 
     /* Now process everything else */
-
-    if (!configServerFlags(xf86configptr->conf_flags,
-			   xf86ConfigLayout.options) ||
-         !configFiles(xf86configptr->conf_files) ||
-	!configExtensions(xf86configptr->conf_extensions)
-#ifdef XF86DRI
-	|| !configDRI(xf86configptr->conf_dri)
-#endif
-       ) {
+    if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){
              ErrorF ("Problem when converting the config data structures\n");
              return CONFIG_PARSE_ERROR;
     }
 
+    configFiles(xf86configptr->conf_files);
+    configExtensions(xf86configptr->conf_extensions);
+#ifdef XF86DRI
+    configDRI(xf86configptr->conf_dri);
+#endif
+
     checkInput(&xf86ConfigLayout);
 
     /*
diff-tree f6a983533bdc84752562ef0be25b320678bf08a1 (from 21e8f4eb02842f877336db08c332d8ee4a381ee0)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sat Jun 2 16:37:39 2007 -0400

    Don't warn about default behaviour when autoconfigging.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 67e8af4..877ea62 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -615,7 +615,7 @@ configFiles(XF86ConfFilesPtr fileconf)
       pathFrom = X_CONFIG;
       if (*f) {
         if (xf86Info.useDefaultFontPath) {
-          xf86Msg(X_WARNING, "Including the default font path %s.\n", defaultFontPath);
+          xf86Msg(X_DEFAULT, "Including the default font path %s.\n", defaultFontPath);
           char *g = xnfalloc(strlen(defaultFontPath) + strlen(f) + 3);
           strcpy(g, f);
           strcat(g, ",");
@@ -632,7 +632,7 @@ configFiles(XF86ConfFilesPtr fileconf)
       }
     } 
    } else {
-      xf86Msg(X_WARNING,
+      xf86Msg(X_DEFAULT,
 	    "No FontPath specified.  Using compiled-in default.\n");
       pathFrom = X_DEFAULT;
    }
@@ -1474,13 +1474,13 @@ checkCoreInputDevices(serverLayoutPtr se
     }
 
     if (pointerMsg) {
-	xf86Msg(X_WARNING, "The core pointer device wasn't specified "
+	xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
 		"explicitly in the layout.\n"
 		"\tUsing the %s.\n", pointerMsg);
     }
 
     if (keyboardMsg) {
-	xf86Msg(X_WARNING, "The core keyboard device wasn't specified "
+	xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
 		"explicitly in the layout.\n"
 		"\tUsing the %s.\n", keyboardMsg);
     }
@@ -1937,7 +1937,7 @@ configScreen(confScreenPtr screenp, XF86
     }
 
     if (defaultMonitor) {
-	xf86Msg(X_WARNING, "No monitor specified for screen \"%s\".\n"
+	xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
 		"\tUsing a default monitor configuration.\n", screenp->id);
     }
     return TRUE;
@@ -2457,7 +2457,7 @@ xf86HandleConfigFile(Bool autoconfig)
 
     if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
 	if (xf86ScreenName == NULL) {
-	    xf86Msg(X_WARNING,
+	    xf86Msg(X_DEFAULT,
 		    "No Layout section.  Using the first Screen section.\n");
 	}
 	if (!configImpliedLayout(&xf86ConfigLayout,
diff-tree 21e8f4eb02842f877336db08c332d8ee4a381ee0 (from 0e1384d8318637f75d04d3d1b7600f7cad40117e)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sat Jun 2 16:13:01 2007 -0400

    Don't print lack of DRI support as an error in AIGLX init.

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index d93d460..156e846 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -1001,13 +1001,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     size_t buffer_size;
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
 
-    if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable")) {
-	LogMessage(X_ERROR, "AIGLX: DRI module not loaded\n");
-	return NULL;
-    }
-
-    if (!DRIQueryDirectRenderingCapable(pScreen, &isCapable) || !isCapable) {
-	LogMessage(X_ERROR,
+    if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") ||
+	!DRIQueryDirectRenderingCapable(pScreen, &isCapable) ||
+	!isCapable) {
+	LogMessage(X_INFO,
 		   "AIGLX: Screen %d is not DRI capable\n", pScreen->myNum);
 	return NULL;
     }
diff-tree 0e1384d8318637f75d04d3d1b7600f7cad40117e (from 66702f3c1c6c884e83744c72da173cc32f22b2f4)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sat Jun 2 16:07:20 2007 -0400

    Delete VDIF support; it was never used anyway.

diff --git a/hw/xfree86/ddc/Makefile.am b/hw/xfree86/ddc/Makefile.am
index 04d3e44..cd146c5 100644
--- a/hw/xfree86/ddc/Makefile.am
+++ b/hw/xfree86/ddc/Makefile.am
@@ -1,9 +1,9 @@
-sdk_HEADERS = edid.h vdif.h xf86DDC.h
+sdk_HEADERS = edid.h xf86DDC.h
 
 noinst_LIBRARIES = libddc.a
 
 libddc_a_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \
-                   interpret_vdif.c print_vdif.c ddcProperty.c
+                   ddcProperty.c
 
 INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
 
diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c
index 37efb5b..6ff0726 100644
--- a/hw/xfree86/ddc/ddcProperty.c
+++ b/hw/xfree86/ddc/ddcProperty.c
@@ -35,7 +35,6 @@
 
 #define EDID1_ATOM_NAME         "XFree86_DDC_EDID1_RAWDATA"
 #define EDID2_ATOM_NAME         "XFree86_DDC_EDID2_RAWDATA"
-#define VDIF_ATOM_NAME          "XFree86_DDC_VDIF_RAWDATA"
 
 static void
 addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
@@ -103,16 +102,6 @@ addRootWindowProperties(ScrnInfoPtr pScr
 	xf86RegisterRootWindowProperty(scrnIndex, EDID2Atom, XA_INTEGER, 8,
 		256, (unsigned char *)EDID2rawdata);
     }
-
-#if 0
-    if (DDC->vdif) {
-#define VDIF_DUMMY_STRING "setting dummy VDIF property - please insert correct values\n"
-
-	VDIFAtom = MakeAtom(VDIF_ATOM_NAME, sizeof(VDIF_ATOM_NAME), TRUE);
-	xf86RegisterRootWindowProperty(scrnIndex, VDIFAtom, XA_STRING, 8,
-		strlen(VDIF_DUMMY_STRING), VDIF_DUMMY_STRING);
-    }
-#endif
 }
 
 Bool
diff --git a/hw/xfree86/ddc/edid.h b/hw/xfree86/ddc/edid.h
index 30499a6..0b6a15a 100644
--- a/hw/xfree86/ddc/edid.h
+++ b/hw/xfree86/ddc/edid.h
@@ -12,8 +12,6 @@
 #ifndef _EDID_H_
 #define _EDID_H_ 
 
-#include "vdif.h"
-
 /* read complete EDID record */
 #define EDID1_LEN 128
 #define BITS_PER_BYTE 9
@@ -453,7 +451,7 @@ typedef struct {
   struct established_timings timings1;
   struct std_timings timings2[8];
   struct detailed_monitor_section det_mon[4];
-  xf86vdifPtr vdif;
+  void *vdif; /* unused */
   int no_sections;
   Uchar *rawData;
 } xf86Monitor, *xf86MonPtr;
diff --git a/hw/xfree86/ddc/interpret_vdif.c b/hw/xfree86/ddc/interpret_vdif.c
deleted file mode 100644
index 3a17e2f..0000000
--- a/hw/xfree86/ddc/interpret_vdif.c
+++ /dev/null
@@ -1,132 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/Xarch.h>
-#include "xf86DDC.h"
-#include "vdif.h"
-
-static xf86VdifLimitsPtr* get_limits(CARD8 *c);
-static xf86VdifGammaPtr* get_gamma(CARD8 *c);
-static xf86VdifTimingPtr* get_timings(CARD8 *c);
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-static CARD32 swap_byte_order(CARD32 c);
-#endif
-
-xf86vdifPtr
-xf86InterpretVdif(CARD8 *c)
-{
-    xf86VdifPtr p = (xf86VdifPtr)c;
-    xf86vdifPtr vdif;
-    int i;
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-    int length;
-#endif
-    unsigned long l = 0;
-
-    if (c == NULL) return NULL;
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-    length = swap_byte_order(p->FileLength);
-    for (i = 0; i < (length >>2); i++) 
-	((CARD32*)c)[i] = swap_byte_order(((CARD32*)c)[i]) ;
-#endif  
-    if (p->VDIFId[0] != 'V' || p->VDIFId[1] != 'D' || p->VDIFId[2] != 'I'
-	|| p->VDIFId[3] != 'F') return NULL;
-    for ( i = 12; i < p->FileLength; i++) 
-	l += c[i];
-    if ( l != p->Checksum) return NULL;
-    vdif = xalloc(sizeof(xf86vdif));  
-    vdif->vdif = p;
-    vdif->limits = get_limits(c);
-    vdif->timings = get_timings(c);
-    vdif->gamma = get_gamma(c);
-    vdif->strings = VDIF_STRING(((xf86VdifPtr)c),0);
-    xfree(c);
-    return vdif;
-}
-
-static xf86VdifLimitsPtr*
-get_limits(CARD8 *c)
-{ 
-    int num, i, j;
-    xf86VdifLimitsPtr *pp;
-    xf86VdifLimitsPtr p;
-
-    num = ((xf86VdifPtr)c)->NumberOperationalLimits;
-    pp = xalloc(sizeof(xf86VdifLimitsPtr) * (num+1));
-    p = VDIF_OPERATIONAL_LIMITS(((xf86VdifPtr)c));
-    j = 0;
-    for ( i = 0; i<num; i++) {
-	if (p->Header.ScnTag == VDIF_OPERATIONAL_LIMITS_TAG)
-	    pp[j++] = p;
-	VDIF_NEXT_OPERATIONAL_LIMITS(p);
-    }
-    pp[j] = NULL;
-    return pp;
-}
-
-static xf86VdifGammaPtr*
-get_gamma(CARD8 *c)
-{ 
-    int num, i, j;
-    xf86VdifGammaPtr *pp;
-    xf86VdifGammaPtr p;
-
-    num = ((xf86VdifPtr)c)->NumberOptions;
-    pp = xalloc(sizeof(xf86VdifGammaPtr) * (num+1));
-    p = (xf86VdifGammaPtr)VDIF_OPTIONS(((xf86VdifPtr)c));
-    j = 0;
-    for ( i = 0; i<num; i++)
-    {
-	if (p->Header.ScnTag == VDIF_GAMMA_TABLE_TAG)
-	    pp[j++] = p;
-	VDIF_NEXT_OPTIONS(p);
-    }
-    pp[j] = NULL;
-    return pp;
-}
-
-static xf86VdifTimingPtr*
-get_timings(CARD8 *c)
-{
-    int num, num_limits;
-    int i,j,k;
-    xf86VdifLimitsPtr lp;
-    xf86VdifTimingPtr *pp;
-    xf86VdifTimingPtr p;
-  
-    num = ((xf86VdifPtr)c)->NumberOperationalLimits;
-    lp = VDIF_OPERATIONAL_LIMITS(((xf86VdifPtr)c));
-    num_limits = 0;
-    for (i = 0; i < num; i++) {
-	if (lp->Header.ScnTag == VDIF_OPERATIONAL_LIMITS_TAG)
-	    num_limits += lp->NumberPreadjustedTimings;
-	VDIF_NEXT_OPERATIONAL_LIMITS(lp);
-    }
-    pp = xalloc(sizeof(xf86VdifTimingPtr) 
-				      * (num_limits+1));
-    j = 0;
-    lp = VDIF_OPERATIONAL_LIMITS(((xf86VdifPtr) c));
-    for (i = 0; i < num; i++) {
-	p = VDIF_PREADJUSTED_TIMING(lp);
-	for (k = 0; k < lp->NumberPreadjustedTimings; k++) {
-	    if (p->Header.ScnTag == VDIF_PREADJUSTED_TIMING_TAG)
-		pp[j++] = p;
-	    VDIF_NEXT_PREADJUSTED_TIMING(p);
-	}
-	VDIF_NEXT_OPERATIONAL_LIMITS(lp);
-    }
-    pp[j] = NULL;
-    return pp;
-}
-
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-static CARD32
-swap_byte_order(CARD32 c)
-{
-    return ((c & 0xFF000000) >> 24) | ((c & 0xFF0000) >> 8)
-	| ((c & 0xFF00) << 8) | ((c & 0xFF) << 24);
-}
-
-#endif
diff --git a/hw/xfree86/ddc/print_vdif.c b/hw/xfree86/ddc/print_vdif.c
deleted file mode 100644
index 13cd3ab..0000000
--- a/hw/xfree86/ddc/print_vdif.c
+++ /dev/null
@@ -1,225 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "vdif.h"
-#include "misc.h"
-#include "xf86DDC.h"
-
-static void print_vdif(xf86VdifPtr l, char *s);
-static void print_timings(xf86VdifTimingPtr *pt);
-static void print_limits(xf86VdifLimitsPtr *pl);
-static void print_gamma(xf86VdifGammaPtr *pg);
-static void print_type(CARD8 c);
-static void print_polarity(CARD8 c);
-
-void
-xf86print_vdif(xf86vdifPtr v)
-{
-    print_vdif(v->vdif,v->strings);
-    print_limits(v->limits);
-    print_timings(v->timings);
-    print_gamma(v->gamma);
-}
-
-static void
-print_vdif(xf86VdifPtr l, char *s)
-{
-    ErrorF("Version %i.%i",l->VDIFVersion,l->VDIFRevision);
-    ErrorF(" Date: %i/%i/%i, Manufactured: %i/%i/%i\n",l->Date[0],
-	   l->Date[1],l->Date[2],l->DateManufactured[0],
-	   l->DateManufactured[1],l->DateManufactured[2]);
-    ErrorF("File Revision: %i",l->FileRevision);
-    ErrorF("Manufacturer: %s\n",s + l->Manufacturer);
-    ErrorF("ModelNumber: %s\n",s + l->ModelNumber);
-    ErrorF("VDIFIndex: %s\n",s +l->MinVDIFIndex);
-    ErrorF("Version: %s\n",s + l->Version);
-    ErrorF("SerialNumber %s\n",s + l->SerialNumber);
-    ErrorF("MonitorType: ");
-    switch (l->MonitorType) {
-    case VDIF_MONITOR_MONOCHROME:
-	ErrorF("Mono\n");
-	break;
-    case VDIF_MONITOR_COLOR:
-	ErrorF("Color\n");
-	break;
-    }
-    ErrorF("CRT Size: %i inches\n",l->CRTSize);
-    switch (l->MonitorType) {
-    case VDIF_MONITOR_MONOCHROME:
-	ErrorF("Border:  %i percent\n",
-	       l->BorderRed);
-	ErrorF("Phosphor Decay: 1: %i,",l->RedPhosphorDecay);
-	if (l->GreenPhosphorDecay !=0)
-	    ErrorF(" 2: %i,",l->GreenPhosphorDecay);
-	if (l->BluePhosphorDecay !=0)
-	    ErrorF(" 3: %i",l->BluePhosphorDecay);
-	ErrorF(" ms\n");
-	if (l->RedChromaticity_x)
-	    ErrorF("Chromaticity: 1: x:%f, y:%f;  ",
-		   l->RedChromaticity_x/1000.0,l->RedChromaticity_y/1000.0);
-	if (l->GreenChromaticity_x)
-	    ErrorF("Chromaticity: 2: x:%f, y:%f;  ",
-		   l->GreenChromaticity_x/1000.0,l->GreenChromaticity_y/1000.0);
-	if (l->BlueChromaticity_x)
-	    ErrorF("Chromaticity: 3: x:%f, y:%f  ",
-		   l->BlueChromaticity_x/1000.0,l->BlueChromaticity_y/1000.0);
-	ErrorF("\n");
-	ErrorF("Gamma: %f\n",l->RedGamma/1000.0);
-	break;
-    case VDIF_MONITOR_COLOR:
-	ErrorF("Border: Red: %i Green: %i Blue: %i percent\n",
-	       l->BorderRed,l->BorderGreen,l->BorderBlue);
-	ErrorF("Phosphor Decay: Red: %i, Green: %i, Blue: %i ms\n",
-	       l->RedPhosphorDecay,l->GreenPhosphorDecay,l->BluePhosphorDecay);
-	ErrorF("Chromaticity: Red: x:%f, y:%f;  Green: x:%f, y:%f;  "
-	       "Blue: x:%f, y:%f\n",
-	       l->RedChromaticity_x/1000.0,l->RedChromaticity_y/1000.0,
-	       l->GreenChromaticity_x/1000.0,l->GreenChromaticity_y/1000.0,
-	       l->BlueChromaticity_x/1000.0,l->BlueChromaticity_y/1000.0);
-	ErrorF("Gamma: Red:%f, Green:%f, Blue:%f\n",l->RedGamma/1000.0,
-	       l->GreenGamma/1000.0,l->BlueGamma/1000.0);
-	break;
-    }
-    ErrorF("White Point: x: %f y: %f Y: %f\n",l->WhitePoint_x/1000.0,
-	   l->WhitePoint_y/1000.0,l->WhitePoint_Y/1000.0);
-}
-
-static void 
-print_limits(xf86VdifLimitsPtr *pl)
-{
-    int i = 0;
-    xf86VdifLimitsPtr l;
-
-    while((l = pl[i]) != NULL) {
-	ErrorF("Max display resolution: %i x %i pixel\n",l->MaxHorPixel,
-	       l->MaxVerPixel);
-	ErrorF("Size of active area: %i x %i millimeters\n",l->MaxHorActiveLength,
-	       l->MaxVerActiveHeight);
-	ErrorF("Video Type: ");
-	print_type(l->VideoType);
-	ErrorF("Sync Type: ");
-	print_type(l->SyncType);
-	ErrorF("Sync Configuration ");
-	switch (l->SyncConfiguration) {
-	case VDIF_SYNC_SEPARATE:
-	    ErrorF("separate\n");
-	    break;
-	case VDIF_SYNC_C:
-	    ErrorF("composite C\n");
-	    break;
-	case VDIF_SYNC_CP:
-	    ErrorF("composite CP\n");
-	    break;
-	case VDIF_SYNC_G:
-	    ErrorF("composite G\n");
-	    break;
-	case VDIF_SYNC_GP:
-	    ErrorF("composite GP\n");
-	    break;
-	case VDIF_SYNC_OTHER:
-	    ErrorF("other\n");
-	    break;
-	}
-	ErrorF("Termination Resistance: %i\n",l->TerminationResistance);
-	ErrorF("Levels: white: %i, black: %i, blank: %i, sync: %i mV\n",
-	       l->WhiteLevel,l->BlackLevel,l->BlankLevel,l->SyncLevel);
-	ErrorF("Max. Pixel Clock: %f MHz\n",l->MaxPixelClock/1000.0);
-	ErrorF("Freq. Range: Hor.: %f - %f kHz, Ver.: %f - %f Hz\n",
-	       l->MaxHorFrequency/1000.0,l->MinHorFrequency/1000.0,
-	       l->MaxVerFrequency/1000.0,l->MinVerFrequency/1000.0);
-	ErrorF("Retrace time: Hor: %f us,  Ver: %f ms\n",l->MinHorRetrace/1000.0,
-	       l->MinVerRetrace/1000.0);
-    }
-}
-
-static void 
-print_timings(xf86VdifTimingPtr *pt)
-{
-    int i = 0;
-    xf86VdifTimingPtr t;
-
-    while((t = pt[i]) != NULL) {
-	ErrorF("SVGA / SVPMI mode number: %i\n",t->PreadjustedTimingName);
-	ErrorF("Mode %i x %i\n",t->HorPixel,t->VerPixel);
-	ErrorF("Size: %i x %i mm\n",t->HorAddrLength,t->VerAddrHeight);
-	ErrorF("Ratios: %i/%i\n",t->PixelWidthRatio,t->PixelHeightRatio);
-	ErrorF("Character width: %i",t->CharacterWidth);
-	ErrorF("Clock: %f MHz HFreq.: %f kHz, VFreq: %f Hz\n",t->PixelClock/1000.0,
-	       t->HorFrequency/1000.0,t->VerFrequency/1000.0);
-	ErrorF("Htotal: %f us, Vtotal %f ms\n", t->HorTotalTime/1000.0,
-	       t->VerTotalTime/1000.0);
-	ErrorF("HDisp: %f, HBlankStart: %f, HBlankLength: %f, "
-	       "HSyncStart: %f HSyncEnd: %f us\n",t->HorAddrTime/1000.0,
-	       t->HorBlankStart/1000.0,t->HorBlankTime/1000.0,
-	       t->HorSyncStart/1000.0,t->HorSyncTime/1000.0);
-	ErrorF("VDisp: %f, VBlankStart: %f, VBlankLength: %f, "
-	       "VSyncStart: %f VSyncEnd: %f us\n",t->VerAddrTime/1000.0,
-	       t->VerBlankStart/1000.0,t->VerBlankTime/1000.0,
-	       t->VerSyncStart/1000.0,t->VerSyncTime/1000.0);
-	ErrorF("Scan Type: ");
-	switch (t->ScanType) {
-	case VDIF_SCAN_INTERLACED:
-	    ErrorF("interlaced   ");
-	    break;
-	case VDIF_SCAN_NONINTERLACED:
-	    ErrorF("non interlaced   ");
-	    break;
-	case VDIF_SCAN_OTHER:
-	    ErrorF("other   ");
-	    break;
-	}
-	ErrorF("Polarity: H: ");
-	print_polarity(t->HorSyncPolarity);
-	ErrorF("V: ");
-	print_polarity(t->VerSyncPolarity);
-	ErrorF("\n");
-    }
-}
-
-static void
-print_gamma(xf86VdifGammaPtr *pg)
-{
-    int i = 0;
-    xf86VdifGammaPtr g;
-
-    while((g = pg[i]) != NULL) {
-	ErrorF("Gamma Table Entries: %i\n",g->GammaTableEntries);
-    }
-}
-
-static void
-print_type(CARD8 c)
-{
-    switch (c) {
-    case VDIF_VIDEO_TTL :
-	ErrorF("TTL\n");
-	break;
-    case VDIF_VIDEO_ANALOG :
-	ErrorF("Analog\n");
-	break;
-    case VDIF_VIDEO_ECL:
-	ErrorF("ECL\n");
-	break;
-    case VDIF_VIDEO_DECL:
-	ErrorF("DECL\n");
-	break;
-    case VDIF_VIDEO_OTHER:
-	ErrorF("other\n");
-	break;
-    }
-}
-
-static void
-print_polarity(CARD8 c)
-{
-    switch (c) {
-    case VDIF_POLARITY_NEGATIVE:
-	ErrorF(" Neg.");
-	break;
-    case VDIF_POLARITY_POSITIVE:
-	ErrorF(" Pos.");
-	break;
-    }
-}
diff --git a/hw/xfree86/ddc/vdif.h b/hw/xfree86/ddc/vdif.h
deleted file mode 100644
index 1777b68..0000000
--- a/hw/xfree86/ddc/vdif.h
+++ /dev/null
@@ -1,174 +0,0 @@
-
-#ifndef _VDIF_H
-#define _VDIF_H
-
-#define VDIF_MONITOR_MONOCHROME 0
-#define VDIF_MONITOR_COLOR 1
-#define VDIF_VIDEO_TTL 0
-#define VDIF_VIDEO_ANALOG 1
-#define VDIF_VIDEO_ECL 2
-#define VDIF_VIDEO_DECL 3
-#define VDIF_VIDEO_OTHER 4
-#define VDIF_SYNC_SEPARATE 0
-#define VDIF_SYNC_C 1
-#define VDIF_SYNC_CP 2
-#define VDIF_SYNC_G 3
-#define VDIF_SYNC_GP 4
-#define VDIF_SYNC_OTHER 5
-#define VDIF_SCAN_NONINTERLACED 0
-#define VDIF_SCAN_INTERLACED 1
-#define VDIF_SCAN_OTHER 2
-#define VDIF_POLARITY_NEGATIVE 0
-#define VDIF_POLARITY_POSITIVE 1
-
-#include <X11/Xmd.h>
-
-#undef  CARD32
-#define CARD32 unsigned int	/* ... on all supported platforms */
-
-typedef struct _VDIF { /* Monitor Description: */
-    CARD8 VDIFId[4]; /* alway "VDIF" */
-    CARD32 FileLength; /* lenght of the whole file */
-    CARD32 Checksum; /* sum of all bytes in the file after*/
-    /* this field */
-    CARD16 VDIFVersion; /* structure version number */
-    CARD16 VDIFRevision; /* structure revision number */
-    CARD16 Date[3]; /* file date Year/Month/Day */
-    CARD16 DateManufactured[3]; /* date Year/Month/Day */
-    CARD32 FileRevision; /* file revision string */
-    CARD32 Manufacturer; /* ASCII ID of the manufacturer */
-    CARD32 ModelNumber; /* ASCII ID of the model */
-    CARD32 MinVDIFIndex; /* ASCII ID of Minimum VDIF index */
-    CARD32 Version; /* ASCII ID of the model version */
-    CARD32 SerialNumber; /* ASCII ID of the serial number */
-    CARD8 MonitorType; /* Monochrome or Color */
-    CARD8 CRTSize; /* inches */
-    CARD8 BorderRed; /* percent */
-    CARD8 BorderGreen; /* percent */
-    CARD8 BorderBlue; /* percent */
-    CARD8 Reserved1; /* padding */
-    CARD16 Reserved2; /* padding */
-    CARD32 RedPhosphorDecay; /* microseconds */
-    CARD32 GreenPhosphorDecay; /* microseconds */
-    CARD32 BluePhosphorDecay; /* microseconds */
-    CARD16 WhitePoint_x; /* WhitePoint in CIExyY (scale 1000) */
-    CARD16 WhitePoint_y;
-    CARD16 WhitePoint_Y;
-    CARD16 RedChromaticity_x; /* Red chromaticity in x,y */
-    CARD16 RedChromaticity_y;
-    CARD16 GreenChromaticity_x; /* Green chromaticity in x,y */
-    CARD16 GreenChromaticity_y;
-    CARD16 BlueChromaticity_x; /* Blue chromaticity in x,y */
-    CARD16 BlueChromaticity_y;
-    CARD16 RedGamma; /* Gamme curve exponent (scale 1000) */
-    CARD16 GreenGamma;
-    CARD16 BlueGamma;
-    CARD32 NumberOperationalLimits;
-    CARD32 OffsetOperationalLimits;
-    CARD32 NumberOptions; /* optinal sections (gamma table) */
-    CARD32 OffsetOptions;
-    CARD32 OffsetStringTable;
-} xf86VdifRec, *xf86VdifPtr;
-
-typedef enum { /* Tags for section identification */
-    VDIF_OPERATIONAL_LIMITS_TAG = 1,
-    VDIF_PREADJUSTED_TIMING_TAG,
-    VDIF_GAMMA_TABLE_TAG
-} VDIFScnTag;
-
-typedef struct _VDIFScnHdr { /* Generic Section Header: */
-    CARD32 ScnLength; /* lenght of section */
-    CARD32 ScnTag; /* tag for section identification */
-} VDIFScnHdrRec, *VDIFScnHdrPtr;
-
-typedef struct _VDIFLimits { /* Operational Limits: */
-    VDIFScnHdrRec Header; /* common section info */
-    CARD16 MaxHorPixel; /* pixels */
-    CARD16 MaxVerPixel; /* lines */
-    CARD16 MaxHorActiveLength; /* millimeters */
-    CARD16 MaxVerActiveHeight; /* millimeters */
-    CARD8 VideoType; /* TTL / Analog / ECL / DECL */
-    CARD8 SyncType; /* TTL / Analog / ECL / DECL */
-    CARD8 SyncConfiguration; /* separate / composite / other */
-    CARD8 Reserved1; /* padding */
-    CARD16 Reserved2; /* padding */
-    CARD16 TerminationResistance; /* */
-    CARD16 WhiteLevel; /* millivolts */
-    CARD16 BlackLevel; /* millivolts */
-    CARD16 BlankLevel; /* millivolts */
-    CARD16 SyncLevel; /* millivolts */
-    CARD32 MaxPixelClock; /* kiloHertz */
-    CARD32 MinHorFrequency; /* Hertz */
-    CARD32 MaxHorFrequency; /* Hertz */
-    CARD32 MinVerFrequency; /* milliHertz */
-    CARD32 MaxVerFrequency; /* milliHertz */
-    CARD16 MinHorRetrace; /* nanoseconds */
-    CARD16 MinVerRetrace; /* microseconds */
-    CARD32 NumberPreadjustedTimings;
-    CARD32 OffsetNextLimits;
-} xf86VdifLimitsRec, *xf86VdifLimitsPtr;
-
-typedef struct _VDIFTiming { /* Preadjusted Timing: */
-    VDIFScnHdrRec Header; /* common section info */
-    CARD32 PreadjustedTimingName; /* SVGA/SVPMI mode number */
-    CARD16 HorPixel; /* pixels */
-    CARD16 VerPixel; /* lines */
-    CARD16 HorAddrLength; /* millimeters */
-    CARD16 VerAddrHeight; /* millimeters */
-    CARD8 PixelWidthRatio; /* gives H:V */
-    CARD8 PixelHeightRatio;
-    CARD8 Reserved1; /* padding */
-    CARD8 ScanType; /* noninterlaced / interlaced / other*/
-    CARD8 HorSyncPolarity; /* negative / positive */
-    CARD8 VerSyncPolarity; /* negative / positive */
-    CARD16 CharacterWidth; /* pixels */
-    CARD32 PixelClock; /* kiloHertz */
-    CARD32 HorFrequency; /* Hertz */
-    CARD32 VerFrequency; /* milliHertz */
-    CARD32 HorTotalTime; /* nanoseconds */
-    CARD32 VerTotalTime; /* microseconds */
-    CARD16 HorAddrTime; /* nanoseconds */
-    CARD16 HorBlankStart; /* nanoseconds */
-    CARD16 HorBlankTime; /* nanoseconds */
-    CARD16 HorSyncStart; /* nanoseconds */
-    CARD16 HorSyncTime; /* nanoseconds */
-    CARD16 VerAddrTime; /* microseconds */
-    CARD16 VerBlankStart; /* microseconds */
-    CARD16 VerBlankTime; /* microseconds */
-    CARD16 VerSyncStart; /* microseconds */
-    CARD16 VerSyncTime; /* microseconds */
-} xf86VdifTimingRec, *xf86VdifTimingPtr; 
-
-typedef struct _VDIFGamma { /* Gamma Table: */
-    VDIFScnHdrRec Header; /* common section info */
-    CARD16 GammaTableEntries; /* count of grays or RGB 3-tuples */
-    CARD16 Unused1;
-} xf86VdifGammaRec, *xf86VdifGammaPtr;
-
-/* access macros */
-#define VDIF_OPERATIONAL_LIMITS(vdif) \
-((xf86VdifLimitsPtr)((char*)(vdif) + (vdif)->OffsetOperationalLimits))
-#define VDIF_NEXT_OPERATIONAL_LIMITS(limits) limits = \
-     ((xf86VdifLimitsPtr)((char*)(limits) + (limits)->OffsetNextLimits))
-#define VDIF_PREADJUSTED_TIMING(limits) \
-((xf86VdifTimingPtr)((char*)(limits) + (limits)->Header.ScnLength))
-#define VDIF_NEXT_PREADJUSTED_TIMING(timing) timing = \
-     ((xf86VdifTimingPtr)((char*)(timing) + (timing)->Header.ScnLength))
-#define VDIF_OPTIONS(vdif) \
-     ((VDIFScnHdrPtr)((char*)(vdif) + (vdif)->OffsetOptions))
-#define VDIF_NEXT_OPTIONS(options) options = \
-     ((xf86VdifGammaPtr)((char*)(options) + (options)->Header.ScnLength))
-#define VDIF_STRING(vdif, string) \
-     ((char*)((char*)vdif + vdif->OffsetStringTable + (string)))
-
-typedef struct  _vdif {
-    xf86VdifPtr vdif;
-    xf86VdifLimitsPtr *limits;
-    xf86VdifTimingPtr *timings;
-    xf86VdifGammaPtr *gamma;
-    char * strings;
-} xf86vdif, *xf86vdifPtr;
-
-#undef CARD32
-
-#endif
diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c
index 21984bc..e47b8b8 100644
--- a/hw/xfree86/ddc/xf86DDC.c
+++ b/hw/xfree86/ddc/xf86DDC.c
@@ -38,12 +38,6 @@ static unsigned char* EDID1Read_DDC2(
     I2CBusPtr pBus
 );
 
-static unsigned char * VDIFRead(
-    int scrnIndex, 
-    I2CBusPtr pBus, 
-    int start
-);
-
 static unsigned char * DDCRead_DDC2(
     int scrnIndex,
     I2CBusPtr pBus, 
@@ -138,7 +132,6 @@ xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     unsigned char *EDID_block = NULL;
-    unsigned char *VDIF_Block = NULL;
     xf86MonPtr tmp = NULL;
     /* Default DDC and DDC2 to enabled. */
     Bool noddc = FALSE, noddc2 = FALSE;
@@ -171,11 +164,6 @@ xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr
     else
         ErrorF("Sections to follow: %i\n",tmp->no_sections);
 #endif
-    if (tmp) {
-        VDIF_Block = 
-            VDIFRead(scrnIndex, pBus, EDID1_LEN * (tmp->no_sections + 1));    
-        tmp->vdif = xf86InterpretVdif(VDIF_Block);
-    }
     
     return tmp;
 }
@@ -253,35 +241,6 @@ EDID1Read_DDC2(int scrnIndex, I2CBusPtr 
     return  DDCRead_DDC2(scrnIndex, pBus, 0, EDID1_LEN);
 }
 
-static unsigned char*
-VDIFRead(int scrnIndex, I2CBusPtr pBus, int start)
-{
-    unsigned char * Buffer, *v_buffer = NULL, *v_bufferp = NULL;
-    int i, num = 0;
-
-    /* read VDIF length in 64 byte blocks */
-    Buffer = DDCRead_DDC2(scrnIndex, pBus,start,64);
-    if (Buffer == NULL)
-	return NULL;
-#ifdef DEBUG
-    ErrorF("number of 64 bit blocks: %i\n",Buffer[0]);
-#endif
-    if ((num = Buffer[0]) > 0)
-	v_buffer = v_bufferp = xalloc(sizeof(unsigned char) * 64 * num);
-
-    for (i = 0; i < num; i++) {
-	Buffer = DDCRead_DDC2(scrnIndex, pBus,start,64);
-	if (Buffer == NULL) {
-	    xfree (v_buffer);
-	    return NULL;
-	}
-	memcpy(v_bufferp,Buffer,63); /* 64th byte is checksum */
-	xfree(Buffer);
-	v_bufferp += 63;
-    }
-    return v_buffer;
-}
-
 static unsigned char *
 DDCRead_DDC2(int scrnIndex, I2CBusPtr pBus, int start, int len)
 {
diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h
index 7799471..3b072dd 100644
--- a/hw/xfree86/ddc/xf86DDC.h
+++ b/hw/xfree86/ddc/xf86DDC.h
@@ -43,10 +43,6 @@ extern xf86MonPtr xf86InterpretEDID(
     int screenIndex, Uchar *block
 );
 
-extern xf86vdifPtr xf86InterpretVdif(
-    CARD8 *c
-);
-
 extern void 
 xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC);
 
@@ -55,10 +51,6 @@ extern Bool xf86SetDDCproperties(
     xf86MonPtr DDC
 );
 
-extern void xf86print_vdif(
-    xf86vdifPtr v
-);
-
 DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC);
 
 #endif
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 6535e4c..b4ae42f 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -1236,8 +1236,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86DoEDID_DDC2)
     SYMFUNC(xf86InterpretEDID)
     SYMFUNC(xf86PrintEDID)
-    SYMFUNC(xf86InterpretVdif)
-    SYMFUNC(xf86print_vdif)
     SYMFUNC(xf86DDCMonitorSet)
     SYMFUNC(xf86SetDDCproperties)
 
diff-tree 66702f3c1c6c884e83744c72da173cc32f22b2f4 (from fa877d7ff25c4ec45288e1fea70d4f5e1baf3ef3)
Author: Henry Zhao <henryz at localhost.localdomain>
Date:   Fri Jun 1 23:55:40 2007 -0700

    Need to use minPitch in miScanLineWidth() to get the shrinked
    linePitch.

diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index fc905df..b343788 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -1890,7 +1890,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, Disp
 		       virtX, virtY, vx, vy);
 	    virtX = vx;
 	    virtY = vy;
-	    linePitch = miScanLineWidth(vx, vy, linePitch, apertureSize,
+	    linePitch = miScanLineWidth(vx, vy, minPitch, apertureSize,
 					BankFormat, pitchInc);
 	}
     }
diff-tree fa877d7ff25c4ec45288e1fea70d4f5e1baf3ef3 (from 99eae8bea6724a24477375ad5b2d31cc4883cf6b)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Wed May 30 13:06:45 2007 +0100

    Fix mode validation against the maximum X/Y values configured
    at server startup, and not against the virtual X/Y parameters
    as they can change.
    
    This fixes an issue when canGrow is TRUE and modes get dropped
    when using the virtual X/Y parameters.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 88c31af..d20a3a3 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1217,8 +1217,15 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
     int			o;
 
-    if (maxX == 0 || maxY == 0)
-	xf86RandR12GetOriginalVirtualSize (scrn, &maxX, &maxY);
+    /* When canGrow was TRUE in the initial configuration we have to
+     * compare against the maximum values so that we don't drop modes.
+     * When canGrow was FALSE, the maximum values would have been clamped
+     * anyway.
+     */
+    if (maxX == 0 || maxY == 0) {
+	maxX = config->maxWidth;
+	maxY = config->maxHeight;
+    }
 
     /* Elide duplicate modes before defaulting code uses them */
     xf86PruneDuplicateMonitorModes (scrn->monitor);
diff-tree 99eae8bea6724a24477375ad5b2d31cc4883cf6b (from 3c6f1428489c1f71acd41066ea73ef4ae7c60f17)
Author: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date:   Tue May 29 22:04:36 2007 -0400

    I/O enable/disable update for the Hurd

diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c
index 45e9a09..b889283 100644
--- a/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/hw/xfree86/os-support/hurd/hurd_video.c
@@ -117,49 +117,29 @@ xf86LinearVidMem()
 /**************************************************************************
  * I/O Permissions section                                                 
  ***************************************************************************/
-mach_port_t io_port;
+
+/*
+ * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
+ * this.
+ */
+extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on);
 
 Bool
 xf86EnableIO()
 {
-    mach_port_t device;
-    kern_return_t err;
-
-    err = get_privileged_ports(NULL, &device);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86EnableIO() can't get_privileged_ports. (%s)\n",strerror(errno));
-    }
-    err = device_open(device,D_READ|D_WRITE,"io",&io_port);
-    mach_port_deallocate(mach_task_self(), device);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86EnableIO() can't device_open. (%s)\n",strerror(errno));
-    }
-
-    err = i386_io_port_add(mach_thread_self (), io_port);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86EnableIO() can't i386_io_port_add.(io_port) (%s)\n",strerror(errno));
+    if (ioperm(0, 0xffff, 1)) {
+	FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno));
+	return FALSE;
     }
+    ioperm(0x40,4,0); /* trap access to the timer chip */
+    ioperm(0x60,4,0); /* trap access to the keyboard controller */
     return TRUE;
 }
 	
 void
 xf86DisableIO()
 {
-    kern_return_t err;
-
-    err = i386_io_port_remove(mach_thread_self (), io_port);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86DisableIO() can't i386_io_port_remove.(io_port) (%s)\n",strerror(errno));
-    }
-    mach_port_deallocate(mach_task_self(), io_port);
+    ioperm(0,0xffff,0);
     return;
 }
 
diff-tree 3c6f1428489c1f71acd41066ea73ef4ae7c60f17 (from ee20c481eede0954f4a8bef5113979b101863c32)
Author: Julien Cristau <jcristau at debian.org>
Date:   Tue May 29 22:01:30 2007 -0400

    Make sure that the ramdac symbols are present in the server
    
    The former ramdac module is now built into the server, so its symbols need to
    be explicitly exported to drivers (Debian #423129).

diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 5175f01..6535e4c 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -96,6 +96,11 @@
 #endif
 #include "xf86DDC.h"
 #include "edid.h"
+#include "xf86Cursor.h"
+#include "xf86RamDac.h"
+#include "BT.h"
+#include "IBM.h"
+#include "TI.h"
 
 #ifndef HAS_GLIBC_SIGSETJMP
 #if defined(setjmp) && defined(__GNU_LIBRARY__) && \
@@ -1255,4 +1260,50 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86I2CWriteRead)
     SYMFUNC(xf86I2CWriteVec)
     SYMFUNC(xf86I2CWriteWord)
+
+    /* ramdac/xf86RamDac.c */
+    SYMFUNC(RamDacCreateInfoRec)
+    SYMFUNC(RamDacHelperCreateInfoRec)
+    SYMFUNC(RamDacDestroyInfoRec)
+    SYMFUNC(RamDacHelperDestroyInfoRec)
+    SYMFUNC(RamDacInit)
+    SYMFUNC(RamDacHandleColormaps)
+    SYMFUNC(RamDacFreeRec)
+    SYMFUNC(RamDacGetHWIndex)
+    SYMVAR(RamDacHWPrivateIndex)
+    SYMVAR(RamDacScreenPrivateIndex)
+
+    /* ramdac/xf86Cursor.c */
+    SYMFUNC(xf86InitCursor)
+    SYMFUNC(xf86CreateCursorInfoRec)
+    SYMFUNC(xf86DestroyCursorInfoRec)
+    SYMFUNC(xf86ForceHWCursor)
+
+    /* ramdac/BT.c */
+    SYMFUNC(BTramdacProbe)
+    SYMFUNC(BTramdacSave)
+    SYMFUNC(BTramdacRestore)
+    SYMFUNC(BTramdacSetBpp)
+
+    /* ramdac/IBM.c */
+    SYMFUNC(IBMramdacProbe)
+    SYMFUNC(IBMramdacSave)
+    SYMFUNC(IBMramdacRestore)
+    SYMFUNC(IBMramdac526SetBpp)
+    SYMFUNC(IBMramdac640SetBpp)
+    SYMFUNC(IBMramdac526CalculateMNPCForClock)
+    SYMFUNC(IBMramdac640CalculateMNPCForClock)
+    SYMFUNC(IBMramdac526HWCursorInit)
+    SYMFUNC(IBMramdac640HWCursorInit)
+    SYMFUNC(IBMramdac526SetBppWeak)
+
+    /* ramdac/TI.c */
+    SYMFUNC(TIramdacCalculateMNPForClock)
+    SYMFUNC(TIramdacProbe)
+    SYMFUNC(TIramdacSave)
+    SYMFUNC(TIramdacRestore)
+    SYMFUNC(TIramdac3026SetBpp)
+    SYMFUNC(TIramdac3030SetBpp)
+    SYMFUNC(TIramdacHWCursorInit)
+    SYMFUNC(TIramdacLoadPalette)
 };
diff-tree ee20c481eede0954f4a8bef5113979b101863c32 (from 60de6c7ef9bdcee043f63e8e0d493e6feba6a9d0)
Author: Matthieu Herrb <matthieu at deville.herrb.com>
Date:   Tue May 29 14:54:27 2007 -0600

    Remove wscons keyboard handling stuff that doesn't belong there anymore.

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 3610c17..4da74e5 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -1208,31 +1208,3 @@ _X_EXPORT void
 DDXRingBell(int volume, int pitch, int duration) {
     xf86OSRingBell(volume, pitch, duration);
 }
-
-#ifdef WSCONS_SUPPORT
-
-/* XXX Currently XKB is mandatory. */
-
-extern int WSKbdToKeycode(int);
-
-void
-xf86PostWSKbdEvent(struct wscons_event *event)
-{
-  int type = event->type;
-  int value = event->value;
-  unsigned int keycode;
-  int blocked;
-
-  if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) {
-    Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE);
-
-    /* map the scancodes to standard XFree86 scancode */  	
-    keycode = WSKbdToKeycode(value);
-    if (!down) keycode |= 0x80;
-    /* It seems better to block SIGIO there */
-    blocked = xf86BlockSIGIO();
-    xf86PostKbdEvent(keycode);
-    xf86UnblockSIGIO(blocked);
-  }
-}
-#endif /* WSCONS_SUPPORT */
diff-tree 60de6c7ef9bdcee043f63e8e0d493e6feba6a9d0 (from parents)
Merge: 3a6549a163aba26bf4ac58b050c493fba0df14c6 2f13b7c113c17239e382dd3640e9c29201d8ab1f
Author: Matthieu Herrb <matthieu at deville.herrb.com>
Date:   Tue May 29 12:14:49 2007 -0600

    Merge branch 'master' of ssh://herrb@git.freedesktop.org/git/xorg/xserver

diff-tree 3a6549a163aba26bf4ac58b050c493fba0df14c6 (from 047bf3349bb697c73c95729a8bbf15f72605901f)
Author: Matthieu Herrb <matthieu at deville.herrb.com>
Date:   Tue May 29 12:14:23 2007 -0600

    Make this build on OpenBSD

diff --git a/hw/xfree86/os-support/bsd/bsd_bell.c b/hw/xfree86/os-support/bsd/bsd_bell.c
index b7a0c48..0d24201 100644
--- a/hw/xfree86/os-support/bsd/bsd_bell.c
+++ b/hw/xfree86/os-support/bsd/bsd_bell.c
@@ -27,7 +27,7 @@
 #include <xorg-config.h>
 #endif
 
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+#if defined (SYSCONS_SUPPORT)
 #include <sys/kbio.h>
 #endif
 
@@ -77,7 +77,7 @@ xf86OSRingBell(int loudness, int pitch, 
                         wsb.pitch = pitch;
                         wsb.period = duration;
                         wsb.volume = loudness;
-                        ioctl(KBD_FD(xf86Info), WSKBDIO_COMPLEXBELL,
+                        ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL,
                                       &wsb);
                         break;
 #endif
diff-tree 2f13b7c113c17239e382dd3640e9c29201d8ab1f (from ba0b7d47ab0c24d5a29228f8af583044060464bd)
Author: Drew Parsons <dparsons at debian.org>
Date:   Wed May 30 02:13:36 2007 +1000

    Update Xprint build for pixman.
    
    Xprt links libfb, which now uses pixman.  Update configure.ac to
    require module $PIXMAN for XPRINT.
    Also, use $(top_builddir) to reference libfb.la and other local
    libraries, rather than using the relative reference ../..

diff --git a/configure.ac b/configure.ac
index 7ff712f..350245e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1600,7 +1600,7 @@ AC_MSG_CHECKING([whether to build Xprint
 AC_MSG_RESULT([$XPRINT])
 
 if test "x$XPRINT" = xyes; then
-	PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau])
+	PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau $PIXMAN])
 	XPRINT_EXTENSIONS="$XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS"
 	XPRINT_LIBS="$DIX_LIB $CONFIG_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB $LIBS $XPRINT_LIBS"
 	AC_SUBST([XPRINT_CFLAGS])
diff --git a/hw/xprint/Makefile.am b/hw/xprint/Makefile.am
index 45168b1..dc8764a 100644
--- a/hw/xprint/Makefile.am
+++ b/hw/xprint/Makefile.am
@@ -10,9 +10,9 @@ Xprt_CFLAGS = @DIX_CFLAGS@ @XPRINT_CFLAG
 
 Xprt_LDFLAGS = -L$(top_srcdir)
 Xprt_LDADD = @XPRINT_LIBS@ ps/libps.la raster/libraster.la  \
-	pcl/libpcl.la pcl-mono/libpcl.la ../../fb/libfb.la \
-	../../render/librender.la ../../mi/libmi.la ../../Xext/libXext.la \
-	@FREETYPE_LIBS@
+	pcl/libpcl.la pcl-mono/libpcl.la $(top_builddir)/fb/libfb.la \
+	$(top_builddir)/render/librender.la $(top_builddir)/mi/libmi.la \
+	$(top_builddir)/Xext/libXext.la  @FREETYPE_LIBS@
 
 miinitext-wrapper.c:
 	echo "#include \"$(top_srcdir)/mi/miinitext.c\"" >> $@
diff-tree ba0b7d47ab0c24d5a29228f8af583044060464bd (from 2267bf48b385c93243e26c3bb84ebb04c7fdb39f)
Author: David Nusinow <dnusinow at debian.org>
Date:   Mon May 28 21:57:04 2007 -0400

    Fix for GNU/kFreeBSD

diff --git a/hw/kdrive/linux/agp.c b/hw/kdrive/linux/agp.c
index c2ae625..4fb0cb3 100644
--- a/hw/kdrive/linux/agp.c
+++ b/hw/kdrive/linux/agp.c
@@ -65,7 +65,7 @@ of the copyright holder.
 
 #include <linux/agpgart.h>
 
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <sys/ioctl.h>
 #include <sys/agpio.h>
 #endif
diff-tree 2267bf48b385c93243e26c3bb84ebb04c7fdb39f (from 857ddbb660a21cad1c16f4fb2dc8a904d6655304)
Author: Bastian Blank <waldi at debian.org>
Date:   Mon May 28 21:55:05 2007 -0400

    Fixes for s390

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index ea995ed..becd3da 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -1365,7 +1365,7 @@ do {									\
 #    define write_mem_barrier()   /* NOP */
 
 #    if !defined(__SUNPRO_C)
-#    if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)
+#    if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__)
 #     ifdef GCCUSESGAS
 
 /*
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 4b58046..02a1310 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -567,7 +567,7 @@ xf86EnableIO(void)
 #endif
 	}
 	close(fd);
-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__)
         if (ioperm(0, 1024, 1) || iopl(3)) {
                 if (errno == ENODEV)
                         ErrorF("xf86EnableIOPorts: no I/O ports found\n");
diff-tree 857ddbb660a21cad1c16f4fb2dc8a904d6655304 (from 78d01d1008973899d931ef44b47d5f0b5f220b0d)
Author: Eugene Konev <ejka at imfi.kspu.ru>
Date:   Mon May 28 21:53:02 2007 -0400

    Allow configurable serverconfigdir for security policy location
    Allow the location of the SERVERCONFIGdir variable to be defined at
    compile-time. This allows us to specify where the security policy will be
    located (Debian uses this to put it in /etc). The default is to the
    previous location.

diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index 6ea3d74..d0d23b7 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -34,7 +34,6 @@ MODULE_SRCS =			\
 	xcmisc.c
 
 # Extra configuration files ship with some extensions
-SERVERCONFIGdir = $(libdir)/xserver
 SERVERCONFIG_DATA =
 
 # Optional sources included if extension enabled by configure.ac rules
diff --git a/configure.ac b/configure.ac
index 37199cf..7ff712f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -465,6 +465,9 @@ AC_ARG_WITH(xkb-output,       AS_HELP_ST
 AC_ARG_WITH(rgb-path,         AS_HELP_STRING([--with-rgb-path=PATH], [Path to RGB database (default: ${datadir}/X11/rgb)]),
 				[ RGBPATH="$withval" ],
 				[ RGBPATH="${datadir}/X11/rgb" ])
+AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH], [Path to server config (default: ${libdir}/xserver)]),
+				[ SERVERCONFIG="$withval" ],
+				[ SERVERCONFIG="${libdir}/xserver" ])
 APPLE_APPLICATIONS_DIR="${bindir}/Applications"
 AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: ${bindir}/Applications)]),
                                [ APPLE_APPLICATIONS_DIR="${withval}" ].
@@ -938,6 +941,7 @@ VENDOR_MAN_VERSION="Version ${VENDOR_VER
 
 AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
 AC_DEFINE_DIR(RGB_DB, RGBPATH, [Default RGB path])
+AC_DEFINE_DIR(SERVERCONFIGdir, SERVERCONFIG, [Server config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
 AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path])
 AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_STRING"], [Vendor name])
diff-tree 78d01d1008973899d931ef44b47d5f0b5f220b0d (from d98bd4bf908c2c51fcfd3a4c3230de17f2567244)
Author: Gerhard Tonn <gt at debian.org>
Date:   Mon May 28 21:48:58 2007 -0400

    Miscellaneous fixes for S/390.

diff --git a/include/servermd.h b/include/servermd.h
index e6ca11e..4f32a9d 100644
--- a/include/servermd.h
+++ b/include/servermd.h
@@ -515,7 +515,15 @@ SOFTWARE.
 #define GLYPHPADBYTES		4
 #define GETLEFTBITS_ALIGNMENT	1
 #endif
- 
+
+/* linux on IBM S/390 */
+#if defined (linux) && defined (__s390__)
+#define IMAGE_BYTE_ORDER	MSBFirst
+#define BITMAP_BIT_ORDER	MSBFirst
+#define GLYPHPADBYTES		4
+#define GETLEFTBITS_ALIGNMENT	1
+#endif /* linux/s390 */ 
+
 /* size of buffer to use with GetImage, measured in bytes. There's obviously
  * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
  * you) used and the number of times the ddx routine has to be called.
diff-tree d98bd4bf908c2c51fcfd3a4c3230de17f2567244 (from 6bf8d5019313ee2251a44dfb7ad3435a3c6db7eb)
Author: Branden Robinson <branden at debian.org>
Date:   Mon May 28 21:44:59 2007 -0400

    Overhaul xorg.conf manpage
    
    Major stylistic cleanups, greatly expanded cross-reference ("SEE ALSO")
    section and some typo fixes.
    
    This patch by Branden Robinson. Forward-ported by Fabio M. Di Nitto.

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index f2cb5ef..4103974 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -3,7 +3,7 @@
 .ds q \N'34'
 .TH __xconfigfile__ __filemansuffix__ __vendorversion__
 .SH NAME
-__xconfigfile__ - Configuration File for __xservername__
+__xconfigfile__ \- configuration File for __xservername__ X server
 .SH INTRODUCTION
 .B __xservername__
 supports several mechanisms for supplying/obtaining configuration and
@@ -21,9 +21,10 @@ manual page.
 .SH DESCRIPTION
 .B __xservername__
 uses a configuration file called
-.B __xconfigfile__
-for its initial setup.  This configuration file is searched for in the
-following places when the server is started as a normal user:
+.I __xconfigfile__
+for its initial setup.
+This configuration file is searched for in the following places when the
+server is started as a normal user:
 .PP
 .RS 4
 .nf
@@ -31,30 +32,31 @@ following places when the server is star
 .IR __projectroot__/etc/X11/ <cmdline>
 .IB /etc/X11/ $XORGCONFIG
 .IB __projectroot__/etc/X11/ $XORGCONFIG
-.I /etc/X11/__xconfigfile__-4
+.I /etc/X11/__xconfigfile__\-4
 .I /etc/X11/__xconfigfile__
 .I /etc/__xconfigfile__
 .IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
-.I __projectroot__/etc/X11/__xconfigfile__-4
+.I __projectroot__/etc/X11/__xconfigfile__\-4
 .I __projectroot__/etc/X11/__xconfigfile__
 .IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
-.I __projectroot__/lib/X11/__xconfigfile__-4
+.I __projectroot__/lib/X11/__xconfigfile__\-4
 .I __projectroot__/lib/X11/__xconfigfile__
 .fi
 .RE
 .PP
 where
 .I <cmdline>
-is a relative path (with no ".." components) specified with the
+is a relative path (with no \(lq..\(rq components) specified with the
 .B \-config
 command line option,
 .B $XORGCONFIG
-is the relative path (with no ".." components) specified by that
+is the relative path (with no \(lq..\(rq components) specified by that
 environment variable, and
 .I <hostname>
-is the machine's hostname as reported by gethostname(3).
+is the machine's hostname as reported by
+.BR gethostname (__oslibmansuffix__).
 .PP
-When the __xservername__ server is started by the "root" user, the config file
+When the __xservername__ server is started by the \(lqroot\(rq user, the config file
 search locations are as follows:
 .PP
 .RS 4
@@ -66,14 +68,14 @@ search locations are as follows:
 .IB /etc/X11/ $XORGCONFIG
 .IB __projectroot__/etc/X11/ $XORGCONFIG
 .BI $HOME /__xconfigfile__
-.I /etc/X11/__xconfigfile__-4
+.I /etc/X11/__xconfigfile__\-4
 .I /etc/X11/__xconfigfile__
 .I /etc/__xconfigfile__
 .IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
-.I __projectroot__/etc/X11/__xconfigfile__-4
+.I __projectroot__/etc/X11/__xconfigfile__\-4
 .I __projectroot__/etc/X11/__xconfigfile__
 .IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
-.I __projectroot__/lib/X11/__xconfigfile__-4
+.I __projectroot__/lib/X11/__xconfigfile__\-4
 .I __projectroot__/lib/X11/__xconfigfile__
 .fi
 .RE
@@ -90,13 +92,13 @@ environment variable (absolute or relati
 is the path specified by that environment variable (usually the home
 directory), and
 .I <hostname>
-is the machine's hostname as reported by gethostname(3).
+is the machine's hostname as reported by
+.BR gethostname (__oslibmansuffix__).
 .PP
 The
-.B __xconfigfile__
-file is composed of a number of sections which may be present in any
-order.  Each section has
-the form:
+.I __xconfigfile__
+file is composed of a number of sections which may be present in any order.
+Each section has the form:
 .PP
 .RS 4
 .nf
@@ -121,13 +123,14 @@ The section names are:
 .BR "Modes          " "Video modes descriptions"
 .BR "Screen         " "Screen configuration"
 .BR "ServerLayout   " "Overall layout"
-.BR "DRI            " "DRI-specific configuration"
-.BR "Vendor         " "Vendor-specific configuration"
+.BR "DRI            " "DRI\-specific configuration"
+.BR "Vendor         " "Vendor\-specific configuration"
 .fi
 .RE
 .PP
 The following obsolete section names are still recognised for compatibility
-purposes.  In new config files, the
+purposes.
+In new config files, the
 .B InputDevice
 section should be used instead.
 .PP
@@ -144,35 +147,38 @@ section is no longer recognised.
 .PP
 The
 .B ServerLayout
-sections are at the highest level.  They bind together the input and
-output devices that will be used in a session.  The input devices
-are described in the
+sections are at the highest level.  
+They bind together the input and output devices that will be used in a session.  
+The input devices are described in the
 .B InputDevice
-sections.  Output devices usually consist of multiple independent
-components (e.g., a graphics board and a monitor).  These multiple
-components are bound together in the
+sections.  
+Output devices usually consist of multiple independent components (e.g.,
+a graphics board and a monitor).  
+These multiple components are bound together in the
 .B Screen
 sections, and it is these that are referenced by the
 .B ServerLayout
-section.  Each
+section.  
+Each
 .B Screen
-section binds together a graphics board and a monitor.  The graphics
-boards are described in the
+section binds together a graphics board and a monitor.  
+The graphics boards are described in the
 .B Device
 sections, and the monitors are described in the
 .B Monitor
 sections.
 .PP
-Config file keywords are case-insensitive, and "_" characters are
-ignored.  Most strings (including
+Config file keywords are case\-insensitive, and \(lq_\(rq characters are
+ignored.  
+Most strings (including
 .B Option
 names) are also case-insensitive, and insensitive to white space and
-"_" characters.
+\(lq_\(rq characters.
 .PP
-Each config file entry usually takes up a single line in the file.
-They consist of a keyword, which is possibly followed by one or
-more arguments, with the number and types of the arguments depending
-on the keyword.  The argument types are:
+Each config file entry usually takes up a single line in the file.  They 
+consist of a keyword, which is possibly followed by one or more arguments, 
+with the number and types of the arguments depending on the keyword.  
+The argument types are:
 .PP
 .RS 4
 .nf
@@ -182,17 +188,18 @@ on the keyword.  The argument types are:
 .fi
 .RE
 .PP
-Note: hex integer values must be prefixed with "0x", and octal values
-with "0".
+Note: hex integer values must be prefixed with \(lq0x\(rq, and octal values
+with \(lq0\(rq.
 .PP
 A special keyword called
 .B Option
-may be used to provide free-form data to various components of the server.
+may be used to provide free\-form data to various components of the server.
 The
 .B Option
-keyword takes either one or two string arguments.  The first is the option
-name, and the optional second argument is the option value.  Some commonly
-used option value types include:
+keyword takes either one or two string arguments.
+The first is the option name, and the optional second argument is the
+option value.
+Some commonly used option value types include:
 .PP
 .RS 4
 .nf
@@ -209,8 +216,8 @@ Note that
 .B Option
 values, not just strings, must be enclosed in quotes.
 .PP
-Boolean options may optionally have a value specified.  When no value
-is specified, the option's value is
+Boolean options may optionally have a value specified.
+When no value is specified, the option's value is
 .BR TRUE .
 The following boolean option values are recognised as
 .BR TRUE :
@@ -263,30 +270,35 @@ When the unit name is omitted, the corre
 the value and the expectations of the appropriate range of the value.
 It is recommended that the units always be specified when using frequency
 option values to avoid any errors in determining the value.
-.SH FILES SECTION
+.SH "FILES SECTION"
 The
 .B Files
 section is used to specify some path names required by the server.
-Some of these paths can also be set from the command line (see Xserver(__appmansuffix__)
-and __xservername__(__appmansuffix__)).  The command line settings override the values specified
-in the config file.  The
+Some of these paths can also be set from the command line (see
+.BR Xserver (__appmansuffix__)
+and
+.BR __xservername__ (__appmansuffix__)).
+The command line settings override the values specified in the config
+file.
+The
 .B Files
 section is optional, as are all of the entries that may appear in it.
 .PP
 The entries that can appear in this section are:
 .TP 7
 .BI "FontPath \*q" path \*q
-sets the search path for fonts.  This path is a comma separated list of
-font path elements which the __xservername__ server searches for font databases.
+sets the search path for fonts.
+This path is a comma separated list of font path elements which the __xservername__
+server searches for font databases.
 Multiple
 .B FontPath
 entries may be specified, and they will be concatenated to build up the
 fontpath used by the server.  Font path elements may be either absolute
-directory paths, or a font server identifier.  Font server identifiers
-have the form:
+directory paths, or a font server identifier.
+Font server identifiers have the form:
 .PP
 .RS 11
-.IR <trans> / <hostname> : <port-number>
+.IR <trans> / <hostname> : <port\-number>
 .RE
 .PP
 .RS 7
@@ -294,16 +306,16 @@ where
 .I <trans>
 is the transport type to use to connect to the font server (e.g.,
 .B unix
-for UNIX-domain sockets or
+for UNIX\-domain sockets or
 .B tcp
 for a TCP/IP connection),
 .I <hostname>
 is the hostname of the machine running the font server, and
-.I <port-number>
+.I <port\-number>
 is the port number that the font server is listening on (usually 7100).
 .PP
 When this entry is not specified in the config file, the server falls back
-to the compiled-in default font path, which contains the following
+to the compiled\-in default font path, which contains the following
 font path elements:
 .PP
 .RS 4
@@ -338,7 +350,7 @@ font path when the server starts up.
 .BI "RGBPath \*q" path \*q
 sets the path name for the RGB color database.
 When this entry is not specified in the config file, the server falls back
-to the compiled-in default RGB path, which is:
+to the compiled\-in default RGB path, which is:
 .PP
 .RS 11
 .I __projectroot__/share/X11/rgb
@@ -350,9 +362,10 @@ is added to this path if the server was 
 binary format RGB color databases.
 .TP 7
 .BI "ModulePath \*q" path \*q
-sets the search path for loadable __xservername__ server modules.  This path is
-a comma separated list of directories which the __xservername__ server searches
-for loadable modules loading in the order specified.  Multiple
+sets the search path for loadable __xservername__ server modules.
+This path is a comma separated list of directories which the __xservername__ server
+searches for loadable modules loading in the order specified.
+Multiple
 .B ModulePath
 entries may be specified, and they will be concatenated to build the
 module search path used by the server.
@@ -360,8 +373,8 @@ module search path used by the server.
 .ig
 .TP 7
 .BI "LogFile \*q" path \*q
-sets the name of the __xservername__ server log file.  The default log file name
-is
+sets the name of the __xservername__ server log file.
+The default log file name is
 .PP
 .RS 11
 .RI __logdir__/__xservername__. <n> .log
@@ -372,15 +385,18 @@ where
 .I <n>
 is the display number for the __xservername__ server.
 ..
-.SH SERVERFLAGS SECTION
+.SH "SERVERFLAGS SECTION"
 In addition to options specific to this section (described below), the
 .B ServerFlags
 section is used to specify some global
-__xservername__ server options.  All of the entries in this section are
+__xservername__ server options.  
+All of the entries in this section are
 .BR Options ,
 although for compatibility purposes some of the old style entries are
-still recognised.  Those old style entries are not documented here, and
-using them is discouraged.  The
+still recognised.  
+Those old style entries are not documented here, and using them is 
+discouraged.  
+The
 .B ServerFlags
 section is optional, as are the entries that may be specified in it.
 .PP
@@ -392,11 +408,12 @@ may be overridden by
 .B Options
 specified in the active
 .B ServerLayout
-section.  Options with command line equivalents are overridden when their
-command line equivalent is used.  The options recognised by this section
-are:
+section.
+Options with command line equivalents are overridden when their command
+line equivalent is used.
+The options recognised by this section are:
 .TP 7
-.BI "Option \*qDefaultServerLayout\*q  \*q" layout-id \*q
+.BI "Option \*qDefaultServerLayout\*q  \*q" layout\-id \*q
 This specifies the default
 .B ServerLayout
 section to use in the absence of the
@@ -404,148 +421,185 @@ section to use in the absence of the
 command line option.
 .TP 7
 .BI "Option \*qNoTrapSignals\*q  \*q" boolean \*q
-This prevents the __xservername__ server from trapping a range of unexpected
-fatal signals and exiting cleanly.  Instead, the __xservername__ server will die
-and drop core where the fault occurred.  The default behaviour is
-for the __xservername__ server to exit cleanly, but still drop a core file.  In
-general you never want to use this option unless you are debugging
-an __xservername__ server problem and know how to deal with the consequences.
+This prevents the __xservername__ server from trapping a range of unexpected fatal
+signals and exiting cleanly.
+Instead, the __xservername__ server will die and drop core where the fault occurred.
+The default behaviour is for the __xservername__ server to exit cleanly, but still drop a
+core file.
+In general you never want to use this option unless you are debugging an __xservername__
+server problem and know how to deal with the consequences.
 .TP 7
 .BI "Option \*qDontVTSwitch\*q  \*q" boolean \*q
 This disallows the use of the
 .BI Ctrl+Alt+F n
 sequence (where
 .RI F n
-refers to one of the numbered function keys).  That sequence is normally
-used to switch to another \*qvirtual terminal\*q on operating systems
-that have this feature.  When this option is enabled, that key sequence has
-no special meaning and is passed to clients.  Default: off.
+refers to one of the numbered function keys).
+That sequence is normally used to switch to another \*qvirtual terminal\*q
+on operating systems that have this feature.
+When this option is enabled, that key sequence has no special meaning and
+is passed to clients.
+Default: off.
 .TP 7
 .BI "Option \*qDontZap\*q  \*q" boolean \*q
 This disallows the use of the
 .B Ctrl+Alt+Backspace
-sequence.  That sequence is normally used to terminate the __xservername__ server.
-When this option is enabled, that key sequence has no special meaning
-and is passed to clients.  Default: off.
+sequence.
+That sequence is normally used to terminate the __xservername__ server.
+When this option is enabled, that key sequence has no special meaning and
+is passed to clients.
+Default: off.
 .TP 7
 .BI "Option \*qDontZoom\*q  \*q" boolean \*q
 This disallows the use of the
-.B Ctrl+Alt+Keypad-Plus
+.B Ctrl+Alt+Keypad\-Plus
 and
-.B Ctrl+Alt+Keypad-Minus
-sequences.  These sequences allows you to switch between video modes.
+.B Ctrl+Alt+Keypad\-Minus
+sequences.
+These sequences allows you to switch between video modes.
 When this option is enabled, those key sequences have no special meaning
-and are passed to clients.  Default: off.
+and are passed to clients.
+Default: off.
 .TP 7
 .BI "Option \*qDisableVidModeExtension\*q  \*q" boolean \*q
 This disables the parts of the VidMode extension used by the xvidtune client
-that can be used to change the video modes.  Default: the VidMode extension
-is enabled.
+that can be used to change the video modes.
+Default: the VidMode extension is enabled.
 .TP 7
 .BI "Option \*qAllowNonLocalXvidtune\*q  \*q" boolean \*q
 This allows the xvidtune client (and other clients that use the VidMode
-extension) to connect from another host.  Default: off.
+extension) to connect from another host.
+Default: off.
 .TP 7
 .BI "Option \*qDisableModInDev\*q  \*q" boolean \*q
-This disables the parts of the __xservername__-Misc extension that can be used to
-modify the input device settings dynamically.  Default: that functionality
-is enabled.
+This disables the parts of the __xservername__\-Misc extension that can be used to
+modify the input device settings dynamically.
+Default: that functionality is enabled.
 .TP 7
 .BI "Option \*qAllowNonLocalModInDev\*q  \*q" boolean \*q
 This allows a client to connect from another host and change keyboard
-and mouse settings in the running server.  Default: off.
+and mouse settings in the running server.
+Default: off.
 .TP 7
 .BI "Option \*qAllowMouseOpenFail\*q  \*q" boolean \*q
 This allows the server to start up even if the mouse device can't be
-opened/initialised.  Default: false.
+opened/initialised.
+Default: false.
 .TP 7
 .BI "Option \*qVTInit\*q  \*q" command \*q
 Runs
 .I command
 after the VT used by the server has been opened.
-The command string is passed to "/bin/sh -c", and is run with the
-real user's id with stdin and stdout set to the VT.  The purpose
-of this option is to allow system dependent VT initialisation
-commands to be run.  This option should rarely be needed.  Default: not set.
+The command string is passed to \*q/bin/sh \-c\*q, and is run with the real
+user's id with stdin and stdout set to the VT.
+The purpose of this option is to allow system dependent VT initialisation
+commands to be run.
+This option should rarely be needed.
+Default: not set.
 .TP 7
 .BI "Option \*qVTSysReq\*q  \*q" boolean \*q
-enables the SYSV-style VT switch sequence for non-SYSV systems
-which support VT switching.  This sequence is
-.B Alt-SysRq
-followed
-by a function key
+enables the SYSV\-style VT switch sequence for non\-SYSV systems
+which support VT switching.
+This sequence is
+.B Alt\-SysRq
+followed by a function key
 .RB ( Fn ).
 This prevents the __xservername__ server trapping the
 keys used for the default VT switch sequence, which means that clients can
-access them.  Default: off.
+access them.
+Default: off.
 .TP 7
 .BI "Option \*qXkbDisable\*q \*q" boolean \*q
-disable/enable the XKEYBOARD extension.  The \-kb command line
-option overrides this config file option.  Default: XKB is enabled.
+disable/enable the XKEYBOARD extension.
+The \-kb command line option overrides this config file option.
+Default: XKB is enabled.
 .\" The following four options are "undocumented".
 .ig
 .TP 7
 .BI "Option \*qPciProbe1\*q"
-Use PCI probe method 1.  Default: set.
+Use PCI probe method 1.
+Default: set.
 .TP 7
 .BI "Option \*qPciProbe2\*q"
-Use PCI probe method 2.  Default: not set.
+Use PCI probe method 2.
+Default: not set.
 .TP 7
 .BI "Option \*qPciForceConfig1\*q"
-Force the use PCI config type 1.  Default: not set.
+Force the use PCI config type 1.
+Default: not set.
 .TP 7
 .BI "Option \*qPciForceConfig2\*q"
-Force the use PCI config type 2.  Default: not set.
+Force the use PCI config type 2. 
+Default: not set.
 ..
 .TP 7
 .BI "Option \*qBlankTime\*q  \*q" time \*q
-sets the inactivity timeout for the blanking phase of the screensaver.
+sets the inactivity timeout for the
+.B blank
+phase of the screensaver.
 .I time
-is in minutes.  This is equivalent to the __xservername__ server's `-s' flag,
-and the value can be changed at run-time with xset(__appmansuffix__).  Default: 10
-minutes.
+is in minutes.
+This is equivalent to the __xservername__ server's
+.B \-s
+flag, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 10 minutes.
 .TP 7
 .BI "Option \*qStandbyTime\*q  \*q" time \*q
-sets the inactivity timeout for the "standby" phase of DPMS mode.
+sets the inactivity timeout for the
+.B standby
+phase of DPMS mode.
 .I time
-is in minutes, and the value can be changed at run-time with xset(__appmansuffix__).
-Default: 20 minutes.  This is only suitable for VESA DPMS compatible
-monitors, and may not be supported by all video drivers.  It is only
-enabled for screens that have the
+is in minutes, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 20 minutes.
+This is only suitable for VESA DPMS compatible monitors, and may not be
+supported by all video drivers.
+It is only enabled for screens that have the
 .B \*qDPMS\*q
 option set (see the MONITOR section below).
 .TP 7
 .BI "Option \*qSuspendTime\*q  \*q" time \*q
-sets the inactivity timeout for the "suspend" phase of DPMS mode.
+sets the inactivity timeout for the
+.B suspend
+phase of DPMS mode.
 .I time
-is in minutes, and the value can be changed at run-time with xset(__appmansuffix__).
-Default: 30 minutes.  This is only suitable for VESA DPMS compatible
-monitors, and may not be supported by all video drivers.  It is only
-enabled for screens that have the
+is in minutes, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 30 minutes.
+This is only suitable for VESA DPMS compatible monitors, and may not be
+supported by all video drivers.
+It is only enabled for screens that have the
 .B \*qDPMS\*q
 option set (see the MONITOR section below).
 .TP 7
 .BI "Option \*qOffTime\*q  \*q" time \*q
-sets the inactivity timeout for the "off" phase of DPMS mode.
+sets the inactivity timeout for the
+.B off
+phase of DPMS mode.
 .I time
-is in minutes, and the value can be changed at run-time with xset(__appmansuffix__).
-Default: 40 minutes.  This is only suitable for VESA DPMS compatible
-monitors, and may not be supported by all video drivers.  It is only
-enabled for screens that have the
+is in minutes, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 40 minutes. 
+This is only suitable for VESA DPMS compatible monitors, and may not be
+supported by all video drivers.
+It is only enabled for screens that have the
 .B \*qDPMS\*q
 option set (see the MONITOR section below).
 .TP 7
 .BI "Option \*qPixmap\*q  \*q" bpp \*q
-This sets the pixmap format to use for depth 24.  Allowed values for
+This sets the pixmap format to use for depth 24.
+Allowed values for
 .I bpp
-are 24 and 32.  Default: 32 unless driver constraints don't allow this
-(which is rare).  Note: some clients don't behave well when this value
-is set to 24.
+are 24 and 32.
+Default: 32 unless driver constraints don't allow this (which is rare).
+Note: some clients don't behave well when this value is set to 24.
 .TP 7
 .BI "Option \*qPC98\*q  \*q" boolean \*q
-Specify that the machine is a Japanese PC-98 machine.  This should not
-be enabled for anything other than the Japanese-specific PC-98
-architecture.  Default: auto-detected.
+Specify that the machine is a Japanese PC\-98 machine.
+This should not be enabled for anything other than the Japanese\-specific
+PC\-98 architecture.
+Default: auto\-detected.
 .\" Doubt this should be documented.
 .ig
 .TP 7
@@ -555,48 +609,54 @@ Default: 0.
 ..
 .TP 7
 .BI "Option \*qNoPM\*q  \*q" boolean \*q
-Disables something to do with power management events.  Default: PM
-enabled on platforms that support it.
+Disables something to do with power management events.
+Default: PM enabled on platforms that support it.
 .TP 7
 .BI "Option \*qXinerama\*q  \*q" boolean \*q
-enable or disable XINERAMA extension. Default is disabled.
+enable or disable XINERAMA extension.
+Default is disabled.
 .TP 7
 .BI "Option \*qAllowDeactivateGrabs\*q \*q" boolean \*q
 This option enables the use of the
-.B Ctrl+Alt+Keypad-Divide
-key sequence to deactivate any active keyboard and mouse grabs.  Default:
-off.
+.B Ctrl+Alt+Keypad\-Divide
+key sequence to deactivate any active keyboard and mouse grabs.
+Default: off.
 .TP 7
 .BI "Option \*qAllowClosedownGrabs\*q \*q" boolean \*q
 This option enables the use of the
-.B Ctrl+Alt+Keypad-Multiply
-key sequence to kill clients with an active keyboard or mouse grab as
-well as killing any application that may have locked the server, normally
-using the XGrabServer(__libmansuffix__) Xlib function.  Default: off.
+.B Ctrl+Alt+Keypad\-Multiply
+key sequence to kill clients with an active keyboard or mouse grab as well
+as killing any application that may have locked the server, normally using
+the
+.BR XGrabServer(__libmansuffix__)
+Xlib function.
+Default: off.
 .br
 Note that the options
-.BI AllowDeactivateGrabs
+.B AllowDeactivateGrabs
 and
-.BI AllowClosedownGrabs
+.B AllowClosedownGrabs
 will allow users to remove the grab used by screen saver/locker programs.
-An API was written to such cases. If you enable this option, make sure
-your screen saver/locker is updated.
+An API was written to such cases.
+If you enable this option, make sure your screen saver/locker is updated.
+Default: off.
 .TP 7
 .BI "Option \*qHandleSpecialKeys\*q \*q" when \*q
 This option controls when the server uses the builtin handler to process
 special key combinations (such as
 .BR Ctrl+Alt+Backspace ).
-Normally the XKEYBOARD extension keymaps will provide mappings for each
-of the special key combinations, so the builtin handler is not needed
-unless the XKEYBOARD extension is disabled.  The value of
+Normally the XKEYBOARD extension keymaps will provide mappings for each of
+the special key combinations, so the builtin handler is not needed unless
+the XKEYBOARD extension is disabled.
+The value of
 .I when
 can be
 .BR Always ,
 .BR Never ,
 or
 .BR WhenNeeded .
-Default: Use the builtin handler only if needed.  The server will scan
-the keymap for a mapping to the
+Default: Use the builtin handler only if needed.
+The server will scan the keymap for a mapping to the
 .B Terminate
 action and, if found, use XKEYBOARD for processing actions, otherwise
 the builtin handler will be used.
@@ -612,21 +672,22 @@ default.
 .BI "Option \*qIgnoreABI\*q \*q" boolean \*q
 Allow modules built for a different, potentially incompatible version of
 the X server to load. Disabled by default.
-.SH MODULE SECTION
+.SH "MODULE SECTION"
 The
 .B Module
 section is used to specify which __xservername__ server modules should be loaded.
 This section is ignored when the __xservername__ server is built in static form.
 The types of modules normally loaded in this section are __xservername__ server
-extension modules, and font rasteriser modules.  Most other module types
-are loaded automatically when they are needed via other mechanisms.
+extension modules, and font rasteriser modules.
+Most other module types are loaded automatically when they are needed via
+other mechanisms.
 The
 .B Module
 section is optional, as are all of the entries that may be specified in
 it.
 .PP
-Entries in this section may be in two forms.   The first and most commonly
-used form is an entry that uses the
+Entries in this section may be in two forms.
+The first and most commonly used form is an entry that uses the
 .B Load
 keyword, as described here:
 .TP 7
@@ -634,8 +695,9 @@ keyword, as described here:
 This instructs the server to load the module called
 .IR modulename .
 The module name given should be the module's standard name, not the
-module file name.  The standard name is case-sensitive, and does not
-include the "lib" prefix, or the ".a", ".o", or ".so" suffixes.
+module file name.
+The standard name is case\-sensitive, and does not include the \(lqlib\(rq
+prefix, or the \(lq.a\(rq, \(lq.o\(rq, or \(lq.so\(rq suffixes.
 .PP
 .RS 7
 Example: the Type 1 font rasteriser can be loaded with the following entry:
@@ -668,13 +730,13 @@ being
 that are passed to the module when it is loaded.
 .PP
 Example: the extmod module (which contains a miscellaneous group of
-server extensions) can be loaded, with the XFree86-DGA extension
+server extensions) can be loaded, with the XFree86\-DGA extension
 disabled by using the following entry:
 .PP
 .RS 4
 .nf
 .B "SubSection \*qextmod\*q"
-.B "   Option  \*qomit XFree86-DGA\*q"
+.B "   Option  \*qomit XFree86\-DGA\*q"
 .B EndSubSection
 .fi
 .RE
@@ -696,17 +758,20 @@ __projectroot__/lib/modules/extensions
 .fi
 .RE
 .PP
-The "bitmap" font modules is loaded automatically.  It is recommended
-that at very least the "extmod" extension module be loaded.  If it isn't
-some commonly used server extensions (like the SHAPE extension) will not be
-available.
-.SH INPUTDEVICE SECTION
+The \(lqbitmap\(rq font module is loaded automatically.
+It is recommended
+that at very least the \(lqextmod\(rq extension module be loaded.
+If it isn't, some commonly used server extensions (like the SHAPE
+extension) will not be available.
+.SH "INPUTDEVICE SECTION"
 The config file may have multiple
 .B InputDevice
-sections.  There will normally be at least two: one for the core (primary)
-keyboard, and one of the core pointer.  If either of these two is missing,
-a default configuration for the missing ones will be used.  Currently the
-default configuration may not work as expected on all platforms.
+sections.
+There will normally be at least two: one for the core (primary) keyboard,
+and one of the core pointer.
+If either of these two is missing, a default configuration for the missing
+ones will be used.
+Currently the default configuration may not work as expected on all platforms.
 .PP
 .B InputDevice
 sections have the following format:
@@ -728,18 +793,21 @@ and
 .B Driver
 entries are required in all
 .B InputDevice
-sections.  All other entries are optional.
+sections.
+All other entries are optional.
 .PP
 The
 .B Identifier
-entry specifies the unique name for this input device.  The
+entry specifies the unique name for this input device.
+The
 .B Driver
 entry specifies the name of the driver to use for this input device.
 When using the loadable server, the input driver module
 .RI \*q inputdriver \*q
 will be loaded for each active
 .B InputDevice
-section.  An
+section.
+An
 .B InputDevice
 section is considered active if it is referenced by an active
 .B ServerLayout
@@ -749,7 +817,10 @@ or
 .B \-pointer
 command line options, or if it is selected implicitly as the core pointer
 or keyboard device in the absence of such explicit references.
-The most commonly used input drivers are "keyboard" and "mouse".
+The most commonly used input drivers are
+.BR keyboard (__drivermansuffix__)
+and
+.BR mouse (__drivermansuffix__).
 .PP
 In the absence of an explicitly specified core input device, the first
 .B InputDevice
@@ -757,21 +828,24 @@ marked as
 .B CorePointer
 (or
 .BR CoreKeyboard )
-is used.  If there is no match there, the first
+is used.
+If there is no match there, the first
 .B InputDevice
-that uses the "mouse" (or "keyboard" or "kbd") driver is used.  The final
-fallback is to use built-in default configurations.
+that uses the \(lqmouse\(rq (or \(lqkeyboard\(rq or \(lqkbd\(rq) driver is used.
+The final fallback is to use built\-in default configurations.
 .PP
 .B InputDevice
-sections recognise some driver-independent
+sections recognise some driver\-independent
 .BR Options ,
-which are described here.  See the individual input driver manual pages
-for a description of the device-specific options.
+which are described here.
+See the individual input driver manual pages for a description of the
+device\-specific options.
 .TP 7
 .BI "Option \*qCorePointer\*q"
 When this is set, the input device is installed as the core (primary)
-pointer device.  There must be exactly one core pointer.  If this option
-is not set here, or in the
+pointer device.
+There must be exactly one core pointer.
+If this option is not set here, or in the
 .B ServerLayout
 section, or from the
 .B \-pointer
@@ -783,8 +857,9 @@ section is used.
 .TP 7
 .BI "Option \*qCoreKeyboard\*q"
 When this is set, the input device is to be installed as the core
-(primary) keyboard device.  There must be exactly one core keyboard.  If
-this option is not set here, in the
+(primary) keyboard device.
+There must be exactly one core keyboard.
+If this option is not set here, in the
 .B ServerLayout
 section, or from the
 .B \-keyboard
@@ -798,19 +873,21 @@ section is used.
 .TP 7
 .BI "Option \*qSendCoreEvents\*q  \*q" boolean \*q
 Both of these options are equivalent, and when enabled cause the
-input device to always report core events.  This can be used, for
-example, to allow an additional pointer device to generate core
-pointer events (like moving the cursor, etc).
+input device to always report core events.
+This can be used, for example, to allow an additional pointer device to
+generate core pointer events (like moving the cursor, etc).
 .TP 4
 .BI "Option \*qHistorySize\*q  \*q" number \*q
-Sets the motion history size.  Default: 0.
+Sets the motion history size.
+Default: 0.
 .TP 7
 .BI "Option \*qSendDragEvents\*q  \*q" boolean \*q
 ???
-.SH DEVICE SECTION
+.SH "DEVICE SECTION"
 The config file may have multiple
 .B Device
-sections.  There must be at least one, for the video card being used.
+sections.
+There must be at least one, for the video card being used.
 .PP
 .B Device
 sections have the following format:
@@ -836,27 +913,30 @@ sections.  All other entries are optiona
 .PP
 The
 .B Identifier
-entry specifies the unique name for this graphics device.  The
+entry specifies the unique name for this graphics device.
+The
 .B Driver
 entry specifies the name of the driver to use for this graphics device.
 When using the loadable server, the driver module
 .RI \*q driver \*q
 will be loaded for each active
 .B Device
-section.  A
+section.
+A
 .B Device
 section is considered active if it is referenced by an active
 .B Screen
 section.
 .PP
 .B Device
-sections recognise some driver-independent entries and
+sections recognise some driver\-independent entries and
 .BR Options ,
-which are described here.  Not all drivers make use of these
-driver-independent entries, and many of those that do don't require them
-to be specified because the information is auto-detected.  See the
-individual graphics driver manual pages for further information about
-this, and for a description of the device-specific options.
+which are described here.
+Not all drivers make use of these
+driver\-independent entries, and many of those that do don't require them
+to be specified because the information is auto\-detected.
+See the individual graphics driver manual pages for further information
+about this, and for a description of the device\-specific options.
 Note that most of the
 .B Options
 listed here (but not the other entries) may be specified in the
@@ -865,118 +945,133 @@ section instead of here in the
 .B Device
 section.
 .TP 7
-.BI "BusID  \*q" bus-id \*q
-This specifies the bus location of the graphics card.  For PCI/AGP cards,
+.BI "BusID  \*q" bus\-id \*q
+This specifies the bus location of the graphics card.
+For PCI/AGP cards,
 the
-.I bus-id
+.I bus\-id
 string has the form
 .BI PCI: bus : device : function
-(e.g., "PCI:1:0:0" might be appropriate for an AGP card).
+(e.g., \(lqPCI:1:0:0\(rq might be appropriate for an AGP card).
 This field is usually optional in single-head configurations when using
-the primary graphics card.  In multi-head configurations, or when using
-a secondary graphics card in a single-head configuration, this entry is
-mandatory.  Its main purpose is to make an unambiguous connection between
-the device section and the hardware it is representing.  This information
-can usually be found by running the __xservername__ server with the
+the primary graphics card.
+In multi-head configurations, or when using a secondary graphics card in a
+single-head configuration, this entry is mandatory.
+Its main purpose is to make an unambiguous connection between the device
+section and the hardware it is representing.
+This information can usually be found by running the __xservername__ server
+with the
 .B \-scanpci
 command line option.
 .TP 7
 .BI "Screen  " number
 This option is mandatory for cards where a single PCI entity can drive more
 than one display (i.e., multiple CRTCs sharing a single graphics accelerator
-and video memory).  One
+and video memory).
+One
 .B Device
 section is required for each head, and this
 parameter determines which head each of the
 .B Device
-sections applies to.  The legal values of
+sections applies to.
+The legal values of
 .I number
 range from 0 to one less than the total number of heads per entity.
 Most drivers require that the primary screen (0) be present.
 .TP 7
 .BI "Chipset  \*q" chipset \*q
 This usually optional entry specifies the chipset used on the graphics
-board.  In most cases this entry is not required because the drivers
-will probe the hardware to determine the chipset type.  Don't
-specify it unless the driver-specific documentation recommends that you
+board.
+In most cases this entry is not required because the drivers will probe the
+hardware to determine the chipset type.
+Don't specify it unless the driver-specific documentation recommends that you
 do.
 .TP 7
-.BI "Ramdac  \*q" ramdac-type \*q
+.BI "Ramdac  \*q" ramdac\-type \*q
 This optional entry specifies the type of RAMDAC used on the graphics
-board.  This is only used by a few of the drivers, and in most cases it
-is not required because the drivers will probe the hardware to determine
-the RAMDAC type where possible.  Don't specify it unless the
-driver-specific documentation recommends that you do.
+board.
+This is only used by a few of the drivers, and in most cases it is not
+required because the drivers will probe the hardware to determine the
+RAMDAC type where possible.
+Don't specify it unless the driver-specific documentation recommends that you
+do.
 .TP 7
 .BI "DacSpeed  " speed
 .TP 7
-.BI "DacSpeed  " "speed-8 speed-16 speed-24 speed-32"
+.BI "DacSpeed  " "speed\-8 speed\-16 speed\-24 speed\-32"
 This optional entry specifies the RAMDAC speed rating (which is usually
-printed on the RAMDAC chip).  The speed is in MHz.  When one value is
-given, it applies to all framebuffer pixel sizes.  When multiple values
-are give, they apply to the framebuffer pixel sizes 8, 16, 24 and 32
-respectively.  This is not used by many drivers, and only needs to be
-specified when the speed rating of the RAMDAC is different from the
-defaults built in to driver, or when the driver can't auto-detect the
-correct defaults.  Don't specify it unless the driver-specific
-documentation recommends that you do.
+printed on the RAMDAC chip).
+The speed is in MHz.
+When one value is given, it applies to all framebuffer pixel sizes.
+When multiple values are given, they apply to the framebuffer pixel sizes
+8, 16, 24 and 32 respectively.
+This is not used by many drivers, and only needs to be specified when the
+speed rating of the RAMDAC is different from the defaults built in to
+driver, or when the driver can't auto-detect the correct defaults.
+Don't specify it unless the driver-specific documentation recommends that you
+do.
 .TP 7
 .BI "Clocks  " "clock ..."
-specifies the pixel that are on your graphics board.  The clocks are in
-MHz, and may be specified as a floating point number.  The value is
-stored internally to the nearest kHz.  The ordering of the clocks is
-important.  It must match the order in which they are selected on the
-graphics board.  Multiple
+specifies the pixel that are on your graphics board.
+The clocks are in MHz, and may be specified as a floating point number.
+The value is stored internally to the nearest kHz.
+The ordering of the clocks is important.
+It must match the order in which they are selected on the graphics board.
+Multiple
 .B Clocks
-lines may be specified, and each is concatenated to form the list.  Most
-drivers do not use this entry, and it is only required for some older
-boards with non-programmable clocks.  Don't specify this entry unless
-the driver-specific documentation explicitly recommends that you do.
+lines may be specified, and each is concatenated to form the list.
+Most drivers do not use this entry, and it is only required for some older
+boards with non-programmable clocks.
+Don't specify this entry unless the driver-specific documentation explicitly
+recommends that you do.
 .TP
-.BI "ClockChip  \*q" clockchip-type \*q
+.BI "ClockChip  \*q" clockchip\-type \*q
 This optional entry is used to specify the clock chip type on graphics
-boards which have a programmable clock generator.  Only a few __xservername__
-drivers support programmable clock chips.  For details, see the appropriate
-driver manual page.
+boards which have a programmable clock generator.
+Only a few __xservername__ drivers support programmable clock chips.
+For details, see the appropriate driver manual page.
 .TP 7
 .BI "VideoRam  " "mem"
 This optional entry specifies the amount of video ram that is installed
-on the graphics board. This is measured in kBytes.  In most cases this
-is not required because the __xservername__ server probes the graphics board to
-determine this quantity.  The driver-specific documentation should
-indicate when it might be needed.
+on the graphics board.
+This is measured in kBytes.
+In most cases this is not required because the __xservername__ server probes
+the graphics board to determine this quantity.
+The driver-specific documentation should indicate when it might be needed.
 .TP 7
 .BI "BiosBase  " "baseaddress"
 This optional entry specifies the base address of the video BIOS for
-the VGA board.  This address is normally auto-detected, and should only
-be specified if the driver-specific documentation recommends it.
+the VGA board.
+This address is normally auto-detected, and should only be specified if the
+driver-specific documentation recommends it.
 .TP 7
 .BI "MemBase  " "baseaddress"
 This optional entry specifies the memory base address of a graphics
-board's linear frame buffer.  This entry is not used by many drivers,
-and it should only be specified if the driver-specific documentation
-recommends it.
+board's linear frame buffer.
+This entry is not used by many drivers, and it should only be specified if
+the driver-specific documentation recommends it.
 .TP 7
 .BI "IOBase  " "baseaddress"
-This optional entry specifies the IO base address.  This entry is not
-used by many drivers, and it should only be specified if the
-driver-specific documentation recommends it.
+This optional entry specifies the IO base address.
+This entry is not used by many drivers, and it should only be specified if
+the driver-specific documentation recommends it.
 .TP 7
 .BI "ChipID  " "id"
 This optional entry specifies a numerical ID representing the chip type.
-For PCI cards, it is usually the device ID.  This can be used to override
-the auto-detection, but that should only be done when the driver-specific
-documentation recommends it.
+For PCI cards, it is usually the device ID.
+This can be used to override the auto-detection, but that should only be done
+when the driver-specific documentation recommends it.
 .TP 7
 .BI "ChipRev  " "rev"
-This optional entry specifies the chip revision number.  This can be
-used to override the auto-detection, but that should only be done when
-the driver-specific documentation recommends it.
+This optional entry specifies the chip revision number.
+This can be used to override the auto-detection, but that should only be done
+when the driver-specific documentation recommends it.
 .TP 7
 .BI "TextClockFreq  " "freq"
 This optional entry specifies the pixel clock frequency that is used
-for the regular text mode.  The frequency is specified in MHz.  This is
-rarely used.
+for the regular text mode.
+The frequency is specified in MHz.
+This is rarely used.
 .TP 7
 .BI "Option \*qModeDebug\*q \*q" boolean \*q
 Enable printing of additional debugging information about modesetting to
@@ -989,19 +1084,22 @@ This optional entry allows an IRQ number
 .B Options
 Option flags may be specified in the
 .B Device
-sections.  These include driver-specific options and driver-independent
-options.  The former are described in the driver-specific documentation.
+sections.
+These include driver\-specific options and driver\-independent options.
+The former are described in the driver\-specific documentation.
 Some of the latter are described below in the section about the
 .B Screen
 section, and they may also be included here.
 
-.SH VIDEOADAPTOR SECTION
-Nobody wants to say how this works.  Maybe nobody knows ...
+.SH "VIDEOADAPTOR SECTION"
+Nobody wants to say how this works.
+Maybe nobody knows ...
 
-.SH MONITOR SECTION
+.SH "MONITOR SECTION"
 The config file may have multiple
 .B Monitor
-sections.  There should normally be at least one, for the monitor being used,
+sections.
+There should normally be at least one, for the monitor being used,
 but a default configuration will be created when one isn't specified.
 .PP
 .B Monitor
@@ -1025,7 +1123,8 @@ entry.
 .PP
 The
 .B Identifier
-entry specifies the unique name for this monitor.  The
+entry specifies the unique name for this monitor.
+The
 .B Monitor
 section may be used to provide information about the specifications of the
 monitor, monitor-specific
@@ -1033,8 +1132,8 @@ monitor, monitor-specific
 and information about the video modes to use with the monitor.
 .PP
 With RandR 1.2-enabled drivers, monitor sections are tied to specific outputs 
-of the video card.  Each output has a name, and the server will look for a
-Monitor named
+of the video card.
+Each output has a name, and the server will look for a Monitor named
 .B \*qMonitor-outputname\*q
 for configuration of that output (for example, 
 .B \*qMonitor-VGA\*q
@@ -1042,16 +1141,17 @@ for a VGA output)
 .PP
 Specifying video modes is optional because the server will use the DDC or other
 information provided by the monitor to automatically configure the list of
-modes available.  When modes are specified explicitly in the
+modes available.
+When modes are specified explicitly in the
 .B Monitor
 section (with the
 .BR Modes ,
 .BR ModeLine ,
 or
 .B UseModes
-keywords), built-in modes with the same names are not included.  Built-in
-modes with different names are, however, still implicitly included, when they
-meet the requirements of the monitor.
+keywords), built-in modes with the same names are not included.
+Built-in modes with different names are, however, still implicitly included,
+when they meet the requirements of the monitor.
 .PP
 The entries that may be used in
 .B Monitor
@@ -1063,69 +1163,79 @@ This optional entry specifies the monito
 .BI "ModelName  \*q" model \*q
 This optional entry specifies the monitor's model.
 .TP 7
-.BI "HorizSync  " "horizsync-range"
+.BI "HorizSync  " "horizsync\-range"
 gives the range(s) of horizontal sync frequencies supported by the
 monitor.
-.I horizsync-range
+.I horizsync\-range
 may be a comma separated list of either discrete values or ranges of
-values.  A range of values is two values separated by a dash.  By default
-the values are in units of kHz.  They may be specified in MHz or Hz if
+values.
+A range of values is two values separated by a dash.
+By default the values are in units of kHz.
+They may be specified in MHz or Hz
+if
 .B MHz
 or
 .B Hz
-is added to the end of the line.  The data given here is used by the
-__xservername__ server to determine if video modes are within the specifications
-of the monitor.  This information should be available in the monitor's
-handbook.  If this entry is omitted, a default range of 28\-33kHz is
-used.
+is added to the end of the line.
+The data given here is used by the __xservername__ server to determine if video
+modes are within the specifications of the monitor.
+This information should be available in the monitor's handbook.
+If this entry is omitted, a default range of 28\-33kHz is used.
 .TP 7
-.BI "VertRefresh  " "vertrefresh-range"
+.BI "VertRefresh  " "vertrefresh\-range"
 gives the range(s) of vertical refresh frequencies supported by the
 monitor.
-.I vertrefresh-range
+.I vertrefresh\-range
 may be a comma separated list of either discrete values or ranges of
-values.  A range of values is two values separated by a dash.  By default
-the values are in units of Hz.  They may be specified in MHz or kHz if
+values.
+A range of values is two values separated by a dash.
+By default the values are in units of Hz.
+They may be specified in MHz or kHz
+if
 .B MHz
 or
 .B kHz
-is added to the end of the line.  The data given here is used by the
-__xservername__ server to determine if video modes are within the specifications
-of the monitor.  This information should be available in the monitor's
-handbook.  If this entry is omitted, a default range of 43-72Hz is used.
+is added to the end of the line.
+The data given here is used by the __xservername__ server to determine if video
+modes are within the specifications of the monitor.
+This information should be available in the monitor's handbook.
+If this entry is omitted, a default range of 43\-72Hz is used.
 .TP 7
 .BI "DisplaySize  " "width height"
 This optional entry gives the width and height, in millimetres, of the
-picture area of the monitor. If given this is used to calculate the
-horizontal and vertical pitch (DPI) of the screen.
+picture area of the monitor.
+If given this is used to calculate the horizontal and vertical pitch (DPI) of
+the screen.
 .TP 7
-.BI "Gamma  " "gamma-value"
+.BI "Gamma  " "gamma\-value"
 .TP 7
-.BI "Gamma  " "red-gamma green-gamma blue-gamma"
+.BI "Gamma  " "red\-gamma green\-gamma blue\-gamma"
 This is an optional entry that can be used to specify the gamma correction
-for the monitor.  It may be specified as either a single value or as
-three separate RGB values.  The values should be in the range 0.1 to
-10.0, and the default is 1.0.  Not all drivers are capable of using this
-information.
+for the monitor.
+It may be specified as either a single value or as three separate RGB values.
+The values should be in the range 0.1 to 10.0, and the default is 1.0.
+Not all drivers are capable of using this information.
 .TP 7
-.BI "UseModes  \*q" modesection-id \*q
+.BI "UseModes  \*q" modesection\-id \*q
 Include the set of modes listed in the
 .B Modes
 section called
-.IR modesection-id.
+.IR modesection\-id.
 This makes all of the modes defined in that section available for use by
 this monitor.
 .TP 7
 .BI "Mode  \*q" name \*q
 This is an optional multi-line entry that can be used to provide
-definitions for video modes for the monitor.  In most cases this isn't
-necessary because the built-in set of VESA standard modes will be
-sufficient.  The
+definitions for video modes for the monitor.
+In most cases this isn't necessary because the built-in set of VESA standard
+modes will be sufficient.
+The
 .B Mode
 keyword indicates the start of a multi-line video mode description.
 The mode description is terminated with the
 .B EndMode
-keyword.  The mode description consists of the following entries:
+keyword.
+The mode description consists of the following entries:
 .RS 7
 .TP 4
 .BI "DotClock  " clock
@@ -1161,52 +1271,60 @@ and
 may be used to select the composite sync polarity.
 .TP 4
 .BI "HSkew  " hskew
-specifies the number of pixels (towards the right edge of the screen)
-by which the display enable signal is to be skewed.  Not all drivers
-use this information.  This option might become necessary to override
-the default value supplied by the server (if any).  "Roving" horizontal
-lines indicate this value needs to be increased.  If the last few pixels
-on a scan line appear on the left of the screen, this value should be
-decreased.
+specifies the number of pixels (towards the right edge of the screen) by
+which the display enable signal is to be skewed.
+Not all drivers use this information.
+This option might become necessary to override the default value supplied
+by the server (if any).
+\(lqRoving\(rq horizontal lines indicate this value needs to be increased.
+If the last few pixels on a scan line appear on the left of the screen,
+this value should be decreased.
 .TP 4
 .BI "VScan  " vscan
 specifies the number of times each scanline is painted on the screen.
-Not all drivers use this information.  Values less than 1 are treated
-as 1, which is the default.  Generally, the
+Not all drivers use this information.
+Values less than 1 are treated as 1, which is the default.
+Generally, the
 .B \*qDoubleScan\*q
 .B Flag
 mentioned above doubles this value.
 .RE
 .TP 7
-.BI "ModeLine  \*q" name \*q " mode-description"
+.BI "ModeLine  \*q" name \*q " mode\-description"
 This entry is a more compact version of the
 .B Mode
 entry, and it also can be used to specify video modes for the monitor.
-is a single line format for specifying video modes.  In most cases this
-isn't necessary because the built-in set of VESA standard modes will be
-sufficient.
+is a single line format for specifying video modes.
+In most cases this isn't necessary because the built\-in set of VESA
+standard modes will be sufficient.
 .PP
 .RS 7
 The
-.I mode-description
-is in four sections, the first three of which are mandatory.  The first
-is the dot (pixel) clock.  This is a single number specifying the pixel
-clock rate for the mode in MHz.  The second section is a list of four
-numbers specifying the horizontal timings.  These numbers are the
+.I mode\-description
+is in four sections, the first three of which are mandatory.
+The first is the dot (pixel) clock.
+This is a single number specifying the pixel clock rate for the mode in
+MHz.
+The second section is a list of four numbers specifying the horizontal
+timings.
+These numbers are the
 .IR hdisp ,
 .IR hsyncstart ,
 .IR hsyncend ,
 and
 .I htotal
-values.  The third section is a list of four numbers specifying the
-vertical timings.  These numbers are the
+values.
+The third section is a list of four numbers specifying the vertical
+timings.
+These numbers are the
 .IR vdisp ,
 .IR vsyncstart ,
 .IR vsyncend ,
 and
 .I vtotal
-values.  The final section is a list of flags specifying other
-characteristics of the mode.
+values.
+The final section is a list of flags specifying other characteristics of
+the mode.
 .B Interlace
 indicates that the mode is interlaced.
 .B DoubleScan
@@ -1225,7 +1343,8 @@ Additionally, on some hardware,
 .B +CSync
 and
 .B \-CSync
-may be used to select the composite sync polarity.  The
+may be used to select the composite sync polarity.
+The
 .B HSkew
 and
 .B VScan
@@ -1305,20 +1424,22 @@ Valid values for rotation are \*qnormal\
 \*qinverted\*q.
 (RandR 1.2-supporting drivers only)
 
-.SH MODES SECTION
+.SH "MODES SECTION"
 The config file may have multiple
 .B Modes
-sections, or none.  These sections provide a way of defining sets of
-video modes independently of the
+sections, or none.
+These sections provide a way of defining sets of video modes independently
+of the
 .B Monitor
 sections.
 .B Monitor
 sections may include the definitions provided in these sections by
 using the
 .B UseModes
-keyword.  In most cases the
+keyword.
+In most cases the
 .B Modes
-sections are not necessary because the built-in set of VESA standard modes
+sections are not necessary because the built\-in set of VESA standard modes
 will be sufficient.
 .PP
 .B Modes
@@ -1346,21 +1467,24 @@ and
 entries that are described above in the
 .B Monitor
 section.
-.SH SCREEN SECTION
+.SH "SCREEN SECTION"
 The config file may have multiple
 .B Screen
-sections.  There must be at least one, for the "screen" being used.
-A "screen" represents the binding of a graphics device
+sections.
+There must be at least one, for the \(lqscreen\(rq being used.
+A \(lqscreen\(rq represents the binding of a graphics device
 .RB ( Device
 section) and a monitor
 .RB ( Monitor
-section).  A
+section).
+A
 .B Screen
-section is considered "active" if it is referenced by an active
+section is considered \(lqactive\(rq if it is referenced by an active
 .B ServerLayout
 section or by the
 .B \-screen
-command line option.  If neither of those is present, the first
+command line option.
+If neither of those is present, the first
 .B Screen
 section found in the config file is considered the active one.
 .PP
@@ -1388,94 +1512,104 @@ The
 .B Identifier
 and
 .B Device
-entries are mandatory.  All others are optional.
+entries are mandatory.
+All others are optional.
 .PP
 The
 .B Identifier
-entry specifies the unique name for this screen.  The
+entry specifies the unique name for this screen.
+The
 .B Screen
 section provides information specific to the whole screen, including
-screen-specific
+screen\-specific
 .BR Options .
-In multi-head configurations, there will be multiple active
+In multi\-head configurations, there will be multiple active
 .B Screen
 sections, one for each head.
 The entries available
 for this section are:
 .TP 7
-.BI "Device  \*q" device-id \*q
+.BI "Device  \*q" device\-id \*q
 This mandatory entry specifies the
 .B Device
-section to be used for this screen.  This is what ties a specific
-graphics card to a screen.  The
-.I device-id
+section to be used for this screen.
+This is what ties a specific graphics card to a screen.
+The
+.I device\-id
 must match the
 .B Identifier
 of a
 .B Device
 section in the config file.
 .TP 7
-.BI "Monitor  \*q" monitor-id \*q
+.BI "Monitor  \*q" monitor\-id \*q
 specifies which monitor description is to be used for this screen.
 If a
 .B Monitor
-name is not specified, a default configuration is used.  Currently the default
-configuration may not function as expected on all platforms.
+name is not specified, a default configuration is used.
+Currently the default configuration may not function as expected on all
+platforms.
 .TP 7
-.BI "VideoAdaptor  \*q" xv-id \*q
+.BI "VideoAdaptor  \*q" xv\-id \*q
 specifies an optional Xv video adaptor description to be used with this
 screen.
 .TP 7
 .BI "DefaultDepth  " depth
-specifies which color depth the server should use by default.  The
+specifies which color depth the server should use by default.
+The
 .B \-depth
-command line option can be used to override this.  If neither is specified,
-the default depth is driver-specific, but in most cases is 8.
+command line option can be used to override this.
+If neither is specified, the default depth is driver\-specific, but in most
+cases is 8.
 .TP 7
 .BI "DefaultFbBpp  " bpp
-specifies which framebuffer layout to use by default.  The
+specifies which framebuffer layout to use by default.
+The
 .B \-fbbpp
-command line option can be used to override this.  In most cases the
-driver will chose the best default value for this.  The only case where
-there is even a choice in this value is for depth 24, where some hardware
-supports both a packed 24 bit framebuffer layout and a sparse 32 bit
-framebuffer layout.
+command line option can be used to override this.
+In most cases the driver will chose the best default value for this.
+The only case where there is even a choice in this value is for depth 24,
+where some hardware supports both a packed 24 bit framebuffer layout and a
+sparse 32 bit framebuffer layout.
 .TP 7
 .B Options
 Various
 .B Option
 flags may be specified in the
 .B Screen
-section.  Some are driver-specific and are described in the driver
-documentation.  Others are driver-independent, and will eventually be
-described here.
+section.
+Some are driver\-specific and are described in the driver documentation.
+Others are driver\-independent, and will eventually be described here.
 .\" XXX These should really be in an xaa man page.
 .TP 7
 .BI "Option \*qAccel\*q"
 Enables XAA (X Acceleration Architecture), a mechanism that makes video
-cards' 2D hardware acceleration available to the 
-__xservername__ server.  This
-option is on by default, but it may be necessary to turn it off if there
-are bugs in the driver.  There are many options to disable specific
-accelerated operations, listed below.  Note that disabling an operation
-will have no effect if the operation is not accelerated (whether due to
-lack of support in the hardware or in the driver).
+cards' 2D hardware acceleration available to the  __xservername__ server.
+This option is on by default, but it may be necessary to turn it off if
+there are bugs in the driver.
+There are many options to disable specific accelerated operations, listed
+below.
+Note that disabling an operation will have no effect if the operation is
+not accelerated (whether due to lack of support in the hardware or in the
+driver).
 .TP 7
 .BI "Option \*qBiosLocation\*q \*q" address \*q
 Set the location of the BIOS for the Int10 module. One may select a BIOS
 of another card for posting or the legacy V_BIOS range located at 0xc0000
-or an alternative address (BUS_ISA).  This is only useful under very
-special circumstances and should be used with extreme care.
+or an alternative address (BUS_ISA).
+This is only useful under very special circumstances and should be used with
+extreme care.
 .TP 7
 .BI "Option \*qInitPrimary\*q \*q" boolean \*q
-Use the Int10 module to initialize the primary graphics card. Normally,
-only secondary cards are soft-booted using the Int10 module, as the
+Use the Int10 module to initialize the primary graphics card.
+Normally, only secondary cards are soft-booted using the Int10 module, as the
 primary card has already been initialized by the BIOS at boot time.
 Default: false.
 .TP 7
 .BI "Option \*qNoInt10\*q \*q" boolean \*q
 Disables the Int10 module, a module that uses the int10 call to the BIOS
-of the graphics card to initialize it. Default: false.
+of the graphics card to initialize it.
+Default: false.
 .TP 7
 .BI "Option \*qNoMTRR\*q"
 Disables MTRR (Memory Type Range Register) support, a feature of modern
@@ -1485,14 +1619,14 @@ known to exhibit problems when MTRR's ar
 .TP 7
 .BI "Option \*qXaaNoCPUToScreenColorExpandFill\*q"
 Disables accelerated rectangular expansion blits from source patterns
-stored in system memory (using a memory-mapped aperture).
+stored in system memory (using a memory\-mapped aperture).
 .TP 7
 .BI "Option \*qXaaNoColor8x8PatternFillRect\*q"
-Disables accelerated fills of a rectangular region with a full-color
+Disables accelerated fills of a rectangular region with a full\-color
 pattern.
 .TP 7
 .BI "Option \*qXaaNoColor8x8PatternFillTrap\*q"
-Disables accelerated fills of a trapezoidal region with a full-color
+Disables accelerated fills of a trapezoidal region with a full\-color
 pattern.
 .TP 7
 .BI "Option \*qXaaNoDashedBresenhamLine\*q"
@@ -1502,8 +1636,8 @@ Disables accelerated dashed Bresenham li
 Disables accelerated dashed line draws between two arbitrary points.
 .TP 7
 .BI "Option \*qXaaNoImageWriteRect\*q"
-Disables accelerated transfers of full-color rectangular patterns from
-system memory to video memory (using a memory-mapped aperture).
+Disables accelerated transfers of full\-color rectangular patterns from
+system memory to video memory (using a memory\-mapped aperture).
 .TP 7
 .BI "Option \*qXaaNoMono8x8PatternFillRect\*q"
 Disables accelerated fills of a rectangular region with a monochrome
@@ -1524,7 +1658,7 @@ Disables accelerated rectangular expansi
 stored in system memory (one scan line at a time).
 .TP 7
 .BI "Option \*qXaaNoScanlineImageWriteRect\*q"
-Disables accelerated transfers of full-color rectangular patterns from
+Disables accelerated transfers of full\-color rectangular patterns from
 system memory to video memory (one scan line at a time).
 .TP 7
 .BI "Option \*qXaaNoScreenToScreenColorExpandFill\*q"
@@ -1539,10 +1673,10 @@ video memory to another part of video me
 Disables accelerated solid Bresenham line draws.
 .TP 7
 .BI "Option \*qXaaNoSolidFillRect\*q"
-Disables accelerated solid-color fills of rectangles.
+Disables accelerated solid\-color fills of rectangles.
 .TP 7
 .BI "Option \*qXaaNoSolidFillTrap\*q"
-Disables accelerated solid-color fills of Bresenham trapezoids.
+Disables accelerated solid\-color fills of Bresenham trapezoids.
 .TP 7
 .BI "Option \*qXaaNoSolidHorVertLine\*q"
 Disables accelerated solid horizontal and vertical line draws.
@@ -1554,27 +1688,30 @@ Each
 .B Screen
 section may optionally contain one or more
 .B Display
-subsections.  Those subsections provide depth/fbbpp specific configuration
-information, and the one chosen depends on the depth and/or fbbpp that
-is being used for the screen.  The
+subsections.
+Those subsections provide depth/fbbpp specific configuration information,
+and the one chosen depends on the depth and/or fbbpp that is being used for
+the screen.
+The
 .B Display
 subsection format is described in the section below.
 
-.SH DISPLAY SUBSECTION
+.SH "DISPLAY SUBSECTION"
 Each
 .B Screen
 section may have multiple
 .B Display
-subsections.  
-The "active"
+subsections.
+The \(lqactive\(rq
 .B Display
 subsection is the first that matches the depth and/or fbbpp values being
 used, or failing that, the first that has neither a depth or fbbpp value
-specified.  The
+specified.
+The
 .B Display
-subsections are optional.  When there isn't one that matches the depth
-and/or fbbpp values being used, all the parameters that can be specified
-here fall back to their defaults.
+subsections are optional.
+When there isn't one that matches the depth and/or fbbpp values being used,
+all the parameters that can be specified here fall back to their defaults.
 .PP
 .B Display
 subsections have the following format:
@@ -1588,78 +1725,88 @@ subsections have the following format:
 .B  "    EndSubSection"
 .fi
 .RE
-.PP
 .TP 7
 .BI "Depth  " depth
 This entry specifies what colour depth the
 .B Display
-subsection is to be used for.  This entry is usually specified,
-but it may be omitted to create a match-all
+subsection is to be used for.
+This entry is usually specified, but it may be omitted to create a match\-all
 .B Display
 subsection or when wishing to match only against the
 .B FbBpp
-parameter.  The range of
+parameter.
+The range of
 .I depth
-values that are allowed depends on the driver.  Most driver support
-8, 15, 16 and 24.  Some also support 1 and/or 4, and some may support
-other values (like 30).  Note:
+values that are allowed depends on the driver.
+Most drivers support 8, 15, 16 and 24.
+Some also support 1 and/or 4, and some may support other values (like 30).
+Note:
 .I depth
 means the number of bits in a pixel that are actually used to determine
-the pixel colour.  32 is not a valid
+the pixel colour.
+32 is not a valid
 .I depth
-value.  Most hardware that uses 32 bits per pixel only uses 24 of them
-to hold the colour information, which means that the colour depth is
-24, not 32.
+value.
+Most hardware that uses 32 bits per pixel only uses 24 of them to hold the
+colour information, which means that the colour depth is 24, not 32.
 .TP 7
 .BI "FbBpp  " bpp
 This entry specifies the framebuffer format this
 .B Display
-subsection is to be used for.  This entry is only needed when providing
-depth 24 configurations that allow a choice between a 24 bpp packed
-framebuffer format and a 32bpp sparse framebuffer format.  In most cases
-this entry should not be used.
+subsection is to be used for.
+This entry is only needed when providing depth 24 configurations that allow
+a choice between a 24 bpp packed framebuffer format and a 32bpp sparse
+framebuffer format.
+In most cases this entry should not be used.
 .TP 7
-.BI "Weight  " "red-weight green-weight blue-weight"
+.BI "Weight  " "red\-weight green\-weight blue\-weight"
 This optional entry specifies the relative RGB weighting to be used
 for a screen is being used at depth 16 for drivers that allow multiple
-formats.  This may also be specified from the command line with the
+formats.
+This may also be specified from the command line with the
 .B \-weight
-option (see __xservername__(__appmansuffix__)).
+option (see
+.BR __xservername__(__appmansuffix__)).
 .TP 7
 .BI "Virtual  " "xdim ydim"
 This optional entry specifies the virtual screen resolution to be used.
 .I xdim
 must be a multiple of either 8 or 16 for most drivers, and a multiple
-of 32 when running in monochrome mode.  The given value will be rounded
-down if this is not the case.  Video modes which are too large for the
-specified virtual size will be rejected.  If this entry is not present,
-the virtual screen resolution will be set to accommodate all the valid
-video modes given in the
+of 32 when running in monochrome mode.
+The given value will be rounded down if this is not the case.
+Video modes which are too large for the specified virtual size will be
+rejected.
+If this entry is not present, the virtual screen resolution will be set to
+accommodate all the valid video modes given in the
 .B Modes
-entry.  Some drivers/hardware combinations do not support virtual screens.
-Refer to the appropriate driver-specific documentation for details.
+entry.
+Some drivers/hardware combinations do not support virtual screens.
+Refer to the appropriate driver\-specific documentation for details.
 .TP 7
 .BI "ViewPort  " "x0 y0"
 This optional entry sets the upper left corner of the initial display.
 This is only relevant when the virtual screen resolution is different
-from the resolution of the initial video mode.  If this entry is not
-given, then the initial display will be centered in the virtual display
-area.
-.TP 7
-.BI "Modes  \*q" mode-name \*q " ..."
-This optional entry specifies the list of video modes to use.  Each
-.I mode-name
-specified must be in double quotes.  They must correspond to those
-specified or referenced in the appropriate
+from the resolution of the initial video mode.
+If this entry is not given, then the initial display will be centered in
+the virtual display area.
+.TP 7
+.BI "Modes  \*q" mode\-name \*q " ..."
+This optional entry specifies the list of video modes to use.
+Each
+.I mode\-name
+specified must be in double quotes.
+They must correspond to those specified or referenced in the appropriate
 .B Monitor
-section (including implicitly referenced built-in VESA standard modes).
+section (including implicitly referenced built\-in VESA standard modes).
 The server will delete modes from this list which don't satisfy various
-requirements.  The first valid mode in this list will be the default
-display mode for startup.  The list of valid modes is converted internally
-into a circular list.  It is possible to switch to the next mode with
-.B Ctrl+Alt+Keypad-Plus
+requirements.
+The first valid mode in this list will be the default display mode for
+startup.
+The list of valid modes is converted internally into a circular list.
+It is possible to switch to the next mode with
+.B Ctrl+Alt+Keypad\-Plus
 and to the previous mode with
-.BR Ctrl+Alt+Keypad-Minus .
+.BR Ctrl+Alt+Keypad\-Minus .
 When this entry is omitted, the valid modes referenced by the appropriate
 .B Monitor
 section will be used.  If the
@@ -1667,10 +1814,12 @@ section will be used.  If the
 section contains no modes, then the selection will be taken from the
 built-in VESA standard modes.
 .TP 7
-.BI "Visual  \*q" visual-name \*q
-This optional entry sets the default root visual type.  This may also
-be specified from the command line (see the Xserver(__appmansuffix__) man page).  The
-visual types available for depth 8 are (default is
+.BI "Visual  \*q" visual\-name \*q
+This optional entry sets the default root visual type.
+This may also be specified from the command line (see the
+.BR Xserver(__appmansuffix__)
+man page).
+The visual types available for depth 8 are (default is
 .BR PseudoColor ):
 .PP
 .RS 11
@@ -1716,43 +1865,48 @@ The visual type available for the depth 
 .RE
 .TP 7
 .BI "Black  " "red green blue"
-This optional entry allows the "black" colour to be specified.  This
-is only supported at depth 1.  The default is black.
+This optional entry allows the \(lqblack\(rq colour to be specified.
+This is only supported at depth 1.
+The default is black.
 .TP 7
 .BI "White  " "red green blue"
-This optional entry allows the "white" colour to be specified.  This
-is only supported at depth 1.  The default is white.
+This optional entry allows the \(lqwhite\(rq colour to be specified.
+This is only supported at depth 1.
+The default is white.
 .TP 7
 .B Options
 Option flags may be specified in the
 .B Display
-subsections.  These may include driver-specific options and
-driver-independent options.  The former are described in the
-driver-specific documentation.  Some of the latter are described above
-in the section about the
+subsections.
+These may include driver\-specific options and driver\-independent options.
+The former are described in the driver\-specific documentation.
+Some of the latter are described above in the section about the
 .B Screen
 section, and they may also be included here.
-.SH SERVERLAYOUT SECTION
+.SH "SERVERLAYOUT SECTION"
 The config file may have multiple
 .B ServerLayout
-sections.  
-A "server layout" represents the binding of one or more screens
+sections.
+A \(lqserver layout\(rq represents the binding of one or more screens
 .RB ( Screen
 sections) and one or more input devices
 .RB ( InputDevice
-sections) to form a complete configuration.  In multi-head configurations,
-it also specifies the relative layout of the heads.  A
+sections) to form a complete configuration.
+In multi\-head configurations, it also specifies the relative layout of the
+heads.
+A
 .B ServerLayout
-section is considered "active" if it is referenced by the
+section is considered \(lqactive\(rq if it is referenced by the
 .B \-layout
 command line option or by an
 .B "Option \*qDefaultServerLayout\*q"
 entry in the
 .B ServerFlags
-section (the former takes precedence over the latter).  If those options are
-not used, the first
+section (the former takes precedence over the latter).
+If those options are not used, the first
 .B ServerLayout
-section found in the config file is considered the active one.  If no
+section found in the config file is considered the active one.
+If no
 .B ServerLayout
 sections are present, the single active screen and two active (core)
 input devices are selected as described in the relevant sections above.
@@ -1764,9 +1918,9 @@ sections have the following format:
 .nf
 .B  "Section \*qServerLayout\*q"
 .BI "    Identifier   \*q" name \*q
-.BI "    Screen       \*q" screen-id \*q
+.BI "    Screen       \*q" screen\-id \*q
 .I  "    ..."
-.BI "    InputDevice  \*q" idev-id \*q
+.BI "    InputDevice  \*q" idev\-id \*q
 .I  "    ..."
 .I  "    options"
 .I  "    ..."
@@ -1784,10 +1938,11 @@ entry.
 .PP
 The
 .B Identifier
-entry specifies the unique name for this server layout.  The
+entry specifies the unique name for this server layout.
+The
 .B ServerLayout
 section provides information specific to the whole session, including
-session-specific
+session\-specific
 .BR Options .
 The
 .B ServerFlags
@@ -1798,21 +1953,25 @@ section.
 .PP
 The entries that may be used in this section are described here.
 .TP 7
-.BI "Screen  " "screen-num" " \*qscreen-id\*q " "position-information"
+.BI "Screen  " "screen\-num" " \*qscreen\-id\*q " "position\-information"
 One of these entries must be given for each screen being used in
-a session.  The
-.I screen-id
+a session.
+The
+.I screen\-id
 field is mandatory, and specifies the
 .B Screen
-section being referenced.  The
-.I screen-num
+section being referenced.
+The
+.I screen\-num
 field is optional, and may be used to specify the screen number
-in multi-head configurations.  When this field is omitted, the
-screens will be numbered in the order that they are listed in.
-The numbering starts from 0, and must be consecutive.  The
-.I position-information
-field describes the way multiple screens are positioned.  There are
-a number of different ways that this information can be provided:
+in multi\-head configurations.
+When this field is omitted, the screens will be numbered in the order that
+they are listed in.
+The numbering starts from 0, and must be consecutive.
+The
+.I position\-information
+field describes the way multiple screens are positioned.
+There are a number of different ways that this information can be provided:
 .RS 7
 .TP 4
 .I  "x y"
@@ -1822,48 +1981,53 @@ These both specify that the upper left c
 .RI ( x , y ).
 The
 .B Absolute
-keyword is optional.  Some older versions of __xservername__ (4.2 and earlier) don't
-recognise the
+keyword is optional.
+Some older versions of __xservername__ (4.2 and earlier) don't recognise the
 .B Absolute
 keyword, so it's safest to just specify the coordinates without it.
 .TP 4
-.BI "RightOf   \*q" screen-id \*q
+.BI "RightOf   \*q" screen\-id \*q
 .TP 4
-.BI "LeftOf    \*q" screen-id \*q
+.BI "LeftOf    \*q" screen\-id \*q
 .TP 4
-.BI "Above     \*q" screen-id \*q
+.BI "Above     \*q" screen\-id \*q
 .TP 4
-.BI "Below     \*q" screen-id \*q
+.BI "Below     \*q" screen\-id \*q
 .TP 4
-.BI "Relative  \*q" screen-id \*q " x y"
-These give the screen's location relative to another screen.  The first four
-position the screen immediately to the right, left, above or below the
-other screen.  When positioning to the right or left, the top edges are
-aligned.  When positioning above or below, the left edges are aligned.
+.BI "Relative  \*q" screen\-id \*q " x y"
+These give the screen's location relative to another screen.
+The first four position the screen immediately to the right, left, above or
+below the other screen.
+When positioning to the right or left, the top edges are aligned.
+When positioning above or below, the left edges are aligned.
 The
 .B Relative
 form specifies the offset of the screen's origin (upper left corner)
 relative to the origin of another screen.
 .RE
 .TP 7
-.BI "InputDevice  \*q" idev-id "\*q \*q" option \*q " ..."
+.BI "InputDevice  \*q" idev\-id "\*q \*q" option \*q " ..."
 One of these entries should be given for each input device being used in
-a session.  Normally at least two are required, one each for the core
-pointer and keyboard devices.  If either of those is missing, suitable
+a session.
+Normally at least two are required, one each for the core pointer and
+keyboard devices.
+If either of those is missing, suitable
 .B InputDevice
 entries are searched for using the method described above in the
 .B INPUTDEVICE
 section.  The
-.I idev-id
+.I idev\-id
 field is mandatory, and specifies the name of the
 .B InputDevice
-section being referenced.  Multiple
+section being referenced.
+Multiple
 .I option
-fields may be specified, each in double quotes.  The options permitted
-here are any that may also be given in the
+fields may be specified, each in double quotes.
+The options permitted here are any that may also be given in the
 .B InputDevice
-sections.  Normally only session-specific input device options would be
-used here.  The most commonly used options are:
+sections.
+Normally only session\-specific input device options would be used here.
+The most commonly used options are:
 .PP
 .RS 11
 .nf
@@ -1881,8 +2045,9 @@ and core keyboard devices respectively.
 .B Options
 In addition to the following, any option permitted in the
 .B ServerFlags
-section may also be specified here.  When the same option appears in both
-places, the value given here overrides the one given in the
+section may also be specified here.
+When the same option appears in both places, the value given here overrides
+the one given in the
 .B ServerFlags
 section.
 .TP 7
@@ -1895,9 +2060,11 @@ option (described in
 .BR "DEVICE SECTION" ,
 above) for the format of the
 .I bus\-id
-parameter.  This option overrides
+parameter.
+This option overrides
 .BR SingleCard ,
-if specified.  At present, only PCI devices can be isolated in this manner.
+if specified.
+At present, only PCI devices can be isolated in this manner.
 .TP 7
 .BI "Option \*qSingleCard\*q  \*q" boolean \*q
 As
@@ -1921,68 +2088,97 @@ section for a dual headed configuration 
 .B "EndSection"
 .fi
 .RE
-.SH DRI SECTION
+.SH "DRI SECTION"
 This optional section is used to provide some information for the
-Direct Rendering Infrastructure.  Details about the format of this section
-can be found on-line at
+Direct Rendering Infrastructure.  
+Details about the format of this section
+can be found in the README.DRI document, which is also available on-line at
 .IR <http://dri.freedesktop.org/> .
-.SH VENDOR SECTION
+.SH "VENDOR SECTION"
 The optional
 .B Vendor
-section may be used to provide vendor-specific configuration information.
+section may be used to provide vendor\-specific configuration information.
 Multiple
 .B Vendor
 sections may be present, and they may contain an
 .B Identifier
 entry and multiple
 .B Option
-flags.  The data therein is not used in this release.
+flags.  
+The data therein is not used in this release.
 .PP
-.SH FILES
-For an example of an __xconfigfile__ file, see the file installed as
-__projectroot__/lib/X11/__xconfigfile__.eg.
-.fi
 .SH "SEE ALSO"
-X(__miscmansuffix__),
-Xserver(__appmansuffix__),
-__xservername__(__appmansuffix__),
-apm(__drivermansuffix__),
-.\" .IR ati(__drivermansuffix__),
-chips(__drivermansuffix__),
-cirrus(__drivermansuffix__),
-cyrix(__drivermansuffix__),
-fbdev(__drivermansuffix__),
-glide(__drivermansuffix__),
-glint(__drivermansuffix__),
-i128(__drivermansuffix__),
-i740(__drivermansuffix__),
-i810(__drivermansuffix__),
-imstt(__drivermansuffix__),
-mga(__drivermansuffix__),
-neomagic(__drivermansuffix__),
-nv(__drivermansuffix__),
-r128(__drivermansuffix__),
-rendition(__drivermansuffix__),
-savage(__drivermansuffix__),
-s3virge(__drivermansuffix__),
-.\" .IR shadowfb(__drivermansuffix__),
-siliconmotion(__drivermansuffix__),
-sis(__drivermansuffix__),
-sunbw2(__drivermansuffix__),
-suncg14(__drivermansuffix__),
-suncg3(__drivermansuffix__),
-suncg6(__drivermansuffix__),
-sunffb(__drivermansuffix__),
-sunleo(__drivermansuffix__),
-suntcx(__drivermansuffix__),
-tdfx(__drivermansuffix__),
-tga(__drivermansuffix__),
-trident(__drivermansuffix__),
-tseng(__drivermansuffix__),
-v4l(__drivermansuffix__),
-vesa(__drivermansuffix__),
-vga(__drivermansuffix__),
-vmware(__drivermansuffix__),
+General:
+.BR X (__miscmansuffix__),
+.BR Xserver (__appmansuffix__),
+.BR __xservername__ (__appmansuffix__).
+.PP
+.B Not all modules or interfaces are available on all platforms.
+.PP
+Display drivers:
+.BR apm (__drivermansuffix__),
+.\" .BR ati (__drivermansuffix__),
+.BR chips (__drivermansuffix__),
+.BR cirrus (__drivermansuffix__),
+.BR cyrix (__drivermansuffix__),
+.BR fbdev (__drivermansuffix__),
+.BR glide (__drivermansuffix__),
+.BR glint (__drivermansuffix__),
+.BR i128 (__drivermansuffix__),
+.BR i740 (__drivermansuffix__),
+.BR i810 (__drivermansuffix__),
+.BR imstt (__drivermansuffix__),
+.BR mga (__drivermansuffix__),
+.BR neomagic (__drivermansuffix__),
+.BR nv (__drivermansuffix__),
+.BR r128 (__drivermansuffix__),
+.BR rendition (__drivermansuffix__),
+.BR savage (__drivermansuffix__),
+.BR s3virge (__drivermansuffix__),
+.BR siliconmotion (__drivermansuffix__),
+.BR sis (__drivermansuffix__),
+.BR sunbw2 (__drivermansuffix__),
+.BR suncg14 (__drivermansuffix__),
+.BR suncg3 (__drivermansuffix__),
+.BR suncg6 (__drivermansuffix__),
+.BR sunffb (__drivermansuffix__),
+.BR sunleo (__drivermansuffix__),
+.BR suntcx (__drivermansuffix__),
+.BR tdfx (__drivermansuffix__),
+.BR tga (__drivermansuffix__),
+.BR trident (__drivermansuffix__),
+.BR tseng (__drivermansuffix__),
+.BR vesa (__drivermansuffix__),
+.BR vga (__drivermansuffix__),
+.BR via (__drivermansuffix__),
+.BR vmware (__drivermansuffix__).
+.PP
+Input drivers:
+.\" .BR acecad (__drivermansuffix__),
+.\" .BR calcomp (__drivermansuffix__),
+.BR citron (__drivermansuffix__),
+.BR dmc (__drivermansuffix__),
+.BR dynapro (__drivermansuffix__),
+.BR elographics (__drivermansuffix__),
+.BR fpit (__drivermansuffix__),
+.BR js_x (__drivermansuffix__),
+.BR kbd (__drivermansuffix__),
+.BR keyboard (__drivermansuffix__),
+.\" .BR magictouch (__drivermansuffix__),
+.BR microtouch (__drivermansuffix__),
+.BR mouse (__drivermansuffix__),
+.BR mutouch (__drivermansuffix__),
+.BR palmax (__drivermansuffix__),
+.BR penmount (__drivermansuffix__),
+.BR tek4957 (__drivermansuffix__),
+.\" .BR ur98 (__drivermansuffix__),
+.BR void (__drivermansuffix__),
+.BR wacom (__drivermansuffix__).
+.PP
+Other modules and interfaces:
+.BR fbdevhw (__drivermansuffix__),
+.\" .BR shadowfb (__drivermansuffix__),
+.BR v4l (__drivermansuffix__).
 .br
 .SH AUTHORS
 This manual page was largely rewritten by David Dawes
diff-tree 6bf8d5019313ee2251a44dfb7ad3435a3c6db7eb (from 6fdd134a0c3e6fdde9b089100e8783705c9cc6ac)
Author: David Nusinow <dnusinow at debian.org>
Date:   Mon May 28 21:42:10 2007 -0400

    Read ROM in chunks
    This patch speeds up reads of the ROM by reading in large chunks rather
    than one byte at a time. This patch was by Dann Frazier.

diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 2aaa89c..3d8266e 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -788,8 +788,10 @@ xf86ReadDomainMemory(PCITAG Tag, ADDRESS
 	write(fd, "1", 2);
 	lseek(fd, 0, SEEK_SET);
 
+    len = min(Len, st.st_size);
+
         /* copy the ROM until we hit Len, EOF or read error */
-        for (i = 0; i < Len && read(fd, Buf, 1) > 0; Buf++, i++)
+        for (; len && (size = read(fd, Buf, len)) > 0 ; Buf+=size, len-=size)
             ;
 
 	write(fd, "0", 2);
diff-tree 6fdd134a0c3e6fdde9b089100e8783705c9cc6ac (from 6a870992d81a6bacfa9d313c15784fdb281d474f)
Author: David Nusinow <dnusinow at debian.org>
Date:   Mon May 28 21:39:12 2007 -0400

    Fix up xnest manpage
    I believe this patch was originally by Branden Robinson

diff --git a/hw/xnest/Xnest.man.pre b/hw/xnest/Xnest.man.pre
index 131c224..024d88e 100644
--- a/hw/xnest/Xnest.man.pre
+++ b/hw/xnest/Xnest.man.pre
@@ -1,6 +1,6 @@
 .\" $Xorg: Xnest.man,v 1.3 2000/08/17 19:53:28 cpqbld Exp $
 .\" Copyright (c) 1993, 1994  X Consortium
-.\" 
+.\"
 .\" Permission is hereby granted, free of charge, to any person obtaining
 .\" a copy of this software and associated documentation files (the
 .\" "Software"), to deal in the Software without restriction, including
@@ -8,10 +8,10 @@
 .\" distribute, sublicense, and/or sell copies of the Software, and to
 .\" permit persons to whom the Software is furnished to do so, subject to
 .\" the following conditions:
-.\" 
+.\"
 .\" The above copyright notice and this permission notice shall be included
 .\" in all copies or substantial portions of the Software.
-.\" 
+.\"
 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -19,7 +19,7 @@
 .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 .\" OTHER DEALINGS IN THE SOFTWARE.
-.\" 
+.\"
 .\" Except as contained in this notice, the name of the X Consortium shall
 .\" not be used in advertising or otherwise to promote the sale, use or
 .\" other dealings in this Software without prior written authorization
@@ -27,238 +27,402 @@
 .\"
 .\" $XFree86: xc/programs/Xserver/hw/xnest/Xnest.man,v 1.6 2001/01/27 18:21:00 dawes Exp $
 .\"
-.TH XNEST 1 __xorgversion__
+.TH Xnest __appmansuffix__ __xorgversion__
 .SH NAME
 Xnest \- a nested X server
 .SH SYNOPSIS
 .B Xnest
-[-options]
+[
+.I options
+]
 .SH DESCRIPTION
-\fIXnest\fP is a client and a server.  \fIXnest\fP is a client of the
-real server which manages windows and graphics requests on its behalf.
-\fIXnest\fP is a server to its own clients.  \fIXnest\fP manages
-windows and graphics requests on their behalf.  To these clients
-\fIXnest\fP appears to be a conventional server.
+.B Xnest
+is both an X client and an X server.
+.B Xnest
+is a client of the real server which manages windows and graphics requests on
+its behalf.
+.B Xnest
+is a server to its own clients.
+.B Xnest
+manages windows and graphics requests on their behalf.
+To these clients,
+.B Xnest
+appears to be a conventional server.
 .SH OPTIONS
-\fIXnest\fP supports all standard options of the sample server
-implementation.  For more details, please see the manual page on your
-system for \fIXserver\fP.  The following additional arguments are
-supported as well.
-.TP 4
-.B \-display \fIstring\fP
+.B Xnest
+supports all standard options of the sample server implementation.
+For more details, please see
+.BR Xserver (__appmansuffix__).
+The following additional arguments are supported as well.
+.TP
+.BI "\-display " string
 This option specifies the display name of the real server that
-\fIXnest\fP should try to connect with.  If it is not provided on the
-command line \fIXnest\fP will read the \fIDISPLAY\fP environment
-variable in order to find out the same information.
-.TP 4
+.B Xnest
+should try to connect to.
+If it is not provided on the command line,
+.B Xnest
+will read the
+.I DISPLAY
+environment variable in order to find out this information.
+.TP
 .B \-sync
-This option tells \fIXnest\fP to synchronize its window and graphics
-operations with the real server.  This is a useful option for
-debugging, but it will slow down the performance considerably.  It
-should not be used unless absolutely necessary.
-.TP 4
+This option tells
+.B Xnest
+to synchronize its window and graphics operations with the real server.
+This is a useful option for debugging, but it will slow down
+.BR Xnest 's
+performance considerably.
+It should not be used unless absolutely necessary.
+.TP
 .B \-full
-This option tells \fIXnest\fP to utilize full regeneration of real
-server objects and reopen a new connection to the real server each
-time the nested server regenerates.  The sample server implementation
-regenerates all objects in the server when the last client of this
-server terminates.  When this happens, \fIXnest\fP by default
-maintains the same top level window and the same real server
-connection in each new generation.  If the user selects full
-regeneration, even the top level window and the connection to the real
-server will be regenerated for each server generation.
-.TP 4
-.B \-class \fIstring\fP
+This option tells
+.B Xnest
+to utilize full regeneration of real server objects and reopen a new connection
+to the real server each time the nested server regenerates.
+The sample server implementation regenerates all objects in the server when the
+last client of this server terminates.
+When this happens,
+.B Xnest
+by default maintains the same top-level window and the same real server
+connection in each new generation.
+If the user selects full regeneration, even the top-level window and the
+connection to the real server will be regenerated for each server generation.
+.TP
+.BI "\-class " string
 This option specifies the default visual class of the nested server.
-It is similar to the \fI-cc\fP option from the set of standard options
-except that it will accept a string rather than a number for the
-visual class specification.  The string must be one of the following
-six values: \fIStaticGray\fP, \fIGrayScale\fP, \fIStaticColor\fP,
-\fIPseudoColor\fP, \fITrueColor\fP, or \fIDirectColor\fP.  If both,
-\fI-class\fP and \fI-cc\fP options are specified, the last instance of
-either option assumes precedence.  The class of the default visual of
-the nested server need not be the same as the class of the default
-visual of the real server; although, it has to be supported by the
-real server.  See \fIxdpyinfo\fP for a list of supported visual
-classes on the real server before starting \fIXnest\fP.  If the user
-chooses a static class, all the colors in the default colormap will be
-preallocated.  If the user chooses a dynamic class, colors in the
-default colormap will be available to individual clients for
-allocation.
-.TP 4
-.B \-depth \fIint\fP
+It is similar to the
+.B \-cc
+option from the set of standard options except that it will accept a string
+rather than a number for the visual class specification.
+The
+.I string
+must be one of the following six values:
+.BR StaticGray ,
+.BR GrayScale ,
+.BR StaticColor ,
+.BR PseudoColor ,
+.BR TrueColor ,
+or
+.BR DirectColor .
+If both the
+.B \-class
+and
+.B \-cc
+options are specified, the last instance of either option takes precedence.
+The class of the default visual of the nested server need not be the same as the
+class of the default visual of the real server, but it must be supported by the
+real server.
+Use
+.BR xdpyinfo (__appmansuffix__)
+to obtain a list of supported visual classes on the real server before starting
+.BR Xnest .
+If the user chooses a static class, all the colors in the default color map will
+be preallocated.
+If the user chooses a dynamic class, colors in the default color map will be
+available to individual clients for allocation.
+.TP
+.BI "\-depth " int
 This option specifies the default visual depth of the nested server.
-The depth of the default visual of the nested server need not be the
-same as the depth of the default visual of the real server; although,
-it has to be supported by the real server.  See \fIxdpyinfo\fP for a
-list of supported visual depths on the real server before starting
-\fIXnest\fP.
-.TP 4
+The depth of the default visual of the nested server need not be the same as the
+depth of the default visual of the real server, but it must be supported by the
+real server.
+Use
+.BR xdpyinfo (__appmansuffix__)
+to obtain a list of supported visual depths on the real server before starting
+.BR Xnest .
+.TP
 .B \-sss
-This option tells \fIXnest\fP to use the software screen saver.  By
-default \fIXnest\fP will use the screen saver that corresponds to the
-hardware screen saver in the real server.  Of course, even this screen
-saver is software generated since \fIXnest\fP does not control any
-actual hardware.  However, it is treated as a hardware screen saver
-within the sample server code.
-.TP 4
-.B \-geometry \fIWxH+X+Y\fP
-This option specifies geometry parameters for the top level
-\fIXnest\fP windows.  These windows corresponds to the root windows of
-the nested server.  The width and height specified with this option
-will be the maximum width and height of each top level \fIXnest\fP
-window.  \fIXnest\fP will allow the user to make any top level window
-smaller, but it will not actually change the size of the nested server
-root window.  As of yet, there is no mechanism within the sample
-server implementation to change the size of the root window after
-screen initialization.  In order to do so, one would probably need to
-extend the X protocol.  Therefore, it is not likely that this will be
-available any time soon.  If this option is not specified \fIXnest\fP
-will choose width and height to be 3/4 of the dimensions of the root
-window of the real server.
-.TP 4
-.B \-bw \fIint\fP
-This option specifies the border width of the top level \fIXnest\fP
-window.  The integer parameter must be a positive number.  The default
-border width is 1.
-.TP 4
-.B \-name \fIstring\fP
-This option specifies the name of the top level \fIXnest\fP window.
+This option tells
+.B Xnest
+to use the software screen saver.
+By default,
+.B Xnest
+will use the screen saver that corresponds to the hardware screen saver in the
+real server.
+Of course, even this screen saver is software-generated since
+.B Xnest
+does not control any actual hardware.
+However, it is treated as a hardware screen saver within the sample server code.
+.TP
+.B \-geometry \fIW\fBx\fIH\fB+\fIX\fB+\fIY\fP
+This option specifies the geometry parameters for the top-level
+.B Xnest
+window.
+See \(lqGEOMETRY SPECIFICATIONS\(rq in
+.BR X (__miscmansuffix__)
+for a discusson of this option's syntax.
+This window corresponds to the root window of the nested server.
+The width
+.I W
+and height
+.I H
+specified with this option will be the maximum width and height of each
+top-level
+.B Xnest
+window.
+.B Xnest
+will allow the user to make any top-level window smaller, but it will not
+actually change the size of the nested server root window.
+.B Xnest
+does not yet support the RANDR extension for resizing, rotation, and reflection
+of the root window.
+If this option is not specified,
+.B Xnest
+will choose
+.I W
+and
+.I H
+to be 3/4ths the dimensions of the root window of the real server.
+.TP
+.BI "\-bw " int
+This option specifies the border width of the top-level
+.B Xnest
+window.
+The integer parameter
+.I int
+must be positive.
+The default border width is 1.
+.TP
+.BI "\-name " string
+This option specifies the name of the top-level
+.B Xnest
+window as
+.IR string .
 The default value is the program name.
-.TP 4
-.B \-scrns \fIint\fP
-This option specifies the number of screens to create in the nested
-server.  For each screen, \fIXnest\fP will create a separate top level
-window.  Each screen is referenced by the number after the dot in the
-client display name specification.  For example, \fIxterm -display
-:1.1\fP will open an \fIxterm\fP client in the nested server with the
-display number \fI:1\fP on the second screen.  The number of screens
-is limited by the hard coded constant in the server sample code which
-is usually 3.
-.TP 4
+.TP
+.BI "\-scrns " int
+This option specifies the number of screens to create in the nested server.
+For each screen,
+.B Xnest
+will create a separate top-level window.
+Each screen is referenced by the number after the dot in the client display name
+specification.
+For example,
+.B xterm \-display :1.1
+will open an
+.BR xterm (__appmansuffix__)
+client in the nested server with the display number
+.B :1
+on the second screen.
+The number of screens is limited by the hard-coded constant in the server sample
+code, which is usually 3.
+.TP
 .B \-install
-This option tells \fIXnest\fP to do its own colormap installation by
-bypassing the real window manager.  For it to work properly the user
-will probably have to temporarily quit the real window manager.  By
-default \fIXnest\fP will keep the nested client window whose colormap
-should be installed in the real server in the
-\fIWM\_COLORMAP\_WINDOWS\fP property of the top level \fIXnest\fP
-window.  If this colormap is of the same visual type as the root
-window of the nested server, \fIXnest\fP will associate this colormap
-with the top level \fIXnest\fP window as well.  Since this does not
-have to be the case, window managers should look primarily at the
-\fIWM\_COLORMAP\_WINDOWS\fP property rather than the colormap
-associated with the top level \fIXnest\fP window.  Unfortunately,
-window managers are not very good at doing that yet so this option
-might come in handy.
-.TP 4
-.B \-parent \fIwindow_id\fP
-This option tells \fIXnest\fP to use the \fIwindow_id\fP as the
-root window instead of creating a window. This option is used
-by the xrx xnestplugin.
-.SH USAGE 
-Starting up \fIXnest\fP is as simple as starting up \fIxclock\fP from
-a terminal emulator.  If a user wishes to run \fIXnest\fP on the same
-workstation as the real server, it is important that the nested server
-is given its own listening socket address.  Therefore, if there is a
-server already running on the user's workstation, \fIXnest\fP will
-have to be started up with a new display number.  Since there is
-usually no more than one server running on a workstation, specifying
-\fIXnest :1\fP on the command line will be sufficient for most users.
-For each server running on the workstation the display number needs to
-be incremented by one.  Thus, if you wish to start another
-\fIXnest\fP, you will need to type \fIXnest :2\fP on the command line.
-.PP
-To run clients in the nested server each client needs to be given the
-same display number as the nested server.  For example, \fIxterm
--display :1\fP will start up an \fIxterm\fP in the first nested server
-and \fIxterm -display :2\fP will start an \fIxterm\fP in the second
-nested server from the example above.  Additional clients can be
-started from these \fIxterm\fPs in each nested server.
-.SH XNEST AS A CLIENT
-\fIXnest\fP behaves and looks to the real server and other real
-clients as another real client.  It is a rather demanding client,
-however, since almost any window or graphics request from a nested
-client will result in a window or graphics request from \fIXnest\fP to
-the real server.  Therefore, it is desirable that \fIXnest\fP and the
-real server are on a local network, or even better, on the same
-machine.  As of now, \fIXnest\fP assumes that the real server supports
-the shape extension.  There is no way to turn off this assumption
-dynamically.  \fIXnest\fP can be compiled without the shape extension
-built in, and in that case the real server need not support it.  The
-dynamic shape extension selection support should be considered in
-further development of \fIXnest\fP.
-.PP
-Since \fIXnest\fP need not use the same default visual as the the real
-server, the top level window of the \fIXnest\fP client always has its
-own colormap.  This implies that other windows' colors will not be
-displayed properly while the keyboard or pointer focus is in the
-\fIXnest\fP window, unless the real server has support for more than
-one installed colormap at any time.  The colormap associated with the
-top window of the \fIXnest\fP client need not be the appropriate
-colormap that the nested server wants installed in the real server.
-In the case that a nested client attempts to install a colormap of a
-different visual from the default visual of the nested server,
-\fIXnest\fP will put the top window of this nested client and all
-other top windows of the nested clients that use the same colormap
-into the \fIWM\_COLORMAP\_WINDOWS\fP property of the top level
-\fIXnest\fP window on the real server.  Thus, it is important that the
-real window manager that manages the \fIXnest\fP top level window
-looks at the \fIWM\_COLORMAP\_WINDOWS\fP property rather than the
-colormap associated with the top level \fIXnest\fP window.  Since most
-window managers appear to not implement this convention properly as of
-yet, \fIXnest\fP can optionally do direct installation of colormaps
-into the real server bypassing the real window manager.  If the user
-chooses this option, it is usually necessary to temporarily disable
-the real window manager since it will interfere with the \fIXnest\fP
-scheme of colormap installation.
-.PP
-Keyboard and pointer control procedures of the nested server change
-the keyboard and pointer control parameters of the real server.
-Therefore, after \fIXnest\fP is started up, it will change the
-keyboard and pointer controls of the real server to its own internal
-defaults.  Perhaps there should be a command line option to tell
-\fIXnest\fP to inherit the keyboard and pointer control parameters
-from the real server rather than imposing its own.  This is a future
-consideration.
-.SH XNEST AS A SERVER
-\fIXnest\fP as a server looks exactly like a real server to its own
-clients.  For the clients there is no way of telling if they are
-running on a real or a nested server.
-.PP
-As already mentioned, \fIXnest\fP is a very user friendly server when
-it comes to customization.  \fIXnest\fP will pick up a number of
-command line arguments that can configure its default visual class and
-depth, number of screens, etc.  In the future, \fIXnest\fP should read
-a customization input file to provide even greater freedom and
-simplicity in selecting the desired layout.  Unfortunately, there is
-no support for backing store and save under as of yet, but this should
-also be considered in the future development of \fIXnest\fP.
+This option tells
+.B Xnest
+to do its own color map installation by bypassing the real window manager.
+For it to work properly, the user will probably have to temporarily quit the
+real window manager.
+By default,
+.B Xnest
+will keep the nested client window whose color map should be installed in the
+real server in the
+.I WM_COLORMAP_WINDOWS
+property of the top-level
+.B Xnest
+window.
+If this color map is of the same visual type as the root window of the nested
+server,
+.B Xnest
+will associate this color map with the top-level
+.B Xnest
+window as well.
+Since this does not have to be the case, window managers should look primarily
+at the
+.I WM_COLORMAP_WINDOWS
+property rather than the color map associated with the top-level
+.B Xnest
+window.
+.\" Is the following still true?  This sentence is several years old.
+Unfortunately, window managers are not very good at doing that yet so this
+option might come in handy.
+.TP
+.BI "\-parent " window_id
+This option tells
+.B Xnest
+to use
+.I window_id
+as the root window instead of creating a window.
+.\" XRX is dead, dead, dead.
+.\" This option is used by the xrx xnestplugin.
+.SH "EXTENDED DESCRIPTION"
+Starting up
+.B Xnest
+is just as simple as starting up
+.BR xclock (__appmansuffix__)
+from a terminal emulator.
+If a user wishes to run
+.B Xnest
+on the same
+workstation as the real server, it is important that the nested server is given
+its own listening socket address.
+Therefore, if there is a server already running on the user's workstation,
+.B Xnest
+will have to be started up with a new display number.
+Since there is usually no more than one server running on a workstation,
+specifying
+.RB \(oq "Xnest :1" \(cq
+on the command line will be sufficient for most users.
+For each server running on the workstation, the display number needs to be
+incremented by one.
+Thus, if you wish to start another
+.BR Xnest ,
+you will need to type
+.RB \(oq "Xnest :2" \(cq
+on the command line.
+.PP
+To run clients in the nested server, each client needs to be given the same
+display number as the nested server.
+For example,
+.RB \(oq "xterm \-display :1" \(cq
+will start up an
+.B xterm
+process in the first nested server
+and
+.RB \(oq "xterm \-display :2" \(cq
+will start an
+.B xterm
+in the second nested server from the example above.
+Additional clients can be started from these
+.BR xterm s
+in each nested server.
+.SS "Xnest as a client"
+.B Xnest
+behaves and looks to the real server and other real clients as another real
+client.
+It is a rather demanding client, however, since almost any window or graphics
+request from a nested client will result in a window or graphics request from
+.B Xnest
+to the real server.
+Therefore, it is desirable that
+.B Xnest
+and the real server are on a local network, or even better, on the same machine.
+.B Xnest
+assumes that the real server supports the SHAPE extension.
+There is no way to turn off this assumption dynamically.
+.B Xnest
+can be compiled without the SHAPE extension built in, in which case the real
+server need not support it.
+Dynamic SHAPE extension selection support may be considered in further
+development of
+.BR Xnest .
+.PP
+Since
+.B Xnest
+need not use the same default visual as the the real server, the top-level
+window of the
+.B Xnest
+client always has its own color map.
+This implies that other windows' colors will not be displayed properly while the
+keyboard or pointer focus is in the
+.B Xnest
+window, unless the real server has support for more than one installed color map
+at any time.
+The color map associated with the top window of the
+.B Xnest
+client need not be the appropriate color map that the nested server wants
+installed in the real server.
+In the case that a nested client attempts to install a color map of a different
+visual from the default visual of the nested server,
+.B Xnest
+will put the top window of this nested client and all other top windows of the
+nested clients that use the same color map into the
+.I WM_COLORMAP_WINDOWS
+property of the top-level
+.B Xnest
+window on the real server.
+Thus, it is important that the real window manager that manages the
+.B Xnest
+top-level window looks at the
+.I WM_COLORMAP_WINDOWS
+property rather than the color map associated with the top-level
+.B Xnest
+window.
+Since most window managers don't yet appear to implement this convention
+properly,
+.B Xnest
+can optionally do direct installation of color maps into the real server
+bypassing the real window manager.
+If the user chooses this option, it is usually necessary to temporarily disable
+the real window manager since it will interfere with the
+.B Xnest
+scheme of color map installation.
+.PP
+Keyboard and pointer control procedures of the nested server change the keyboard
+and pointer control parameters of the real server.
+Therefore, after
+.B Xnest
+is started up, it will change the keyboard and pointer controls of the real
+server to its own internal defaults.
+.SS "Xnest as a server"
+.B Xnest
+as a server looks exactly like a real server to its own clients.
+For the clients, there is no way of telling if they are running on a real or a
+nested server.
+.PP
+As already mentioned,
+.B Xnest
+is a very user-friendly server when it comes to customization.
+.B Xnest
+will pick up a number of command-line arguments that can configure its default
+visual class and depth, number of screens, etc.
 .PP
 The only apparent intricacy from the users' perspective about using
-\fIXnest\fP as a server is the selection of fonts.  \fIXnest\fP
-manages fonts by loading them locally and then passing the font name
-to the real server and asking it to load that font remotely.  This
-approach avoids the overload of sending the glyph bits across the
-network for every text operation, although it is really a bug.  The
-proper implementation of fonts should be moved into the \fIos\fP
-layer. The consequence of this approach is that the user will have to
-worry about two different font paths - a local one for the nested
-server and a remote one for the real server - since \fIXnest\fP does
-not propagate its font path to the real server.  The reason for this
-is because real and nested servers need not run on the same file
-system which makes the two font paths mutually incompatible.  Thus, if
-there is a font in the local font path of the nested server, there is
-no guarantee that this font exists in the remote font path of the real
-server.  \fIXlsfonts\fP client, if run on the nested server will list
-fonts in the local font path and if run on the real server will list
-fonts in the remote font path.  Before a font can be successfully
-opened by the nested server it has to exist in local and remote font
-paths.  It is the users' responsibility to make sure that this is the
-case.
+.B Xnest
+as a server is the selection of fonts.
+.B Xnest
+manages fonts by loading them locally and then passing the font name to the real
+server and asking it to load that font remotely.
+This approach avoids the overload of sending the glyph bits across the network
+for every text operation, although it is really a bug.
+The consequence of this approach is that the user will have to worry about two
+different font paths \(em a local one for the nested server and a remote one for
+the real server \(em since
+.B Xnest
+does not propagate its font path to the real server.
+The reason for this is because real and nested servers need not run on the same
+file system which makes the two font paths mutually incompatible.
+Thus, if there is a font in the local font path of the nested server, there is
+no guarantee that this font exists in the remote font path of the real server.
+The
+.BR xlsfonts (__appmansuffix__)
+client, if run on the nested server, will list fonts in the local font path and,
+if run on the real server, will list fonts in the remote font path.
+Before a font can be successfully opened by the nested server, it has to exist
+in local and remote font paths.
+It is the users' responsibility to make sure that this is the case.
+.SH "FUTURE DIRECTIONS"
+Make dynamic the requirement for the SHAPE extension in the real server, rather
+than having to recompile
+.B Xnest
+to turn this requirement on and off.
+.PP
+Perhaps there should be a command-line option to tell
+.B Xnest
+to inherit the keyboard and pointer control parameters from the real server
+rather than imposing its own.
+.PP
+.B Xnest
+should read a customization input file to provide even greater freedom and
+simplicity in selecting the desired layout.
+.PP
+There is no support for backing store and save unders, but this should also be
+considered.
+.PP
+.\" Is the following still true now that client-side font rendering is
+.\" considered the way to go?
+The proper implementation of fonts should be moved into the
+.I os
+layer.
 .SH BUGS
-Won't run well on servers supporting different visual depths.
-Still crashes randomly.  Probably has some memory leaks.
+Doesn't run well on servers supporting different visual depths.
+.PP
+Still crashes randomly.
+.PP
+Probably has some memory leaks.
 .SH AUTHOR
 Davor Matic, MIT X Consortium
-
+.SH "SEE ALSO"
+.BR Xserver (__appmansuffix__),
+.BR xdpyinfo (__appmansuffix__),
+.BR X (__miscmansuffix__)
diff-tree 6a870992d81a6bacfa9d313c15784fdb281d474f (from 3c982bc1a49509dda7bc469b0eced44df02755b3)
Author: Keith Packard <keithp at dulcimer.keithp.com>
Date:   Fri May 25 20:33:08 2007 -0700

    xf86XVFillKeyHelper assumed root clip never changed.
    
    When the root window changed size, xf86XVFillKeyHelper would not revalidate
    the GC, leaving the clip at the old size causing lossage (and possibly
    memory corruption if the screen and frame buffer shrank).
    
    Fixed by just using a scratch GC; saving memory, eliminating bugs and
    shrinking the code.

diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 02fcde6..6abe31c 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -1875,42 +1875,35 @@ xf86XVFillKeyHelperDrawable (DrawablePtr
 _X_EXPORT void
 xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
 {
-   XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
    DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
    XID pval[2];
    BoxPtr pbox = REGION_RECTS(clipboxes);
    int i, nbox = REGION_NUM_RECTS(clipboxes);
    xRectangle *rects;
+   GCPtr gc;
 
    if(!xf86Screens[pScreen->myNum]->vtSema) return;
 
-   if(!ScreenPriv->videoGC) {
-       int status;
-       pval[0] = key;
-       pval[1] = IncludeInferiors;
-       ScreenPriv->videoGC = CreateGC(root, GCForeground | GCSubwindowMode,
-				      pval, &status);
-       if(!ScreenPriv->videoGC) return;
-       ValidateGC(root, ScreenPriv->videoGC);
-   } else if (key != ScreenPriv->videoGC->fgPixel){
-       pval[0] = key;
-       ChangeGC(ScreenPriv->videoGC, GCForeground, pval);
-       ValidateGC(root, ScreenPriv->videoGC);
-   }
+   gc = GetScratchGC(root->depth, pScreen);
+   pval[0] = key;
+   pval[1] = IncludeInferiors;
+   (void) ChangeGC(gc, GCForeground|GCSubwindowMode, pval);
+   ValidateGC(root, gc);
 
-   rects = ALLOCATE_LOCAL(nbox * sizeof(xRectangle));
+   rects = xalloc (nbox * sizeof(xRectangle));
 
-   for(i = 0; i < nbox; i++, pbox++) {
+   for(i = 0; i < nbox; i++, pbox++) 
+   {
       rects[i].x = pbox->x1;
       rects[i].y = pbox->y1;
       rects[i].width = pbox->x2 - pbox->x1;
       rects[i].height = pbox->y2 - pbox->y1;
    }
-
-   (*ScreenPriv->videoGC->ops->PolyFillRect)(
-			     root, ScreenPriv->videoGC, nbox, rects);
-
-   DEALLOCATE_LOCAL(rects);
+   
+   (*gc->ops->PolyFillRect)(root, gc, nbox, rects);
+   
+   xfree (rects);
+   FreeScratchGC (gc);
 }
 
 /* xf86XVClipVideoHelper -
diff-tree 3c982bc1a49509dda7bc469b0eced44df02755b3 (from 4d7469f75fadfc4a59664e88e18eb304203670f4)
Author: Luo Jie <luojie at nlsde.buaa.edu.cn>
Date:   Thu May 24 11:13:03 2007 -0700

    Reinstate an apparently mis-deleted ';' from a for loop with no body.
    
    Fixes an error returning "No core keyboard" with multiple keyboards.

diff --git a/dix/devices.c b/dix/devices.c
index e227617..da6e590 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -425,6 +425,7 @@ InitAndStartDevices(void)
     for (dev = inputInfo.devices;
 	 dev && (dev != inputInfo.keyboard);
 	 dev = dev->next)
+	;
     if (!dev || (dev != inputInfo.keyboard)) {
 	ErrorF("No core keyboard\n");
 	return BadImplementation;
diff-tree 4d7469f75fadfc4a59664e88e18eb304203670f4 (from 0b988450462ddb005311e68502357baf272e6371)
Author: Luo Jie <luojie at nlsde.buaa.edu.cn>
Date:   Thu May 24 11:04:06 2007 -0700

    Fix a typo in using memcpy in xwin.

diff --git a/hw/xwin/winmultiwindowclass.c b/hw/xwin/winmultiwindowclass.c
index d8909f0..57c4346 100755
--- a/hw/xwin/winmultiwindowclass.c
+++ b/hw/xwin/winmultiwindowclass.c
@@ -264,7 +264,7 @@ winMultiWindowGetTransientFor (WindowPtr
       if (prop->propertyName == XA_WM_TRANSIENT_FOR)
         {
           if (ppDaddy)
-            memcpy (*ppDaddy, prop->data, sizeof (WindowPtr *));
+            memcpy (*ppDaddy, prop->data, sizeof (WindowPtr));
           return 1;
         }
       else
diff-tree 0b988450462ddb005311e68502357baf272e6371 (from 1f48995d66c0072caa7e5ce2845be642221dd56d)
Author: Luo Jie <luojie at nlsde.buaa.edu.cn>
Date:   Thu May 24 11:02:28 2007 -0700

    Fix os/utils.c compile with mingw.

diff --git a/os/utils.c b/os/utils.c
index 5058285..dd5acd3 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -64,8 +64,10 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xos.h>
 #include <stdio.h>
 #include <time.h>
+#if !defined(WIN32) || !defined(__MINGW32__)
 #include <sys/time.h>
 #include <sys/resource.h>
+#endif
 #include "misc.h"
 #include <X11/X.h>
 #define XSERV_t
@@ -527,6 +529,13 @@ GiveUp(int sig)
     errno = olderrno;
 }
 
+#if defined WIN32 && defined __MINGW32__
+_X_EXPORT CARD32
+GetTimeInMillis (void)
+{
+  return GetTickCount ();
+}
+#else
 _X_EXPORT CARD32
 GetTimeInMillis(void)
 {
@@ -541,6 +550,7 @@ GetTimeInMillis(void)
     X_GETTIMEOFDAY(&tv);
     return(tv.tv_sec * 1000) + (tv.tv_usec / 1000);
 }
+#endif
 
 _X_EXPORT void
 AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
@@ -798,11 +808,13 @@ ProcessCommandLine(int argc, char *argv[
 	}
 	else if ( strcmp( argv[i], "-core") == 0)
 	{
-	    struct rlimit   core_limit;
 	    CoreDump = TRUE;
+#if !defined(WIN32) || !defined(__MINGW32__)
+	    struct rlimit   core_limit;
 	    getrlimit (RLIMIT_CORE, &core_limit);
 	    core_limit.rlim_cur = core_limit.rlim_max;
 	    setrlimit (RLIMIT_CORE, &core_limit);
+#endif
 	}
 	else if ( strcmp( argv[i], "-dpi") == 0)
 	{
diff-tree 1f48995d66c0072caa7e5ce2845be642221dd56d (from 8f98be7db303bc3db650054efb86843c70114451)
Author: Luo Jie <luojie at nlsde.buaa.edu.cn>
Date:   Thu May 24 11:01:15 2007 -0700

    Fix build of composite, dix, and randr when Xinerama is disabled.

diff --git a/composite/compext.c b/composite/compext.c
index ba37e7d..bea8bcf 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -696,11 +696,13 @@ CompositeExtensionInit (void)
 	if (GetPictureScreenIfSet(pScreen) == NULL)
 	    return;
     }
+#ifdef PANORAMIX
     /* Xinerama's rewriting of window drawing before Composite gets to it
      * breaks Composite.
      */
     if (!noPanoramiXExtension)
 	return;
+#endif
 
     CompositeClientWindowType = CreateNewResourceType (FreeCompositeClientWindow);
     if (!CompositeClientWindowType)
diff --git a/dix/events.c b/dix/events.c
index bc6b6ae..887cbcd 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -695,6 +695,13 @@ XineramaChangeToCursor(CursorPtr cursor)
     }
 }
 
+#else
+#define SyntheticMotion(x, y) \
+     PostSyntheticMotion(x, y, \
+                         0, \
+                         syncEvents.playingEvents ? \
+                           syncEvents.time.milliseconds : \
+                           currentTime.milliseconds);
 
 #endif  /* PANORAMIX */
 
diff --git a/randr/Makefile.am b/randr/Makefile.am
index 9bf0e65..20b0f72 100644
--- a/randr/Makefile.am
+++ b/randr/Makefile.am
@@ -2,6 +2,8 @@ noinst_LTLIBRARIES = librandr.la
 
 AM_CFLAGS = $(DIX_CFLAGS)
 
+XINERAMA_SRCS = rrxinerama.c
+
 if XORG
 sdk_HEADERS = randrstr.h
 endif
@@ -18,5 +20,9 @@ librandr_la_SOURCES =	\
 	rrpointer.c	\
 	rrproperty.c	\
 	rrscreen.c	\
-	rrsdispatch.c	\
-	rrxinerama.c
+	rrsdispatch.c
+
+if XINERAMA
+librandr_la_SOURCES += ${XINERAMA_SRCS}
+endif
+
diff --git a/randr/randr.c b/randr/randr.c
index 4dd0ee5..958f9c1 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -358,8 +358,9 @@ RRExtensionInit (void)
 	SRRScreenChangeNotifyEvent;
     EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr)
 	SRRNotifyEvent;
-
+#ifdef PANORAMIX
     RRXineramaExtensionInit();
+#endif
 }
 
 static int
diff-tree 8f98be7db303bc3db650054efb86843c70114451 (from 9616a042855399f0ee9c6489ea824621ea5fee18)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu May 24 11:00:04 2007 -0700

    Fix bswap detection on BSD (mis-added '_' in function names).

diff --git a/configure.ac b/configure.ac
index d7d00e2..37199cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,19 +123,19 @@ b = __swap16(a);
 ], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no'])
 	AC_MSG_RESULT([$SYS_ENDIAN__SWAP])
 
-	AC_MSG_CHECKING([for bswap_16 variant of <sys/endian.h> byteswapping macros])
+	AC_MSG_CHECKING([for bswap16 variant of <sys/endian.h> byteswapping macros])
 	AC_LINK_IFELSE([AC_LANG_PROGRAM([
 #include <sys/endian.h>
  ], [
 int a = 1, b;
-b = bswap_16(a);
+b = bswap16(a);
  ])
 ], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no'])
 	AC_MSG_RESULT([$SYS_ENDIAN_BSWAP])
 
     	if test "$SYS_ENDIAN_BSWAP" = "yes" ; then
 		USE_SYS_ENDIAN_H=yes
-		BSWAP=bswap_
+		BSWAP=bswap
 	else	
 	    	if test "$SYS_ENDIAN__SWAP" = "yes" ; then
 			USE_SYS_ENDIAN_H=yes
diff-tree 9616a042855399f0ee9c6489ea824621ea5fee18 (from 649e7f82d8d4333443493056b81eb20d6cf022bc)
Author: Matthias Drochner <drochner at netbsd.org>
Date:   Tue Apr 10 16:15:40 2007 -0700

    Fix build on NetBSD/amd64.

diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index f4ea3f5..ae16b78 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -50,6 +50,11 @@
 #include <machine/mtrr.h>
 #include <machine/sysarch.h>
 #include <sys/queue.h>
+#ifdef __x86_64__
+#define i386_set_mtrr x86_64_set_mtrr
+#define i386_get_mtrr x86_64_get_mtrr
+#define i386_iopl x86_64_iopl
+#endif
 #endif
 
 #if defined(__OpenBSD__) && defined(__amd64__)
diff-tree 649e7f82d8d4333443493056b81eb20d6cf022bc (from 047bf3349bb697c73c95729a8bbf15f72605901f)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu May 24 12:10:05 2007 +0200

    Consolidate portPriv->pDraw assignments into xf86XVEnlistPortInWindow.
    
    This avoids a crash in xf86XVReputVideo and also cleans up the code slightly.

diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 2b097d2..02fcde6 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -979,6 +979,9 @@ xf86XVEnlistPortInWindow(WindowPtr pWin,
 	winPriv->next = PrivRoot;
 	pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv;
    }
+
+   portPriv->pDraw = (DrawablePtr)pWin;
+
    return Success;
 }
 
@@ -1375,7 +1378,6 @@ xf86XVPutVideo(
   result =  xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
   if(result != Success) return result;
 
-  portPriv->pDraw = pDraw;
   portPriv->type = XvInputMask;
 
   /* save a copy of these parameters */
@@ -1479,7 +1481,6 @@ xf86XVPutStill(
 
      xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
      portPriv->isOn = XV_ON;
-     portPriv->pDraw = pDraw;
      portPriv->drw_x = drw_x;  portPriv->drw_y = drw_y;
      portPriv->drw_w = drw_w;  portPriv->drw_h = drw_h;
      portPriv->type = 0;  /* no mask means it's transient and should
@@ -1529,7 +1530,6 @@ xf86XVGetVideo(
   result =  xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
   if(result != Success) return result;
 
-  portPriv->pDraw = pDraw;
   portPriv->type = XvOutputMask;
 
   /* save a copy of these parameters */
@@ -1784,7 +1784,6 @@ xf86XVPutImage(
 	(portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
 
      portPriv->isOn = XV_ON;
-     portPriv->pDraw = pDraw;
      portPriv->drw_x = drw_x;  portPriv->drw_y = drw_y;
      portPriv->drw_w = drw_w;  portPriv->drw_h = drw_h;
      portPriv->type = 0;  /* no mask means it's transient and should
diff-tree 047bf3349bb697c73c95729a8bbf15f72605901f (from 9d87ef4e0dff40ea39f1b209c67b90079fc79065)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed May 23 16:56:05 2007 -0400

    Delete trapezoid rendering code; replace with pixman calls

diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index 6e8da24..07b4fbb 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -30,77 +30,13 @@
 
 #ifdef RENDER
 
+#include <pixman/pixman.h>
+
 #include "picturestr.h"
 #include "mipict.h"
 #include "renderedge.h"
 #include "fbpict.h"
 
-#if 0
-void
-fbAddTraps (PicturePtr	pPicture,
-	    INT16	x_off,
-	    INT16	y_off,
-	    int		ntrap,
-	    xTrap	*traps)
-{
-    FbBits	*buf;
-    int		bpp;
-    int		width;
-    int		stride;
-    int		height;
-    int		pxoff, pyoff;
-
-    xFixed	x_off_fixed;
-    xFixed	y_off_fixed;
-    RenderEdge  l, r;
-    xFixed	t, b;
-    
-    fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
-
-    width = pPicture->pDrawable->width;
-    height = pPicture->pDrawable->height;
-    x_off += pxoff;
-    y_off += pyoff;
-    
-    x_off_fixed = IntToxFixed(y_off);
-    y_off_fixed = IntToxFixed(y_off);
-
-    while (ntrap--)
-    {
-	t = traps->top.y + y_off_fixed;
-	if (t < 0)
-	    t = 0;
-	t = RenderSampleCeilY (t, bpp);
-    
-	b = traps->bot.y + y_off_fixed;
-	if (xFixedToInt (b) >= height)
-	    b = IntToxFixed (height) - 1;
-	b = RenderSampleFloorY (b, bpp);
-	
-	if (b >= t)
-	{
-	    /* initialize edge walkers */
-	    RenderEdgeInit (&l, bpp, t,
-			    traps->top.l + x_off_fixed,
-			    traps->top.y + y_off_fixed,
-			    traps->bot.l + x_off_fixed,
-			    traps->bot.y + y_off_fixed);
-	
-	    RenderEdgeInit (&r, bpp, t,
-			    traps->top.r + x_off_fixed,
-			    traps->top.y + y_off_fixed,
-			    traps->bot.r + x_off_fixed,
-			    traps->bot.y + y_off_fixed);
-	    
-	    fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
-	}
-	traps++;
-    }
-
-    fbFinishAccess (pPicture->pDrawable);
-}
-#endif
-
 void
 fbAddTraps (PicturePtr	pPicture,
 	    INT16	x_off,
@@ -108,65 +44,16 @@ fbAddTraps (PicturePtr	pPicture,
 	    int		ntrap,
 	    xTrap	*traps)
 {
-    FbBits	*buf;
-    int		bpp;
-    int		width;
-    int		stride;
-    int		height;
-    int		pxoff, pyoff;
-
-    xFixed	x_off_fixed;
-    xFixed	y_off_fixed;
-    RenderEdge  l, r;
-    xFixed	t, b;
-
     pixman_image_t *image = image_from_pict (pPicture, FALSE);
-    
-    fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
-
-    width = pPicture->pDrawable->width;
-    height = pPicture->pDrawable->height;
-#if 0
-    x_off += pxoff;
-    y_off += pyoff;
-#endif
-    
-    x_off_fixed = IntToxFixed(y_off);
-    y_off_fixed = IntToxFixed(y_off);
 
-    while (ntrap--)
-    {
-	t = traps->top.y + y_off_fixed;
-	if (t < 0)
-	    t = 0;
-	t = RenderSampleCeilY (t, bpp);
+    if (!image)
+	return;
     
-	b = traps->bot.y + y_off_fixed;
-	if (xFixedToInt (b) >= height)
-	    b = IntToxFixed (height) - 1;
-	b = RenderSampleFloorY (b, bpp);
-	
-	if (b >= t)
-	{
-	    /* initialize edge walkers */
-	    RenderEdgeInit (&l, bpp, t,
-			    traps->top.l + x_off_fixed,
-			    traps->top.y + y_off_fixed,
-			    traps->bot.l + x_off_fixed,
-			    traps->bot.y + y_off_fixed);
-	
-	    RenderEdgeInit (&r, bpp, t,
-			    traps->top.r + x_off_fixed,
-			    traps->top.y + y_off_fixed,
-			    traps->bot.r + x_off_fixed,
-			    traps->bot.y + y_off_fixed);
-	    
-	    pixman_rasterize_edges (image, &l, &r, t, b);
-	}
-	traps++;
-    }
+    pixman_add_traps (image, x_off, y_off, ntrap, (pixman_trap_t *)traps);
 
     fbFinishAccess (pPicture->pDrawable);
+
+    pixman_image_unref (image);
 }
 
 void
@@ -175,58 +62,16 @@ fbRasterizeTrapezoid (PicturePtr    pPic
 		      int	    x_off,
 		      int	    y_off)
 {
-    FbBits	*buf;
-    int		bpp;
-    int		width;
-    int		stride;
-    int		height;
-    int		pxoff, pyoff;
-
-    xFixed	x_off_fixed;
-    xFixed	y_off_fixed;
-    RenderEdge	l, r;
-    xFixed	t, b;
-    pixman_image_t *image;
-    
-    if (!xTrapezoidValid (trap))
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
+
+    if (!image)
 	return;
 
-    image = image_from_pict (pPicture, FALSE);
-    
-    fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
-
-    width = pPicture->pDrawable->width;
-    height = pPicture->pDrawable->height;
-#if 0
-    x_off += pxoff;
-    y_off += pyoff;
-#endif
-    
-    x_off_fixed = IntToxFixed(x_off);
-    y_off_fixed = IntToxFixed(y_off);
-    t = trap->top + y_off_fixed;
-    if (t < 0)
-	t = 0;
-    t = RenderSampleCeilY (t, bpp);
-
-    b = trap->bottom + y_off_fixed;
-    if (xFixedToInt (b) >= height)
-	b = IntToxFixed (height) - 1;
-    b = RenderSampleFloorY (b, bpp);
-    
-    if (b >= t)
-    {
-	/* initialize edge walkers */
-	RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off);
-	RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off);
-
-	pixman_rasterize_edges (image, &l, &r, t, b);
-#if 0
-	fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
-#endif
-    }
+    pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap, x_off, y_off);
 
     fbFinishAccess (pPicture->pDrawable);
+
+    pixman_image_unref (image);
 }
 
 static int
diff-tree 9d87ef4e0dff40ea39f1b209c67b90079fc79065 (from 2a960c442bd7560630f52b55d82ec0517542ee5a)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed May 23 15:50:25 2007 -0400

    - Make image_from_pict() non-static
    - Delete fbedge.c and fbedgeimp.h
    - Use pixman_rasterize_edges() in fbtrap.c

diff --git a/fb/Makefile.am b/fb/Makefile.am
index 01e81da..28c0cc7 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -69,9 +69,7 @@ libfb_la_SOURCES = 	\
 	fbutil.c	\
 	fbwindow.c	\
 	fbpseudocolor.c \
-	fbpseudocolor.h \
-	fbedge.c	\
-	fbedgeimp.h
+	fbpseudocolor.h
 
 libwfb_la_SOURCES = $(libfb_la_SOURCES)
 
diff --git a/fb/fb.h b/fb/fb.h
index e605078..7d94886 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2146,4 +2146,8 @@ void
 fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
 
 
+pixman_image_t *image_from_pict (PicturePtr pict,
+				 Bool       has_clip);
+
 #endif /* _FB_H_ */
+
diff --git a/fb/fbedge.c b/fb/fbedge.c
deleted file mode 100644
index 70fc423..0000000
--- a/fb/fbedge.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * $Id$
- *
- * Copyright © 2004 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <string.h>
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-#ifdef RENDER
-
-#include "picturestr.h"
-#include "mipict.h"
-#include "renderedge.h"
-#include "fbpict.h"
-
-/*
- * 4 bit alpha
- */
-
-#define N_BITS	4
-#define rasterizeEdges	fbRasterizeEdges4
-
-#if BITMAP_BIT_ORDER == LSBFirst
-#define Shift4(o)	((o) << 2)
-#else
-#define Shift4(o)	((1-(o)) << 2)
-#endif
-
-#define Get4(x,o)	(((x) >> Shift4(o)) & 0xf)
-#define Put4(x,o,v)	(((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o)))
-
-#define DefineAlpha(line,x) \
-    CARD8   *__ap = (CARD8 *) line + ((x) >> 1); \
-    int	    __ao = (x) & 1
-
-#define StepAlpha	((__ap += __ao), (__ao ^= 1))
-
-#define AddAlpha(a) {						\
-    CARD8   __o = READ(__ap);					\
-    CARD8   __a = (a) + Get4(__o, __ao);			\
-    WRITE(__ap, Put4 (__o, __ao, __a | (0 - ((__a) >> 4))));	\
-}
-
-#include "fbedgeimp.h"
-
-#undef AddAlpha
-#undef StepAlpha
-#undef DefineAlpha
-#undef rasterizeEdges
-#undef N_BITS
-
-
-/*
- * 1 bit alpha
- */
-
-#define N_BITS 1
-#define rasterizeEdges	fbRasterizeEdges1
-
-#include "fbedgeimp.h"
-
-#undef rasterizeEdges
-#undef N_BITS
-
-/*
- * 8 bit alpha
- */
-
-static INLINE CARD8
-clip255 (int x)
-{
-    if (x > 255) return 255;
-    return x;
-}
-
-static INLINE void
-add_saturate_8 (CARD8 *buf, int value, int length)
-{
-    while (length--)
-    {
-        WRITE(buf, clip255 (READ(buf) + value));
-        buf++;
-    }
-}
-
-/*
- * We want to detect the case where we add the same value to a long
- * span of pixels.  The triangles on the end are filled in while we
- * count how many sub-pixel scanlines contribute to the middle section.
- *
- *                 +--------------------------+
- *  fill_height =|   \                      /
- *                     +------------------+
- *                      |================|
- *                   fill_start       fill_end
- */
-static void
-fbRasterizeEdges8 (FbBits	*buf,
-		   int		width,
-		   int		stride,
-		   RenderEdge	*l,
-		   RenderEdge	*r,
-		   xFixed	t,
-		   xFixed	b)
-{
-    xFixed  y = t;
-    FbBits  *line;
-    int fill_start = -1, fill_end = -1;
-    int fill_size = 0;
-
-    line = buf + xFixedToInt (y) * stride;
-
-    for (;;)
-    {
-        CARD8 *ap = (CARD8 *) line;
-	xFixed	lx, rx;
-	int	lxi, rxi;
-	
-	/* clip X */
-	lx = l->x;
-	if (lx < 0)
-	    lx = 0;
-	rx = r->x;
-	if (xFixedToInt (rx) >= width)
-	    rx = IntToxFixed (width);
-	
-	/* Skip empty (or backwards) sections */
-	if (rx > lx)
-	{
-            int lxs, rxs;
-
-	    /* Find pixel bounds for span. */
-	    lxi = xFixedToInt (lx);
-	    rxi = xFixedToInt (rx);
-
-            /* Sample coverage for edge pixels */
-            lxs = RenderSamplesX (lx, 8);
-            rxs = RenderSamplesX (rx, 8);
-
-            /* Add coverage across row */
-            if (lxi == rxi)
-            {
-                WRITE(ap +lxi, clip255 (READ(ap + lxi) + rxs - lxs));
-            }
-            else
-            {
-                WRITE(ap + lxi, clip255 (READ(ap + lxi) + N_X_FRAC(8) - lxs));
-
-                /* Move forward so that lxi/rxi is the pixel span */
-                lxi++;
-
-                /* Don't bother trying to optimize the fill unless
-                 * the span is longer than 4 pixels. */
-                if (rxi - lxi > 4)
-                {
-                    if (fill_start < 0)
-                    {
-                        fill_start = lxi;
-                        fill_end = rxi;
-                        fill_size++;
-                    }
-                    else
-                    {
-                        if (lxi >= fill_end || rxi < fill_start)
-                        {
-                            /* We're beyond what we saved, just fill it */
-                            add_saturate_8 (ap + fill_start,
-                                            fill_size * N_X_FRAC(8),
-                                            fill_end - fill_start);
-                            fill_start = lxi;
-                            fill_end = rxi;
-                            fill_size = 1;
-                        }
-                        else
-                        {
-                            /* Update fill_start */
-                            if (lxi > fill_start)
-                            {
-                                add_saturate_8 (ap + fill_start,
-                                                fill_size * N_X_FRAC(8),
-                                                lxi - fill_start);
-                                fill_start = lxi;
-                            }
-                            else if (lxi < fill_start)
-                            {
-                                add_saturate_8 (ap + lxi, N_X_FRAC(8),
-                                                fill_start - lxi);
-                            }
-
-                            /* Update fill_end */
-                            if (rxi < fill_end)
-                            {
-                                add_saturate_8 (ap + rxi,
-                                                fill_size * N_X_FRAC(8),
-                                                fill_end - rxi);
-                                fill_end = rxi;
-                            }
-                            else if (fill_end < rxi)
-                            {
-                                add_saturate_8 (ap + fill_end,
-                                                N_X_FRAC(8),
-                                                rxi - fill_end);
-                            }
-                            fill_size++;
-                        }
-                    }
-                }
-                else
-                {
-                    add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi);
-                }
-
-                /* Do not add in a 0 alpha here. This check is
-                 * necessary to avoid a buffer overrun, (when rx
-                 * is exactly on a pixel boundary). */
-                if (rxs)
-                    WRITE(ap + rxi, clip255 (READ(ap + rxi) + rxs));
-            }
-	}
-
-	if (y == b) {
-            /* We're done, make sure we clean up any remaining fill. */
-            if (fill_start != fill_end) {
-                if (fill_size == N_Y_FRAC(8))
-                {
-                    MEMSET_WRAPPED (ap + fill_start, 0xff, fill_end - fill_start);
-                }
-                else
-                {
-                    add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
-                                    fill_end - fill_start);
-                }
-            }
-	    break;
-        }
-
-	if (xFixedFrac (y) != Y_FRAC_LAST(8))
-	{
-	    RenderEdgeStepSmall (l);
-	    RenderEdgeStepSmall (r);
-	    y += STEP_Y_SMALL(8);
-	}
-	else
-	{
-	    RenderEdgeStepBig (l);
-	    RenderEdgeStepBig (r);
-	    y += STEP_Y_BIG(8);
-            if (fill_start != fill_end)
-            {
-                if (fill_size == N_Y_FRAC(8))
-                {
-                    MEMSET_WRAPPED (ap + fill_start, 0xff, fill_end - fill_start);
-                }
-                else
-                {
-                    add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
-                                    fill_end - fill_start);
-                }
-                fill_start = fill_end = -1;
-                fill_size = 0;
-            }
-	    line += stride;
-	}
-    }
-}
-
-void
-fbRasterizeEdges (FbBits	*buf,
-		  int		bpp,
-		  int		width,
-		  int		stride,
-		  RenderEdge	*l,
-		  RenderEdge	*r,
-		  xFixed	t,
-		  xFixed	b)
-{
-    switch (bpp) {
-    case 1:
-	fbRasterizeEdges1 (buf, width, stride, l, r, t, b);
-	break;
-    case 4:
-	fbRasterizeEdges4 (buf, width, stride, l, r, t, b);
-	break;
-    case 8:
-	fbRasterizeEdges8 (buf, width, stride, l, r, t, b);
-	break;
-    }
-}
-
-#endif /* RENDER */
diff --git a/fb/fbedgeimp.h b/fb/fbedgeimp.h
deleted file mode 100644
index 57da31a..0000000
--- a/fb/fbedgeimp.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * $Id$
- *
- * Copyright © 2004 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef rasterizeSpan
-#endif
-
-static void
-rasterizeEdges (FbBits		*buf,
-		int		width,
-		int		stride,
-		RenderEdge	*l,
-		RenderEdge	*r,
-		xFixed		t,
-		xFixed		b)
-{
-    xFixed  y = t;
-    FbBits  *line;
-    
-    line = buf + xFixedToInt (y) * stride;
-    
-    for (;;)
-    {
-	xFixed	lx, rx;
-	int	lxi, rxi;
-	
-	/* clip X */
-	lx = l->x;
-	if (lx < 0)
-	    lx = 0;
-	rx = r->x;
-	if (xFixedToInt (rx) >= width)
-	    rx = IntToxFixed (width);
-	
-	/* Skip empty (or backwards) sections */
-	if (rx > lx)
-	{
-
-	    /* Find pixel bounds for span */
-	    lxi = xFixedToInt (lx);
-	    rxi = xFixedToInt (rx);
-
-#if N_BITS == 1
-	    {
-		FbBits  *a = line;
-		FbBits  startmask, endmask;
-		int	    nmiddle;
-		int	    width = rxi - lxi;
-		int	    x = lxi;
-
-		a += x >> FB_SHIFT;
-		x &= FB_MASK;
-
-		FbMaskBits (x, width, startmask, nmiddle, endmask);
-		if (startmask) {
-		    WRITE(a, READ(a) | startmask);
-		    a++;
-		}
-		while (nmiddle--)
-		    WRITE(a++, FB_ALLONES);
-		if (endmask)
-		    WRITE(a, READ(a) | endmask);
-	    }
-#else
-	    {
-		DefineAlpha(line,lxi);
-		int	    lxs, rxs;
-
-		/* Sample coverage for edge pixels */
-		lxs = RenderSamplesX (lx, N_BITS);
-		rxs = RenderSamplesX (rx, N_BITS);
-
-		/* Add coverage across row */
-		if (lxi == rxi)
-		{
-		    AddAlpha (rxs - lxs);
-		}
-		else
-		{
-		    int	xi;
-
-		    AddAlpha (N_X_FRAC(N_BITS) - lxs);
-		    StepAlpha;
-		    for (xi = lxi + 1; xi < rxi; xi++)
-		    {
-			AddAlpha (N_X_FRAC(N_BITS));
-			StepAlpha;
-		    }
-		    /* Do not add in a 0 alpha here. This check is necessary
-		     * to avoid a buffer overrun when rx is exactly on a pixel
-		     * boundary.
-		     */
-		    if (rxs != 0)
-			AddAlpha (rxs);
-		}
-	    }
-#endif
-	}
-
-	if (y == b)
-	    break;
-
-#if N_BITS > 1
-	if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS))
-	{
-	    RenderEdgeStepSmall (l);
-	    RenderEdgeStepSmall (r);
-	    y += STEP_Y_SMALL(N_BITS);
-	}
-	else
-#endif
-	{
-	    RenderEdgeStepBig (l);
-	    RenderEdgeStepBig (r);
-	    y += STEP_Y_BIG(N_BITS);
-	    line += stride;
-	}
-    }
-}
-
-#undef rasterizeSpan
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 3ad4a22..00dde61 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -108,7 +108,8 @@ create_conical_gradient_image (PictGradi
 }
 
 static pixman_image_t *
-create_bits_picture (PicturePtr pict)
+create_bits_picture (PicturePtr pict,
+		     Bool       has_clip)
 {
     FbBits *bits;
     FbStride stride;
@@ -142,7 +143,8 @@ create_bits_picture (PicturePtr pict)
     /* pCompositeClip is undefined for source pictures, so
      * only set the clip region for pictures with drawables
      */
-    pixman_image_set_clip_region (image, pict->pCompositeClip);
+    if (has_clip)
+	pixman_image_set_clip_region (image, pict->pCompositeClip);
     
     /* Indexed table */
     if (pict->pFormat->index.devPrivate)
@@ -153,114 +155,6 @@ create_bits_picture (PicturePtr pict)
     return image;
 }
 
-static pixman_image_t *image_from_pict (PicturePtr pict);
-
-static void
-set_image_properties (pixman_image_t *image, PicturePtr pict)
-{
-    pixman_repeat_t repeat;
-    pixman_filter_t filter;
-    
-    if (pict->transform)
-    {
-	pixman_image_set_transform (
-	    image, (pixman_transform_t *)pict->transform);
-    }
-    
-    switch (pict->repeatType)
-    {
-    default:
-    case RepeatNone:
-	repeat = PIXMAN_REPEAT_NONE;
-	break;
-	
-    case RepeatPad:
-	repeat = PIXMAN_REPEAT_PAD;
-	break;
-	
-    case RepeatNormal:
-	repeat = PIXMAN_REPEAT_NORMAL;
-	break;
-	
-    case RepeatReflect:
-	repeat = PIXMAN_REPEAT_REFLECT;
-	break;
-    }
-    
-    pixman_image_set_repeat (image, repeat);
-    
-    if (pict->alphaMap)
-    {
-	pixman_image_t *alpha_map = image_from_pict (pict->alphaMap);
-	
-	pixman_image_set_alpha_map (
-	    image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
-	
-	pixman_image_unref (alpha_map);
-    }
-    
-    pixman_image_set_component_alpha (image, pict->componentAlpha);
-
-    switch (pict->filter)
-    {
-    default:
-    case PictFilterNearest:
-    case PictFilterFast:
-	filter = PIXMAN_FILTER_NEAREST;
-	break;
-	
-    case PictFilterBilinear:
-    case PictFilterGood:
-	filter = PIXMAN_FILTER_BILINEAR;
-	break;
-	
-    case PictFilterConvolution:
-	filter = PIXMAN_FILTER_CONVOLUTION;
-	break;
-    }
-    
-    pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
-}
-
-static pixman_image_t *
-image_from_pict (PicturePtr pict)
-{
-    pixman_image_t *image = NULL;
-
-    if (!pict)
-	return NULL;
-
-    if (pict->pDrawable)
-    {
-	image = create_bits_picture (pict);
-    }
-    else if (pict->pSourcePict)
-    {
-	SourcePict *sp = pict->pSourcePict;
-	
-	if (sp->type == SourcePictTypeSolidFill)
-	{
-	    image = create_solid_fill_image (pict);
-	}
-	else
-	{
-	    PictGradient *gradient = &pict->pSourcePict->gradient;
-	    
-	    if (sp->type == SourcePictTypeLinear)
-		image = create_linear_gradient_image (gradient);
-	    else if (sp->type == SourcePictTypeRadial)
-		image = create_radial_gradient_image (gradient);
-	    else if (sp->type == SourcePictTypeConical)
-		image = create_conical_gradient_image (gradient);
-	}
-    }
-    
-    if (image)
-	set_image_properties (image, pict);
-    
-    return image;
-}
-
 #define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
 void
@@ -401,9 +295,9 @@ fbComposite (CARD8      op,
 				   xMask, yMask, xDst, yDst, width, height))
         return;
 
-    src = image_from_pict (pSrc);
-    mask = image_from_pict (pMask);
-    dest = image_from_pict (pDst);
+    src = image_from_pict (pSrc, TRUE);
+    mask = image_from_pict (pMask, TRUE);
+    dest = image_from_pict (pDst, TRUE);
 
     if (src && dest && !(pMask && !mask))
     {
@@ -466,6 +360,116 @@ fbPictureInit (ScreenPtr pScreen, PictFo
     return TRUE;
 }
 
+static void
+set_image_properties (pixman_image_t *image, PicturePtr pict)
+{
+    pixman_repeat_t repeat;
+    pixman_filter_t filter;
+    
+    if (pict->transform)
+    {
+	pixman_image_set_transform (
+	    image, (pixman_transform_t *)pict->transform);
+    }
+    
+    switch (pict->repeatType)
+    {
+    default:
+    case RepeatNone:
+	repeat = PIXMAN_REPEAT_NONE;
+	break;
+	
+    case RepeatPad:
+	repeat = PIXMAN_REPEAT_PAD;
+	break;
+	
+    case RepeatNormal:
+	repeat = PIXMAN_REPEAT_NORMAL;
+	break;
+	
+    case RepeatReflect:
+	repeat = PIXMAN_REPEAT_REFLECT;
+	break;
+    }
+    
+    pixman_image_set_repeat (image, repeat);
+    
+    if (pict->alphaMap)
+    {
+	pixman_image_t *alpha_map = image_from_pict (pict->alphaMap, TRUE);
+	
+	pixman_image_set_alpha_map (
+	    image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
+	
+	pixman_image_unref (alpha_map);
+    }
+    
+    pixman_image_set_component_alpha (image, pict->componentAlpha);
+
+    switch (pict->filter)
+    {
+    default:
+    case PictFilterNearest:
+    case PictFilterFast:
+	filter = PIXMAN_FILTER_NEAREST;
+	break;
+	
+    case PictFilterBilinear:
+    case PictFilterGood:
+	filter = PIXMAN_FILTER_BILINEAR;
+	break;
+	
+    case PictFilterConvolution:
+	filter = PIXMAN_FILTER_CONVOLUTION;
+	break;
+    }
+    
+    pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
+}
+
+pixman_image_t *
+image_from_pict (PicturePtr pict,
+		 Bool       has_clip)
+{
+    pixman_image_t *image = NULL;
+
+    if (!pict)
+	return NULL;
+
+    if (pict->pDrawable)
+    {
+	image = create_bits_picture (pict, has_clip);
+    }
+    else if (pict->pSourcePict)
+    {
+	SourcePict *sp = pict->pSourcePict;
+	
+	if (sp->type == SourcePictTypeSolidFill)
+	{
+	    image = create_solid_fill_image (pict);
+	}
+	else
+	{
+	    PictGradient *gradient = &pict->pSourcePict->gradient;
+	    
+	    if (sp->type == SourcePictTypeLinear)
+		image = create_linear_gradient_image (gradient);
+	    else if (sp->type == SourcePictTypeRadial)
+		image = create_radial_gradient_image (gradient);
+	    else if (sp->type == SourcePictTypeConical)
+		image = create_conical_gradient_image (gradient);
+	}
+    }
+    
+    if (image)
+	set_image_properties (image, pict);
+    
+    return image;
+}
+
+
+
+
 #ifdef USE_MMX
 /* The CPU detection code needs to be in a file not compiled with
  * "-mmmx -msse", as gcc would generate CMOV instructions otherwise
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 3bd0a78..b4c1dcf 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -412,18 +412,6 @@ fbCompositeGeneral (CARD8	op,
 		    CARD16	width,
 		    CARD16	height);
 
-
-/* fbedge.c */
-void
-fbRasterizeEdges (FbBits	*buf,
-		  int		bpp,
-		  int		width,
-		  int		stride,
-		  RenderEdge	*l,
-		  RenderEdge	*r,
-		  xFixed	t,
-		  xFixed	b);
-
 /* fbpict.c */
 void
 fbComposite (CARD8      op,
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index 478a80f..6e8da24 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -35,6 +35,7 @@
 #include "renderedge.h"
 #include "fbpict.h"
 
+#if 0
 void
 fbAddTraps (PicturePtr	pPicture,
 	    INT16	x_off,
@@ -98,6 +99,75 @@ fbAddTraps (PicturePtr	pPicture,
 
     fbFinishAccess (pPicture->pDrawable);
 }
+#endif
+
+void
+fbAddTraps (PicturePtr	pPicture,
+	    INT16	x_off,
+	    INT16	y_off,
+	    int		ntrap,
+	    xTrap	*traps)
+{
+    FbBits	*buf;
+    int		bpp;
+    int		width;
+    int		stride;
+    int		height;
+    int		pxoff, pyoff;
+
+    xFixed	x_off_fixed;
+    xFixed	y_off_fixed;
+    RenderEdge  l, r;
+    xFixed	t, b;
+
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
+    
+    fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
+
+    width = pPicture->pDrawable->width;
+    height = pPicture->pDrawable->height;
+#if 0
+    x_off += pxoff;
+    y_off += pyoff;
+#endif
+    
+    x_off_fixed = IntToxFixed(y_off);
+    y_off_fixed = IntToxFixed(y_off);
+
+    while (ntrap--)
+    {
+	t = traps->top.y + y_off_fixed;
+	if (t < 0)
+	    t = 0;
+	t = RenderSampleCeilY (t, bpp);
+    
+	b = traps->bot.y + y_off_fixed;
+	if (xFixedToInt (b) >= height)
+	    b = IntToxFixed (height) - 1;
+	b = RenderSampleFloorY (b, bpp);
+	
+	if (b >= t)
+	{
+	    /* initialize edge walkers */
+	    RenderEdgeInit (&l, bpp, t,
+			    traps->top.l + x_off_fixed,
+			    traps->top.y + y_off_fixed,
+			    traps->bot.l + x_off_fixed,
+			    traps->bot.y + y_off_fixed);
+	
+	    RenderEdgeInit (&r, bpp, t,
+			    traps->top.r + x_off_fixed,
+			    traps->top.y + y_off_fixed,
+			    traps->bot.r + x_off_fixed,
+			    traps->bot.y + y_off_fixed);
+	    
+	    pixman_rasterize_edges (image, &l, &r, t, b);
+	}
+	traps++;
+    }
+
+    fbFinishAccess (pPicture->pDrawable);
+}
 
 void
 fbRasterizeTrapezoid (PicturePtr    pPicture,
@@ -116,16 +186,21 @@ fbRasterizeTrapezoid (PicturePtr    pPic
     xFixed	y_off_fixed;
     RenderEdge	l, r;
     xFixed	t, b;
+    pixman_image_t *image;
     
     if (!xTrapezoidValid (trap))
 	return;
 
+    image = image_from_pict (pPicture, FALSE);
+    
     fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
 
     width = pPicture->pDrawable->width;
     height = pPicture->pDrawable->height;
+#if 0
     x_off += pxoff;
     y_off += pyoff;
+#endif
     
     x_off_fixed = IntToxFixed(x_off);
     y_off_fixed = IntToxFixed(y_off);
@@ -144,8 +219,11 @@ fbRasterizeTrapezoid (PicturePtr    pPic
 	/* initialize edge walkers */
 	RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off);
 	RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off);
-	
+
+	pixman_rasterize_edges (image, &l, &r, t, b);
+#if 0
 	fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
+#endif
     }
 
     fbFinishAccess (pPicture->pDrawable);
diff-tree 2a960c442bd7560630f52b55d82ec0517542ee5a (from 3ba3ede9bbdfc6376b6f6e0b6ce8280a05e6584d)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed May 23 13:08:26 2007 -0400

    Port renderedge.c to pixman

diff --git a/render/renderedge.c b/render/renderedge.c
index c2ffabe..e92174f 100644
--- a/render/renderedge.c
+++ b/render/renderedge.c
@@ -36,16 +36,7 @@
 _X_EXPORT xFixed
 RenderSampleCeilY (xFixed y, int n)
 {
-    xFixed   f = xFixedFrac(y);
-    xFixed   i = xFixedFloor(y);
-    
-    f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
-    if (f > Y_FRAC_LAST(n))
-    {
-	f = Y_FRAC_FIRST(n);
-	i += xFixed1;
-    }
-    return (i | f);
+    return pixman_sample_ceil_y (y, n);
 }
 
 #define _div(a,b)    ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
@@ -57,16 +48,7 @@ RenderSampleCeilY (xFixed y, int n)
 _X_EXPORT xFixed
 RenderSampleFloorY (xFixed y, int n)
 {
-    xFixed   f = xFixedFrac(y);
-    xFixed   i = xFixedFloor (y);
-    
-    f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
-    if (f < Y_FRAC_FIRST(n))
-    {
-	f = Y_FRAC_LAST(n);
-	i -= xFixed1;
-    }
-    return (i | f);
+    return pixman_sample_floor_y (y, n);
 }
 
 /*
@@ -75,52 +57,7 @@ RenderSampleFloorY (xFixed y, int n)
 _X_EXPORT void
 RenderEdgeStep (RenderEdge *e, int n)
 {
-    xFixed_48_16	ne;
-
-    e->x += n * e->stepx;
-    
-    ne = e->e + n * (xFixed_48_16) e->dx;
-    
-    if (n >= 0)
-    {
-	if (ne > 0)
-	{
-	    int nx = (ne + e->dy - 1) / e->dy;
-	    e->e = ne - nx * (xFixed_48_16) e->dy;
-	    e->x += nx * e->signdx;
-	}
-    }
-    else
-    {
-	if (ne <= -e->dy)
-	{
-	    int nx = (-ne) / e->dy;
-	    e->e = ne + nx * (xFixed_48_16) e->dy;
-	    e->x -= nx * e->signdx;
-	}
-    }
-}
-
-/*
- * A private routine to initialize the multi-step
- * elements of an edge structure
- */
-static void
-_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p)
-{
-    xFixed	stepx;
-    xFixed_48_16	ne;
-    
-    ne = n * (xFixed_48_16) e->dx;
-    stepx = n * e->stepx;
-    if (ne > 0)
-    {
-	int nx = ne / e->dy;
-	ne -= nx * e->dy;
-	stepx += nx * e->signdx;
-    }
-    *dx_p = ne;
-    *stepx_p = stepx;
+    pixman_edge_step (e, n);
 }
 
 /*
@@ -136,35 +73,7 @@ RenderEdgeInit (RenderEdge	*e,
 		xFixed		x_bot,
 		xFixed		y_bot)
 {
-    xFixed	dx, dy;
-
-    e->x = x_top;
-    e->e = 0;
-    dx = x_bot - x_top;
-    dy = y_bot - y_top;
-    e->dy = dy;
-    e->dx = 0;
-    if (dy)
-    {
-	if (dx >= 0)
-	{
-	    e->signdx = 1;
-	    e->stepx = dx / dy;
-	    e->dx = dx % dy;
-	    e->e = -dy;
-	}
-	else
-	{
-	    e->signdx = -1;
-	    e->stepx = -(-dx / dy);
-	    e->dx = -dx % dy;
-	    e->e = 0;
-	}
-    
-	_RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
-	_RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
-    }
-    RenderEdgeStep (e, y_start - y_top);
+    pixman_edge_init (e, n, y_start, x_top, y_top, x_bot, y_bot);
 }
 
 /*
@@ -179,24 +88,6 @@ RenderLineFixedEdgeInit (RenderEdge *e,
 			 int	    x_off,
 			 int	    y_off)
 {
-    xFixed	x_off_fixed = IntToxFixed(x_off);
-    xFixed	y_off_fixed = IntToxFixed(y_off);
-    xPointFixed	*top, *bot;
-
-    if (line->p1.y <= line->p2.y)
-    {
-	top = &line->p1;
-	bot = &line->p2;
-    }
-    else
-    {
-	top = &line->p2;
-	bot = &line->p1;
-    }
-    RenderEdgeInit (e, n, y,
-		    top->x + x_off_fixed,
-		    top->y + y_off_fixed,
-		    bot->x + x_off_fixed,
-		    bot->y + y_off_fixed);
+    pixman_line_fixed_edge_init (e, n, y, (pixman_line_fixed_t *)line, x_off, y_off);
 }
 
diff --git a/render/renderedge.h b/render/renderedge.h
index d621d9d..38f9f09 100644
--- a/render/renderedge.h
+++ b/render/renderedge.h
@@ -50,20 +50,7 @@
  * and can be quickly stepped across small or large gaps in the
  * sample grid
  */
-
-typedef struct {
-    xFixed   x;
-    xFixed   e;
-    xFixed   stepx;
-    xFixed   signdx;
-    xFixed   dy;
-    xFixed   dx;
-
-    xFixed   stepx_small;
-    xFixed   stepx_big;
-    xFixed   dx_small;
-    xFixed   dx_big;
-} RenderEdge;
+typedef pixman_edge_t RenderEdge;
 
 /*
  * Step across a small sample grid gap
diff-tree 3ba3ede9bbdfc6376b6f6e0b6ce8280a05e6584d (from cc648e609d472472bac4a2e568eb3598b3690ba3)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed May 23 12:56:04 2007 -0400

    Add missing offsets for window coordinates - reported by Colin Harrison

diff --git a/fb/fbpict.c b/fb/fbpict.c
index eb78ced..3ad4a22 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -384,6 +384,19 @@ fbComposite (CARD8      op,
     pixman_region16_t region;
     pixman_image_t *src, *mask, *dest;
     
+    xDst += pDst->pDrawable->x;
+    yDst += pDst->pDrawable->y;
+    if (pSrc->pDrawable)
+    {
+        xSrc += pSrc->pDrawable->x;
+        ySrc += pSrc->pDrawable->y;
+    }
+    if (pMask && pMask->pDrawable)
+    {
+	xMask += pMask->pDrawable->x;
+	yMask += pMask->pDrawable->y;
+    }
+
     if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc, ySrc,
 				   xMask, yMask, xDst, yDst, width, height))
         return;
diff-tree cc648e609d472472bac4a2e568eb3598b3690ba3 (from e6a7198e7cd96f1fe0654cc6811a977821579258)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Tue May 22 10:51:56 2007 +0200

    EXA: Export ExaOffscreenMarkUsed.
    
    Can be used to inform EXA that an offscreen area is used outside of EXA.

diff --git a/exa/exa.h b/exa/exa.h
index cd90bbc..9ea5933 100644
--- a/exa/exa.h
+++ b/exa/exa.h
@@ -721,6 +721,9 @@ exaOffscreenAlloc(ScreenPtr pScreen, int
 ExaOffscreenArea *
 exaOffscreenFree(ScreenPtr pScreen, ExaOffscreenArea *area);
 
+void
+ExaOffscreenMarkUsed (PixmapPtr pPixmap);
+
 unsigned long
 exaGetPixmapOffset(PixmapPtr pPix);
 
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index ece5898..a6d98cd 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -323,9 +323,6 @@ ExaCheckComposite (CARD8      op,
 
 /* exa_offscreen.c */
 void
-ExaOffscreenMarkUsed (PixmapPtr pPixmap);
-
-void
 ExaOffscreenSwapOut (ScreenPtr pScreen);
 
 void
diff-tree e6a7198e7cd96f1fe0654cc6811a977821579258 (from 6324bfc468f7a645d2fee59f1c921a4328a4639f)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Tue May 22 10:51:55 2007 +0200

    Bug #8991: Add glXGetDrawableAttributes dispatch; fix texture format therein.
    
    Adapted to master branch by Michel Dänzer <michel at tungstengraphics.com>.

diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c
index 932878f..ed5c138 100644
--- a/GL/glx/glxcmds.c
+++ b/GL/glx/glxcmds.c
@@ -1679,6 +1679,7 @@ DoGetDrawableAttributes(__GLXclientState
     xGLXGetDrawableAttributesReply reply;
     CARD32 attributes[4];
     int numAttribs;
+    PixmapPtr	pixmap;
 
     glxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
     if (!glxPixmap) {
@@ -1693,10 +1694,19 @@ DoGetDrawableAttributes(__GLXclientState
     reply.numAttribs = numAttribs;
 
     attributes[0] = GLX_TEXTURE_TARGET_EXT;
-    attributes[1] = GLX_TEXTURE_RECTANGLE_EXT;
     attributes[2] = GLX_Y_INVERTED_EXT;
     attributes[3] = GL_FALSE;
 
+    /* XXX this is merely less wrong, see fdo bug #8991 */
+    pixmap = (PixmapPtr) glxPixmap->pDraw;
+    if ((pixmap->drawable.width & (pixmap->drawable.width - 1)) ||
+	(pixmap->drawable.height & (pixmap->drawable.height - 1))
+	/* || strstr(CALL_GetString(GL_EXTENSIONS,
+	             "GL_ARB_texture_non_power_of_two")) */)
+	attributes[1] = GLX_TEXTURE_RECTANGLE_EXT;
+    else
+	attributes[1] = GLX_TEXTURE_2D_EXT;
+
     if (client->swapped) {
 	__glXSwapGetDrawableAttributesReply(client, &reply, attributes);
     } else {
diff --git a/GL/glx/indirect_dispatch.h b/GL/glx/indirect_dispatch.h
index 17a372f..24f4bed 100644
--- a/GL/glx/indirect_dispatch.h
+++ b/GL/glx/indirect_dispatch.h
@@ -211,8 +211,6 @@ extern HIDDEN int __glXDisp_ReadPixels(s
 extern HIDDEN int __glXDispSwap_ReadPixels(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN void __glXDisp_EdgeFlagv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_EdgeFlagv(GLbyte * pc);
-extern HIDDEN void __glXDisp_Rotatef(GLbyte * pc);
-extern HIDDEN void __glXDispSwap_Rotatef(GLbyte * pc);
 extern HIDDEN void __glXDisp_TexParameterf(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_TexParameterf(GLbyte * pc);
 extern HIDDEN void __glXDisp_TexParameteri(GLbyte * pc);
@@ -519,6 +517,8 @@ extern HIDDEN void __glXDisp_SecondaryCo
 extern HIDDEN void __glXDispSwap_SecondaryColor3ivEXT(GLbyte * pc);
 extern HIDDEN void __glXDisp_TexCoord4iv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_TexCoord4iv(GLbyte * pc);
+extern HIDDEN int __glXDisp_GetDrawableAttributesSGIX(struct __GLXclientStateRec *, GLbyte *);
+extern HIDDEN int __glXDispSwap_GetDrawableAttributesSGIX(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN void __glXDisp_SampleMaskSGIS(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_SampleMaskSGIS(GLbyte * pc);
 extern HIDDEN void __glXDisp_ColorTableParameteriv(GLbyte * pc);
@@ -849,10 +849,8 @@ extern HIDDEN int __glXDisp_GetHistogram
 extern HIDDEN int __glXDispSwap_GetHistogramParameteriv(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDisp_GetHistogramParameterivEXT(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_GetHistogramParameterivEXT(struct __GLXclientStateRec *, GLbyte *);
-extern HIDDEN int __glXDisp_GetConvolutionFilter(struct __GLXclientStateRec *, GLbyte *);
-extern HIDDEN int __glXDispSwap_GetConvolutionFilter(struct __GLXclientStateRec *, GLbyte *);
-extern HIDDEN int __glXDisp_GetConvolutionFilterEXT(struct __GLXclientStateRec *, GLbyte *);
-extern HIDDEN int __glXDispSwap_GetConvolutionFilterEXT(struct __GLXclientStateRec *, GLbyte *);
+extern HIDDEN void __glXDisp_Rotatef(GLbyte * pc);
+extern HIDDEN void __glXDispSwap_Rotatef(GLbyte * pc);
 extern HIDDEN int __glXDisp_GetProgramivARB(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_GetProgramivARB(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN void __glXDisp_BlendFuncSeparateEXT(GLbyte * pc);
@@ -877,6 +875,10 @@ extern HIDDEN void __glXDisp_Map2f(GLbyt
 extern HIDDEN void __glXDispSwap_Map2f(GLbyte * pc);
 extern HIDDEN void __glXDisp_ProgramStringARB(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_ProgramStringARB(GLbyte * pc);
+extern HIDDEN int __glXDisp_GetConvolutionFilter(struct __GLXclientStateRec *, GLbyte *);
+extern HIDDEN int __glXDispSwap_GetConvolutionFilter(struct __GLXclientStateRec *, GLbyte *);
+extern HIDDEN int __glXDisp_GetConvolutionFilterEXT(struct __GLXclientStateRec *, GLbyte *);
+extern HIDDEN int __glXDispSwap_GetConvolutionFilterEXT(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDisp_GetTexGenfv(struct __GLXclientStateRec *, GLbyte *);
diff --git a/GL/glx/indirect_table.c b/GL/glx/indirect_table.c
index 60d6760..9d0383c 100644
--- a/GL/glx/indirect_table.c
+++ b/GL/glx/indirect_table.c
@@ -1231,8 +1231,8 @@ const struct __glXDispatchInfo Render_di
 };
 
 /*****************************************************************/
-/* tree depth = 13 */
-static const int_fast16_t VendorPriv_dispatch_tree[155] = {
+/* tree depth = 12 */
+static const int_fast16_t VendorPriv_dispatch_tree[152] = {
     /* [0] -> opcode range [0, 131072], node depth 1 */
     2,
     5,
@@ -1474,17 +1474,12 @@ static const int_fast16_t VendorPriv_dis
 
     /* [149] -> opcode range [65536, 65568], node depth 12 */
     1,
-    152,
-    EMPTY_LEAF,
-
-    /* [152] -> opcode range [65536, 65552], node depth 13 */
-    1,
     LEAF(88),
     EMPTY_LEAF,
 
 };
 
-static const void *VendorPriv_function_table[96][2] = {
+static const void *VendorPriv_function_table[104][2] = {
     /* [  0] =     0 */ {NULL, NULL},
     /* [  1] =     1 */ {__glXDisp_GetConvolutionFilterEXT, __glXDispSwap_GetConvolutionFilterEXT},
     /* [  2] =     2 */ {__glXDisp_GetConvolutionParameterfvEXT, __glXDispSwap_GetConvolutionParameterfvEXT},
@@ -1581,6 +1576,14 @@ static const void *VendorPriv_function_t
     /* [ 93] = 65541 */ {__glXDisp_CreateContextWithConfigSGIX, __glXDispSwap_CreateContextWithConfigSGIX},
     /* [ 94] = 65542 */ {__glXDisp_CreateGLXPixmapWithConfigSGIX, __glXDispSwap_CreateGLXPixmapWithConfigSGIX},
     /* [ 95] = 65543 */ {NULL, NULL},
+    /* [ 96] = 65544 */ {NULL, NULL},
+    /* [ 97] = 65545 */ {NULL, NULL},
+    /* [ 98] = 65546 */ {__glXDisp_GetDrawableAttributesSGIX, __glXDispSwap_GetDrawableAttributesSGIX},
+    /* [ 99] = 65547 */ {NULL, NULL},
+    /* [ 100] = 65548 */ {NULL, NULL},
+    /* [ 101] = 65549 */ {NULL, NULL},
+    /* [ 102] = 65550 */ {NULL, NULL},
+    /* [ 103] = 65551 */ {NULL, NULL},
 };
 
 const struct __glXDispatchInfo VendorPriv_dispatch_info = {
diff-tree 6324bfc468f7a645d2fee59f1c921a4328a4639f (from 5006d08d7fc56d3d380cc6b75297f94e8594eb54)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Tue May 22 10:51:53 2007 +0200

    AIGLX: Zero-copy texture-from-pixmap.
    
    When available, use the 2D driver texOffsetStart hook and the 3D driver
    setTexOffset hook to save the overhead of passing the pixmap data to
    glTex(Sub)Image.
    
    The basic idea is to update the driver specific 'offset' for bound pixmaps
    before dispatching a GLX render request and to flush immediately afterwards
    if there are any pixmaps bound. This should ensure that the 3D driver can
    use pixmaps for texturing directly regardless of the X server moving them
    around.

diff --git a/GL/glx/glxdrawable.h b/GL/glx/glxdrawable.h
index 20e9b43..6500cc7 100644
--- a/GL/glx/glxdrawable.h
+++ b/GL/glx/glxdrawable.h
@@ -42,6 +42,10 @@
 
 #include <damage.h>
 
+#ifdef XF86DRI
+#include <GL/internal/dri_interface.h>
+#endif
+
 typedef struct {
 
     DrawablePtr pDraw;
@@ -50,7 +54,12 @@ typedef struct {
     ScreenPtr pScreen;
     Bool idExists;
     int refcnt;
+#ifdef XF86DRI
     DamagePtr pDamage;
+    __DRIcontext *pDRICtx;
+    GLint texname;
+    unsigned long offset;
+#endif
 } __GLXpixmap;
 
 struct __GLXdrawable {
diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index c30f372..d93d460 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -76,6 +76,11 @@ struct __GLXDRIscreen {
     xf86EnterVTProc *enterVT;
     xf86LeaveVTProc *leaveVT;
 
+    DRITexOffsetStartProcPtr texOffsetStart;
+    DRITexOffsetFinishProcPtr texOffsetFinish;
+    __GLXpixmap* texOffsetOverride[16];
+    GLuint lastTexOffsetOverride;
+
     unsigned char glx_enable_bits[__GLX_EXT_BYTES];
 };
 
@@ -125,30 +130,75 @@ struct __GLXDRIdrawable {
 static const char CREATE_NEW_SCREEN_FUNC[] =
     "__driCreateNewScreen_" STRINGIFY (INTERNAL_VERSION);
 
-/* The DRI driver entry point version wasn't bumped when the
- * copySubBuffer functionality was added to the DRI drivers, but the
- * functionality is still conditional on the value of the
- * internal_api_version passed to __driCreateNewScreen.  However, the
- * screen constructor doesn't fail for a DRI driver that's older than
- * the passed in version number, so there's no way we can know for
- * sure that we can actually use the copySubBuffer functionality.  But
- * since the earliest (and at this point only) released mesa version
- * (6.5) that uses the 20050727 entry point does have copySubBuffer,
- * we'll just settle for that.  We still have to pass in a higher to
- * the screen constructor to enable the functionality.
- */
-#define COPY_SUB_BUFFER_INTERNAL_VERSION 20060314
 
 static void
-__glXDRIleaveServer(void)
+__glXDRIleaveServer(GLboolean rendering)
 {
-  DRIBlockHandler(NULL, NULL, NULL);
+    int i;
+
+    for (i = 0; rendering && i < screenInfo.numScreens; i++) {
+	__GLXDRIscreen * const screen =
+	    (__GLXDRIscreen *) __glXgetActiveScreen(i);
+	GLuint lastOverride = screen->lastTexOffsetOverride;
+
+	if (lastOverride) {
+	    __GLXpixmap **texOffsetOverride = screen->texOffsetOverride;
+	    int j;
+
+	    for (j = 0; j < lastOverride; j++) {
+		__GLXpixmap *pGlxPix = texOffsetOverride[j];
+
+		if (pGlxPix && pGlxPix->texname) {
+		    pGlxPix->offset =
+			screen->texOffsetStart((PixmapPtr)pGlxPix->pDraw);
+		}
+	    }
+	}
+    }
+
+    DRIBlockHandler(NULL, NULL, NULL);
+
+    for (i = 0; rendering && i < screenInfo.numScreens; i++) {
+	__GLXDRIscreen * const screen =
+	    (__GLXDRIscreen *) __glXgetActiveScreen(i);
+	GLuint lastOverride = screen->lastTexOffsetOverride;
+
+	if (lastOverride) {
+	    __GLXpixmap **texOffsetOverride = screen->texOffsetOverride;
+	    int j;
+
+	    for (j = 0; j < lastOverride; j++) {
+		__GLXpixmap *pGlxPix = texOffsetOverride[j];
+
+		if (pGlxPix && pGlxPix->texname) {
+		    screen->driScreen.setTexOffset(pGlxPix->pDRICtx,
+						   pGlxPix->texname,
+						   pGlxPix->offset,
+						   pGlxPix->pDraw->depth,
+						   ((PixmapPtr)pGlxPix->pDraw)->
+						   devKind);
+		}
+	    }
+	}
+    }
 }
     
 static void
-__glXDRIenterServer(void)
+__glXDRIenterServer(GLboolean rendering)
 {
-  DRIWakeupHandler(NULL, 0, NULL);
+    int i;
+
+    for (i = 0; rendering && i < screenInfo.numScreens; i++) {
+	__GLXDRIscreen * const screen =
+	    (__GLXDRIscreen *) __glXgetActiveScreen(i);
+
+	if (screen->lastTexOffsetOverride) {
+	    CALL_Flush(GET_DISPATCH(), ());
+	    break;
+	}
+    }
+
+    DRIWakeupHandler(NULL, 0, NULL);
 }
 
 /**
@@ -289,19 +339,6 @@ __glXDRIcontextForceCurrent(__GLXcontext
 					      &context->driContext);
 }
 
-static int
-glxCountBits(int word)
-{
-    int ret = 0;
-
-    while (word) {
-        ret += (word & 1);
-        word >>= 1;
-    }
-
-    return ret;
-}
-
 static void
 glxFillAlphaChannel (PixmapPtr pixmap, int x, int y, int width, int height)
 {
@@ -335,19 +372,75 @@ __glXDRIbindTexImage(__GLXcontext *baseC
 		     int buffer,
 		     __GLXpixmap *glxPixmap)
 {
-    RegionPtr	pRegion;
+    RegionPtr	pRegion = NULL;
     PixmapPtr	pixmap;
-    int		bpp;
+    int		w, h, bpp, override = 0;
     GLenum	target, format, type;
+    ScreenPtr pScreen = glxPixmap->pScreen;
+    __GLXDRIscreen * const screen =
+	(__GLXDRIscreen *) __glXgetActiveScreen(pScreen->myNum);
 
     pixmap = (PixmapPtr) glxPixmap->pDraw;
+    w = pixmap->drawable.width;
+    h = pixmap->drawable.height;
+
+    if (h & (h - 1) || w & (w - 1))
+	target = GL_TEXTURE_RECTANGLE_ARB;
+    else
+	target = GL_TEXTURE_2D;
+
+    if (screen->texOffsetStart && screen->driScreen.setTexOffset) {
+	__GLXpixmap **texOffsetOverride = screen->texOffsetOverride;
+	int i, firstEmpty = 16, texname;
+
+	for (i = 0; i < 16; i++) {
+	    if (texOffsetOverride[i] == glxPixmap)
+		goto alreadyin; 
+
+	    if (firstEmpty == 16 && !texOffsetOverride[i])
+		firstEmpty = i;
+	}
+
+	if (firstEmpty == 16) {
+	    ErrorF("%s: Failed to register texture offset override\n", __func__);
+	    goto nooverride;
+	}
+
+	if (firstEmpty >= screen->lastTexOffsetOverride)
+	    screen->lastTexOffsetOverride = firstEmpty + 1;
+
+	texOffsetOverride[firstEmpty] = glxPixmap;
+
+alreadyin:
+	override = 1;
+
+	glxPixmap->pDRICtx = &((__GLXDRIcontext*)baseContext)->driContext;
+
+	CALL_GetIntegerv(GET_DISPATCH(), (target == GL_TEXTURE_2D ?
+					  GL_TEXTURE_BINDING_2D :
+					  GL_TEXTURE_BINDING_RECTANGLE_NV,
+					  &texname));
+
+	if (texname == glxPixmap->texname)
+	    return Success;
+
+	glxPixmap->texname = texname;
+
+	screen->driScreen.setTexOffset(glxPixmap->pDRICtx, texname, 0,
+				       pixmap->drawable.depth, pixmap->devKind);
+    }
+nooverride:
+
     if (!glxPixmap->pDamage) {
-        glxPixmap->pDamage = DamageCreate(NULL, NULL, DamageReportNone,
-					  TRUE, glxPixmap->pScreen, NULL);
-	if (!glxPixmap->pDamage)
-            return BadAlloc;
+	if (!override) {
+	    glxPixmap->pDamage = DamageCreate(NULL, NULL, DamageReportNone,
+					      TRUE, pScreen, NULL);
+	    if (!glxPixmap->pDamage)
+		return BadAlloc;
+
+	    DamageRegister ((DrawablePtr) pixmap, glxPixmap->pDamage);
+	}
 
-	DamageRegister ((DrawablePtr) pixmap, glxPixmap->pDamage);
 	pRegion = NULL;
     } else {
 	pRegion = DamageRegion(glxPixmap->pDamage);
@@ -360,30 +453,22 @@ __glXDRIbindTexImage(__GLXcontext *baseC
 	bpp = 4;
 	format = GL_BGRA;
 	type =
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-	    GL_UNSIGNED_BYTE;
-#else
-	    GL_UNSIGNED_INT_8_8_8_8_REV;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+	    !override ? GL_UNSIGNED_INT_8_8_8_8_REV :
 #endif
+	    GL_UNSIGNED_BYTE;
     } else {
 	bpp = 2;
 	format = GL_RGB;
 	type = GL_UNSIGNED_SHORT_5_6_5;
     }
 
-    if (!(glxCountBits(pixmap->drawable.width) == 1 &&
-	  glxCountBits(pixmap->drawable.height) == 1)
-	/* || strstr(CALL_GetString(GL_EXTENSIONS,
-	             "GL_ARB_texture_non_power_of_two")) */)
-	target = GL_TEXTURE_RECTANGLE_ARB;
-    else
-	target = GL_TEXTURE_2D;
-
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,
 				       pixmap->devKind / bpp) );
+
     if (pRegion == NULL)
     {
-	if (pixmap->drawable.depth == 24)
+	if (!override && pixmap->drawable.depth == 24)
 	    glxFillAlphaChannel(pixmap,
 				pixmap->drawable.x,
 				pixmap->drawable.y,
@@ -404,8 +489,8 @@ __glXDRIbindTexImage(__GLXcontext *baseC
 			  0,
 			  format,
 			  type,
-			  pixmap->devPrivate.ptr) );
-    } else {
+			  override ? NULL : pixmap->devPrivate.ptr) );
+    } else if (!override) {
         int i, numRects;
 	BoxPtr p;
 
@@ -436,7 +521,8 @@ __glXDRIbindTexImage(__GLXcontext *baseC
 	}
     }
 
-    DamageEmpty(glxPixmap->pDamage);
+    if (!override)
+	DamageEmpty(glxPixmap->pDamage);
 
     return Success;
 }
@@ -446,6 +532,40 @@ __glXDRIreleaseTexImage(__GLXcontext *ba
 			int buffer,
 			__GLXpixmap *pixmap)
 {
+    ScreenPtr pScreen = pixmap->pScreen;
+    __GLXDRIscreen * const screen =
+	(__GLXDRIscreen *) __glXgetActiveScreen(pScreen->myNum);
+    GLuint lastOverride = screen->lastTexOffsetOverride;
+
+    if (lastOverride) {
+	__GLXpixmap **texOffsetOverride = screen->texOffsetOverride;
+	int i;
+
+	for (i = 0; i < lastOverride; i++) {
+	    if (texOffsetOverride[i] == pixmap) {
+		if (screen->texOffsetFinish)
+		    screen->texOffsetFinish((PixmapPtr)pixmap->pDraw);
+
+		texOffsetOverride[i] = NULL;
+
+		if (i + 1 == lastOverride) {
+		    lastOverride = 0;
+
+		    while (i--) {
+			if (texOffsetOverride[i]) {
+			    lastOverride = i + 1;
+			    break;
+			}
+		    }
+
+		    screen->lastTexOffsetOverride = lastOverride;
+
+		    break;
+		}
+	    }
+	}
+    }
+
     return Success;
 }
 
@@ -666,9 +786,9 @@ static GLboolean createContext(__DRInati
     fakeID = FakeClientID(0);
     *(XID *) contextID = fakeID;
 
-    __glXDRIenterServer();
+    __glXDRIenterServer(GL_FALSE);
     retval = DRICreateContext(pScreen, visual, fakeID, hw_context);
-    __glXDRIleaveServer();
+    __glXDRIleaveServer(GL_FALSE);
     return retval;
 }
 
@@ -677,9 +797,9 @@ static GLboolean destroyContext(__DRInat
 {
     GLboolean retval;
 
-    __glXDRIenterServer();
+    __glXDRIenterServer(GL_FALSE);
     retval = DRIDestroyContext(screenInfo.screens[screen], context);
-    __glXDRIleaveServer();
+    __glXDRIleaveServer(GL_FALSE);
     return retval;
 }
 
@@ -694,12 +814,12 @@ createDrawable(__DRInativeDisplay *dpy, 
     if (!pDrawable)
 	return GL_FALSE;
 
-    __glXDRIenterServer();
+    __glXDRIenterServer(GL_FALSE);
     retval = DRICreateDrawable(screenInfo.screens[screen],
 			    drawable,
 			    pDrawable,
 			    hHWDrawable);
-    __glXDRIleaveServer();
+    __glXDRIleaveServer(GL_FALSE);
     return retval;
 }
 
@@ -713,11 +833,11 @@ destroyDrawable(__DRInativeDisplay *dpy,
     if (!pDrawable)
 	return GL_FALSE;
 
-    __glXDRIenterServer();
+    __glXDRIenterServer(GL_FALSE);
     retval = DRIDestroyDrawable(screenInfo.screens[screen],
 			     drawable,
 			     pDrawable);
-    __glXDRIleaveServer();
+    __glXDRIleaveServer(GL_FALSE);
     return retval;
 }
 
@@ -754,14 +874,14 @@ getDrawableInfo(__DRInativeDisplay *dpy,
 	return GL_FALSE;
     }
 
-    __glXDRIenterServer();
+    __glXDRIenterServer(GL_FALSE);
     retval = DRIGetDrawableInfo(screenInfo.screens[screen],
 				pDrawable, index, stamp,
 				x, y, width, height,
 				numClipRects, &pClipRects,
 				backX, backY,
 				numBackClipRects, &pBackClipRects);
-    __glXDRIleaveServer();
+    __glXDRIleaveServer(GL_FALSE);
 
     if (*numClipRects > 0) {
 	size = sizeof (drm_clip_rect_t) * *numClipRects;
@@ -866,7 +986,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     __DRIframebuffer  framebuffer;
     int   fd = -1;
     int   status;
-    int api_ver = COPY_SUB_BUFFER_INTERNAL_VERSION;
+    int api_ver = 20070121;
     drm_magic_t magic;
     drmVersionPtr version;
     int newlyopened;
@@ -1048,6 +1168,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 	goto handle_error;
     }
 
+    DRIGetTexOffsetFuncs(pScreen, &screen->texOffsetStart,
+			 &screen->texOffsetFinish);
+
     __glXScreenInit(&screen->base, pScreen);
 
     buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index ca874e3..c09120c 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -238,9 +238,9 @@ GLboolean __glXFreeContext(__GLXcontext 
      * the latter case we need to lift the DRI lock manually. */
 
     if (!glxBlockClients) {
-	__glXleaveServer();
+	__glXleaveServer(GL_FALSE);
 	cx->destroy(cx);
-	__glXenterServer();
+	__glXenterServer(GL_FALSE);
     } else {
 	cx->next = glxPendingDestroyContexts;
 	glxPendingDestroyContexts = cx;
@@ -439,49 +439,49 @@ void glxResumeClients(void)
 	AttendClient(__glXClients[i]->client);
     }
 
-    __glXleaveServer();
+    __glXleaveServer(GL_FALSE);
     for (cx = glxPendingDestroyContexts; cx != NULL; cx = next) {
 	next = cx->next;
 
 	cx->destroy(cx);
     }
     glxPendingDestroyContexts = NULL;
-    __glXenterServer();
+    __glXenterServer(GL_FALSE);
 }
 
 static void
-__glXnopEnterServer(void)
+__glXnopEnterServer(GLboolean rendering)
 {
 }
     
 static void
-__glXnopLeaveServer(void)
+__glXnopLeaveServer(GLboolean rendering)
 {
 }
 
-static void (*__glXenterServerFunc)(void) = __glXnopEnterServer;
-static void (*__glXleaveServerFunc)(void)  = __glXnopLeaveServer;
+static void (*__glXenterServerFunc)(GLboolean) = __glXnopEnterServer;
+static void (*__glXleaveServerFunc)(GLboolean)  = __glXnopLeaveServer;
 
-void __glXsetEnterLeaveServerFuncs(void (*enter)(void),
-				   void (*leave)(void))
+void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean),
+				   void (*leave)(GLboolean))
 {
   __glXenterServerFunc = enter;
   __glXleaveServerFunc = leave;
 }
 
 
-void __glXenterServer(void)
+void __glXenterServer(GLboolean rendering)
 {
   glxServerLeaveCount--;
 
   if (glxServerLeaveCount == 0)
-    (*__glXenterServerFunc)();
+    (*__glXenterServerFunc)(rendering);
 }
 
-void __glXleaveServer(void)
+void __glXleaveServer(GLboolean rendering)
 {
   if (glxServerLeaveCount == 0)
-    (*__glXleaveServerFunc)();
+    (*__glXleaveServerFunc)(rendering);
 
   glxServerLeaveCount++;
 }
@@ -546,11 +546,12 @@ static int __glXDispatch(ClientPtr clien
 								       opcode,
 								       client->swapped);
     if (proc != NULL) {
-	__glXleaveServer();
+	GLboolean rendering = opcode <= X_GLXRenderLarge;
+	__glXleaveServer(rendering);
 
 	retval = (*proc)(cl, (GLbyte *) stuff);
 
-	__glXenterServer();
+	__glXenterServer(rendering);
     }
     else {
 	retval = BadRequest;
diff --git a/GL/glx/glxglcore.c b/GL/glx/glxglcore.c
index b50740c..df9be07 100644
--- a/GL/glx/glxglcore.c
+++ b/GL/glx/glxglcore.c
@@ -106,11 +106,11 @@ __glXMesaDrawableSwapBuffers(__GLXdrawab
      * why we need to re-take the lock and swap in the server context
      * before calling XMesaSwapBuffers() here.  /me shakes head. */
 
-    __glXenterServer();
+    __glXenterServer(GL_FALSE);
 
     XMesaSwapBuffers(glxPriv->xm_buf);
 
-    __glXleaveServer();
+    __glXleaveServer(GL_FALSE);
 
     return GL_TRUE;
 }
diff --git a/GL/glx/glxserver.h b/GL/glx/glxserver.h
index 49cad73..fa09c15 100644
--- a/GL/glx/glxserver.h
+++ b/GL/glx/glxserver.h
@@ -131,10 +131,10 @@ struct __GLXprovider {
 
 void GlxPushProvider(__GLXprovider *provider);
 
-void __glXsetEnterLeaveServerFuncs(void (*enter)(void),
-				   void (*leave)(void));
-void __glXenterServer(void);
-void __glXleaveServer(void);
+void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean),
+				   void (*leave)(GLboolean));
+void __glXenterServer(GLboolean rendering);
+void __glXleaveServer(GLboolean rendering);
 
 void glxSuspendClients(void);
 void glxResumeClients(void);
diff-tree 5006d08d7fc56d3d380cc6b75297f94e8594eb54 (from ff2eae86b6a8760befbbc5d605debebe7b024c05)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Tue May 22 10:51:52 2007 +0200

    DRI: Add TexOffset driver hooks.
    
    To be used by AIGLX for GLX_EXT_texture_from_pixmap without several data copies.
    
    The texOffsetStart hook must make sure that the given pixmap is accessible by
    the GPU for texturing and return an 'offset' that can be used by the 3D
    driver for that purpose.
    
    The texOffsetFinish hook is called when the pixmap is no longer being used for
    texturing.

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 355d281..fae0b43 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -2210,6 +2210,19 @@ DRIGetContext(ScreenPtr pScreen)
     return pDRIPriv->myContext;
 }
 
+void
+DRIGetTexOffsetFuncs(ScreenPtr pScreen,
+		     DRITexOffsetStartProcPtr *texOffsetStartFunc,
+		     DRITexOffsetFinishProcPtr *texOffsetFinishFunc)
+{
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+    if (!pDRIPriv) return;
+
+    *texOffsetStartFunc  = pDRIPriv->pDriverInfo->texOffsetStart;
+    *texOffsetFinishFunc = pDRIPriv->pDriverInfo->texOffsetFinish;
+}
+
 /* This lets get at the unwrapped functions so that they can correctly
  * call the lowerlevel functions, and choose whether they will be
  * called at every level of recursion (eg in validatetree).
diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h
index a21338a..e49bb6f 100644
--- a/hw/xfree86/dri/dri.h
+++ b/hw/xfree86/dri/dri.h
@@ -107,9 +107,12 @@ typedef struct {
  */
 
 #define DRIINFO_MAJOR_VERSION   5
-#define DRIINFO_MINOR_VERSION   2
+#define DRIINFO_MINOR_VERSION   3
 #define DRIINFO_PATCH_VERSION   0
 
+typedef unsigned long long (*DRITexOffsetStartProcPtr)(PixmapPtr pPix);
+typedef void (*DRITexOffsetFinishProcPtr)(PixmapPtr pPix);
+
 typedef struct {
     /* driver call back functions
      *
@@ -180,6 +183,10 @@ typedef struct {
     /* New with DRI version 5.2.0 */
     Bool                allocSarea;
     Bool                keepFDOpen;
+
+    /* New with DRI version 5.3.0 */
+    DRITexOffsetStartProcPtr  texOffsetStart;
+    DRITexOffsetFinishProcPtr texOffsetFinish;
 } DRIInfoRec, *DRIInfoPtr;
 
 
@@ -358,7 +365,9 @@ extern void *DRIMasterSareaPointer(ScrnI
 
 extern drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn);
 
-
+extern void DRIGetTexOffsetFuncs(ScreenPtr pScreen,
+				 DRITexOffsetStartProcPtr *texOffsetStartFunc,
+				 DRITexOffsetFinishProcPtr *texOffsetFinishFunc);
 
 #define _DRI_H_
 
diff-tree ff2eae86b6a8760befbbc5d605debebe7b024c05 (from 56fd92715567cd32e4b725b3791de9ac4e3879aa)
Author: David Nusinow <dnusinow at debian.org>
Date:   Mon May 21 19:50:04 2007 -0400

    Fix boolean thinko that prevented working without a server layout

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 7f1105f..67e8af4 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1809,7 +1809,7 @@ configImpliedLayout(serverLayoutPtr serv
     indp = xnfalloc(sizeof(IDevRec));
     indp->identifier = NULL;
     servlayoutp->inputs = indp;
-    if (!xf86Info.allowEmptyInput && checkCoreInputDevices(servlayoutp, TRUE))
+    if (!xf86Info.allowEmptyInput && !checkCoreInputDevices(servlayoutp, TRUE))
 	return FALSE;
     
     return TRUE;
diff-tree 56fd92715567cd32e4b725b3791de9ac4e3879aa (from 7e2c935920cafadbd87c351f1a3239932864fb90)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Mon May 21 20:00:25 2007 -0400

    Remove fast path code from fbpict.c
    
    Remove the various fast path functions from fbpict, and instead use
    pixman_image_composite().

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 84d19ac..eb78ced 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -39,898 +39,6 @@
 #include "fbpict.h"
 #include "fbmmx.h"
 
-CARD32
-fbOver (CARD32 x, CARD32 y)
-{
-    CARD16  a = ~x >> 24;
-    CARD16  t;
-    CARD32  m,n,o,p;
-
-    m = FbOverU(x,y,0,a,t);
-    n = FbOverU(x,y,8,a,t);
-    o = FbOverU(x,y,16,a,t);
-    p = FbOverU(x,y,24,a,t);
-    return m|n|o|p;
-}
-
-CARD32
-fbOver24 (CARD32 x, CARD32 y)
-{
-    CARD16  a = ~x >> 24;
-    CARD16  t;
-    CARD32  m,n,o;
-
-    m = FbOverU(x,y,0,a,t);
-    n = FbOverU(x,y,8,a,t);
-    o = FbOverU(x,y,16,a,t);
-    return m|n|o;
-}
-
-CARD32
-fbIn (CARD32 x, CARD8 y)
-{
-    CARD16  a = y;
-    CARD16  t;
-    CARD32  m,n,o,p;
-
-    m = FbInU(x,0,a,t);
-    n = FbInU(x,8,a,t);
-    o = FbInU(x,16,a,t);
-    p = FbInU(x,24,a,t);
-    return m|n|o|p;
-}
-
-/*
- * Naming convention:
- *
- *  opSRCxMASKxDST
- */
-
-void
-fbCompositeSolidMask_nx8x8888 (CARD8      op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16      xSrc,
-			       INT16      ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height)
-{
-    CARD32	src, srca;
-    CARD32	*dstLine, *dst, d, dstMask;
-    CARD8	*maskLine, *mask, m;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    dstMask = FbFullMask (pDst->pDrawable->depth);
-    srca = src >> 24;
-    if (src == 0)
-	return;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    m = READ(mask++);
-	    if (m == 0xff)
-	    {
-		if (srca == 0xff)
-		    WRITE(dst, src & dstMask);
-		else
-		    WRITE(dst, fbOver (src, READ(dst)) & dstMask);
-	    }
-	    else if (m)
-	    {
-		d = fbIn (src, m);
-		WRITE(dst, fbOver (d, READ(dst)) & dstMask);
-	    }
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pMask->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-void
-fbCompositeSolidMask_nx8888x8888C (CARD8      op,
-				   PicturePtr pSrc,
-				   PicturePtr pMask,
-				   PicturePtr pDst,
-				   INT16      xSrc,
-				   INT16      ySrc,
-				   INT16      xMask,
-				   INT16      yMask,
-				   INT16      xDst,
-				   INT16      yDst,
-				   CARD16     width,
-				   CARD16     height)
-{
-    CARD32	src, srca;
-    CARD32	*dstLine, *dst, d, dstMask;
-    CARD32	*maskLine, *mask, ma;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    CARD32	m, n, o, p;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    dstMask = FbFullMask (pDst->pDrawable->depth);
-    srca = src >> 24;
-    if (src == 0)
-	return;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    ma = READ(mask++);
-	    if (ma == 0xffffffff)
-	    {
-		if (srca == 0xff)
-		    WRITE(dst, src & dstMask);
-		else
-		    WRITE(dst, fbOver (src, READ(dst)) & dstMask);
-	    }
-	    else if (ma)
-	    {
-		d = READ(dst);
-#define FbInOverC(src,srca,msk,dst,i,result) { \
-    CARD16  __a = FbGet8(msk,i); \
-    CARD32  __t, __ta; \
-    CARD32  __i; \
-    __t = FbIntMult (FbGet8(src,i), __a,__i); \
-    __ta = (CARD8) ~FbIntMult (srca, __a,__i); \
-    __t = __t + FbIntMult(FbGet8(dst,i),__ta,__i); \
-    __t = (CARD32) (CARD8) (__t | (-(__t >> 8))); \
-    result = __t << (i); \
-}
-		FbInOverC (src, srca, ma, d, 0, m);
-		FbInOverC (src, srca, ma, d, 8, n);
-		FbInOverC (src, srca, ma, d, 16, o);
-		FbInOverC (src, srca, ma, d, 24, p);
-		WRITE(dst, m|n|o|p);
-	    }
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pMask->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-void
-fbCompositeSolidMask_nx8x0888 (CARD8      op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16      xSrc,
-			       INT16      ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height)
-{
-    CARD32	src, srca;
-    CARD8	*dstLine, *dst;
-    CARD32	d;
-    CARD8	*maskLine, *mask, m;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    srca = src >> 24;
-    if (src == 0)
-	return;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    m = READ(mask++);
-	    if (m == 0xff)
-	    {
-		if (srca == 0xff)
-		    d = src;
-		else
-		{
-		    d = Fetch24(dst);
-		    d = fbOver24 (src, d);
-		}
-		Store24(dst,d);
-	    }
-	    else if (m)
-	    {
-		d = fbOver24 (fbIn(src,m), Fetch24(dst));
-		Store24(dst,d);
-	    }
-	    dst += 3;
-	}
-    }
-
-    fbFinishAccess (pMask->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-void
-fbCompositeSolidMask_nx8x0565 (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height)
-{
-    CARD32	src, srca;
-    CARD16	*dstLine, *dst;
-    CARD32	d;
-    CARD8	*maskLine, *mask, m;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    srca = src >> 24;
-    if (src == 0)
-	return;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    m = READ(mask++);
-	    if (m == 0xff)
-	    {
-		if (srca == 0xff)
-		    d = src;
-		else
-		{
-		    d = READ(dst);
-		    d = fbOver24 (src, cvt0565to0888(d));
-		}
-		WRITE(dst, cvt8888to0565(d));
-	    }
-	    else if (m)
-	    {
-		d = READ(dst);
-		d = fbOver24 (fbIn(src,m), cvt0565to0888(d));
-		WRITE(dst, cvt8888to0565(d));
-	    }
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pMask->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-void
-fbCompositeSolidMask_nx8888x0565C (CARD8      op,
-				   PicturePtr pSrc,
-				   PicturePtr pMask,
-				   PicturePtr pDst,
-				   INT16      xSrc,
-				   INT16      ySrc,
-				   INT16      xMask,
-				   INT16      yMask,
-				   INT16      xDst,
-				   INT16      yDst,
-				   CARD16     width,
-				   CARD16     height)
-{
-    CARD32	src, srca;
-    CARD16	src16;
-    CARD16	*dstLine, *dst;
-    CARD32	d;
-    CARD32	*maskLine, *mask, ma;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    CARD32	m, n, o;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    srca = src >> 24;
-    if (src == 0)
-	return;
-
-    src16 = cvt8888to0565(src);
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    ma = READ(mask++);
-	    if (ma == 0xffffffff)
-	    {
-		if (srca == 0xff)
-		{
-		    WRITE(dst, src16);
-		}
-		else
-		{
-		    d = READ(dst);
-		    d = fbOver24 (src, cvt0565to0888(d));
-		    WRITE(dst, cvt8888to0565(d));
-		}
-	    }
-	    else if (ma)
-	    {
-		d = READ(dst);
-		d = cvt0565to0888(d);
-		FbInOverC (src, srca, ma, d, 0, m);
-		FbInOverC (src, srca, ma, d, 8, n);
-		FbInOverC (src, srca, ma, d, 16, o);
-		d = m|n|o;
-		WRITE(dst, cvt8888to0565(d));
-	    }
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pMask->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-void
-fbCompositeSrc_8888x8888 (CARD8      op,
-			 PicturePtr pSrc,
-			 PicturePtr pMask,
-			 PicturePtr pDst,
-			 INT16      xSrc,
-			 INT16      ySrc,
-			 INT16      xMask,
-			 INT16      yMask,
-			 INT16      xDst,
-			 INT16      yDst,
-			 CARD16     width,
-			 CARD16     height)
-{
-    CARD32	*dstLine, *dst, dstMask;
-    CARD32	*srcLine, *src, s;
-    FbStride	dstStride, srcStride;
-    CARD8	a;
-    CARD16	w;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-
-    dstMask = FbFullMask (pDst->pDrawable->depth);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w--)
-	{
-	    s = READ(src++);
-	    a = s >> 24;
-	    if (a == 0xff)
-		WRITE(dst, s & dstMask);
-	    else if (a)
-		WRITE(dst, fbOver (s, READ(dst)) & dstMask);
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pSrc->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-void
-fbCompositeSrc_8888x0888 (CARD8      op,
-			 PicturePtr pSrc,
-			 PicturePtr pMask,
-			 PicturePtr pDst,
-			 INT16      xSrc,
-			 INT16      ySrc,
-			 INT16      xMask,
-			 INT16      yMask,
-			 INT16      xDst,
-			 INT16      yDst,
-			 CARD16     width,
-			 CARD16     height)
-{
-    CARD8	*dstLine, *dst;
-    CARD32	d;
-    CARD32	*srcLine, *src, s;
-    CARD8	a;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w--)
-	{
-	    s = READ(src++);
-	    a = s >> 24;
-	    if (a)
-	    {
-		if (a == 0xff)
-		    d = s;
-		else
-		    d = fbOver24 (s, Fetch24(dst));
-		Store24(dst,d);
-	    }
-	    dst += 3;
-	}
-    }
-
-    fbFinishAccess (pSrc->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-void
-fbCompositeSrc_8888x0565 (CARD8      op,
-			 PicturePtr pSrc,
-			 PicturePtr pMask,
-			 PicturePtr pDst,
-			 INT16      xSrc,
-			 INT16      ySrc,
-			 INT16      xMask,
-			 INT16      yMask,
-			 INT16      xDst,
-			 INT16      yDst,
-			 CARD16     width,
-			 CARD16     height)
-{
-    CARD16	*dstLine, *dst;
-    CARD32	d;
-    CARD32	*srcLine, *src, s;
-    CARD8	a;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w--)
-	{
-	    s = READ(src++);
-	    a = s >> 24;
-	    if (a)
-	    {
-		if (a == 0xff)
-		    d = s;
-		else
-		{
-		    d = READ(dst);
-		    d = fbOver24 (s, cvt0565to0888(d));
-		}
-		WRITE(dst, cvt8888to0565(d));
-	    }
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pDst->pDrawable);
-    fbFinishAccess (pSrc->pDrawable);
-}
-
-void
-fbCompositeSrcAdd_8000x8000 (CARD8	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height)
-{
-    CARD8	*dstLine, *dst;
-    CARD8	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    CARD8	s, d;
-    CARD16	t;
-
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w--)
-	{
-	    s = READ(src++);
-	    if (s)
-	    {
-		if (s != 0xff)
-		{
-		    d = READ(dst);
-		    t = d + s;
-		    s = t | (0 - (t >> 8));
-		}
-		WRITE(dst, s);
-	    }
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pDst->pDrawable);
-    fbFinishAccess (pSrc->pDrawable);
-}
-
-void
-fbCompositeSrcAdd_8888x8888 (CARD8	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height)
-{
-    CARD32	*dstLine, *dst;
-    CARD32	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    CARD32	s, d;
-    CARD16	t;
-    CARD32	m,n,o,p;
-
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w--)
-	{
-	    s = READ(src++);
-	    if (s)
-	    {
-		if (s != 0xffffffff)
-		{
-		    d = READ(dst);
-		    if (d)
-		    {
-			m = FbAdd(s,d,0,t);
-			n = FbAdd(s,d,8,t);
-			o = FbAdd(s,d,16,t);
-			p = FbAdd(s,d,24,t);
-			s = m|n|o|p;
-		    }
-		}
-		WRITE(dst, s);
-	    }
-	    dst++;
-	}
-    }
-
-    fbFinishAccess (pDst->pDrawable);
-    fbFinishAccess (pSrc->pDrawable);
-}
-
-static void
-fbCompositeSrcAdd_8888x8x8 (CARD8      op,
-			    PicturePtr pSrc,
-			    PicturePtr pMask,
-			    PicturePtr pDst,
-			    INT16      xSrc,
-			    INT16      ySrc,
-			    INT16      xMask,
-			    INT16      yMask,
-			    INT16      xDst,
-			    INT16      yDst,
-			    CARD16     width,
-			    CARD16     height)
-{
-    CARD8	*dstLine, *dst;
-    CARD8	*maskLine, *mask;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-    CARD32	src;
-    CARD8	sa;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-    fbComposeGetSolid (pSrc, src, pDst->format);
-    sa = (src >> 24);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    CARD16	tmp;
-	    CARD16	a;
-	    CARD32	m, d;
-	    CARD32	r;
-
-	    a = READ(mask++);
-	    d = READ(dst);
-
-	    m = FbInU (sa, 0, a, tmp);
-	    r = FbAdd (m, d, 0, tmp);
-
-	    WRITE(dst++, r);
-	}
-    }
-    
-    fbFinishAccess(pDst->pDrawable);
-    fbFinishAccess(pMask->pDrawable);
-}
-
-void
-fbCompositeSrcAdd_1000x1000 (CARD8	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height)
-{
-    FbBits	*dstBits, *srcBits;
-    FbStride	dstStride, srcStride;
-    int		dstBpp, srcBpp;
-    int		dstXoff, dstYoff;
-    int		srcXoff, srcYoff;
-
-    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
-
-    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
-
-    fbBlt (srcBits + srcStride * (ySrc + srcYoff),
-	   srcStride,
-	   xSrc + srcXoff,
-
-	   dstBits + dstStride * (yDst + dstYoff),
-	   dstStride,
-	   xDst + dstXoff,
-
-	   width,
-	   height,
-
-	   GXor,
-	   FB_ALLONES,
-	   srcBpp,
-
-	   FALSE,
-	   FALSE);
-
-    fbFinishAccess(pDst->pDrawable);
-    fbFinishAccess(pSrc->pDrawable);
-}
-
-void
-fbCompositeSolidMask_nx1xn (CARD8      op,
-			    PicturePtr pSrc,
-			    PicturePtr pMask,
-			    PicturePtr pDst,
-			    INT16      xSrc,
-			    INT16      ySrc,
-			    INT16      xMask,
-			    INT16      yMask,
-			    INT16      xDst,
-			    INT16      yDst,
-			    CARD16     width,
-			    CARD16     height)
-{
-    FbBits	*dstBits;
-    FbStip	*maskBits;
-    FbStride	dstStride, maskStride;
-    int		dstBpp, maskBpp;
-    int		dstXoff, dstYoff;
-    int		maskXoff, maskYoff;
-    FbBits	src;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    fbGetStipDrawable (pMask->pDrawable, maskBits, maskStride, maskBpp, maskXoff, maskYoff);
-    fbGetDrawable (pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
-
-    switch (dstBpp) {
-    case 32:
-	break;
-    case 24:
-	break;
-    case 16:
-	src = cvt8888to0565(src);
-	break;
-    }
-
-    src = fbReplicatePixel (src, dstBpp);
-
-    fbBltOne (maskBits + maskStride * (yMask + maskYoff),
-	      maskStride,
-	      xMask + maskXoff,
-
-	      dstBits + dstStride * (yDst + dstYoff),
-	      dstStride,
-	      (xDst + dstXoff) * dstBpp,
-	      dstBpp,
-
-	      width * dstBpp,
-	      height,
-
-	      0x0,
-	      src,
-	      FB_ALLONES,
-	      0x0);
-
-    fbFinishAccess (pDst->pDrawable);
-    fbFinishAccess (pMask->pDrawable);
-}
-
-# define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
-
-/*
- * Apply a constant alpha value in an over computation
- */
-static void
-fbCompositeSrcSrc_nxn  (CARD8	   op,
-			PicturePtr pSrc,
-			PicturePtr pMask,
-			PicturePtr pDst,
-			INT16      xSrc,
-			INT16      ySrc,
-			INT16      xMask,
-			INT16      yMask,
-			INT16      xDst,
-			INT16      yDst,
-			CARD16     width,
-			CARD16     height);
-
-/*
- * Simple bitblt
- */
-
-static void
-fbCompositeSrcSrc_nxn  (CARD8	   op,
-			PicturePtr pSrc,
-			PicturePtr pMask,
-			PicturePtr pDst,
-			INT16      xSrc,
-			INT16      ySrc,
-			INT16      xMask,
-			INT16      yMask,
-			INT16      xDst,
-			INT16      yDst,
-			CARD16     width,
-			CARD16     height)
-{
-    FbBits	*dst;
-    FbBits	*src;
-    FbStride	dstStride, srcStride;
-    int		srcXoff, srcYoff;
-    int		dstXoff, dstYoff;
-    int		srcBpp;
-    int		dstBpp;
-    Bool	reverse = FALSE;
-    Bool	upsidedown = FALSE;
-    
-    fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
-    fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
-	
-    fbBlt (src + (ySrc + srcYoff) * srcStride,
-	   srcStride,
-	   (xSrc + srcXoff) * srcBpp,
- 
-	   dst + (yDst + dstYoff) * dstStride,
-	   dstStride,
-	   (xDst + dstXoff) * dstBpp,
-
-	   (width) * dstBpp,
-	   (height),
-
-	   GXcopy,
-	   FB_ALLONES,
-	   dstBpp,
-
-	   reverse,
-	   upsidedown);
-    
-    fbFinishAccess(pSrc->pDrawable);
-    fbFinishAccess(pDst->pDrawable);
-}
-
 static pixman_image_t *
 create_solid_fill_image (PicturePtr pict)
 {
@@ -1153,39 +261,7 @@ image_from_pict (PicturePtr pict)
     return image;
 }
 
-static void
-fbCompositeRectWrapper  (CARD8	   op,
-			 PicturePtr pSrc,
-			 PicturePtr pMask,
-			 PicturePtr pDst,
-			 INT16      xSrc,
-			 INT16      ySrc,
-			 INT16      xMask,
-			 INT16      yMask,
-			 INT16      xDst,
-			 INT16      yDst,
-			 CARD16     width,
-			 CARD16     height)
-{
-    pixman_image_t *src = image_from_pict (pSrc);
-    pixman_image_t *dest = image_from_pict (pDst);
-    pixman_image_t *mask = image_from_pict (pMask);
-
-    if (!src || !dest || (pMask && !mask))
-	goto out;
-
-    pixman_image_composite_rect (op, src, mask, dest,
-				 xSrc, ySrc, xMask, yMask, xDst, yDst,
-				 width, height);
-    
-out:
-    if (src)
-	pixman_image_unref (src);
-    if (mask)
-	pixman_image_unref (mask);
-    if (dest)
-	pixman_image_unref (dest);
-}    
+#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
 void
 fbWalkCompositeRegion (CARD8 op,
@@ -1305,591 +381,32 @@ fbComposite (CARD8      op,
 	     CARD16     width,
 	     CARD16     height)
 {
-    Bool	    srcRepeat = pSrc->pDrawable && pSrc->repeatType == RepeatNormal;
-    Bool	    maskRepeat = FALSE;
-    Bool	    srcTransform = pSrc->transform != 0;
-    Bool	    maskTransform = FALSE;
-    Bool	    srcAlphaMap = pSrc->alphaMap != 0;
-    Bool	    maskAlphaMap = FALSE;
-    Bool	    dstAlphaMap = pDst->alphaMap != 0;
-    CompositeFunc   func = NULL;
-
-#ifdef USE_MMX
-    static Bool mmx_setup = FALSE;
-    if (!mmx_setup) {
-        fbComposeSetupMMX();
-        mmx_setup = TRUE;
-    }
-#endif
-
-    if (srcRepeat && srcTransform &&
-	pSrc->pDrawable->width == 1 &&
-	pSrc->pDrawable->height == 1)
-	srcTransform = FALSE;
+    pixman_region16_t region;
+    pixman_image_t *src, *mask, *dest;
     
-    if (pMask && pMask->pDrawable)
-    {
-	maskRepeat = pMask->repeatType == RepeatNormal;
-
-	if (pMask->filter == PictFilterConvolution)
-	    maskTransform = TRUE;
-
-	maskAlphaMap = pMask->alphaMap != 0;
+    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc, ySrc,
+				   xMask, yMask, xDst, yDst, width, height))
+        return;
 
-	if (maskRepeat && maskTransform &&
-	    pMask->pDrawable->width == 1 &&
-	    pMask->pDrawable->height == 1)
-	    maskTransform = FALSE;
-    }
+    src = image_from_pict (pSrc);
+    mask = image_from_pict (pMask);
+    dest = image_from_pict (pDst);
 
-    if (pSrc->pDrawable && (!pMask || pMask->pDrawable)
-        && !srcTransform && !maskTransform
-        && !maskAlphaMap && !srcAlphaMap && !dstAlphaMap
-        && (pSrc->filter != PictFilterConvolution)
-        && (!pMask || pMask->filter != PictFilterConvolution))
-    switch (op) {
-    case PictOpOver:
-	if (pMask)
-	{
-	    if (fbCanGetSolid(pSrc) &&
-		!maskRepeat)
-	    {
-		if (PICT_FORMAT_COLOR(pSrc->format)) {
-		    switch (pMask->format) {
-		    case PICT_a8:
-			switch (pDst->format) {
-			case PICT_r5g6b5:
-			case PICT_b5g6r5:
-#ifdef USE_MMX
-			    if (fbHaveMMX())
-				func = fbCompositeSolidMask_nx8x0565mmx;
-			    else
-#endif
-				func = fbCompositeSolidMask_nx8x0565;
-			    break;
-			case PICT_r8g8b8:
-			case PICT_b8g8r8:
-			    func = fbCompositeSolidMask_nx8x0888;
-			    break;
-			case PICT_a8r8g8b8:
-			case PICT_x8r8g8b8:
-			case PICT_a8b8g8r8:
-			case PICT_x8b8g8r8:
-#ifdef USE_MMX
-			    if (fbHaveMMX())
-				func = fbCompositeSolidMask_nx8x8888mmx;
-			    else
-#endif
-				func = fbCompositeSolidMask_nx8x8888;
-			    break;
-			default:
-			    break;
-			}
-			break;
-		    case PICT_a8r8g8b8:
-			if (pMask->componentAlpha) {
-			    switch (pDst->format) {
-			    case PICT_a8r8g8b8:
-			    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x8888Cmmx;
-				else
-#endif
-				    func = fbCompositeSolidMask_nx8888x8888C;
-				break;
-			    case PICT_r5g6b5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x0565Cmmx;
-				else
-#endif
-				    func = fbCompositeSolidMask_nx8888x0565C;
-				break;
-			    default:
-				break;
-			    }
-			}
-#if 0
-			else
-			{
-			    switch (pDst->format) {
-                            case PICT_r5g6b5:
-                                func = fbCompositeSolidMask_nx8888x0565;
-                                break;
-			    default:
-				break;
-                            }
-			}
-#endif
-			break;
-		    case PICT_a8b8g8r8:
-			if (pMask->componentAlpha) {
-			    switch (pDst->format) {
-			    case PICT_a8b8g8r8:
-			    case PICT_x8b8g8r8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x8888Cmmx;
-				else
-#endif
-				    func = fbCompositeSolidMask_nx8888x8888C;
-				break;
-			    case PICT_b5g6r5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x0565Cmmx;
-				else
-#endif
-				    func = fbCompositeSolidMask_nx8888x0565C;
-				break;
-			    default:
-				break;
-			    }
-			}
-#if 0
-			else
-			{
-			    switch (pDst->format) {
-                            case PICT_b5g6r5:
-                                func = fbCompositeSolidMask_nx8888x0565;
-                                break;
-			    default:
-				break;
-                            }
-			}
-#endif
-			break;
-		    case PICT_a1:
-			switch (pDst->format) {
-			case PICT_r5g6b5:
-			case PICT_b5g6r5:
-			case PICT_r8g8b8:
-			case PICT_b8g8r8:
-			case PICT_a8r8g8b8:
-			case PICT_x8r8g8b8:
-			case PICT_a8b8g8r8:
-			case PICT_x8b8g8r8:
-			{
-			    FbBits src;
-
-			    fbComposeGetSolid(pSrc, src, pDst->format);
-			    if ((src & 0xff000000) == 0xff000000)
-				func = fbCompositeSolidMask_nx1xn;
-			    break;
-			}
-			default:
-			    break;
-			}
-			break;
-		    default:
-			break;
-		    }
-		}
-		if (func)
-		    srcRepeat = FALSE;
-	    }
-	    else if (!srcRepeat) /* has mask and non-repeating source */
-	    {
-		if (pSrc->pDrawable == pMask->pDrawable &&
-		    xSrc + pSrc->pDrawable->x == xMask + pMask->pDrawable->x &&
-		    ySrc + pSrc->pDrawable->y == yMask + pMask->pDrawable->y &&
-		    !pMask->componentAlpha && !maskRepeat)
-		{
-		    /* source == mask: non-premultiplied data */
-		    switch (pSrc->format) {
-		    case PICT_x8b8g8r8:
-			switch (pMask->format) {
-			case PICT_a8r8g8b8:
-			case PICT_a8b8g8r8:
-			    switch (pDst->format) {
-			    case PICT_a8r8g8b8:
-			    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx8888mmx;
-#endif
-				break;
-			    case PICT_r5g6b5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx0565mmx;
-#endif
-				break;
-			    default:
-				break;
-			    }
-			    break;
-			default:
-			    break;
-			}
-			break;
-		    case PICT_x8r8g8b8:
-			switch (pMask->format) {
-			case PICT_a8r8g8b8:
-			case PICT_a8b8g8r8:
-			    switch (pDst->format) {
-			    case PICT_a8b8g8r8:
-			    case PICT_x8b8g8r8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx8888mmx;
-#endif
-				break;
-			    case PICT_r5g6b5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx0565mmx;
-#endif
-				break;
-			    default:
-				break;
-			    }
-			    break;
-			default:
-			    break;
-			}
-			break;
-		    default:
-			break;
-		    }
-		    break;
-		}
-		else if (maskRepeat &&
-			 pMask->pDrawable->width == 1 &&
-			 pMask->pDrawable->height == 1)
-		{
-		    switch (pSrc->format) {
-#ifdef USE_MMX
-		    case PICT_x8r8g8b8:
-			if ((pDst->format == PICT_a8r8g8b8 ||
-			     pDst->format == PICT_x8r8g8b8) &&
-			    pMask->format == PICT_a8 && fbHaveMMX())
-			    func = fbCompositeSrc_x888x8x8888mmx;
-			break;
-		    case PICT_x8b8g8r8:
-			if ((pDst->format == PICT_a8b8g8r8 ||
-			     pDst->format == PICT_x8b8g8r8) &&
-			    pMask->format == PICT_a8 && fbHaveMMX())
-			    func = fbCompositeSrc_x888x8x8888mmx;
-			break;
-		    case PICT_a8r8g8b8:
-			if ((pDst->format == PICT_a8r8g8b8 ||
-			     pDst->format == PICT_x8r8g8b8) &&
-			    pMask->format == PICT_a8 && fbHaveMMX())
-			    func = fbCompositeSrc_8888x8x8888mmx;
-			break;
-		    case PICT_a8b8g8r8:
-			if ((pDst->format == PICT_a8b8g8r8 ||
-			     pDst->format == PICT_x8b8g8r8) &&
-			    pMask->format == PICT_a8 && fbHaveMMX())
-			    func = fbCompositeSrc_8888x8x8888mmx;
-			break;
-#endif
-		    default:
-			break;
-		    }
-		    
-		    if (func)
-			maskRepeat = FALSE;
-		}
-	    }
-	}
-	else /* no mask */
-	{
-	    if (fbCanGetSolid(pSrc))
-	    {
-		/* no mask and repeating source */
-		switch (pSrc->format) {
-		case PICT_a8r8g8b8:
-		    switch (pDst->format) {
-		    case PICT_a8r8g8b8:
-		    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			{
-			    srcRepeat = FALSE;
-			    func = fbCompositeSolid_nx8888mmx;
-			}
-#endif
-			break;
-		    case PICT_r5g6b5:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			{
-			    srcRepeat = FALSE;
-			    func = fbCompositeSolid_nx0565mmx;
-			}
-#endif
-			break;
-		    default:
-			break;
-		    }
-		    break;
-		default:
-		    break;
-		}
-	    }
-	    else if (! srcRepeat)
-	    {
-		/*
-		 * Formats without alpha bits are just Copy with Over
-		 */
-		if (pSrc->format == pDst->format && !PICT_FORMAT_A(pSrc->format))
-		{
-#ifdef USE_MMX
-		    if (fbHaveMMX() &&
-			(pSrc->format == PICT_x8r8g8b8 || pSrc->format == PICT_x8b8g8r8))
-			func = fbCompositeCopyAreammx;
-		    else
-#endif
-			func = fbCompositeSrcSrc_nxn;
-		}
-		else switch (pSrc->format) {
-		case PICT_a8r8g8b8:
-		    switch (pDst->format) {
-		    case PICT_a8r8g8b8:
-		    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeSrc_8888x8888mmx;
-			else
-#endif
-			    func = fbCompositeSrc_8888x8888;
-			break;
-		    case PICT_r8g8b8:
-			func = fbCompositeSrc_8888x0888;
-			break;
-		    case PICT_r5g6b5:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeSrc_8888x0565mmx;
-			else
-#endif
-			    func = fbCompositeSrc_8888x0565;
-			break;
-		    default:
-			break;
-		    }
-		    break;
-		case PICT_x8r8g8b8:
-		    switch (pDst->format) {
-		    case PICT_a8r8g8b8:
-		    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeCopyAreammx;
-#endif
-			break;
-		    default:
-			break;
-		    }
-		case PICT_x8b8g8r8:
-		    switch (pDst->format) {
-		    case PICT_a8b8g8r8:
-		    case PICT_x8b8g8r8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeCopyAreammx;
-#endif
-			break;
-		    default:
-			break;
-		    }
-		    break;
-		case PICT_a8b8g8r8:
-		    switch (pDst->format) {
-		    case PICT_a8b8g8r8:
-		    case PICT_x8b8g8r8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeSrc_8888x8888mmx;
-			else
-#endif
-			    func = fbCompositeSrc_8888x8888;
-			break;
-		    case PICT_b8g8r8:
-			func = fbCompositeSrc_8888x0888;
-			break;
-		    case PICT_b5g6r5:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeSrc_8888x0565mmx;
-			else
-#endif
-			    func = fbCompositeSrc_8888x0565;
-			break;
-		    default:
-			break;
-		    }
-		    break;
-		default:
-		    break;
-		}
-	    }
-	}
-	break;
-    case PictOpAdd:
-	if (pMask == 0)
-	{
-	    switch (pSrc->format) {
-	    case PICT_a8r8g8b8:
-		switch (pDst->format) {
-		case PICT_a8r8g8b8:
-#ifdef USE_MMX
-		    if (fbHaveMMX())
-			func = fbCompositeSrcAdd_8888x8888mmx;
-		    else
-#endif
-			func = fbCompositeSrcAdd_8888x8888;
-		    break;
-		default:
-		    break;
-		}
-		break;
-	    case PICT_a8b8g8r8:
-		switch (pDst->format) {
-		case PICT_a8b8g8r8:
-#ifdef USE_MMX
-		    if (fbHaveMMX())
-			func = fbCompositeSrcAdd_8888x8888mmx;
-		    else
-#endif
-			func = fbCompositeSrcAdd_8888x8888;
-		    break;
-		default:
-		    break;
-		}
-		break;
-	    case PICT_a8:
-		switch (pDst->format) {
-		case PICT_a8:
-#ifdef USE_MMX
-		    if (fbHaveMMX())
-			func = fbCompositeSrcAdd_8000x8000mmx;
-		    else
-#endif
-			func = fbCompositeSrcAdd_8000x8000;
-		    break;
-		default:
-		    break;
-		}
-		break;
-	    case PICT_a1:
-		switch (pDst->format) {
-		case PICT_a1:
-		    func = fbCompositeSrcAdd_1000x1000;
-		    break;
-		default:
-		    break;
-		}
-		break;
-	    default:
-		break;
-	    }
-	}
-	else
-	{
-	    if ((pSrc->format == PICT_a8r8g8b8	||
-		 pSrc->format == PICT_a8b8g8r8) &&
-		fbCanGetSolid (pSrc)		&&
-		pMask->format == PICT_a8	&&
-		pDst->format == PICT_a8)
-	    {
-		srcRepeat = FALSE;
-#ifdef USE_MMX
-		if (fbHaveMMX())
-		    func = fbCompositeSrcAdd_8888x8x8mmx;
-		else
-#endif
-		    func = fbCompositeSrcAdd_8888x8x8;
-	    }
-	}
-	break;
-    case PictOpSrc:
-	if (pMask)
-	{
-#ifdef USE_MMX
-	    if (fbCanGetSolid (pSrc))
-	    {
-		if (pMask->format == PICT_a8)
-		{
-		    switch (pDst->format)
-		    {
-		    case PICT_a8r8g8b8:
-		    case PICT_x8r8g8b8:
-		    case PICT_a8b8g8r8:
-		    case PICT_x8b8g8r8:
-			if (fbHaveMMX())
-			{
-			    srcRepeat = FALSE;
-			    func = fbCompositeSolidMaskSrc_nx8x8888mmx;
-			}
-			break;
-		    default:
-			break;
-		    }
-		}
-	    }
-#endif
-	}
-	else
-	{
-	    if (pSrc->format == pDst->format)
-	    {
-#ifdef USE_MMX
-		if (pSrc->pDrawable != pDst->pDrawable && fbHaveMMX() &&
-		    (PICT_FORMAT_BPP (pSrc->format) == 16 ||
-		     PICT_FORMAT_BPP (pSrc->format) == 32))
-		    func = fbCompositeCopyAreammx;
-		else
-#endif
-		    func = fbCompositeSrcSrc_nxn;
-	    }
-	}
-	break;
-    case PictOpIn:
-#ifdef USE_MMX
-	if (pSrc->format == PICT_a8 &&
-	    pDst->format == PICT_a8 &&
-	    !pMask)
-	{
-	    if (fbHaveMMX())
-		func = fbCompositeIn_8x8mmx;
-	}
-	else if (srcRepeat && pMask && !pMask->componentAlpha &&
-		 (pSrc->format == PICT_a8r8g8b8 ||
-		  pSrc->format == PICT_a8b8g8r8)   &&
-		 (pMask->format == PICT_a8)        &&
-		 pDst->format == PICT_a8)
-	{
-	    if (fbHaveMMX())
-	    {
-		srcRepeat = FALSE;
-		func = fbCompositeIn_nx8x8mmx;
-	    }
-	}
-#else
-	func = NULL;
-#endif
-       break;
-    default:
-	break;
-    }
-
-    if (!func) {
-	func = fbCompositeRectWrapper;
+    if (src && dest && !(pMask && !mask))
+    {
+	pixman_image_composite (op, src, mask, dest,
+				xSrc, ySrc, xMask, yMask, xDst, yDst,
+				width, height, &region);
     }
-
-    /* if we are transforming, we handle repeats in fbFetchTransformed */
-    if (srcTransform)
-	srcRepeat = FALSE;
-    if (maskTransform)
-	maskRepeat = FALSE;
-
-    fbWalkCompositeRegion (op, pSrc, pMask, pDst, xSrc, ySrc,
-			   xMask, yMask, xDst, yDst, width, height,
-			   srcRepeat, maskRepeat, func);
+    
+    pixman_region_fini (&region);
+    
+    if (src)
+	pixman_image_unref (src);
+    if (mask)
+	pixman_image_unref (mask);
+    if (dest)
+	pixman_image_unref (dest);
 }
 
 void
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 11cab3d..3bd0a78 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -425,197 +425,6 @@ fbRasterizeEdges (FbBits	*buf,
 		  xFixed	b);
 
 /* fbpict.c */
-CARD32
-fbOver (CARD32 x, CARD32 y);
-
-CARD32
-fbOver24 (CARD32 x, CARD32 y);
-
-CARD32
-fbIn (CARD32 x, CARD8 y);
-
-void
-fbCompositeSolidMask_nx8x8888 (CARD8      op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16      xSrc,
-			       INT16      ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height);
-
-void
-fbCompositeSolidMask_nx8x0888 (CARD8      op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16      xSrc,
-			       INT16      ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height);
-
-void
-fbCompositeSolidMask_nx8888x8888C (CARD8      op,
-				   PicturePtr pSrc,
-				   PicturePtr pMask,
-				   PicturePtr pDst,
-				   INT16      xSrc,
-				   INT16      ySrc,
-				   INT16      xMask,
-				   INT16      yMask,
-				   INT16      xDst,
-				   INT16      yDst,
-				   CARD16     width,
-				   CARD16     height);
-
-void
-fbCompositeSolidMask_nx8x0565 (CARD8      op,
-			       PicturePtr pSrc,
-			       PicturePtr pMask,
-			       PicturePtr pDst,
-			       INT16      xSrc,
-			       INT16      ySrc,
-			       INT16      xMask,
-			       INT16      yMask,
-			       INT16      xDst,
-			       INT16      yDst,
-			       CARD16     width,
-			       CARD16     height);
-
-void
-fbCompositeSolidMask_nx8888x0565C (CARD8      op,
-				   PicturePtr pSrc,
-				   PicturePtr pMask,
-				   PicturePtr pDst,
-				   INT16      xSrc,
-				   INT16      ySrc,
-				   INT16      xMask,
-				   INT16      yMask,
-				   INT16      xDst,
-				   INT16      yDst,
-				   CARD16     width,
-				   CARD16     height);
-
-void
-fbCompositeSrc_8888x8888 (CARD8      op,
-			  PicturePtr pSrc,
-			  PicturePtr pMask,
-			  PicturePtr pDst,
-			  INT16      xSrc,
-			  INT16      ySrc,
-			  INT16      xMask,
-			  INT16      yMask,
-			  INT16      xDst,
-			  INT16      yDst,
-			  CARD16     width,
-			  CARD16     height);
-
-void
-fbCompositeSrc_8888x0888 (CARD8      op,
-			 PicturePtr pSrc,
-			 PicturePtr pMask,
-			 PicturePtr pDst,
-			 INT16      xSrc,
-			 INT16      ySrc,
-			 INT16      xMask,
-			 INT16      yMask,
-			 INT16      xDst,
-			 INT16      yDst,
-			 CARD16     width,
-			 CARD16     height);
-
-void
-fbCompositeSrc_8888x0565 (CARD8      op,
-			  PicturePtr pSrc,
-			  PicturePtr pMask,
-			  PicturePtr pDst,
-			  INT16      xSrc,
-			  INT16      ySrc,
-			  INT16      xMask,
-			  INT16      yMask,
-			  INT16      xDst,
-			  INT16      yDst,
-			  CARD16     width,
-			  CARD16     height);
-
-void
-fbCompositeSrc_0565x0565 (CARD8      op,
-			  PicturePtr pSrc,
-			  PicturePtr pMask,
-			  PicturePtr pDst,
-			  INT16      xSrc,
-			  INT16      ySrc,
-			  INT16      xMask,
-			  INT16      yMask,
-			  INT16      xDst,
-			  INT16      yDst,
-			  CARD16     width,
-			  CARD16     height);
-
-void
-fbCompositeSrcAdd_8000x8000 (CARD8	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height);
-
-void
-fbCompositeSrcAdd_8888x8888 (CARD8	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height);
-
-void
-fbCompositeSrcAdd_1000x1000 (CARD8	op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height);
-
-void
-fbCompositeSolidMask_nx1xn (CARD8      op,
-			    PicturePtr pSrc,
-			    PicturePtr pMask,
-			    PicturePtr pDst,
-			    INT16      xSrc,
-			    INT16      ySrc,
-			    INT16      xMask,
-			    INT16      yMask,
-			    INT16      xDst,
-			    INT16      yDst,
-			    CARD16     width,
-			    CARD16     height);
-
 void
 fbComposite (CARD8      op,
 	     PicturePtr pSrc,
diff-tree 7e2c935920cafadbd87c351f1a3239932864fb90 (from 756acea23a0cc56c470bcd77c6f5638d923ab3d1)
Author: Fredrik Höglund <fredrik at kde.org>
Date:   Fri May 18 20:06:14 2007 +0200

    Add a new IDLETIME system sync counter.
    
    This counter exposes the time in milliseconds since the last
    input event. Clients such as screen savers and power managers
    can set an alarm on this counter to find out when the idle time
    reaches a certain value, without having to poll the server.

diff --git a/Xext/sync.c b/Xext/sync.c
index c5441a1..6fc2dcc 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -243,6 +243,11 @@ SyncInitServerTime(
     void
 );
 
+static void
+SyncInitIdleTime(
+    void
+);
+
 static void 
 SyncResetProc(
     ExtensionEntry * /* extEntry */
@@ -2400,6 +2405,7 @@ SyncExtensionInit(INITARGS)
      * because there is always a servertime counter.
      */
     SyncInitServerTime();
+    SyncInitIdleTime();
 
 #ifdef DEBUG
     fprintf(stderr, "Sync Extension %d.%d\n",
@@ -2520,3 +2526,116 @@ SyncInitServerTime(void)
 			    ServertimeQueryValue, ServertimeBracketValues);
     pnext_time = NULL;
 }
+
+
+
+/*
+ * IDLETIME implementation
+ */
+
+static pointer IdleTimeCounter;
+static XSyncValue *pIdleTimeValueLess;
+static XSyncValue *pIdleTimeValueGreater;
+
+static void
+IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
+{
+    CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
+    XSyncIntsToValue (pValue_return, idle, 0);
+}
+
+static void
+IdleTimeBlockHandler (pointer env,
+                      struct timeval **wt,
+                      pointer LastSelectMask)
+{
+    XSyncValue idle;
+
+    if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+	return;
+
+    IdleTimeQueryValue (NULL, &idle);
+
+    if (pIdleTimeValueLess &&
+        XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))
+    {
+	AdjustWaitForDelay (wt, 0);
+    }
+    else if (pIdleTimeValueGreater)
+    {
+	unsigned long timeout = 0;
+
+	if (XSyncValueLessThan (idle, *pIdleTimeValueGreater))
+	{
+	    XSyncValue value;
+	    Bool overflow;
+
+	    XSyncValueSubtract (&value, *pIdleTimeValueGreater,
+	                        idle, &overflow);
+	    timeout = XSyncValueLow32 (value);
+	}
+
+	AdjustWaitForDelay (wt, timeout);
+    }
+}
+
+static void
+IdleTimeWakeupHandler (pointer env,
+                       int rc,
+                       pointer LastSelectMask)
+{
+    XSyncValue idle;
+
+    if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+	return;
+
+    IdleTimeQueryValue (NULL, &idle);
+
+    if ((pIdleTimeValueGreater &&
+         XSyncValueGreaterThan (idle, *pIdleTimeValueGreater)) ||
+        (pIdleTimeValueLess && XSyncValueLessThan (idle, *pIdleTimeValueLess)))
+    {
+	SyncChangeCounter (IdleTimeCounter, idle);
+    }
+}
+
+static void
+IdleTimeBracketValues (pointer pCounter,
+                       CARD64 *pbracket_less,
+                       CARD64 *pbracket_greater)
+{
+    Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater);
+
+    if (registered && !pbracket_less && !pbracket_greater)
+    {
+	RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler,
+	                             IdleTimeWakeupHandler,
+	                             NULL);
+    }
+    else if (!registered && (pbracket_less || pbracket_greater))
+    {
+	RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler,
+	                               IdleTimeWakeupHandler,
+	                               NULL);
+    }
+
+    pIdleTimeValueGreater = pbracket_greater;
+    pIdleTimeValueLess    = pbracket_less;
+}
+
+static void
+SyncInitIdleTime (void)
+{
+    CARD64 resolution;
+    XSyncValue idle;
+
+    IdleTimeQueryValue (NULL, &idle);
+    XSyncIntToValue (&resolution, 4);
+
+    IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution,
+                                               XSyncCounterUnrestricted,
+                                               IdleTimeQueryValue,
+                                               IdleTimeBracketValues);
+
+    pIdleTimeValueLess = pIdleTimeValueGreater = NULL;
+}
diff-tree 756acea23a0cc56c470bcd77c6f5638d923ab3d1 (from 7916419a0092b8bf9713c0840f9e969950d7aa85)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri May 18 13:39:12 2007 -0400

    Use pixman_image_set_indexed() to make 8 bit work

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 324d9b2..84d19ac 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1036,6 +1036,10 @@ create_bits_picture (PicturePtr pict)
      */
     pixman_image_set_clip_region (image, pict->pCompositeClip);
     
+    /* Indexed table */
+    if (pict->pFormat->index.devPrivate)
+	pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
+    
     fbFinishAccess (pict->pDrawable);
 
     return image;
diff-tree 7916419a0092b8bf9713c0840f9e969950d7aa85 (from 998164bac648756e5b5254aa36e075ae360d3972)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri May 18 11:58:24 2007 -0400

    Comment out setup of general MMX code

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 8a132f6..53459a0 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -878,10 +878,15 @@ mmxCombineAddC (CARD32 *dest, CARD32 *sr
     _mm_empty();
 }
 
+#if 0
+/* FIXME: this should be reinstated after adding fbmmx to pixman */
 extern FbComposeFunctions composeFunctions;
+#endif
 
 void fbComposeSetupMMX(void)
 {
+#if 0
+/* FIXME: this should be reinstated after adding fbmmx to pixman */
     /* check if we have MMX support and initialize accordingly */
     if (fbHaveMMX()) {
         composeFunctions.combineU[PictOpOver] = mmxCombineOverU;
@@ -910,6 +915,7 @@ void fbComposeSetupMMX(void)
 
         composeFunctions.combineMaskU = mmxCombineMaskU;
     } 
+#endif
 }
 
 
diff-tree 998164bac648756e5b5254aa36e075ae360d3972 (from a2e3614eb8f0fa198615df492b03ff36bc9c1121)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri May 18 11:36:20 2007 -0400

    Move fbCompositeGeneral() to fbpict.c and remove fbcompose.c

diff --git a/fb/Makefile.am b/fb/Makefile.am
index ab135c9..01e81da 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -42,7 +42,6 @@ libfb_la_SOURCES = 	\
 	fbblt.c		\
 	fbbltone.c	\
 	fbbstore.c	\
-	fbcompose.c	\
 	fbcopy.c	\
 	fbfill.c	\
 	fbfillrect.c	\
diff --git a/fb/fbcompose.c b/fb/fbcompose.c
deleted file mode 100644
index 0e64de0..0000000
--- a/fb/fbcompose.c
+++ /dev/null
@@ -1,4318 +0,0 @@
-/*
- *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
- *             2005 Lars Knoll & Zack Rusin, Trolltech
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-#ifdef RENDER
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-
-#include "picturestr.h"
-#include "mipict.h"
-#include "fbpict.h"
-
-static unsigned int
-SourcePictureClassify (PicturePtr pict,
-		       int	  x,
-		       int	  y,
-		       int	  width,
-		       int	  height)
-{
-    if (pict->pSourcePict->type == SourcePictTypeSolidFill)
-    {
-	pict->pSourcePict->solidFill.class = SourcePictClassHorizontal;
-    }
-    else if (pict->pSourcePict->type == SourcePictTypeLinear)
-    {
-	PictVector   v;
-	xFixed_32_32 l;
-	xFixed_48_16 dx, dy, a, b, off;
-	xFixed_48_16 factors[4];
-	int	     i;
-
-	dx = pict->pSourcePict->linear.p2.x - pict->pSourcePict->linear.p1.x;
-	dy = pict->pSourcePict->linear.p2.y - pict->pSourcePict->linear.p1.y;
-	l = dx * dx + dy * dy;
-	if (l)
-	{
-	    a = (dx << 32) / l;
-	    b = (dy << 32) / l;
-	}
-	else
-	{
-	    a = b = 0;
-	}
-
-	off = (-a * pict->pSourcePict->linear.p1.x
-	       -b * pict->pSourcePict->linear.p1.y) >> 16;
-
-	for (i = 0; i < 3; i++)
-	{
-	    v.vector[0] = IntToxFixed ((i % 2) * (width  - 1) + x);
-	    v.vector[1] = IntToxFixed ((i / 2) * (height - 1) + y);
-	    v.vector[2] = xFixed1;
-
-	    if (pict->transform)
-	    {
-		if (!PictureTransformPoint3d (pict->transform, &v))
-		    return SourcePictClassUnknown;
-	    }
-
-	    factors[i] = ((a * v.vector[0] + b * v.vector[1]) >> 16) + off;
-	}
-
-	if (factors[2] == factors[0])
-	    pict->pSourcePict->linear.class = SourcePictClassHorizontal;
-	else if (factors[1] == factors[0])
-	    pict->pSourcePict->linear.class = SourcePictClassVertical;
-    }
-
-    return pict->pSourcePict->solidFill.class;
-}
-
-#define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
-
-#define SCANLINE_BUFFER_LENGTH 2048
-
-typedef FASTCALL void (*fetchProc)(const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed);
-
-/*
- * All of the fetch functions
- */
-
-static FASTCALL void
-fbFetch_a8r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    MEMCPY_WRAPPED(buffer, (const CARD32 *)bits + x, width*sizeof(CARD32));
-}
-
-static FASTCALL void
-fbFetch_x8r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD32 *pixel = (const CARD32 *)bits + x;
-    const CARD32 *end = pixel + width;
-    while (pixel < end) {
-        WRITE(buffer++, READ(pixel++) | 0xff000000);
-    }
-}
-
-static FASTCALL void
-fbFetch_a8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD32 *pixel = (CARD32 *)bits + x;
-    const CARD32 *end = pixel + width;
-    while (pixel < end) {
-        WRITE(buffer++, ((READ(pixel) & 0xff00ff00) |
-                         ((READ(pixel) >> 16) & 0xff) |
-                         ((READ(pixel) & 0xff) << 16)));
-        ++pixel;
-    }
-}
-
-static FASTCALL void
-fbFetch_x8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD32 *pixel = (CARD32 *)bits + x;
-    const CARD32 *end = pixel + width;
-    while (pixel < end) {
-        WRITE(buffer++, 0xff000000 |
-	      ((READ(pixel) & 0x0000ff00) |
-	       ((READ(pixel) >> 16) & 0xff) |
-	       ((READ(pixel) & 0xff) << 16)));
-        ++pixel;
-    }
-}
-
-static FASTCALL void
-fbFetch_r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + 3*x;
-    const CARD8 *end = pixel + 3*width;
-    while (pixel < end) {
-        CARD32 b = Fetch24(pixel) | 0xff000000;
-        pixel += 3;
-        WRITE(buffer++, b);
-    }
-}
-
-static FASTCALL void
-fbFetch_b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + 3*x;
-    const CARD8 *end = pixel + 3*width;
-    while (pixel < end) {
-        CARD32 b = 0xff000000;
-#if IMAGE_BYTE_ORDER == MSBFirst
-        b |= (READ(pixel++));
-        b |= (READ(pixel++) << 8);
-        b |= (READ(pixel++) << 16);
-#else
-        b |= (READ(pixel++) << 16);
-        b |= (READ(pixel++) << 8);
-        b |= (READ(pixel++));
-#endif
-	WRITE(buffer++, b);
-    }
-}
-
-static FASTCALL void
-fbFetch_r5g6b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32 r = (((p) << 3) & 0xf8) | 
-	    (((p) << 5) & 0xfc00) |
-	    (((p) << 8) & 0xf80000);
-        r |= (r >> 5) & 0x70007;
-        r |= (r >> 6) & 0x300;
-        WRITE(buffer++, 0xff000000 | r);
-    }
-}
-
-static FASTCALL void
-fbFetch_b5g6r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b;
-
-        b = ((p & 0xf800) | ((p & 0xe000) >> 5)) >> 8;
-        g = ((p & 0x07e0) | ((p & 0x0600) >> 6)) << 5;
-        r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
-        WRITE(buffer++, (0xff000000 | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_a1r5g5b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b, a;
-
-        a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24;
-        r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
-        g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
-        b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
-        WRITE(buffer++, (a | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_x1r5g5b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b;
-
-        r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
-        g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
-        b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
-        WRITE(buffer++, (0xff000000 | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_a1b5g5r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b, a;
-
-        a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24;
-        b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
-        g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
-        r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
-        WRITE(buffer++, (a | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_x1b5g5r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b;
-
-        b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
-        g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
-        r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
-        WRITE(buffer++, (0xff000000 | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_a4r4g4b4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b, a;
-
-        a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
-        r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
-        g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
-        b = ((p & 0x000f) | ((p & 0x000f) << 4));
-        WRITE(buffer++, (a | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_x4r4g4b4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b;
-
-        r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
-        g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
-        b = ((p & 0x000f) | ((p & 0x000f) << 4));
-        WRITE(buffer++, (0xff000000 | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_a4b4g4r4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b, a;
-
-        a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
-        b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
-        g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
-        r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
-        WRITE(buffer++, (a | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_x4b4g4r4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD16 *pixel = (const CARD16 *)bits + x;
-    const CARD16 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b;
-
-        b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
-        g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
-        r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
-        WRITE(buffer++, (0xff000000 | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_a8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + x;
-    const CARD8 *end = pixel + width;
-    while (pixel < end) {
-        WRITE(buffer++, READ(pixel++) << 24);
-    }
-}
-
-static FASTCALL void
-fbFetch_r3g3b2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + x;
-    const CARD8 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b;
-
-        r = ((p & 0xe0) | ((p & 0xe0) >> 3) | ((p & 0xc0) >> 6)) << 16;
-        g = ((p & 0x1c) | ((p & 0x18) >> 3) | ((p & 0x1c) << 3)) << 8;
-        b = (((p & 0x03)     ) |
-             ((p & 0x03) << 2) |
-             ((p & 0x03) << 4) |
-             ((p & 0x03) << 6));
-        WRITE(buffer++, (0xff000000 | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_b2g3r3 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + x;
-    const CARD8 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32  r,g,b;
-
-        b = (((p & 0xc0)     ) |
-             ((p & 0xc0) >> 2) |
-             ((p & 0xc0) >> 4) |
-             ((p & 0xc0) >> 6));
-        g = ((p & 0x38) | ((p & 0x38) >> 3) | ((p & 0x30) << 2)) << 8;
-        r = (((p & 0x07)     ) |
-             ((p & 0x07) << 3) |
-             ((p & 0x06) << 6)) << 16;
-        WRITE(buffer++, (0xff000000 | r | g | b));
-    }
-}
-
-static FASTCALL void
-fbFetch_a2r2g2b2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + x;
-    const CARD8 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32   a,r,g,b;
-
-        a = ((p & 0xc0) * 0x55) << 18;
-        r = ((p & 0x30) * 0x55) << 12;
-        g = ((p & 0x0c) * 0x55) << 6;
-        b = ((p & 0x03) * 0x55);
-        WRITE(buffer++, a|r|g|b);
-    }
-}
-
-static FASTCALL void
-fbFetch_a2b2g2r2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + x;
-    const CARD8 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        CARD32   a,r,g,b;
-
-        a = ((p & 0xc0) * 0x55) << 18;
-        b = ((p & 0x30) * 0x55) >> 6;
-        g = ((p & 0x0c) * 0x55) << 6;
-        r = ((p & 0x03) * 0x55) << 16;
-        WRITE(buffer++, a|r|g|b);
-    }
-}
-
-static FASTCALL void
-fbFetch_c8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + x;
-    const CARD8 *end = pixel + width;
-    while (pixel < end) {
-        CARD32  p = READ(pixel++);
-        WRITE(buffer++, indexed->rgba[p]);
-    }
-}
-
-static FASTCALL void
-fbFetch_x4a4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    const CARD8 *pixel = (const CARD8 *)bits + x;
-    const CARD8 *end = pixel + width;
-    while (pixel < end) {
-	CARD8 p = READ(pixel++) & 0xf;
-        WRITE(buffer++, (p | (p << 4)) << 24);
-    }
-}
-
-#define Fetch8(l,o)    (((CARD8 *) (l))[(o) >> 2])
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define Fetch4(l,o)    ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
-#else
-#define Fetch4(l,o)    ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
-#endif
-
-static FASTCALL void
-fbFetch_a4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = Fetch4(bits, i + x);
-
-        p |= p << 4;
-        WRITE(buffer++, p << 24);
-    }
-}
-
-static FASTCALL void
-fbFetch_r1g2b1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = Fetch4(bits, i + x);
-        CARD32  r,g,b;
-
-        r = ((p & 0x8) * 0xff) << 13;
-        g = ((p & 0x6) * 0x55) << 7;
-        b = ((p & 0x1) * 0xff);
-        WRITE(buffer++, 0xff000000|r|g|b);
-    }
-}
-
-static FASTCALL void
-fbFetch_b1g2r1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = Fetch4(bits, i + x);
-        CARD32  r,g,b;
-
-        b = ((p & 0x8) * 0xff) >> 3;
-        g = ((p & 0x6) * 0x55) << 7;
-        r = ((p & 0x1) * 0xff) << 16;
-        WRITE(buffer++, 0xff000000|r|g|b);
-    }
-}
-
-static FASTCALL void
-fbFetch_a1r1g1b1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = Fetch4(bits, i + x);
-        CARD32  a,r,g,b;
-
-        a = ((p & 0x8) * 0xff) << 21;
-        r = ((p & 0x4) * 0xff) << 14;
-        g = ((p & 0x2) * 0xff) << 7;
-        b = ((p & 0x1) * 0xff);
-        WRITE(buffer++, a|r|g|b);
-    }
-}
-
-static FASTCALL void
-fbFetch_a1b1g1r1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = Fetch4(bits, i + x);
-        CARD32  a,r,g,b;
-
-        a = ((p & 0x8) * 0xff) << 21;
-        r = ((p & 0x4) * 0xff) >> 3;
-        g = ((p & 0x2) * 0xff) << 7;
-        b = ((p & 0x1) * 0xff) << 16;
-        WRITE(buffer++, a|r|g|b);
-    }
-}
-
-static FASTCALL void
-fbFetch_c4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = Fetch4(bits, i + x);
-
-        WRITE(buffer++, indexed->rgba[p]);
-    }
-}
-
-
-static FASTCALL void
-fbFetch_a1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = ((CARD32 *)bits)[(i + x) >> 5];
-        CARD32  a;
-#if BITMAP_BIT_ORDER == MSBFirst
-        a = p >> (0x1f - ((i+x) & 0x1f));
-#else
-        a = p >> ((i+x) & 0x1f);
-#endif
-        a = a & 1;
-        a |= a << 1;
-        a |= a << 2;
-        a |= a << 4;
-        WRITE(buffer++, a << 24);
-    }
-}
-
-static FASTCALL void
-fbFetch_g1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  p = ((CARD32 *)bits)[(i+x) >> 5];
-        CARD32 a;
-#if BITMAP_BIT_ORDER == MSBFirst
-        a = p >> (0x1f - ((i+x) & 0x1f));
-#else
-        a = p >> ((i+x) & 0x1f);
-#endif
-        a = a & 1;
-        WRITE(buffer++, indexed->rgba[a]);
-    }
-}
-
-static fetchProc fetchProcForPicture (PicturePtr pict)
-{
-    switch(pict->format) {
-    case PICT_a8r8g8b8: return fbFetch_a8r8g8b8;
-    case PICT_x8r8g8b8: return fbFetch_x8r8g8b8;
-    case PICT_a8b8g8r8: return fbFetch_a8b8g8r8;
-    case PICT_x8b8g8r8: return fbFetch_x8b8g8r8;
-
-        /* 24bpp formats */
-    case PICT_r8g8b8: return fbFetch_r8g8b8;
-    case PICT_b8g8r8: return fbFetch_b8g8r8;
-
-        /* 16bpp formats */
-    case PICT_r5g6b5: return fbFetch_r5g6b5;
-    case PICT_b5g6r5: return fbFetch_b5g6r5;
-
-    case PICT_a1r5g5b5: return fbFetch_a1r5g5b5;
-    case PICT_x1r5g5b5: return fbFetch_x1r5g5b5;
-    case PICT_a1b5g5r5: return fbFetch_a1b5g5r5;
-    case PICT_x1b5g5r5: return fbFetch_x1b5g5r5;
-    case PICT_a4r4g4b4: return fbFetch_a4r4g4b4;
-    case PICT_x4r4g4b4: return fbFetch_x4r4g4b4;
-    case PICT_a4b4g4r4: return fbFetch_a4b4g4r4;
-    case PICT_x4b4g4r4: return fbFetch_x4b4g4r4;
-
-        /* 8bpp formats */
-    case PICT_a8: return  fbFetch_a8;
-    case PICT_r3g3b2: return fbFetch_r3g3b2;
-    case PICT_b2g3r3: return fbFetch_b2g3r3;
-    case PICT_a2r2g2b2: return fbFetch_a2r2g2b2;
-    case PICT_a2b2g2r2: return fbFetch_a2b2g2r2;
-    case PICT_c8: return  fbFetch_c8;
-    case PICT_g8: return  fbFetch_c8;
-    case PICT_x4a4: return fbFetch_x4a4;
-
-        /* 4bpp formats */
-    case PICT_a4: return  fbFetch_a4;
-    case PICT_r1g2b1: return fbFetch_r1g2b1;
-    case PICT_b1g2r1: return fbFetch_b1g2r1;
-    case PICT_a1r1g1b1: return fbFetch_a1r1g1b1;
-    case PICT_a1b1g1r1: return fbFetch_a1b1g1r1;
-    case PICT_c4: return  fbFetch_c4;
-    case PICT_g4: return  fbFetch_c4;
-
-        /* 1bpp formats */
-    case PICT_a1: return  fbFetch_a1;
-    case PICT_g1: return  fbFetch_g1;
-    }
-
-    return NULL;
-}
-
-/*
- * Pixel wise fetching
- */
-
-typedef FASTCALL CARD32 (*fetchPixelProc)(const FbBits *bits, int offset, miIndexedPtr indexed);
-
-static FASTCALL CARD32
-fbFetchPixel_a8r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    return READ((CARD32 *)bits + offset);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_x8r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    return READ((CARD32 *)bits + offset) | 0xff000000;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD32 *)bits + offset);
-
-    return ((pixel & 0xff000000) |
-	    ((pixel >> 16) & 0xff) |
-	    (pixel & 0x0000ff00) |
-	    ((pixel & 0xff) << 16));
-}
-
-static FASTCALL CARD32
-fbFetchPixel_x8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD32 *)bits + offset);
-
-    return ((0xff000000) |
-	    ((pixel >> 16) & 0xff) |
-	    (pixel & 0x0000ff00) |
-	    ((pixel & 0xff) << 16));
-}
-
-static FASTCALL CARD32
-fbFetchPixel_r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD8   *pixel = ((CARD8 *) bits) + (offset*3);
-#if IMAGE_BYTE_ORDER == MSBFirst
-    return (0xff000000 |
-	    (READ(pixel + 0) << 16) |
-	    (READ(pixel + 1) << 8) |
-	    (READ(pixel + 2)));
-#else
-    return (0xff000000 |
-            (READ(pixel + 2) << 16) |
-            (READ(pixel + 1) << 8) |
-            (READ(pixel + 0)));
-#endif
-}
-
-static FASTCALL CARD32
-fbFetchPixel_b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD8   *pixel = ((CARD8 *) bits) + (offset*3);
-#if IMAGE_BYTE_ORDER == MSBFirst
-    return (0xff000000 |
-	    (READ(pixel + 2) << 16) |
-	    (READ(pixel + 1) << 8) |
-	    (READ(pixel + 0)));
-#else
-    return (0xff000000 |
-	    (READ(pixel + 0) << 16) |
-	    (READ(pixel + 1) << 8) |
-	    (READ(pixel + 2)));
-#endif
-}
-
-static FASTCALL CARD32
-fbFetchPixel_r5g6b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  r,g,b;
-
-    r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8;
-    g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
-    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_b5g6r5 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  r,g,b;
-
-    b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8;
-    g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
-    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a1r5g5b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  a,r,g,b;
-
-    a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
-    r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
-    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
-    return (a | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_x1r5g5b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  r,g,b;
-
-    r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
-    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a1b5g5r5 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  a,r,g,b;
-
-    a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
-    b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
-    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
-    return (a | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_x1b5g5r5 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  r,g,b;
-
-    b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
-    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a4r4g4b4 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  a,r,g,b;
-
-    a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
-    r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
-    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-    b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
-    return (a | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_x4r4g4b4 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  r,g,b;
-
-    r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
-    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-    b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a4b4g4r4 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  a,r,g,b;
-
-    a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
-    b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
-    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-    r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
-    return (a | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_x4b4g4r4 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = READ((CARD16 *) bits + offset);
-    CARD32  r,g,b;
-
-    b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
-    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-    r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32   pixel = READ((CARD8 *) bits + offset);
-
-    return pixel << 24;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_r3g3b2 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32   pixel = READ((CARD8 *) bits + offset);
-    CARD32  r,g,b;
-
-    r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16;
-    g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8;
-    b = (((pixel & 0x03)     ) |
-	 ((pixel & 0x03) << 2) |
-	 ((pixel & 0x03) << 4) |
-	 ((pixel & 0x03) << 6));
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_b2g3r3 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32   pixel = READ((CARD8 *) bits + offset);
-    CARD32  r,g,b;
-
-    b = (((pixel & 0xc0)     ) |
-	 ((pixel & 0xc0) >> 2) |
-	 ((pixel & 0xc0) >> 4) |
-	 ((pixel & 0xc0) >> 6));
-    g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8;
-    r = (((pixel & 0x07)     ) |
-	 ((pixel & 0x07) << 3) |
-	 ((pixel & 0x06) << 6)) << 16;
-    return (0xff000000 | r | g | b);
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a2r2g2b2 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32   pixel = READ((CARD8 *) bits + offset);
-    CARD32   a,r,g,b;
-
-    a = ((pixel & 0xc0) * 0x55) << 18;
-    r = ((pixel & 0x30) * 0x55) << 12;
-    g = ((pixel & 0x0c) * 0x55) << 6;
-    b = ((pixel & 0x03) * 0x55);
-    return a|r|g|b;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a2b2g2r2 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32   pixel = READ((CARD8 *) bits + offset);
-    CARD32   a,r,g,b;
-
-    a = ((pixel & 0xc0) * 0x55) << 18;
-    b = ((pixel & 0x30) * 0x55) >> 6;
-    g = ((pixel & 0x0c) * 0x55) << 6;
-    r = ((pixel & 0x03) * 0x55) << 16;
-    return a|r|g|b;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_c8 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32   pixel = READ((CARD8 *) bits + offset);
-    return indexed->rgba[pixel];
-}
-
-static FASTCALL CARD32
-fbFetchPixel_x4a4 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32   pixel = READ((CARD8 *) bits + offset);
-
-    return ((pixel & 0xf) | ((pixel & 0xf) << 4)) << 24;
-}
-
-#define Fetch8(l,o)    (((CARD8 *) (l))[(o) >> 2])
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define Fetch4(l,o)    ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
-#else
-#define Fetch4(l,o)    ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
-#endif
-
-static FASTCALL CARD32
-fbFetchPixel_a4 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = Fetch4(bits, offset);
-
-    pixel |= pixel << 4;
-    return pixel << 24;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_r1g2b1 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = Fetch4(bits, offset);
-    CARD32  r,g,b;
-
-    r = ((pixel & 0x8) * 0xff) << 13;
-    g = ((pixel & 0x6) * 0x55) << 7;
-    b = ((pixel & 0x1) * 0xff);
-    return 0xff000000|r|g|b;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_b1g2r1 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = Fetch4(bits, offset);
-    CARD32  r,g,b;
-
-    b = ((pixel & 0x8) * 0xff) >> 3;
-    g = ((pixel & 0x6) * 0x55) << 7;
-    r = ((pixel & 0x1) * 0xff) << 16;
-    return 0xff000000|r|g|b;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a1r1g1b1 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = Fetch4(bits, offset);
-    CARD32  a,r,g,b;
-
-    a = ((pixel & 0x8) * 0xff) << 21;
-    r = ((pixel & 0x4) * 0xff) << 14;
-    g = ((pixel & 0x2) * 0xff) << 7;
-    b = ((pixel & 0x1) * 0xff);
-    return a|r|g|b;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_a1b1g1r1 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = Fetch4(bits, offset);
-    CARD32  a,r,g,b;
-
-    a = ((pixel & 0x8) * 0xff) << 21;
-    r = ((pixel & 0x4) * 0xff) >> 3;
-    g = ((pixel & 0x2) * 0xff) << 7;
-    b = ((pixel & 0x1) * 0xff) << 16;
-    return a|r|g|b;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_c4 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = Fetch4(bits, offset);
-
-    return indexed->rgba[pixel];
-}
-
-
-static FASTCALL CARD32
-fbFetchPixel_a1 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32  pixel = ((CARD32 *)bits)[offset >> 5];
-    CARD32  a;
-#if BITMAP_BIT_ORDER == MSBFirst
-    a = pixel >> (0x1f - (offset & 0x1f));
-#else
-    a = pixel >> (offset & 0x1f);
-#endif
-    a = a & 1;
-    a |= a << 1;
-    a |= a << 2;
-    a |= a << 4;
-    return a << 24;
-}
-
-static FASTCALL CARD32
-fbFetchPixel_g1 (const FbBits *bits, int offset, miIndexedPtr indexed)
-{
-    CARD32 pixel = ((CARD32 *)bits)[offset >> 5];
-    CARD32 a;
-#if BITMAP_BIT_ORDER == MSBFirst
-    a = pixel >> (0x1f - (offset & 0x1f));
-#else
-    a = pixel >> (offset & 0x1f);
-#endif
-    a = a & 1;
-    return indexed->rgba[a];
-}
-
-static fetchPixelProc fetchPixelProcForPicture (PicturePtr pict)
-{
-    switch(pict->format) {
-    case PICT_a8r8g8b8: return fbFetchPixel_a8r8g8b8;
-    case PICT_x8r8g8b8: return fbFetchPixel_x8r8g8b8;
-    case PICT_a8b8g8r8: return fbFetchPixel_a8b8g8r8;
-    case PICT_x8b8g8r8: return fbFetchPixel_x8b8g8r8;
-
-        /* 24bpp formats */
-    case PICT_r8g8b8: return fbFetchPixel_r8g8b8;
-    case PICT_b8g8r8: return fbFetchPixel_b8g8r8;
-
-        /* 16bpp formats */
-    case PICT_r5g6b5: return fbFetchPixel_r5g6b5;
-    case PICT_b5g6r5: return fbFetchPixel_b5g6r5;
-
-    case PICT_a1r5g5b5: return fbFetchPixel_a1r5g5b5;
-    case PICT_x1r5g5b5: return fbFetchPixel_x1r5g5b5;
-    case PICT_a1b5g5r5: return fbFetchPixel_a1b5g5r5;
-    case PICT_x1b5g5r5: return fbFetchPixel_x1b5g5r5;
-    case PICT_a4r4g4b4: return fbFetchPixel_a4r4g4b4;
-    case PICT_x4r4g4b4: return fbFetchPixel_x4r4g4b4;
-    case PICT_a4b4g4r4: return fbFetchPixel_a4b4g4r4;
-    case PICT_x4b4g4r4: return fbFetchPixel_x4b4g4r4;
-
-        /* 8bpp formats */
-    case PICT_a8: return  fbFetchPixel_a8;
-    case PICT_r3g3b2: return fbFetchPixel_r3g3b2;
-    case PICT_b2g3r3: return fbFetchPixel_b2g3r3;
-    case PICT_a2r2g2b2: return fbFetchPixel_a2r2g2b2;
-    case PICT_a2b2g2r2: return fbFetchPixel_a2b2g2r2;
-    case PICT_c8: return  fbFetchPixel_c8;
-    case PICT_g8: return  fbFetchPixel_c8;
-    case PICT_x4a4: return fbFetchPixel_x4a4;
-
-        /* 4bpp formats */
-    case PICT_a4: return  fbFetchPixel_a4;
-    case PICT_r1g2b1: return fbFetchPixel_r1g2b1;
-    case PICT_b1g2r1: return fbFetchPixel_b1g2r1;
-    case PICT_a1r1g1b1: return fbFetchPixel_a1r1g1b1;
-    case PICT_a1b1g1r1: return fbFetchPixel_a1b1g1r1;
-    case PICT_c4: return  fbFetchPixel_c4;
-    case PICT_g4: return  fbFetchPixel_c4;
-
-        /* 1bpp formats */
-    case PICT_a1: return  fbFetchPixel_a1;
-    case PICT_g1: return  fbFetchPixel_g1;
-    }
-
-    return NULL;
-}
-
-
-
-/*
- * All the store functions
- */
-
-typedef FASTCALL void (*storeProc) (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed);
-
-#define Splita(v)	CARD32	a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
-#define Split(v)	CARD32	r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
-
-static FASTCALL void
-fbStore_a8r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    MEMCPY_WRAPPED(((CARD32 *)bits) + x, values, width*sizeof(CARD32));
-}
-
-static FASTCALL void
-fbStore_x8r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD32 *pixel = (CARD32 *)bits + x;
-    for (i = 0; i < width; ++i)
-        WRITE(pixel++, READ(values + i) & 0xffffff);
-}
-
-static FASTCALL void
-fbStore_a8b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD32 *pixel = (CARD32 *)bits + x;
-    for (i = 0; i < width; ++i)
-        WRITE(pixel++, (READ(values + i) & 0xff00ff00) | ((READ(values + i) >> 16) & 0xff) | ((READ(values + i) & 0xff) << 16));
-}
-
-static FASTCALL void
-fbStore_x8b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD32 *pixel = (CARD32 *)bits + x;
-    for (i = 0; i < width; ++i)
-        WRITE(pixel++, (READ(values + i) & 0x0000ff00) | ((READ(values + i) >> 16) & 0xff) | ((READ(values + i) & 0xff) << 16));
-}
-
-static FASTCALL void
-fbStore_r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8 *pixel = ((CARD8 *) bits) + 3*x;
-    for (i = 0; i < width; ++i) {
-        Store24(pixel, READ(values + i));
-        pixel += 3;
-    }
-}
-
-static FASTCALL void
-fbStore_b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8 *pixel = ((CARD8 *) bits) + 3*x;
-    for (i = 0; i < width; ++i) {
-        CARD32 val = READ(values + i);
-#if IMAGE_BYTE_ORDER == MSBFirst
-        WRITE(pixel++, Blue(val));
-        WRITE(pixel++, Green(val));
-        WRITE(pixel++, Red(val));
-#else
-        WRITE(pixel++, Red(val));
-        WRITE(pixel++, Green(val));
-        WRITE(pixel++, Blue(val));
-#endif
-    }
-}
-
-static FASTCALL void
-fbStore_r5g6b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16 *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(values + i);
-        WRITE(pixel++, ((s >> 3) & 0x001f) |
-	      ((s >> 5) & 0x07e0) |
-	      ((s >> 8) & 0xf800));
-    }
-}
-
-static FASTCALL void
-fbStore_b5g6r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Split(READ(values + i));
-        WRITE(pixel++, ((b << 8) & 0xf800) |
-	      ((g << 3) & 0x07e0) |
-	      ((r >> 3)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_a1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Splita(READ(values + i));
-        WRITE(pixel++, ((a << 8) & 0x8000) |
-	      ((r << 7) & 0x7c00) |
-	      ((g << 2) & 0x03e0) |
-	      ((b >> 3)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_x1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Split(READ(values + i));
-        WRITE(pixel++, ((r << 7) & 0x7c00) |
-	      ((g << 2) & 0x03e0) |
-	      ((b >> 3)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_a1b5g5r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Splita(READ(values + i));
-        WRITE(pixel++, ((a << 8) & 0x8000) |
-	      ((b << 7) & 0x7c00) |
-	      ((g << 2) & 0x03e0) |
-	      ((r >> 3)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_x1b5g5r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Split(READ(values + i));
-        WRITE(pixel++, ((b << 7) & 0x7c00) |
-	      ((g << 2) & 0x03e0) |
-	      ((r >> 3)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_a4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Splita(READ(values + i));
-        WRITE(pixel++, ((a << 8) & 0xf000) |
-	      ((r << 4) & 0x0f00) |
-	      ((g     ) & 0x00f0) |
-	      ((b >> 4)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_x4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Split(READ(values + i));
-        WRITE(pixel++, ((r << 4) & 0x0f00) |
-	      ((g     ) & 0x00f0) |
-	      ((b >> 4)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_a4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Splita(READ(values + i));
-        WRITE(pixel++, ((a << 8) & 0xf000) |
-	      ((b << 4) & 0x0f00) |
-	      ((g     ) & 0x00f0) |
-	      ((r >> 4)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_x4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD16  *pixel = ((CARD16 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Split(READ(values + i));
-        WRITE(pixel++, ((b << 4) & 0x0f00) |
-	      ((g     ) & 0x00f0) |
-	      ((r >> 4)         ));
-    }
-}
-
-static FASTCALL void
-fbStore_a8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8   *pixel = ((CARD8 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        WRITE(pixel++, READ(values + i) >> 24);
-    }
-}
-
-static FASTCALL void
-fbStore_r3g3b2 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8   *pixel = ((CARD8 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Split(READ(values + i));
-        WRITE(pixel++, ((r     ) & 0xe0) |
-	      ((g >> 3) & 0x1c) |
-	      ((b >> 6)       ));
-    }
-}
-
-static FASTCALL void
-fbStore_b2g3r3 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8   *pixel = ((CARD8 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Split(READ(values + i));
-        WRITE(pixel++, ((b     ) & 0xe0) |
-	      ((g >> 3) & 0x1c) |
-	      ((r >> 6)       ));
-    }
-}
-
-static FASTCALL void
-fbStore_a2r2g2b2 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8   *pixel = ((CARD8 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        Splita(READ(values + i));
-        WRITE(pixel++, ((a     ) & 0xc0) |
-	      ((r >> 2) & 0x30) |
-	      ((g >> 4) & 0x0c) |
-	      ((b >> 6)       ));
-    }
-}
-
-static FASTCALL void
-fbStore_c8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8   *pixel = ((CARD8 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        WRITE(pixel++, miIndexToEnt24(indexed,READ(values + i)));
-    }
-}
-
-static FASTCALL void
-fbStore_x4a4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    CARD8   *pixel = ((CARD8 *) bits) + x;
-    for (i = 0; i < width; ++i) {
-        WRITE(pixel++, READ(values + i) >> 28);
-    }
-}
-
-#define Store8(l,o,v)  (((CARD8 *) l)[(o) >> 3] = (v))
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define Store4(l,o,v)  Store8(l,o,((o) & 4 ?			\
-				   (Fetch8(l,o) & 0xf0) | (v) :		\
-				   (Fetch8(l,o) & 0x0f) | ((v) << 4)))
-#else
-#define Store4(l,o,v)  Store8(l,o,((o) & 4 ?			       \
-				   (Fetch8(l,o) & 0x0f) | ((v) << 4) : \
-				   (Fetch8(l,o) & 0xf0) | (v)))
-#endif
-
-static FASTCALL void
-fbStore_a4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        Store4(bits, i + x, READ(values + i)>>28);
-    }
-}
-
-static FASTCALL void
-fbStore_r1g2b1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  pixel;
-
-        Split(READ(values + i));
-        pixel = (((r >> 4) & 0x8) |
-                 ((g >> 5) & 0x6) |
-                 ((b >> 7)      ));
-        Store4(bits, i + x, pixel);
-    }
-}
-
-static FASTCALL void
-fbStore_b1g2r1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  pixel;
-
-        Split(READ(values + i));
-        pixel = (((b >> 4) & 0x8) |
-                 ((g >> 5) & 0x6) |
-                 ((r >> 7)      ));
-        Store4(bits, i + x, pixel);
-    }
-}
-
-static FASTCALL void
-fbStore_a1r1g1b1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  pixel;
-        Splita(READ(values + i));
-        pixel = (((a >> 4) & 0x8) |
-                 ((r >> 5) & 0x4) |
-                 ((g >> 6) & 0x2) |
-                 ((b >> 7)      ));
-        Store4(bits, i + x, pixel);
-    }
-}
-
-static FASTCALL void
-fbStore_a1b1g1r1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  pixel;
-        Splita(READ(values + i));
-        pixel = (((a >> 4) & 0x8) |
-                 ((b >> 5) & 0x4) |
-                 ((g >> 6) & 0x2) |
-                 ((r >> 7)      ));
-        Store4(bits, i + x, pixel);
-    }
-}
-
-static FASTCALL void
-fbStore_c4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  pixel;
-
-        pixel = miIndexToEnt24(indexed, READ(values + i));
-        Store4(bits, i + x, pixel);
-    }
-}
-
-static FASTCALL void
-fbStore_a1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  *pixel = ((CARD32 *) bits) + ((i+x) >> 5);
-        CARD32  mask = FbStipMask((i+x) & 0x1f, 1);
-
-        CARD32 v = READ(values + i) & 0x80000000 ? mask : 0;
-        WRITE(pixel, (READ(pixel) & ~mask) | v);
-    }
-}
-
-static FASTCALL void
-fbStore_g1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  *pixel = ((CARD32 *) bits) + ((i+x) >> 5);
-        CARD32  mask = FbStipMask((i+x) & 0x1f, 1);
-
-        CARD32 v = miIndexToEntY24(indexed,READ(values + i)) ? mask : 0;
-        WRITE(pixel, (READ(pixel) & ~mask) | v);
-    }
-}
-
-
-static storeProc storeProcForPicture (PicturePtr pict)
-{
-    switch(pict->format) {
-    case PICT_a8r8g8b8: return fbStore_a8r8g8b8;
-    case PICT_x8r8g8b8: return fbStore_x8r8g8b8;
-    case PICT_a8b8g8r8: return fbStore_a8b8g8r8;
-    case PICT_x8b8g8r8: return fbStore_x8b8g8r8;
-
-        /* 24bpp formats */
-    case PICT_r8g8b8: return fbStore_r8g8b8;
-    case PICT_b8g8r8: return fbStore_b8g8r8;
-
-        /* 16bpp formats */
-    case PICT_r5g6b5: return fbStore_r5g6b5;
-    case PICT_b5g6r5: return fbStore_b5g6r5;
-
-    case PICT_a1r5g5b5: return fbStore_a1r5g5b5;
-    case PICT_x1r5g5b5: return fbStore_x1r5g5b5;
-    case PICT_a1b5g5r5: return fbStore_a1b5g5r5;
-    case PICT_x1b5g5r5: return fbStore_x1b5g5r5;
-    case PICT_a4r4g4b4: return fbStore_a4r4g4b4;
-    case PICT_x4r4g4b4: return fbStore_x4r4g4b4;
-    case PICT_a4b4g4r4: return fbStore_a4b4g4r4;
-    case PICT_x4b4g4r4: return fbStore_x4b4g4r4;
-
-        /* 8bpp formats */
-    case PICT_a8: return  fbStore_a8;
-    case PICT_r3g3b2: return fbStore_r3g3b2;
-    case PICT_b2g3r3: return fbStore_b2g3r3;
-    case PICT_a2r2g2b2: return fbStore_a2r2g2b2;
-    case PICT_c8: return  fbStore_c8;
-    case PICT_g8: return  fbStore_c8;
-    case PICT_x4a4: return fbStore_x4a4;
-
-        /* 4bpp formats */
-    case PICT_a4: return  fbStore_a4;
-    case PICT_r1g2b1: return fbStore_r1g2b1;
-    case PICT_b1g2r1: return fbStore_b1g2r1;
-    case PICT_a1r1g1b1: return fbStore_a1r1g1b1;
-    case PICT_a1b1g1r1: return fbStore_a1b1g1r1;
-    case PICT_c4: return  fbStore_c4;
-    case PICT_g4: return  fbStore_c4;
-
-        /* 1bpp formats */
-    case PICT_a1: return  fbStore_a1;
-    case PICT_g1: return  fbStore_g1;
-    default:
-        return NULL;
-    }
-}
-
-
-/*
- * Combine src and mask
- */
-static FASTCALL void
-fbCombineMaskU (CARD32 *src, const CARD32 *mask, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 a = READ(mask + i) >> 24;
-        CARD32 s = READ(src + i);
-        FbByteMul(s, a);
-        WRITE(src + i, s);
-    }
-}
-
-/*
- * All of the composing functions
- */
-
-static FASTCALL void
-fbCombineClear (CARD32 *dest, const CARD32 *src, int width)
-{
-    MEMSET_WRAPPED(dest, 0, width*sizeof(CARD32));
-}
-
-static FASTCALL void
-fbCombineSrcU (CARD32 *dest, const CARD32 *src, int width)
-{
-    MEMCPY_WRAPPED(dest, src, width*sizeof(CARD32));
-}
-
-static FASTCALL void
-fbCombineOverU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD32 ia = Alpha(~s);
-
-        FbByteMulAdd(d, ia, s);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineOverReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD32 ia = Alpha(~READ(dest + i));
-        FbByteMulAdd(s, ia, d);
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineInU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 a = Alpha(READ(dest + i));
-        FbByteMul(s, a);
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineInReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 d = READ(dest + i);
-        CARD32 a = Alpha(READ(src + i));
-        FbByteMul(d, a);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineOutU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 a = Alpha(~READ(dest + i));
-        FbByteMul(s, a);
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineOutReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 d = READ(dest + i);
-        CARD32 a = Alpha(~READ(src + i));
-        FbByteMul(d, a);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineAtopU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD32 dest_a = Alpha(d);
-        CARD32 src_ia = Alpha(~s);
-
-        FbByteAddMul(s, dest_a, d, src_ia);
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD32 src_a = Alpha(s);
-        CARD32 dest_ia = Alpha(~d);
-
-        FbByteAddMul(s, dest_ia, d, src_a);
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineXorU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD32 src_ia = Alpha(~s);
-        CARD32 dest_ia = Alpha(~d);
-
-        FbByteAddMul(s, dest_ia, d, src_ia);
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineAddU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        FbByteAdd(d, s);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineSaturateU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD16  sa, da;
-
-        sa = s >> 24;
-        da = ~d >> 24;
-        if (sa > da)
-        {
-            sa = FbIntDiv(da, sa);
-            FbByteMul(s, sa);
-        }
-        FbByteAdd(d, s);
-        WRITE(dest + i, d);
-    }
-}
-
-/*
- * All of the disjoint composing functions
-
- The four entries in the first column indicate what source contributions
- come from each of the four areas of the picture -- areas covered by neither
- A nor B, areas covered only by A, areas covered only by B and finally
- areas covered by both A and B.
-
- Disjoint			Conjoint
- Fa		Fb		Fa		Fb
- (0,0,0,0)	0		0		0		0
- (0,A,0,A)	1		0		1		0
- (0,0,B,B)	0		1		0		1
- (0,A,B,A)	1		min((1-a)/b,1)	1		max(1-a/b,0)
- (0,A,B,B)	min((1-b)/a,1)	1		max(1-b/a,0)	1
- (0,0,0,A)	max(1-(1-b)/a,0) 0		min(1,b/a)	0
- (0,0,0,B)	0		max(1-(1-a)/b,0) 0		min(a/b,1)
- (0,A,0,0)	min(1,(1-b)/a)	0		max(1-b/a,0)	0
- (0,0,B,0)	0		min(1,(1-a)/b)	0		max(1-a/b,0)
- (0,0,B,A)	max(1-(1-b)/a,0) min(1,(1-a)/b)	 min(1,b/a)	max(1-a/b,0)
- (0,A,0,B)	min(1,(1-b)/a)	max(1-(1-a)/b,0) max(1-b/a,0)	min(1,a/b)
- (0,A,B,0)	min(1,(1-b)/a)	min(1,(1-a)/b)	max(1-b/a,0)	max(1-a/b,0)
-
-*/
-
-#define CombineAOut 1
-#define CombineAIn  2
-#define CombineBOut 4
-#define CombineBIn  8
-
-#define CombineClear	0
-#define CombineA	(CombineAOut|CombineAIn)
-#define CombineB	(CombineBOut|CombineBIn)
-#define CombineAOver	(CombineAOut|CombineBOut|CombineAIn)
-#define CombineBOver	(CombineAOut|CombineBOut|CombineBIn)
-#define CombineAAtop	(CombineBOut|CombineAIn)
-#define CombineBAtop	(CombineAOut|CombineBIn)
-#define CombineXor	(CombineAOut|CombineBOut)
-
-/* portion covered by a but not b */
-static INLINE CARD8
-fbCombineDisjointOutPart (CARD8 a, CARD8 b)
-{
-    /* min (1, (1-b) / a) */
-
-    b = ~b;		    /* 1 - b */
-    if (b >= a)		    /* 1 - b >= a -> (1-b)/a >= 1 */
-	return 0xff;	    /* 1 */
-    return FbIntDiv(b,a);   /* (1-b) / a */
-}
-
-/* portion covered by both a and b */
-static INLINE CARD8
-fbCombineDisjointInPart (CARD8 a, CARD8 b)
-{
-    /* max (1-(1-b)/a,0) */
-    /*  = - min ((1-b)/a - 1, 0) */
-    /*  = 1 - min (1, (1-b)/a) */
-
-    b = ~b;		    /* 1 - b */
-    if (b >= a)		    /* 1 - b >= a -> (1-b)/a >= 1 */
-	return 0;	    /* 1 - 1 */
-    return ~FbIntDiv(b,a);  /* 1 - (1-b) / a */
-}
-
-static FASTCALL void
-fbCombineDisjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD32 m,n,o,p;
-        CARD16 Fa, Fb, t, u, v;
-        CARD8 sa = s >> 24;
-        CARD8 da = d >> 24;
-
-        switch (combine & CombineA) {
-        default:
-            Fa = 0;
-            break;
-        case CombineAOut:
-            Fa = fbCombineDisjointOutPart (sa, da);
-            break;
-        case CombineAIn:
-            Fa = fbCombineDisjointInPart (sa, da);
-            break;
-        case CombineA:
-            Fa = 0xff;
-            break;
-        }
-
-        switch (combine & CombineB) {
-        default:
-            Fb = 0;
-            break;
-        case CombineBOut:
-            Fb = fbCombineDisjointOutPart (da, sa);
-            break;
-        case CombineBIn:
-            Fb = fbCombineDisjointInPart (da, sa);
-            break;
-        case CombineB:
-            Fb = 0xff;
-            break;
-        }
-        m = FbGen (s,d,0,Fa,Fb,t, u, v);
-        n = FbGen (s,d,8,Fa,Fb,t, u, v);
-        o = FbGen (s,d,16,Fa,Fb,t, u, v);
-        p = FbGen (s,d,24,Fa,Fb,t, u, v);
-        s = m|n|o|p;
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineDisjointOverU (CARD32 *dest, const CARD32 *src, int width)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  s = READ(src + i);
-        CARD16  a = s >> 24;
-
-        if (a != 0x00)
-        {
-            if (a != 0xff)
-            {
-                CARD32 d = READ(dest + i);
-                a = fbCombineDisjointOutPart (d >> 24, a);
-                FbByteMulAdd(d, a, s);
-                s = d;
-            }
-            WRITE(dest + i, s);
-        }
-    }
-}
-
-static FASTCALL void
-fbCombineDisjointInU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineDisjointGeneralU (dest, src, width, CombineAIn);
-}
-
-static FASTCALL void
-fbCombineDisjointInReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineDisjointGeneralU (dest, src, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineDisjointOutU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineDisjointGeneralU (dest, src, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineDisjointOutReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineDisjointGeneralU (dest, src, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineDisjointGeneralU (dest, src, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineDisjointGeneralU (dest, src, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointXorU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineDisjointGeneralU (dest, src, width, CombineXor);
-}
-
-/* portion covered by a but not b */
-static INLINE CARD8
-fbCombineConjointOutPart (CARD8 a, CARD8 b)
-{
-    /* max (1-b/a,0) */
-    /* = 1-min(b/a,1) */
-
-    /* min (1, (1-b) / a) */
-
-    if (b >= a)		    /* b >= a -> b/a >= 1 */
-	return 0x00;	    /* 0 */
-    return ~FbIntDiv(b,a);   /* 1 - b/a */
-}
-
-/* portion covered by both a and b */
-static INLINE CARD8
-fbCombineConjointInPart (CARD8 a, CARD8 b)
-{
-    /* min (1,b/a) */
-
-    if (b >= a)		    /* b >= a -> b/a >= 1 */
-	return 0xff;	    /* 1 */
-    return FbIntDiv(b,a);   /* b/a */
-}
-
-static FASTCALL void
-fbCombineConjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine)
-{
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32  s = READ(src + i);
-        CARD32 d = READ(dest + i);
-        CARD32  m,n,o,p;
-        CARD16  Fa, Fb, t, u, v;
-        CARD8 sa = s >> 24;
-        CARD8 da = d >> 24;
-
-        switch (combine & CombineA) {
-        default:
-            Fa = 0;
-            break;
-        case CombineAOut:
-            Fa = fbCombineConjointOutPart (sa, da);
-            break;
-        case CombineAIn:
-            Fa = fbCombineConjointInPart (sa, da);
-            break;
-        case CombineA:
-            Fa = 0xff;
-            break;
-        }
-
-        switch (combine & CombineB) {
-        default:
-            Fb = 0;
-            break;
-        case CombineBOut:
-            Fb = fbCombineConjointOutPart (da, sa);
-            break;
-        case CombineBIn:
-            Fb = fbCombineConjointInPart (da, sa);
-            break;
-        case CombineB:
-            Fb = 0xff;
-            break;
-        }
-        m = FbGen (s,d,0,Fa,Fb,t, u, v);
-        n = FbGen (s,d,8,Fa,Fb,t, u, v);
-        o = FbGen (s,d,16,Fa,Fb,t, u, v);
-        p = FbGen (s,d,24,Fa,Fb,t, u, v);
-        s = m|n|o|p;
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineConjointOverU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineAOver);
-}
-
-
-static FASTCALL void
-fbCombineConjointOverReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineBOver);
-}
-
-
-static FASTCALL void
-fbCombineConjointInU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineAIn);
-}
-
-
-static FASTCALL void
-fbCombineConjointInReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineConjointOutU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineConjointOutReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineConjointAtopU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineConjointAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineConjointXorU (CARD32 *dest, const CARD32 *src, int width)
-{
-    fbCombineConjointGeneralU (dest, src, width, CombineXor);
-}
-
-static CombineFuncU fbCombineFuncU[] = {
-    fbCombineClear,
-    fbCombineSrcU,
-    NULL, /* CombineDst */
-    fbCombineOverU,
-    fbCombineOverReverseU,
-    fbCombineInU,
-    fbCombineInReverseU,
-    fbCombineOutU,
-    fbCombineOutReverseU,
-    fbCombineAtopU,
-    fbCombineAtopReverseU,
-    fbCombineXorU,
-    fbCombineAddU,
-    fbCombineSaturateU,
-    NULL,
-    NULL,
-    fbCombineClear,
-    fbCombineSrcU,
-    NULL, /* CombineDst */
-    fbCombineDisjointOverU,
-    fbCombineSaturateU, /* DisjointOverReverse */
-    fbCombineDisjointInU,
-    fbCombineDisjointInReverseU,
-    fbCombineDisjointOutU,
-    fbCombineDisjointOutReverseU,
-    fbCombineDisjointAtopU,
-    fbCombineDisjointAtopReverseU,
-    fbCombineDisjointXorU,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    fbCombineClear,
-    fbCombineSrcU,
-    NULL, /* CombineDst */
-    fbCombineConjointOverU,
-    fbCombineConjointOverReverseU,
-    fbCombineConjointInU,
-    fbCombineConjointInReverseU,
-    fbCombineConjointOutU,
-    fbCombineConjointOutReverseU,
-    fbCombineConjointAtopU,
-    fbCombineConjointAtopReverseU,
-    fbCombineConjointXorU,
-};
-
-static INLINE void
-fbCombineMaskC (CARD32 *src, CARD32 *mask)
-{
-    CARD32 a = *mask;
-
-    CARD32	x;
-    CARD16	xa;
-
-    if (!a)
-    {
-	WRITE(src, 0);
-	return;
-    }
-
-    x = READ(src);
-    if (a == 0xffffffff)
-    {
-	x = x >> 24;
-	x |= x << 8;
-	x |= x << 16;
-	WRITE(mask, x);
-	return;
-    }
-
-    xa = x >> 24;
-    FbByteMulC(x, a);
-    WRITE(src, x);
-    FbByteMul(a, xa);
-    WRITE(mask, a);
-}
-
-static INLINE void
-fbCombineMaskValueC (CARD32 *src, const CARD32 *mask)
-{
-    CARD32 a = READ(mask);
-    CARD32	x;
-
-    if (!a)
-    {
-	WRITE(src, 0);
-	return;
-    }
-
-    if (a == 0xffffffff)
-	return;
-
-    x = READ(src);
-    FbByteMulC(x, a);
-    WRITE(src,x);
-}
-
-static INLINE void
-fbCombineMaskAlphaC (const CARD32 *src, CARD32 *mask)
-{
-    CARD32 a = READ(mask);
-    CARD32	x;
-
-    if (!a)
-	return;
-
-    x = READ(src) >> 24;
-    if (x == 0xff)
-	return;
-    if (a == 0xffffffff)
-    {
-	x = x >> 24;
-	x |= x << 8;
-	x |= x << 16;
-	WRITE(mask, x);
-	return;
-    }
-
-    FbByteMul(a, x);
-    WRITE(mask, a);
-}
-
-static FASTCALL void
-fbCombineClearC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    MEMSET_WRAPPED(dest, 0, width*sizeof(CARD32));
-}
-
-static FASTCALL void
-fbCombineSrcC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-	CARD32 s = READ(src + i);
-	CARD32 m = READ(mask + i);
-
-	fbCombineMaskValueC (&s, &m);
-
-	WRITE(dest, s);
-    }
-}
-
-static FASTCALL void
-fbCombineOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-	CARD32 s = READ(src + i);
-	CARD32 m = READ(mask + i);
-	CARD32 a;
-
-	fbCombineMaskC (&s, &m);
-
-	a = ~m;
-        if (a != 0xffffffff)
-        {
-            if (a)
-            {
-                CARD32 d = READ(dest + i);
-                FbByteMulAddC(d, a, s);
-                s = d;
-            }
-            WRITE(dest + i, s);
-        }
-    }
-}
-
-static FASTCALL void
-fbCombineOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32 d = READ(dest + i);
-        CARD32 a = ~d >> 24;
-
-        if (a)
-        {
-            CARD32 s = READ(src + i);
-	    CARD32 m = READ(mask + i);
-
-	    fbCombineMaskValueC (&s, &m);
-
-            if (a != 0xff)
-            {
-                FbByteMulAdd(s, a, d);
-            }
-            WRITE(dest + i, s);
-        }
-    }
-}
-
-static FASTCALL void
-fbCombineInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32 d = READ(dest + i);
-        CARD16 a = d >> 24;
-        CARD32 s = 0;
-        if (a)
-        {
-	    CARD32 m = READ(mask + i);
-
-	    s = READ(src + i);
-	    fbCombineMaskValueC (&s, &m);
-            if (a != 0xff)
-            {
-                FbByteMul(s, a);
-            }
-        }
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 m = READ(mask + i);
-        CARD32 a;
-
-	fbCombineMaskAlphaC (&s, &m);
-
-	a = m;
-        if (a != 0xffffffff)
-        {
-            CARD32 d = 0;
-            if (a)
-            {
-                d = READ(dest + i);
-                FbByteMulC(d, a);
-            }
-            WRITE(dest + i, d); 
-        }
-    }
-}
-
-static FASTCALL void
-fbCombineOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32 d = READ(dest + i);
-        CARD16 a = ~d >> 24;
-        CARD32 s = 0;
-        if (a)
-        {
-	    CARD32 m = READ(mask + i);
-
-	    s = READ(src + i);
-	    fbCombineMaskValueC (&s, &m);
-
-            if (a != 0xff)
-            {
-                FbByteMul(s, a);
-            }
-        }
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-	CARD32 s = READ(src + i);
-	CARD32 m = READ(mask + i);
-	CARD32 a;
-
-	fbCombineMaskAlphaC (&s, &m);
-
-        a = ~m;
-        if (a != 0xffffffff)
-        {
-            CARD32 d = 0;
-            if (a)
-            {
-                d = READ(dest + i);
-                FbByteMulC(d, a);
-            }
-            WRITE(dest + i, d);
-        }
-    }
-}
-
-static FASTCALL void
-fbCombineAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32 d = READ(dest + i);
-        CARD32 s = READ(src + i);
-        CARD32 m = READ(mask + i);
-        CARD32 ad;
-        CARD16 as = d >> 24;
-
-	fbCombineMaskC (&s, &m);
-
-        ad = ~m;
-
-        FbByteAddMulC(d, ad, s, as);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-
-        CARD32 d = READ(dest + i);
-        CARD32 s = READ(src + i);
-        CARD32 m = READ(mask + i);
-        CARD32 ad;
-        CARD16 as = ~d >> 24;
-
-	fbCombineMaskC (&s, &m);
-
-	ad = m;
-
-        FbByteAddMulC(d, ad, s, as);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32 d = READ(dest + i);
-        CARD32 s = READ(src + i);
-        CARD32 m = READ(mask + i);
-        CARD32 ad;
-        CARD16 as = ~d >> 24;
-
-	fbCombineMaskC (&s, &m);
-
-	ad = ~m;
-
-        FbByteAddMulC(d, ad, s, as);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineAddC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32 s = READ(src + i);
-        CARD32 m = READ(mask + i);
-        CARD32 d = READ(dest + i);
-
-	fbCombineMaskValueC (&s, &m);
-
-        FbByteAdd(d, s);
-        WRITE(dest + i, d);
-    }
-}
-
-static FASTCALL void
-fbCombineSaturateC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32  s, d;
-        CARD16  sa, sr, sg, sb, da;
-        CARD16  t, u, v;
-        CARD32  m,n,o,p;
-
-        d = READ(dest + i);
-        s = READ(src + i);
-	m = READ(mask + i);
-
-	fbCombineMaskC (&s, &m);
-
-        sa = (m >> 24);
-        sr = (m >> 16) & 0xff;
-        sg = (m >>  8) & 0xff;
-        sb = (m      ) & 0xff;
-        da = ~d >> 24;
-
-        if (sb <= da)
-            m = FbAdd(s,d,0,t);
-        else
-            m = FbGen (s, d, 0, (da << 8) / sb, 0xff, t, u, v);
-
-        if (sg <= da)
-            n = FbAdd(s,d,8,t);
-        else
-            n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v);
-
-        if (sr <= da)
-            o = FbAdd(s,d,16,t);
-        else
-            o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v);
-
-        if (sa <= da)
-            p = FbAdd(s,d,24,t);
-        else
-            p = FbGen (s, d, 24, (da << 8) / sa, 0xff, t, u, v);
-
-        WRITE(dest + i, m|n|o|p);
-    }
-}
-
-static FASTCALL void
-fbCombineDisjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32  s, d;
-        CARD32  m,n,o,p;
-        CARD32  Fa, Fb;
-        CARD16  t, u, v;
-        CARD32  sa;
-        CARD8   da;
-
-        s = READ(src + i);
-        m = READ(mask + i);
-        d = READ(dest + i);
-        da = d >> 24;
-
-	fbCombineMaskC (&s, &m);
-
-	sa = m;
-
-        switch (combine & CombineA) {
-        default:
-            Fa = 0;
-            break;
-        case CombineAOut:
-            m = fbCombineDisjointOutPart ((CARD8) (sa >> 0), da);
-            n = fbCombineDisjointOutPart ((CARD8) (sa >> 8), da) << 8;
-            o = fbCombineDisjointOutPart ((CARD8) (sa >> 16), da) << 16;
-            p = fbCombineDisjointOutPart ((CARD8) (sa >> 24), da) << 24;
-            Fa = m|n|o|p;
-            break;
-        case CombineAIn:
-            m = fbCombineDisjointInPart ((CARD8) (sa >> 0), da);
-            n = fbCombineDisjointInPart ((CARD8) (sa >> 8), da) << 8;
-            o = fbCombineDisjointInPart ((CARD8) (sa >> 16), da) << 16;
-            p = fbCombineDisjointInPart ((CARD8) (sa >> 24), da) << 24;
-            Fa = m|n|o|p;
-            break;
-        case CombineA:
-            Fa = 0xffffffff;
-            break;
-        }
-
-        switch (combine & CombineB) {
-        default:
-            Fb = 0;
-            break;
-        case CombineBOut:
-            m = fbCombineDisjointOutPart (da, (CARD8) (sa >> 0));
-            n = fbCombineDisjointOutPart (da, (CARD8) (sa >> 8)) << 8;
-            o = fbCombineDisjointOutPart (da, (CARD8) (sa >> 16)) << 16;
-            p = fbCombineDisjointOutPart (da, (CARD8) (sa >> 24)) << 24;
-            Fb = m|n|o|p;
-            break;
-        case CombineBIn:
-            m = fbCombineDisjointInPart (da, (CARD8) (sa >> 0));
-            n = fbCombineDisjointInPart (da, (CARD8) (sa >> 8)) << 8;
-            o = fbCombineDisjointInPart (da, (CARD8) (sa >> 16)) << 16;
-            p = fbCombineDisjointInPart (da, (CARD8) (sa >> 24)) << 24;
-            Fb = m|n|o|p;
-            break;
-        case CombineB:
-            Fb = 0xffffffff;
-            break;
-        }
-        m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
-        n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
-        o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
-        p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
-        s = m|n|o|p;
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineDisjointOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOver);
-}
-
-static FASTCALL void
-fbCombineDisjointInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineAIn);
-}
-
-static FASTCALL void
-fbCombineDisjointInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineDisjointOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineDisjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineDisjointXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineDisjointGeneralC (dest, src, mask, width, CombineXor);
-}
-
-static FASTCALL void
-fbCombineConjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-        CARD32  s, d;
-        CARD32  m,n,o,p;
-        CARD32  Fa, Fb;
-        CARD16  t, u, v;
-        CARD32  sa;
-        CARD8   da;
-
-        s = READ(src + i);
-        m = READ(mask + i);
-        d = READ(dest + i);
-        da = d >> 24;
-
-	fbCombineMaskC (&s, &m);
-
-        sa = m;
-
-        switch (combine & CombineA) {
-        default:
-            Fa = 0;
-            break;
-        case CombineAOut:
-            m = fbCombineConjointOutPart ((CARD8) (sa >> 0), da);
-            n = fbCombineConjointOutPart ((CARD8) (sa >> 8), da) << 8;
-            o = fbCombineConjointOutPart ((CARD8) (sa >> 16), da) << 16;
-            p = fbCombineConjointOutPart ((CARD8) (sa >> 24), da) << 24;
-            Fa = m|n|o|p;
-            break;
-        case CombineAIn:
-            m = fbCombineConjointInPart ((CARD8) (sa >> 0), da);
-            n = fbCombineConjointInPart ((CARD8) (sa >> 8), da) << 8;
-            o = fbCombineConjointInPart ((CARD8) (sa >> 16), da) << 16;
-            p = fbCombineConjointInPart ((CARD8) (sa >> 24), da) << 24;
-            Fa = m|n|o|p;
-            break;
-        case CombineA:
-            Fa = 0xffffffff;
-            break;
-        }
-
-        switch (combine & CombineB) {
-        default:
-            Fb = 0;
-            break;
-        case CombineBOut:
-            m = fbCombineConjointOutPart (da, (CARD8) (sa >> 0));
-            n = fbCombineConjointOutPart (da, (CARD8) (sa >> 8)) << 8;
-            o = fbCombineConjointOutPart (da, (CARD8) (sa >> 16)) << 16;
-            p = fbCombineConjointOutPart (da, (CARD8) (sa >> 24)) << 24;
-            Fb = m|n|o|p;
-            break;
-        case CombineBIn:
-            m = fbCombineConjointInPart (da, (CARD8) (sa >> 0));
-            n = fbCombineConjointInPart (da, (CARD8) (sa >> 8)) << 8;
-            o = fbCombineConjointInPart (da, (CARD8) (sa >> 16)) << 16;
-            p = fbCombineConjointInPart (da, (CARD8) (sa >> 24)) << 24;
-            Fb = m|n|o|p;
-            break;
-        case CombineB:
-            Fb = 0xffffffff;
-            break;
-        }
-        m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
-        n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
-        o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
-        p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
-        s = m|n|o|p;
-        WRITE(dest + i, s);
-    }
-}
-
-static FASTCALL void
-fbCombineConjointOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineAOver);
-}
-
-static FASTCALL void
-fbCombineConjointOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineBOver);
-}
-
-static FASTCALL void
-fbCombineConjointInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineAIn);
-}
-
-static FASTCALL void
-fbCombineConjointInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineBIn);
-}
-
-static FASTCALL void
-fbCombineConjointOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineAOut);
-}
-
-static FASTCALL void
-fbCombineConjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineBOut);
-}
-
-static FASTCALL void
-fbCombineConjointAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineAAtop);
-}
-
-static FASTCALL void
-fbCombineConjointAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineBAtop);
-}
-
-static FASTCALL void
-fbCombineConjointXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
-{
-    fbCombineConjointGeneralC (dest, src, mask, width, CombineXor);
-}
-
-static CombineFuncC fbCombineFuncC[] = {
-    fbCombineClearC,
-    fbCombineSrcC,
-    NULL, /* Dest */
-    fbCombineOverC,
-    fbCombineOverReverseC,
-    fbCombineInC,
-    fbCombineInReverseC,
-    fbCombineOutC,
-    fbCombineOutReverseC,
-    fbCombineAtopC,
-    fbCombineAtopReverseC,
-    fbCombineXorC,
-    fbCombineAddC,
-    fbCombineSaturateC,
-    NULL,
-    NULL,
-    fbCombineClearC,	    /* 0x10 */
-    fbCombineSrcC,
-    NULL, /* Dest */
-    fbCombineDisjointOverC,
-    fbCombineSaturateC, /* DisjointOverReverse */
-    fbCombineDisjointInC,
-    fbCombineDisjointInReverseC,
-    fbCombineDisjointOutC,
-    fbCombineDisjointOutReverseC,
-    fbCombineDisjointAtopC,
-    fbCombineDisjointAtopReverseC,
-    fbCombineDisjointXorC,  /* 0x1b */
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    fbCombineClearC,
-    fbCombineSrcC,
-    NULL, /* Dest */
-    fbCombineConjointOverC,
-    fbCombineConjointOverReverseC,
-    fbCombineConjointInC,
-    fbCombineConjointInReverseC,
-    fbCombineConjointOutC,
-    fbCombineConjointOutReverseC,
-    fbCombineConjointAtopC,
-    fbCombineConjointAtopReverseC,
-    fbCombineConjointXorC,
-};
-
-
-FbComposeFunctions composeFunctions = {
-    fbCombineFuncU,
-    fbCombineFuncC,
-    fbCombineMaskU
-};
-
-
-static void fbFetchSolid(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
-{
-    FbBits *bits;
-    FbStride stride;
-    int bpp;
-    int xoff, yoff;
-    CARD32 color;
-    CARD32 *end;
-    fetchPixelProc fetch = fetchPixelProcForPicture(pict);
-    miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
-
-    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
-    bits += yoff*stride + (xoff*bpp >> FB_SHIFT);
-
-    color = fetch(bits, 0, indexed);
-
-    end = buffer + width;
-    while (buffer < end)
-        WRITE(buffer++, color);
-    fbFinishAccess (pict->pDrawable);
-}
-
-static void fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
-{
-    FbBits *bits;
-    FbStride stride;
-    int bpp;
-    int xoff, yoff;
-    fetchProc fetch = fetchProcForPicture(pict);
-    miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
-
-    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
-    x += xoff;
-    y += yoff;
-
-    bits += y*stride;
-
-    fetch(bits, x, width, buffer, indexed);
-    fbFinishAccess (pict->pDrawable);
-}
-
-#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
-#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :		\
-		  ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
-
-typedef struct
-{
-    CARD32        left_ag;
-    CARD32        left_rb;
-    CARD32        right_ag;
-    CARD32        right_rb;
-    int32_t       left_x;
-    int32_t       right_x;
-    int32_t       stepper;
-    
-    PictGradientStopPtr      stops;
-    int                      num_stops;
-    unsigned int             spread;
-
-    int		  need_reset;
-} GradientWalker;
-
-static void
-_gradient_walker_init (GradientWalker  *walker,
-		       SourcePictPtr    pGradient,
-		       unsigned int     spread)
-{
-    walker->num_stops = pGradient->gradient.nstops;
-    walker->stops     = pGradient->gradient.stops;
-    walker->left_x    = 0;
-    walker->right_x   = 0x10000;
-    walker->stepper   = 0;
-    walker->left_ag   = 0;
-    walker->left_rb   = 0;
-    walker->right_ag  = 0;
-    walker->right_rb  = 0;
-    walker->spread    = spread;
-
-    walker->need_reset = TRUE;
-}
-
-static void
-_gradient_walker_reset (GradientWalker  *walker,
-                        xFixed_32_32     pos)
-{
-    int32_t                  x, left_x, right_x;
-    xRenderColor          *left_c, *right_c;
-    int                      n, count = walker->num_stops;
-    PictGradientStopPtr      stops = walker->stops;
-    
-    static const xRenderColor   transparent_black = { 0, 0, 0, 0 };
-    
-    switch (walker->spread)
-    {
-    case RepeatNormal:
-	x = (int32_t)pos & 0xFFFF;
-	for (n = 0; n < count; n++)
-	    if (x < stops[n].x)
-		break;
-	if (n == 0) {
-	    left_x =  stops[count-1].x - 0x10000;
-	    left_c = &stops[count-1].color;
-	} else {
-	    left_x =  stops[n-1].x;
-	    left_c = &stops[n-1].color;
-	}
-	
-	if (n == count) {
-	    right_x =  stops[0].x + 0x10000;
-	    right_c = &stops[0].color;
-	} else {
-	    right_x =  stops[n].x;
-	    right_c = &stops[n].color;
-	}
-	left_x  += (pos - x);
-	right_x += (pos - x);
-	break;
-	
-    case RepeatPad:
-	for (n = 0; n < count; n++)
-	    if (pos < stops[n].x)
-		break;
-	
-	if (n == 0) {
-	    left_x =  INT_MIN;
-	    left_c = &stops[0].color;
-	} else {
-	    left_x =  stops[n-1].x;
-	    left_c = &stops[n-1].color;
-	}
-	
-	if (n == count) {
-	    right_x =  INT_MAX;
-	    right_c = &stops[n-1].color;
-	} else {
-	    right_x =  stops[n].x;
-	    right_c = &stops[n].color;
-	}
-	break;
-	
-    case RepeatReflect:
-	x = (int32_t)pos & 0xFFFF;
-	if ((int32_t)pos & 0x10000)
-	    x = 0x10000 - x;
-	for (n = 0; n < count; n++)
-	    if (x < stops[n].x)
-		break;
-	
-	if (n == 0) {
-	    left_x =  -stops[0].x;
-	    left_c = &stops[0].color;
-	} else {
-	    left_x =  stops[n-1].x;
-	    left_c = &stops[n-1].color;
-	}
-	
-	if (n == count) {
-	    right_x = 0x20000 - stops[n-1].x;
-	    right_c = &stops[n-1].color;
-	} else {
-	    right_x =  stops[n].x;
-	    right_c = &stops[n].color;
-	}
-	
-	if ((int32_t)pos & 0x10000) {
-	    xRenderColor  *tmp_c;
-	    int32_t          tmp_x;
-	    
-	    tmp_x   = 0x10000 - right_x;
-	    right_x = 0x10000 - left_x;
-	    left_x  = tmp_x;
-	    
-	    tmp_c   = right_c;
-	    right_c = left_c;
-	    left_c  = tmp_c;
-
-	    x = 0x10000 - x;
-	}
-	left_x  += (pos - x);
-	right_x += (pos - x);
-	break;
-	
-    default:  /* RepeatNone */
-	for (n = 0; n < count; n++)
-	    if (pos < stops[n].x)
-		break;
-	
-	if (n == 0)
-	{
-	    left_x  =  INT_MIN;
-	    right_x =  stops[0].x;
-	    left_c  = right_c = (xRenderColor*) &transparent_black;
-	}
-	else if (n == count)
-	{
-	    left_x  = stops[n-1].x;
-	    right_x = INT_MAX;
-	    left_c  = right_c = (xRenderColor*) &transparent_black;
-	}
-	else
-	{
-	    left_x  =  stops[n-1].x;
-	    right_x =  stops[n].x;
-	    left_c  = &stops[n-1].color;
-	    right_c = &stops[n].color;
-	}
-    }
-    
-    walker->left_x   = left_x;
-    walker->right_x  = right_x;
-    walker->left_ag  = ((left_c->alpha >> 8) << 16)   | (left_c->green >> 8);
-    walker->left_rb  = ((left_c->red & 0xff00) << 8)  | (left_c->blue >> 8);
-    walker->right_ag = ((right_c->alpha >> 8) << 16)  | (right_c->green >> 8);
-    walker->right_rb = ((right_c->red & 0xff00) << 8) | (right_c->blue >> 8);
-    
-    if ( walker->left_x == walker->right_x                ||
-	 ( walker->left_ag == walker->right_ag &&
-	   walker->left_rb == walker->right_rb )   )
-    {
-	walker->stepper = 0;
-    }
-    else
-    {
-	int32_t width = right_x - left_x;
-	walker->stepper = ((1 << 24) + width/2)/width;
-    }
-
-    walker->need_reset = FALSE;
-}
-
-#define  GRADIENT_WALKER_NEED_RESET(w,x)				\
-    ( (w)->need_reset || (x) < (w)->left_x || (x) >= (w)->right_x)
-
-
-/* the following assumes that GRADIENT_WALKER_NEED_RESET(w,x) is FALSE */
-static CARD32
-_gradient_walker_pixel (GradientWalker  *walker,
-                        xFixed_32_32     x)
-{
-    int  dist, idist;
-    CARD32  t1, t2, a, color;
-    
-    if (GRADIENT_WALKER_NEED_RESET (walker, x))
-        _gradient_walker_reset (walker, x);
-    
-    dist  = ((int)(x - walker->left_x)*walker->stepper) >> 16;
-    idist = 256 - dist;
-    
-    /* combined INTERPOLATE and premultiply */
-    t1 = walker->left_rb*idist + walker->right_rb*dist;
-    t1 = (t1 >> 8) & 0xff00ff;
-    
-    t2  = walker->left_ag*idist + walker->right_ag*dist;
-    t2 &= 0xff00ff00;
-    
-    color = t2 & 0xff000000;
-    a     = t2 >> 24;
-    
-    t1  = t1*a + 0x800080;
-    t1  = (t1 + ((t1 >> 8) & 0xff00ff)) >> 8;
-    
-    t2  = (t2 >> 8)*a + 0x800080;
-    t2  = (t2 + ((t2 >> 8) & 0xff00ff));
-    
-    return (color | (t1 & 0xff00ff) | (t2 & 0xff00));
-}
-
-static void fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
-{
-     SourcePictPtr   pGradient = pict->pSourcePict;
-     GradientWalker  walker;
-     CARD32         *end = buffer + width;
- 
-     _gradient_walker_init (&walker, pGradient, pict->repeat);
-    
-    if (pGradient->type == SourcePictTypeSolidFill) {
-        register CARD32 color = pGradient->solidFill.color;
-        while (buffer < end) {
-            WRITE(buffer++, color);
-        }
-    } else if (pGradient->type == SourcePictTypeLinear) {
-        PictVector v, unit;
-        xFixed_32_32 l;
-        xFixed_48_16 dx, dy, a, b, off;
-	
-        /* reference point is the center of the pixel */
-        v.vector[0] = IntToxFixed(x) + xFixed1/2;
-        v.vector[1] = IntToxFixed(y) + xFixed1/2;
-        v.vector[2] = xFixed1;
-        if (pict->transform) {
-            if (!PictureTransformPoint3d (pict->transform, &v))
-                return;
-            unit.vector[0] = pict->transform->matrix[0][0];
-            unit.vector[1] = pict->transform->matrix[1][0];
-            unit.vector[2] = pict->transform->matrix[2][0];
-        } else {
-            unit.vector[0] = xFixed1;
-            unit.vector[1] = 0;
-            unit.vector[2] = 0;
-        }
-
-        dx = pGradient->linear.p2.x - pGradient->linear.p1.x;
-        dy = pGradient->linear.p2.y - pGradient->linear.p1.y;
-        l = dx*dx + dy*dy;
-        if (l != 0) {
-            a = (dx << 32) / l;
-            b = (dy << 32) / l;
-            off = (-a*pGradient->linear.p1.x - b*pGradient->linear.p1.y)>>16;
-        }
-        if (l == 0  || (unit.vector[2] == 0 && v.vector[2] == xFixed1)) {
-            xFixed_48_16 inc, t;
-            /* affine transformation only */
-            if (l == 0) {
-                t = 0;
-                inc = 0;
-            } else {
-                t = ((a*v.vector[0] + b*v.vector[1]) >> 16) + off;
-                inc = (a * unit.vector[0] + b * unit.vector[1]) >> 16;
-            }
-
-	    if (pGradient->linear.class == SourcePictClassVertical)
-	    {
-		register CARD32 color;
-
-		color = _gradient_walker_pixel( &walker, t );
-		while (buffer < end)
-		    WRITE(buffer++, color);
-	    }
-	    else
-	    {
-                if (!mask) {
-                    while (buffer < end)
-                    {
-                        WRITE(buffer, _gradient_walker_pixel (&walker, t));
-                        buffer += 1;
-                        t      += inc;
-                    }
-                } else {
-                    while (buffer < end) {
-                        if (*mask++ & maskBits)
-                        {
-                            WRITE(buffer, _gradient_walker_pixel (&walker, t));
-                        }
-                        buffer += 1;
-                        t      += inc;
-                    }
-                }
-	    }
-	}
-	else /* projective transformation */
-	{
-	    xFixed_48_16 t;
-
-	    if (pGradient->linear.class == SourcePictClassVertical)
-	    {
-		register CARD32 color;
-
-		if (v.vector[2] == 0)
-		{
-		    t = 0;
-		}
-		else
-		{
-		    xFixed_48_16 x, y;
-
-		    x = ((xFixed_48_16) v.vector[0] << 16) / v.vector[2];
-		    y = ((xFixed_48_16) v.vector[1] << 16) / v.vector[2];
-		    t = ((a * x + b * y) >> 16) + off;
-		}
-
- 		color = _gradient_walker_pixel( &walker, t );
-		while (buffer < end)
-		    WRITE(buffer++, color);
-	    }
-	    else
-	    {
-		while (buffer < end)
-		{
-		    if (!mask || *mask++ & maskBits)
-		    {
-			if (v.vector[2] == 0) {
-			    t = 0;
-			} else {
-			    xFixed_48_16 x, y;
-			    x = ((xFixed_48_16)v.vector[0] << 16) / v.vector[2];
-			    y = ((xFixed_48_16)v.vector[1] << 16) / v.vector[2];
-			    t = ((a*x + b*y) >> 16) + off;
-			}
-			WRITE(buffer, _gradient_walker_pixel (&walker, t));
-		    }
-		    ++buffer;
-		    v.vector[0] += unit.vector[0];
-		    v.vector[1] += unit.vector[1];
-		    v.vector[2] += unit.vector[2];
-		}
-            }
-        }
-    } else {
-
-/*
- * In the radial gradient problem we are given two circles (c₁,r₁) and
- * (câ‚‚,râ‚‚) that define the gradient itself. Then, for any point p, we
- * must compute the value(s) of t within [0.0, 1.0] representing the
- * circle(s) that would color the point.
- *
- * There are potentially two values of t since the point p can be
- * colored by both sides of the circle, (which happens whenever one
- * circle is not entirely contained within the other).
- *
- * If we solve for a value of t that is outside of [0.0, 1.0] then we
- * use the extend mode (NONE, REPEAT, REFLECT, or PAD) to map to a
- * value within [0.0, 1.0].
- *
- * Here is an illustration of the problem:
- *
- *              pâ‚‚
- *           p  •
- *           •   ╲
- *        ·       ╲r₂
- *  p₁ ·           ╲
- *  •              θ╲
- *   ╲             ╌╌•
- *    ╲r₁        ·   c₂
- *    θ╲    ·
- *    ╌╌•
- *      c₁
- *
- * Given (c₁,r₁), (c₂,r₂) and p, we must find an angle θ such that two
- * points p₁ and p₂ on the two circles are collinear with p. Then, the
- * desired value of t is the ratio of the length of p₁p to the length
- * of p₁p₂.
- *
- * So, we have six unknown values: (p₁x, p₁y), (p₂x, p₂y), θ and t.
- * We can also write six equations that constrain the problem:
- *
- * Point p₁ is a distance r₁ from c₁ at an angle of θ:
- *
- *	1. p₁x = c₁x + r₁·cos θ
- *	2. p₁y = c₁y + r₁·sin θ
- *
- * Point p₂ is a distance r₂ from c₂ at an angle of θ:
- *
- *	3. p₂x = c₂x + r2·cos θ
- *	4. p₂y = c₂y + r2·sin θ
- *
- * Point p lies at a fraction t along the line segment p₁p₂:
- *
- *	5. px = t·p₂x + (1-t)·p₁x
- *	6. py = t·p₂y + (1-t)·p₁y
- *
- * To solve, first subtitute 1-4 into 5 and 6:
- *
- * px = t·(c₂x + r₂·cos θ) + (1-t)·(c₁x + r₁·cos θ)
- * py = t·(c₂y + r₂·sin θ) + (1-t)·(c₁y + r₁·sin θ)
- *
- * Then solve each for cos θ and sin θ expressed as a function of t:
- *
- * cos θ = (-(c₂x - c₁x)·t + (px - c₁x)) / ((r₂-r₁)·t + r₁)
- * sin θ = (-(c₂y - c₁y)·t + (py - c₁y)) / ((r₂-r₁)·t + r₁)
- *
- * To simplify this a bit, we define new variables for several of the
- * common terms as shown below:
- *
- *              pâ‚‚
- *           p  •
- *           •   ╲
- *        ·  ┆    ╲r₂
- *  p₁ ·     ┆     ╲
- *  •     pdy┆      ╲
- *   ╲       ┆       •c₂
- *    ╲r₁    ┆   ·   ┆
- *     ╲    ·┆       ┆cdy
- *      •╌╌╌╌┴╌╌╌╌╌╌╌┘
- *    c₁  pdx   cdx
- *
- * cdx = (c₂x - c₁x)
- * cdy = (c₂y - c₁y)
- *  dr =  r₂-r₁
- * pdx =  px - c₁x
- * pdy =  py - c₁y
- *
- * Note that cdx, cdy, and dr do not depend on point p at all, so can
- * be pre-computed for the entire gradient. The simplifed equations
- * are now:
- *
- * cos θ = (-cdx·t + pdx) / (dr·t + r₁)
- * sin θ = (-cdy·t + pdy) / (dr·t + r₁)
- *
- * Finally, to get a single function of t and eliminate the last
- * unknown θ, we use the identity sin²θ + cos²θ = 1. First, square
- * each equation, (we knew a quadratic was coming since it must be
- * possible to obtain two solutions in some cases):
- *
- * cos²θ = (cdx²t² - 2·cdx·pdx·t + pdx²) / (dr²·t² + 2·r₁·dr·t + r₁²)
- * sin²θ = (cdy²t² - 2·cdy·pdy·t + pdy²) / (dr²·t² + 2·r₁·dr·t + r₁²)
- *
- * Then add both together, set the result equal to 1, and express as a
- * standard quadratic equation in t of the form At² + Bt + C = 0
- *
- * (cdx² + cdy² - dr²)·t² - 2·(cdx·pdx + cdy·pdy + r₁·dr)·t + (pdx² + pdy² - r₁²) = 0
- *
- * In other words:
- *
- * A = cdx² + cdy² - dr²
- * B = -2·(pdx·cdx + pdy·cdy + r₁·dr)
- * C = pdx² + pdy² - r₁²
- *
- * And again, notice that A does not depend on p, so can be
- * precomputed. From here we just use the quadratic formula to solve
- * for t:
- *
- * t = (-2·B ± ⎷(B² - 4·A·C)) / 2·A
- */
-        /* radial or conical */
-        Bool affine = TRUE;
-        double cx = 1.;
-        double cy = 0.;
-        double cz = 0.;
-	double rx = x + 0.5;
-	double ry = y + 0.5;
-        double rz = 1.;
-
-        if (pict->transform) {
-            PictVector v;
-            /* reference point is the center of the pixel */
-            v.vector[0] = IntToxFixed(x) + xFixed1/2;
-            v.vector[1] = IntToxFixed(y) + xFixed1/2;
-            v.vector[2] = xFixed1;
-            if (!PictureTransformPoint3d (pict->transform, &v))
-                return;
-
-            cx = pict->transform->matrix[0][0]/65536.;
-            cy = pict->transform->matrix[1][0]/65536.;
-            cz = pict->transform->matrix[2][0]/65536.;
-            rx = v.vector[0]/65536.;
-            ry = v.vector[1]/65536.;
-            rz = v.vector[2]/65536.;
-            affine = pict->transform->matrix[2][0] == 0 && v.vector[2] == xFixed1;
-        }
-
-        if (pGradient->type == SourcePictTypeRadial) {
-	    PictRadialGradient *radial;
-	    radial = &pGradient->radial;
-            if (affine) {
-                while (buffer < end) {
-		    if (!mask || *mask++ & maskBits)
-		    {
-			double pdx, pdy;
-			double B, C;
-			double det;
-			double c1x = radial->c1.x / 65536.0;
-			double c1y = radial->c1.y / 65536.0;
-			double r1  = radial->c1.radius / 65536.0;
-                        xFixed_48_16 t;
-
-			pdx = rx - c1x;
-			pdy = ry - c1y;
-
-			B = -2 * (  pdx * radial->cdx
-				  + pdy * radial->cdy
-				  + r1 * radial->dr);
-			C = (pdx * pdx + pdy * pdy - r1 * r1);
-
-                        det = (B * B) - (4 * radial->A * C);
-			if (det < 0.0)
-			    det = 0.0;
-
-			if (radial->A < 0)
-			    t = (xFixed_48_16) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
-			else
-			    t = (xFixed_48_16) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
-			
- 			WRITE(buffer, _gradient_walker_pixel (&walker, t));
-		    }
-		    ++buffer;
-		    
-                    rx += cx;
-                    ry += cy;
-                }
-            } else {
-		/* projective */
-                while (buffer < end) {
-		    if (!mask || *mask++ & maskBits)
-		    {
-			double pdx, pdy;
-			double B, C;
-			double det;
-			double c1x = radial->c1.x / 65536.0;
-			double c1y = radial->c1.y / 65536.0;
-			double r1  = radial->c1.radius / 65536.0;
-                        xFixed_48_16 t;
-			double x, y;
-
-			if (rz != 0) {
-			    x = rx/rz;
-			    y = ry/rz;
-			} else {
-			    x = y = 0.;
-			}
-			
-			pdx = x - c1x;
-			pdy = y - c1y;
-
-			B = -2 * (  pdx * radial->cdx
-				  + pdy * radial->cdy
-				  + r1 * radial->dr);
-			C = (pdx * pdx + pdy * pdy - r1 * r1);
-
-                        det = (B * B) - (4 * radial->A * C);
-			if (det < 0.0)
-			    det = 0.0;
-
-			if (radial->A < 0)
-			    t = (xFixed_48_16) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
-			else
-			    t = (xFixed_48_16) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
-			
- 			WRITE(buffer, _gradient_walker_pixel (&walker, t));
-		    }
-		    ++buffer;
-		    
-                    rx += cx;
-                    ry += cy;
-		    rz += cz;
-                }
-            }
-        } else /* SourcePictTypeConical */ {
-            double a = pGradient->conical.angle/(180.*65536);
-            if (affine) {
-                rx -= pGradient->conical.center.x/65536.;
-                ry -= pGradient->conical.center.y/65536.;
-
-                while (buffer < end) {
-		    double angle;
-
-                    if (!mask || *mask++ & maskBits)
-		    {
-                        xFixed_48_16   t;
-			
-                        angle = atan2(ry, rx) + a;
-			t     = (xFixed_48_16) (angle * (65536. / (2*M_PI)));
-			
-			WRITE(buffer, _gradient_walker_pixel (&walker, t));
-		    }
-
-                    ++buffer;
-                    rx += cx;
-                    ry += cy;
-                }
-            } else {
-                while (buffer < end) {
-                    double x, y;
-                    double angle;
-		    
-                    if (!mask || *mask++ & maskBits)
-                    {
-			xFixed_48_16  t;
-			
-			if (rz != 0) {
-			    x = rx/rz;
-			    y = ry/rz;
-			} else {
-			    x = y = 0.;
-			}
-			x -= pGradient->conical.center.x/65536.;
-			y -= pGradient->conical.center.y/65536.;
-			angle = atan2(y, x) + a;
-			t     = (xFixed_48_16) (angle * (65536. / (2*M_PI)));
-			
-			WRITE(buffer, _gradient_walker_pixel (&walker, t));
-		    }
-		    
-                    ++buffer;
-                    rx += cx;
-                    ry += cy;
-                    rz += cz;
-                }
-            }
-        }
-    }
-}
-
-static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
-{
-    FbBits     *bits;
-    FbStride    stride;
-    int         bpp;
-    int         xoff, yoff, dx, dy;
-    fetchPixelProc   fetch;
-    PictVector	v;
-    PictVector  unit;
-    int         i;
-    BoxRec	box;
-    miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
-    Bool affine = TRUE;
-
-    fetch = fetchPixelProcForPicture(pict);
-
-    fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
-    x += xoff;
-    y += yoff;
-
-    dx = pict->pDrawable->x;
-    dy = pict->pDrawable->y;
-
-    /* reference point is the center of the pixel */
-    v.vector[0] = IntToxFixed(x - dx) + xFixed1 / 2;
-    v.vector[1] = IntToxFixed(y - dy) + xFixed1 / 2;
-    v.vector[2] = xFixed1;
-
-    /* when using convolution filters one might get here without a transform */
-    if (pict->transform) {
-        if (!PictureTransformPoint3d (pict->transform, &v)) {
-            fbFinishAccess (pict->pDrawable);
-            return;
-        }
-        unit.vector[0] = pict->transform->matrix[0][0];
-        unit.vector[1] = pict->transform->matrix[1][0];
-        unit.vector[2] = pict->transform->matrix[2][0];
-        affine = v.vector[2] == xFixed1 && unit.vector[2] == 0;
-    } else {
-        unit.vector[0] = xFixed1;
-        unit.vector[1] = 0;
-        unit.vector[2] = 0;
-    }
-
-    if (pict->filter == PictFilterNearest)
-    {
-        if (pict->repeatType == RepeatNormal) {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
-                for (i = 0; i < width; ++i) {
-		    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    if (!affine) {
-				y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
-				x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
-			    } else {
-				y = MOD(v.vector[1]>>16, pict->pDrawable->height);
-				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
-			    }
-			    WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
-			}
-		    }
-
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            } else {
-                for (i = 0; i < width; ++i) {
-		    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    if (!affine) {
-				y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
-				x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
-			    } else {
-				y = MOD(v.vector[1]>>16, pict->pDrawable->height);
-				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
-			    }
-			    if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
-				WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
-			    else
-				WRITE(buffer + i, 0);
-			}
-		    }
-
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            }
-        } else {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
-                box = pict->pCompositeClip->extents;
-                for (i = 0; i < width; ++i) {
-		    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    if (!affine) {
-				y = DIV(v.vector[1],v.vector[2]);
-				x = DIV(v.vector[0],v.vector[2]);
-			    } else {
-				y = v.vector[1]>>16;
-				x = v.vector[0]>>16;
-			    }
-			    WRITE(buffer + i, ((x < box.x1-dx) | (x >= box.x2-dx) | (y < box.y1-dy) | (y >= box.y2-dy)) ?
-				  0 : fetch(bits + (y + dy)*stride, x + dx, indexed));
-			}
-		    }
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            } else {
-                for (i = 0; i < width; ++i) {
-                    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    if (!affine) {
-				y = DIV(v.vector[1],v.vector[2]);
-				x = DIV(v.vector[0],v.vector[2]);
-			    } else {
-				y = v.vector[1]>>16;
-				x = v.vector[0]>>16;
-			    }
-			    if (POINT_IN_REGION (0, pict->pCompositeClip, x + dx, y + dy, &box))
-				WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
-			    else
-				WRITE(buffer + i, 0);
-			}
-		    }
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            }
-        }
-    } else if (pict->filter == PictFilterBilinear) {
-        /* adjust vector for maximum contribution at 0.5, 0.5 of each texel. */
-        v.vector[0] -= v.vector[2] / 2;
-        v.vector[1] -= v.vector[2] / 2;
-        unit.vector[0] -= unit.vector[2] / 2;
-        unit.vector[1] -= unit.vector[2] / 2;
-
-        if (pict->repeatType == RepeatNormal) {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
-                for (i = 0; i < width; ++i) {
-                    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    int x1, x2, y1, y2, distx, idistx, disty, idisty;
-			    FbBits *b;
-			    CARD32 tl, tr, bl, br, r;
-			    CARD32 ft, fb;
-
-			    if (!affine) {
-				xFixed_48_16 div;
-				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-				x1 = div >> 16;
-				distx = ((xFixed)div >> 8) & 0xff;
-				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-				y1 = div >> 16;
-				disty = ((xFixed)div >> 8) & 0xff;
-			    } else {
-				x1 = v.vector[0] >> 16;
-				distx = (v.vector[0] >> 8) & 0xff;
-				y1 = v.vector[1] >> 16;
-				disty = (v.vector[1] >> 8) & 0xff;
-			    }
-			    x2 = x1 + 1;
-			    y2 = y1 + 1;
-
-			    idistx = 256 - distx;
-			    idisty = 256 - disty;
-
-			    x1 = MOD (x1, pict->pDrawable->width);
-			    x2 = MOD (x2, pict->pDrawable->width);
-			    y1 = MOD (y1, pict->pDrawable->height);
-			    y2 = MOD (y2, pict->pDrawable->height);
-
-			    b = bits + (y1 + dy)*stride;
-
-			    tl = fetch(b, x1 + dx, indexed);
-			    tr = fetch(b, x2 + dx, indexed);
-			    b = bits + (y2 + dy)*stride;
-			    bl = fetch(b, x1 + dx, indexed);
-			    br = fetch(b, x2 + dx, indexed);
-
-			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
-			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-			    WRITE(buffer + i, r);
-			}
-		    }
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            } else {
-                for (i = 0; i < width; ++i) {
-		    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    int x1, x2, y1, y2, distx, idistx, disty, idisty;
-			    FbBits *b;
-			    CARD32 tl, tr, bl, br, r;
-			    CARD32 ft, fb;
-
-			    if (!affine) {
-				xFixed_48_16 div;
-				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-				x1 = div >> 16;
-				distx = ((xFixed)div >> 8) & 0xff;
-				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-				y1 = div >> 16;
-				disty = ((xFixed)div >> 8) & 0xff;
-			    } else {
-				x1 = v.vector[0] >> 16;
-				distx = (v.vector[0] >> 8) & 0xff;
-				y1 = v.vector[1] >> 16;
-				disty = (v.vector[1] >> 8) & 0xff;
-			    }
-			    x2 = x1 + 1;
-			    y2 = y1 + 1;
-
-			    idistx = 256 - distx;
-			    idisty = 256 - disty;
-
-			    x1 = MOD (x1, pict->pDrawable->width);
-			    x2 = MOD (x2, pict->pDrawable->width);
-			    y1 = MOD (y1, pict->pDrawable->height);
-			    y2 = MOD (y2, pict->pDrawable->height);
-
-			    b = bits + (y1 + dy)*stride;
-
-			    tl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y1 + dy, &box)
-				? fetch(b, x1 + dx, indexed) : 0;
-			    tr = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y1 + dy, &box)
-				? fetch(b, x2 + dx, indexed) : 0;
-			    b = bits + (y2 + dy)*stride;
-			    bl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y2 + dy, &box)
-				? fetch(b, x1 + dx, indexed) : 0;
-			    br = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y2 + dy, &box)
-				? fetch(b, x2 + dx, indexed) : 0;
-
-			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
-			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-			    WRITE(buffer + i, r);
-			}
-		    }
-
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            }
-        } else {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
-                box = pict->pCompositeClip->extents;
-                for (i = 0; i < width; ++i) {
-		    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
-			    FbBits *b;
-			    CARD32 tl, tr, bl, br, r;
-			    Bool x1_out, x2_out, y1_out, y2_out;
-			    CARD32 ft, fb;
-
-			    if (!affine) {
-				xFixed_48_16 div;
-				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-				x1 = div >> 16;
-				distx = ((xFixed)div >> 8) & 0xff;
-				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-				y1 = div >> 16;
-				disty = ((xFixed)div >> 8) & 0xff;
-			    } else {
-				x1 = v.vector[0] >> 16;
-				distx = (v.vector[0] >> 8) & 0xff;
-				y1 = v.vector[1] >> 16;
-				disty = (v.vector[1] >> 8) & 0xff;
-			    }
-			    x2 = x1 + 1;
-			    y2 = y1 + 1;
-
-			    idistx = 256 - distx;
-			    idisty = 256 - disty;
-
-			    b = bits + (y1 + dy)*stride;
-			    x_off = x1 + dx;
-
-			    x1_out = (x1 < box.x1-dx) | (x1 >= box.x2-dx);
-			    x2_out = (x2 < box.x1-dx) | (x2 >= box.x2-dx);
-			    y1_out = (y1 < box.y1-dy) | (y1 >= box.y2-dy);
-			    y2_out = (y2 < box.y1-dy) | (y2 >= box.y2-dy);
-
-			    tl = x1_out|y1_out ? 0 : fetch(b, x_off, indexed);
-			    tr = x2_out|y1_out ? 0 : fetch(b, x_off + 1, indexed);
-			    b += stride;
-			    bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed);
-			    br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed);
-
-			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
-			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-			    WRITE(buffer + i, r);
-			}
-		    }
-
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            } else {
-                for (i = 0; i < width; ++i) {
-                    if (!mask || mask[i] & maskBits)
-		    {
-			if (!v.vector[2]) {
-			    WRITE(buffer + i, 0);
-			} else {
-			    int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
-			    FbBits *b;
-			    CARD32 tl, tr, bl, br, r;
-			    CARD32 ft, fb;
-
-			    if (!affine) {
-				xFixed_48_16 div;
-				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-				x1 = div >> 16;
-				distx = ((xFixed)div >> 8) & 0xff;
-				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-				y1 = div >> 16;
-				disty = ((xFixed)div >> 8) & 0xff;
-			    } else {
-				x1 = v.vector[0] >> 16;
-				distx = (v.vector[0] >> 8) & 0xff;
-				y1 = v.vector[1] >> 16;
-				disty = (v.vector[1] >> 8) & 0xff;
-			    }
-			    x2 = x1 + 1;
-			    y2 = y1 + 1;
-
-			    idistx = 256 - distx;
-			    idisty = 256 - disty;
-
-			    b = bits + (y1 + dy)*stride;
-			    x_off = x1 + dx;
-
-			    tl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y1 + dy, &box)
-				? fetch(b, x_off, indexed) : 0;
-			    tr = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y1 + dy, &box)
-				? fetch(b, x_off + 1, indexed) : 0;
-			    b += stride;
-			    bl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y2 + dy, &box)
-				? fetch(b, x_off, indexed) : 0;
-			    br = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y2 + dy, &box)
-				? fetch(b, x_off + 1, indexed) : 0;
-
-			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
-			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-			    WRITE(buffer + i, r);
-			}
-		    }
-
-                    v.vector[0] += unit.vector[0];
-                    v.vector[1] += unit.vector[1];
-                    v.vector[2] += unit.vector[2];
-                }
-            }
-        }
-    } else if (pict->filter == PictFilterConvolution) {
-        xFixed *params = pict->filter_params;
-        INT32 cwidth = xFixedToInt(params[0]);
-        INT32 cheight = xFixedToInt(params[1]);
-        int xoff = (params[0] - xFixed1) >> 1;
-	int yoff = (params[1] - xFixed1) >> 1;
-        params += 2;
-        for (i = 0; i < width; ++i) {
-	    if (!mask || mask[i] & maskBits)
-	    {
-		if (!v.vector[2]) {
-		    WRITE(buffer + i, 0);
-		} else {
-		    int x1, x2, y1, y2, x, y;
-		    INT32 srtot, sgtot, sbtot, satot;
-		    xFixed *p = params;
-
-		    if (!affine) {
-			xFixed_48_16 tmp;
-			tmp = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2] - xoff;
-			x1 = xFixedToInt(tmp);
-			tmp = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2] - yoff;
-			y1 = xFixedToInt(tmp);
-		    } else {
-			x1 = xFixedToInt(v.vector[0] - xoff);
-			y1 = xFixedToInt(v.vector[1] - yoff);
-		    }
-		    x2 = x1 + cwidth;
-		    y2 = y1 + cheight;
-
-		    srtot = sgtot = sbtot = satot = 0;
-
-		    for (y = y1; y < y2; y++) {
-			int ty = (pict->repeatType == RepeatNormal) ? MOD (y, pict->pDrawable->height) : y;
-			for (x = x1; x < x2; x++) {
-			    if (*p) {
-				int tx = (pict->repeatType == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x;
-				if (POINT_IN_REGION (0, pict->pCompositeClip, tx + dx, ty + dy, &box)) {
-				    FbBits *b = bits + (ty + dy)*stride;
-				    CARD32 c = fetch(b, tx + dx, indexed);
-
-				    srtot += Red(c) * *p;
-				    sgtot += Green(c) * *p;
-				    sbtot += Blue(c) * *p;
-				    satot += Alpha(c) * *p;
-				}
-			    }
-			    p++;
-			}
-		    }
-
-		    satot >>= 16;
-		    srtot >>= 16;
-		    sgtot >>= 16;
-		    sbtot >>= 16;
-
-		    if (satot < 0) satot = 0; else if (satot > 0xff) satot = 0xff;
-		    if (srtot < 0) srtot = 0; else if (srtot > 0xff) srtot = 0xff;
-		    if (sgtot < 0) sgtot = 0; else if (sgtot > 0xff) sgtot = 0xff;
-		    if (sbtot < 0) sbtot = 0; else if (sbtot > 0xff) sbtot = 0xff;
-
-		    WRITE(buffer + i, ((satot << 24) |
-				       (srtot << 16) |
-				       (sgtot <<  8) |
-				       (sbtot       )));
-		}
-	    }
-            v.vector[0] += unit.vector[0];
-            v.vector[1] += unit.vector[1];
-            v.vector[2] += unit.vector[2];
-        }
-    }
-
-    fbFinishAccess (pict->pDrawable);
-}
-
-
-static void fbFetchExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
-{
-    int i;
-    CARD32 _alpha_buffer[SCANLINE_BUFFER_LENGTH];
-    CARD32 *alpha_buffer = _alpha_buffer;
-
-    if (!pict->alphaMap) {
-        fbFetchTransformed(pict, x, y, width, buffer, mask, maskBits);
-	return;
-    }
-    if (width > SCANLINE_BUFFER_LENGTH)
-        alpha_buffer = (CARD32 *) malloc(width*sizeof(CARD32));
-
-    fbFetchTransformed(pict, x, y, width, buffer, mask, maskBits);
-    fbFetchTransformed(pict->alphaMap, x - pict->alphaOrigin.x,
-		       y - pict->alphaOrigin.y, width, alpha_buffer,
-		       mask, maskBits);
-    for (i = 0; i < width; ++i) {
-        if (!mask || mask[i] & maskBits)
-	{
-	    int a = alpha_buffer[i]>>24;
-	    WRITE(buffer + i, (a << 24)
-		  | (div_255(Red(READ(buffer + i)) * a) << 16)
-		  | (div_255(Green(READ(buffer + i)) * a) << 8)
-		  | (div_255(Blue(READ(buffer + i)) * a)));
-	}
-    }
-
-    if (alpha_buffer != _alpha_buffer)
-        free(alpha_buffer);
-}
-
-static void fbStore(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
-{
-    FbBits *bits;
-    FbStride stride;
-    int bpp;
-    int xoff, yoff;
-    storeProc store = storeProcForPicture(pict);
-    miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
-
-    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
-    x += xoff;
-    y += yoff;
-
-    bits += y*stride;
-    store(bits, buffer, x, width, indexed);
-    fbFinishAccess (pict->pDrawable);
-}
-
-static void fbStoreExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
-{
-    FbBits *bits, *alpha_bits;
-    FbStride stride, astride;
-    int bpp, abpp;
-    int xoff, yoff;
-    int ax, ay;
-    storeProc store;
-    storeProc astore;
-    miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
-    miIndexedPtr aindexed;
-
-    if (!pict->alphaMap) {
-        fbStore(pict, x, y, width, buffer);
-	return;
-    }
-
-    store = storeProcForPicture(pict);
-    astore = storeProcForPicture(pict->alphaMap);
-    aindexed = (miIndexedPtr) pict->alphaMap->pFormat->index.devPrivate;
-
-    ax = x;
-    ay = y;
-
-    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
-    x += xoff;
-    y += yoff;
-    fbGetDrawable (pict->alphaMap->pDrawable, alpha_bits, astride, abpp, xoff, yoff);
-    ax += xoff;
-    ay += yoff;
-
-    bits       += y*stride;
-    alpha_bits += (ay - pict->alphaOrigin.y)*astride;
-
-
-    store(bits, buffer, x, width, indexed);
-    astore(alpha_bits, buffer, ax - pict->alphaOrigin.x, width, aindexed);
-
-    fbFinishAccess (pict->alphaMap->pDrawable);
-    fbFinishAccess (pict->pDrawable);
-}
-
-typedef void (*scanStoreProc)(PicturePtr , int , int , int , CARD32 *);
-typedef void (*scanFetchProc)(PicturePtr , int , int , int , CARD32 * , CARD32 *, CARD32);
-
-#if 0
-void
-fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer)
-{
-    CARD32 *src_buffer = scanline_buffer;
-    CARD32 *dest_buffer = src_buffer + data->width;
-    int i;
-    scanStoreProc store;
-    scanFetchProc fetchSrc = NULL, fetchMask = NULL, fetchDest = NULL;
-    unsigned int srcClass = SourcePictClassUnknown;
-    unsigned int maskClass = SourcePictClassUnknown;
-    FbBits *bits;
-    FbStride stride;
-    int xoff, yoff;
-    
-    if (data->op == PictOpClear)
-        fetchSrc = NULL;
-    else if (!data->src->pDrawable) {
-        if (data->src->pSourcePict)
-	{
-            fetchSrc = fbFetchSourcePict;
-	    srcClass = SourcePictureClassify (data->src,
-					      data->xSrc, data->ySrc,
-					      data->width, data->height);
-	}
-    } else if (data->src->alphaMap)
-        fetchSrc = fbFetchExternalAlpha;
-    else if (data->src->repeatType == RepeatNormal &&
-             data->src->pDrawable->width == 1 && data->src->pDrawable->height == 1)
-    {
-        fetchSrc = fbFetchSolid;
-	srcClass = SourcePictClassHorizontal;
-    }
-    else if (!data->src->transform && data->src->filter != PictFilterConvolution)
-        fetchSrc = fbFetch;
-    else
-        fetchSrc = fbFetchTransformed;
-    
-    if (data->mask && data->op != PictOpClear) {
-        if (!data->mask->pDrawable) {
-            if (data->mask->pSourcePict)
-                fetchMask = fbFetchSourcePict;
-        } else if (data->mask->alphaMap)
-	{
-            fetchMask = fbFetchExternalAlpha;
-	    maskClass = SourcePictureClassify (data->mask,
-					       data->xMask, data->yMask,
-					       data->width, data->height);
-	}
-        else if (data->mask->repeatType == RepeatNormal
-                 && data->mask->pDrawable->width == 1 && data->mask->pDrawable->height == 1)
-	{
-	    fetchMask = fbFetchSolid;
-	    maskClass = SourcePictClassHorizontal;
-	}
-        else if (!data->mask->transform && data->mask->filter != PictFilterConvolution)
-            fetchMask = fbFetch;
-        else
-            fetchMask = fbFetchTransformed;
-    } else {
-        fetchMask = NULL;
-    }
-    
-    if (data->dest->alphaMap)
-    {
-	fetchDest = fbFetchExternalAlpha;
-	store = fbStoreExternalAlpha;
-	
-	if (data->op == PictOpClear || data->op == PictOpSrc)
-	    fetchDest = NULL;
-    }
-    else
-    {
-	fetchDest = fbFetch;
-	store = fbStore;
-	
-	switch (data->op) {
-	case PictOpClear:
-	case PictOpSrc:
-	    fetchDest = NULL;
-	    /* fall-through */
-	case PictOpAdd:
-	case PictOpOver:
-	    switch (data->dest->format) {
-	    case PICT_a8r8g8b8:
-	    case PICT_x8r8g8b8:
-		store = NULL;
-		break;
-	    default:
-		break;
-	    }
-	    break;
-	}
-    }
-    
-    if (!store)
-    {
-	int bpp;
-	
-	fbGetDrawable (data->dest->pDrawable, bits, stride, bpp, xoff, yoff);
-    }
-    else
-    {
-	bits = NULL;
-	stride = 0;
-	xoff = yoff = 0;
-    }
-    
-    if (fetchSrc		   &&
-	fetchMask		   &&
-	data->mask		   &&
-	data->mask->componentAlpha &&
-	PICT_FORMAT_RGB (data->mask->format))
-    {
-	CARD32 *mask_buffer = dest_buffer + data->width;
-	CombineFuncC compose = composeFunctions.combineC[data->op];
-	if (!compose)
-	    return;
-	
-	for (i = 0; i < data->height; ++i) {
-	    /* fill first half of scanline with source */
-	    if (fetchSrc)
-	    {
-		if (fetchMask)
-		{
-		    /* fetch mask before source so that fetching of
-		       source can be optimized */
-		    fetchMask (data->mask, data->xMask, data->yMask + i,
-			       data->width, mask_buffer, 0, 0);
-		    
-		    if (maskClass == SourcePictClassHorizontal)
-			fetchMask = NULL;
-		}
-		
-		if (srcClass == SourcePictClassHorizontal)
-		{
-		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
-			      data->width, src_buffer, 0, 0);
-		    fetchSrc = NULL;
-		}
-		else
-		{
-		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
-			      data->width, src_buffer, mask_buffer,
-			      0xffffffff);
-		}
-	    }
-	    else if (fetchMask)
-	    {
-		fetchMask (data->mask, data->xMask, data->yMask + i,
-			   data->width, mask_buffer, 0, 0);
-	    }
-	    
-	    if (store)
-	    {
-		/* fill dest into second half of scanline */
-		if (fetchDest)
-		    fetchDest (data->dest, data->xDest, data->yDest + i,
-			       data->width, dest_buffer, 0, 0);
-		
-		/* blend */
-		compose (dest_buffer, src_buffer, mask_buffer, data->width);
-		
-		/* write back */
-		store (data->dest, data->xDest, data->yDest + i, data->width,
-		       dest_buffer);
-	    }
-	    else
-	    {
-		/* blend */
-		compose (bits + (data->yDest + i+ yoff) * stride +
-			 data->xDest + xoff,
-			 src_buffer, mask_buffer, data->width);
-	    }
-	}
-    }
-    else
-    {
-	CARD32 *src_mask_buffer = 0, *mask_buffer = 0;
-	CombineFuncU compose = composeFunctions.combineU[data->op];
-	if (!compose)
-	    return;
-	
-	if (fetchMask)
-	    mask_buffer = dest_buffer + data->width;
-	
-	for (i = 0; i < data->height; ++i) {
-	    /* fill first half of scanline with source */
-	    if (fetchSrc)
-	    {
-		if (fetchMask)
-		{
-		    /* fetch mask before source so that fetching of
-		       source can be optimized */
-		    fetchMask (data->mask, data->xMask, data->yMask + i,
-			       data->width, mask_buffer, 0, 0);
-		    
-		    if (maskClass == SourcePictClassHorizontal)
-			fetchMask = NULL;
-		}
-		
-		if (srcClass == SourcePictClassHorizontal)
-		{
-		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
-			      data->width, src_buffer, 0, 0);
-		    
-		    if (mask_buffer)
-		    {
-			fbCombineInU (mask_buffer, src_buffer, data->width);
-			src_mask_buffer = mask_buffer;
-		    }
-		    else
-			src_mask_buffer = src_buffer;
-		    
-		    fetchSrc = NULL;
-		}
-		else
-		{
-		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
-			      data->width, src_buffer, mask_buffer,
-			      0xff000000);
-		    
-		    if (mask_buffer)
-			composeFunctions.combineMaskU (src_buffer,
-						       mask_buffer,
-						       data->width);
-		    
-		    src_mask_buffer = src_buffer;
-		}
-	    }
-	    else if (fetchMask)
-	    {
-		fetchMask (data->mask, data->xMask, data->yMask + i,
-			   data->width, mask_buffer, 0, 0);
-		
-		fbCombineInU (mask_buffer, src_buffer, data->width);
-		
-		src_mask_buffer = mask_buffer;
-	    }
-	    
-	    if (store)
-	    {
-		/* fill dest into second half of scanline */
-		if (fetchDest)
-		    fetchDest (data->dest, data->xDest, data->yDest + i,
-			       data->width, dest_buffer, 0, 0);
-		
-		/* blend */
-		compose (dest_buffer, src_mask_buffer, data->width);
-		
-		/* write back */
-		store (data->dest, data->xDest, data->yDest + i, data->width,
-		       dest_buffer);
-	    }
-	    else
-	    {
-		/* blend */
-		compose (bits + (data->yDest + i+ yoff) * stride +
-			 data->xDest + xoff,
-			 src_mask_buffer, data->width);
-	    }
-	}
-    }
-
-    if (!store)
-	fbFinishAccess (data->dest->pDrawable);
-}
-#endif
-
-void
-fbCompositeGeneral (CARD8	op,
-		    PicturePtr	pSrc,
-		    PicturePtr	pMask,
-		    PicturePtr	pDst,
-		    INT16	xSrc,
-		    INT16	ySrc,
-		    INT16	xMask,
-		    INT16	yMask,
-		    INT16	xDst,
-		    INT16	yDst,
-		    CARD16	width,
-		    CARD16	height)
-{
-    return fbComposite (op, pSrc, pMask, pDst,
-			xSrc, ySrc, xMask, yMask, xDst, yDst,
-			width, height);
-}
-
-#endif
diff --git a/fb/fbpict.c b/fb/fbpict.c
index fc335ed..324d9b2 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1183,50 +1183,6 @@ out:
 	pixman_image_unref (dest);
 }    
 
-#if 0
-#define SCANLINE_BUFFER_LENGTH 2048
-
-static void
-oldfbCompositeRectWrapper  (CARD8	   op,
-			 PicturePtr pSrc,
-			 PicturePtr pMask,
-			 PicturePtr pDst,
-			 INT16      xSrc,
-			 INT16      ySrc,
-			 INT16      xMask,
-			 INT16      yMask,
-			 INT16      xDst,
-			 INT16      yDst,
-			 CARD16     width,
-			 CARD16     height)
-{
-    CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
-    CARD32 *scanline_buffer = _scanline_buffer;
-    FbComposeData data;
-
-    data.op = op;
-    data.src = pSrc;
-    data.mask = pMask;
-    data.dest = pDst;
-    data.xSrc = xSrc;
-    data.ySrc = ySrc;
-    data.xMask = xMask;
-    data.yMask = yMask;
-    data.xDest = xDst;
-    data.yDest = yDst;
-    data.width = width;
-    data.height = height;
-
-    if (width > SCANLINE_BUFFER_LENGTH)
-        scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32));
-
-    fbCompositeRect (&data, scanline_buffer);
-
-    if (scanline_buffer != _scanline_buffer)
-	free(scanline_buffer);
-}
-#endif
-
 void
 fbWalkCompositeRegion (CARD8 op,
 		       PicturePtr pSrc,
@@ -1932,6 +1888,25 @@ fbComposite (CARD8      op,
 			   srcRepeat, maskRepeat, func);
 }
 
+void
+fbCompositeGeneral (CARD8	op,
+		    PicturePtr	pSrc,
+		    PicturePtr	pMask,
+		    PicturePtr	pDst,
+		    INT16	xSrc,
+		    INT16	ySrc,
+		    INT16	xMask,
+		    INT16	yMask,
+		    INT16	xDst,
+		    INT16	yDst,
+		    CARD16	width,
+		    CARD16	height)
+{
+    return fbComposite (op, pSrc, pMask, pDst,
+			xSrc, ySrc, xMask, yMask, xDst, yDst,
+			width, height);
+}
+
 #endif /* RENDER */
 
 Bool
diff-tree a2e3614eb8f0fa198615df492b03ff36bc9c1121 (from c5ef84c325440af5fbdf9f44c3781d99a0392df9)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Fri May 18 11:33:11 2007 -0400

    Break image_from_pict() into a few subfunctions.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 4034a16..fc335ed 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -931,218 +931,222 @@ fbCompositeSrcSrc_nxn  (CARD8	   op,
     fbFinishAccess(pDst->pDrawable);
 }
 
-/*
- * Solid fill
-void
-fbCompositeSolidSrc_nxn  (CARD8	op,
-			  PicturePtr pSrc,
-			  PicturePtr pMask,
-			  PicturePtr pDst,
-			  INT16      xSrc,
-			  INT16      ySrc,
-			  INT16      xMask,
-			  INT16      yMask,
-			  INT16      xDst,
-			  INT16      yDst,
-			  CARD16     width,
-			  CARD16     height)
+static pixman_image_t *
+create_solid_fill_image (PicturePtr pict)
 {
+    PictSolidFill *solid = &pict->pSourcePict->solidFill;
+    pixman_color_t color;
+    CARD32 a, r, g, b;
+    
+    a = (solid->color & 0xff000000) >> 24;
+    r = (solid->color & 0x00ff0000) >> 16;
+    g = (solid->color & 0x0000ff00) >>  8;
+    b = (solid->color & 0x000000ff) >>  0;
     
+    color.alpha = (a << 8) | a;
+    color.red =   (r << 8) | r;
+    color.green = (g << 8) | g;
+    color.blue =  (b << 8) | b;
+    
+    return pixman_image_create_solid_fill (&color);
 }
- */
-
-#define SCANLINE_BUFFER_LENGTH 2048
 
 static pixman_image_t *
-image_from_pict (PicturePtr pict)
+create_linear_gradient_image (PictGradient *gradient)
 {
-    pixman_image_t *result = NULL;
-
-    if (!pict)
-	return NULL;
+    PictLinearGradient *linear = (PictLinearGradient *)gradient;
+    pixman_point_fixed_t p1;
+    pixman_point_fixed_t p2;
     
-    if (pict->pSourcePict)
-    {
-	SourcePictPtr sp = pict->pSourcePict;
-	
-	if (sp->type == SourcePictTypeSolidFill)
-	{
-	    PictSolidFill *solid = &pict->pSourcePict->solidFill;
-	    pixman_color_t color;
-	    CARD32 a, r, g, b;
-
-	    a = (solid->color & 0xff000000) >> 24;
-	    r = (solid->color & 0x00ff0000) >> 16;
-	    g = (solid->color & 0x0000ff00) >>  8;
-	    b = (solid->color & 0x000000ff) >>  0;
-
-	    color.alpha = (a << 8) | a;
-	    color.red =   (r << 8) | r;
-	    color.green = (g << 8) | g;
-	    color.blue =  (b << 8) | b;
-	    
-	    result = pixman_image_create_solid_fill (&color);
-	}
-	else
-	{
-	    PictGradient *gradient = &pict->pSourcePict->gradient;
-
-	    if (sp->type == SourcePictTypeLinear)
-	    {
-		PictLinearGradient *linear = &pict->pSourcePict->linear;
-		pixman_point_fixed_t p1;
-		pixman_point_fixed_t p2;
-
-		p1.x = linear->p1.x;
-		p1.y = linear->p1.y;
-		p2.x = linear->p2.x;
-		p2.y = linear->p2.y;
-		
-		result = pixman_image_create_linear_gradient (
-		    &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
-	    }
-	    else if (sp->type == SourcePictTypeRadial)
-	    {
-		PictRadialGradient *radial = &pict->pSourcePict->radial;
-		
-		pixman_point_fixed_t c1;
-		pixman_point_fixed_t c2;
-
-		c1.x = radial->c1.x;
-		c1.y = radial->c1.y;
-		c2.x = radial->c2.x;
-		c2.y = radial->c2.y;
-		
-		result = pixman_image_create_radial_gradient (
-		    &c1, &c2, radial->c1.radius,
-		    radial->c2.radius,
-		    (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
-	    }
-	    else if (sp->type == SourcePictTypeConical)
-	    {
-		PictConicalGradient *conical = &pict->pSourcePict->conical;
-		pixman_point_fixed_t center;
-
-		center.x = conical->center.x;
-		center.y = conical->center.y;
-		
-		result = pixman_image_create_conical_gradient (
-		    &center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
-		    gradient->nstops);
-	    }
-	    else
-	    {
-		/* Shouldn't happen */
-		result = NULL;
-	    }
-	}
-    }
-    else if (pict->pDrawable)
-    {
-	FbBits *bits;
-	FbStride stride;
-	int bpp, xoff, yoff;
-
-	fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+    p1.x = linear->p1.x;
+    p1.y = linear->p1.y;
+    p2.x = linear->p2.x;
+    p2.y = linear->p2.y;
+    
+    return pixman_image_create_linear_gradient (
+	&p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
 
-	bits += yoff * stride + xoff;
-	
-	result = pixman_image_create_bits (
-	    pict->format,
-	    pict->pDrawable->width, pict->pDrawable->height,
-	    (uint32_t *)bits, stride * sizeof (FbStride));
+static pixman_image_t *
+create_radial_gradient_image (PictGradient *gradient)
+{
+    PictRadialGradient *radial = (PictRadialGradient *)gradient;
+    pixman_point_fixed_t c1;
+    pixman_point_fixed_t c2;
+    
+    c1.x = radial->c1.x;
+    c1.y = radial->c1.y;
+    c2.x = radial->c2.x;
+    c2.y = radial->c2.y;
+    
+    return pixman_image_create_radial_gradient (
+	&c1, &c2, radial->c1.radius,
+	radial->c2.radius,
+	(pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+}
 
+static pixman_image_t *
+create_conical_gradient_image (PictGradient *gradient)
+{
+    PictConicalGradient *conical = (PictConicalGradient *)gradient;
+    pixman_point_fixed_t center;
+    
+    center.x = conical->center.x;
+    center.y = conical->center.y;
+    
+    return pixman_image_create_conical_gradient (
+	&center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
+	gradient->nstops);
+}
 
+static pixman_image_t *
+create_bits_picture (PicturePtr pict)
+{
+    FbBits *bits;
+    FbStride stride;
+    int bpp, xoff, yoff;
+    pixman_image_t *image;
+    
+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+    
+    bits += yoff * stride + xoff;
+    
+    image = pixman_image_create_bits (
+	pict->format,
+	pict->pDrawable->width, pict->pDrawable->height,
+	(uint32_t *)bits, stride * sizeof (FbStride));
+    
+    
 #ifdef FB_ACCESS_WRAPPER
 #if FB_SHIFT==5
-	
-	pixman_image_set_accessors (
-	    result,
-	    (pixman_read_memory_func_t)wfbReadMemory,
-	    (pixman_write_memory_func_t)wfbWriteMemory);
+    
+    pixman_image_set_accessors (image,
+				(pixman_read_memory_func_t)wfbReadMemory,
+				(pixman_write_memory_func_t)wfbWriteMemory);
+    
 #else
-
-#error The pixman library only works with sizeof (FbBits) == 5
-
+    
+#error The pixman library only works when FbBits is 32 bits wide
+    
 #endif
 #endif
-	
-	/* pCompositeClip is undefined for source pictures, so
-	 * only set the clip region for pictures with drawables
-	 */
-	pixman_image_set_clip_region (
-	    result, pict->pCompositeClip);
+    
+    /* pCompositeClip is undefined for source pictures, so
+     * only set the clip region for pictures with drawables
+     */
+    pixman_image_set_clip_region (image, pict->pCompositeClip);
+    
+    fbFinishAccess (pict->pDrawable);
+
+    return image;
+}
+
+static pixman_image_t *image_from_pict (PicturePtr pict);
 
-	fbFinishAccess (pict->pDrawable);
+static void
+set_image_properties (pixman_image_t *image, PicturePtr pict)
+{
+    pixman_repeat_t repeat;
+    pixman_filter_t filter;
+    
+    if (pict->transform)
+    {
+	pixman_image_set_transform (
+	    image, (pixman_transform_t *)pict->transform);
+    }
+    
+    switch (pict->repeatType)
+    {
+    default:
+    case RepeatNone:
+	repeat = PIXMAN_REPEAT_NONE;
+	break;
+	
+    case RepeatPad:
+	repeat = PIXMAN_REPEAT_PAD;
+	break;
+	
+    case RepeatNormal:
+	repeat = PIXMAN_REPEAT_NORMAL;
+	break;
+	
+    case RepeatReflect:
+	repeat = PIXMAN_REPEAT_REFLECT;
+	break;
+    }
+    
+    pixman_image_set_repeat (image, repeat);
+    
+    if (pict->alphaMap)
+    {
+	pixman_image_t *alpha_map = image_from_pict (pict->alphaMap);
+	
+	pixman_image_set_alpha_map (
+	    image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
+	
+	pixman_image_unref (alpha_map);
     }
+    
+    pixman_image_set_component_alpha (image, pict->componentAlpha);
 
-    if (result)
+    switch (pict->filter)
     {
-	pixman_repeat_t repeat;
-	pixman_filter_t filter;
+    default:
+    case PictFilterNearest:
+    case PictFilterFast:
+	filter = PIXMAN_FILTER_NEAREST;
+	break;
 	
-	if (pict->transform)
-	{
-	    pixman_image_set_transform (
-		result, (pixman_transform_t *)pict->transform);
-	}
+    case PictFilterBilinear:
+    case PictFilterGood:
+	filter = PIXMAN_FILTER_BILINEAR;
+	break;
+	
+    case PictFilterConvolution:
+	filter = PIXMAN_FILTER_CONVOLUTION;
+	break;
+    }
+    
+    pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
+}
 
-	switch (pict->repeatType)
-	{
-	default:
-	case RepeatNone:
-	    repeat = PIXMAN_REPEAT_NONE;
-	    break;
-
-	case RepeatPad:
-	    repeat = PIXMAN_REPEAT_PAD;
-	    break;
-
-	case RepeatNormal:
-	    repeat = PIXMAN_REPEAT_NORMAL;
-	    break;
-
-	case RepeatReflect:
-	    repeat = PIXMAN_REPEAT_REFLECT;
-	    break;
-	}
+static pixman_image_t *
+image_from_pict (PicturePtr pict)
+{
+    pixman_image_t *image = NULL;
 
-	pixman_image_set_repeat (result, repeat);
+    if (!pict)
+	return NULL;
 
-	if (pict->alphaMap)
+    if (pict->pDrawable)
+    {
+	image = create_bits_picture (pict);
+    }
+    else if (pict->pSourcePict)
+    {
+	SourcePict *sp = pict->pSourcePict;
+	
+	if (sp->type == SourcePictTypeSolidFill)
 	{
-	    pixman_image_t *alpha_map = image_from_pict (pict->alphaMap);
-
-	    pixman_image_set_alpha_map (
-		result, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
-
-	    pixman_image_unref (alpha_map);
+	    image = create_solid_fill_image (pict);
 	}
-
-	pixman_image_set_component_alpha (result, pict->componentAlpha);
-
-	switch (pict->filter)
+	else
 	{
-	default:
-	case PictFilterNearest:
-	case PictFilterFast:
-	    filter = PIXMAN_FILTER_NEAREST;
-	    break;
-
-	case PictFilterBilinear:
-	case PictFilterGood:
-	    filter = PIXMAN_FILTER_BILINEAR;
-	    break;
-
-	case PictFilterConvolution:
-	    filter = PIXMAN_FILTER_CONVOLUTION;
-	    break;
+	    PictGradient *gradient = &pict->pSourcePict->gradient;
+	    
+	    if (sp->type == SourcePictTypeLinear)
+		image = create_linear_gradient_image (gradient);
+	    else if (sp->type == SourcePictTypeRadial)
+		image = create_radial_gradient_image (gradient);
+	    else if (sp->type == SourcePictTypeConical)
+		image = create_conical_gradient_image (gradient);
 	}
-
-	pixman_image_set_filter (result, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
     }
     
-    return result;
+    if (image)
+	set_image_properties (image, pict);
+    
+    return image;
 }
 
 static void
@@ -1180,6 +1184,8 @@ out:
 }    
 
 #if 0
+#define SCANLINE_BUFFER_LENGTH 2048
+
 static void
 oldfbCompositeRectWrapper  (CARD8	   op,
 			 PicturePtr pSrc,
diff-tree c5ef84c325440af5fbdf9f44c3781d99a0392df9 (from 076d070e186afeb416976ae74fbfd50c86db10c5)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Thu May 17 21:31:08 2007 -0400

    Make the general compositing code create a pixman image and call
    
    pixman_image_composite(). Leave the general code commented out for now.

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 465f7d3..0e64de0 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -1553,7 +1553,6 @@ fbCombineSrcU (CARD32 *dest, const CARD3
     MEMCPY_WRAPPED(dest, src, width*sizeof(CARD32));
 }
 
-
 static FASTCALL void
 fbCombineOverU (CARD32 *dest, const CARD32 *src, int width)
 {
@@ -4028,6 +4027,7 @@ static void fbStoreExternalAlpha(Picture
 typedef void (*scanStoreProc)(PicturePtr , int , int , int , CARD32 *);
 typedef void (*scanFetchProc)(PicturePtr , int , int , int , CARD32 * , CARD32 *, CARD32);
 
+#if 0
 void
 fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer)
 {
@@ -4294,6 +4294,7 @@ fbCompositeRect (const FbComposeData *da
     if (!store)
 	fbFinishAccess (data->dest->pDrawable);
 }
+#endif
 
 void
 fbCompositeGeneral (CARD8	op,
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 1146e99..4034a16 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1,6 +1,7 @@
 /*
  *
  * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2007 Red Hat, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -29,6 +30,7 @@
 #include <string.h>
 
 #include "fb.h"
+#include <pixman/pixman.h>
 
 #ifdef RENDER
 
@@ -950,7 +952,199 @@ fbCompositeSolidSrc_nxn  (CARD8	op,
  */
 
 #define SCANLINE_BUFFER_LENGTH 2048
- 
+
+static pixman_image_t *
+image_from_pict (PicturePtr pict)
+{
+    pixman_image_t *result = NULL;
+
+    if (!pict)
+	return NULL;
+    
+    if (pict->pSourcePict)
+    {
+	SourcePictPtr sp = pict->pSourcePict;
+	
+	if (sp->type == SourcePictTypeSolidFill)
+	{
+	    PictSolidFill *solid = &pict->pSourcePict->solidFill;
+	    pixman_color_t color;
+	    CARD32 a, r, g, b;
+
+	    a = (solid->color & 0xff000000) >> 24;
+	    r = (solid->color & 0x00ff0000) >> 16;
+	    g = (solid->color & 0x0000ff00) >>  8;
+	    b = (solid->color & 0x000000ff) >>  0;
+
+	    color.alpha = (a << 8) | a;
+	    color.red =   (r << 8) | r;
+	    color.green = (g << 8) | g;
+	    color.blue =  (b << 8) | b;
+	    
+	    result = pixman_image_create_solid_fill (&color);
+	}
+	else
+	{
+	    PictGradient *gradient = &pict->pSourcePict->gradient;
+
+	    if (sp->type == SourcePictTypeLinear)
+	    {
+		PictLinearGradient *linear = &pict->pSourcePict->linear;
+		pixman_point_fixed_t p1;
+		pixman_point_fixed_t p2;
+
+		p1.x = linear->p1.x;
+		p1.y = linear->p1.y;
+		p2.x = linear->p2.x;
+		p2.y = linear->p2.y;
+		
+		result = pixman_image_create_linear_gradient (
+		    &p1, &p2, (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+	    }
+	    else if (sp->type == SourcePictTypeRadial)
+	    {
+		PictRadialGradient *radial = &pict->pSourcePict->radial;
+		
+		pixman_point_fixed_t c1;
+		pixman_point_fixed_t c2;
+
+		c1.x = radial->c1.x;
+		c1.y = radial->c1.y;
+		c2.x = radial->c2.x;
+		c2.y = radial->c2.y;
+		
+		result = pixman_image_create_radial_gradient (
+		    &c1, &c2, radial->c1.radius,
+		    radial->c2.radius,
+		    (pixman_gradient_stop_t *)gradient->stops, gradient->nstops);
+	    }
+	    else if (sp->type == SourcePictTypeConical)
+	    {
+		PictConicalGradient *conical = &pict->pSourcePict->conical;
+		pixman_point_fixed_t center;
+
+		center.x = conical->center.x;
+		center.y = conical->center.y;
+		
+		result = pixman_image_create_conical_gradient (
+		    &center, conical->angle, (pixman_gradient_stop_t *)gradient->stops,
+		    gradient->nstops);
+	    }
+	    else
+	    {
+		/* Shouldn't happen */
+		result = NULL;
+	    }
+	}
+    }
+    else if (pict->pDrawable)
+    {
+	FbBits *bits;
+	FbStride stride;
+	int bpp, xoff, yoff;
+
+	fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+
+	bits += yoff * stride + xoff;
+	
+	result = pixman_image_create_bits (
+	    pict->format,
+	    pict->pDrawable->width, pict->pDrawable->height,
+	    (uint32_t *)bits, stride * sizeof (FbStride));
+
+
+#ifdef FB_ACCESS_WRAPPER
+#if FB_SHIFT==5
+	
+	pixman_image_set_accessors (
+	    result,
+	    (pixman_read_memory_func_t)wfbReadMemory,
+	    (pixman_write_memory_func_t)wfbWriteMemory);
+#else
+
+#error The pixman library only works with sizeof (FbBits) == 5
+
+#endif
+#endif
+	
+	/* pCompositeClip is undefined for source pictures, so
+	 * only set the clip region for pictures with drawables
+	 */
+	pixman_image_set_clip_region (
+	    result, pict->pCompositeClip);
+
+	fbFinishAccess (pict->pDrawable);
+    }
+
+    if (result)
+    {
+	pixman_repeat_t repeat;
+	pixman_filter_t filter;
+	
+	if (pict->transform)
+	{
+	    pixman_image_set_transform (
+		result, (pixman_transform_t *)pict->transform);
+	}
+
+	switch (pict->repeatType)
+	{
+	default:
+	case RepeatNone:
+	    repeat = PIXMAN_REPEAT_NONE;
+	    break;
+
+	case RepeatPad:
+	    repeat = PIXMAN_REPEAT_PAD;
+	    break;
+
+	case RepeatNormal:
+	    repeat = PIXMAN_REPEAT_NORMAL;
+	    break;
+
+	case RepeatReflect:
+	    repeat = PIXMAN_REPEAT_REFLECT;
+	    break;
+	}
+
+	pixman_image_set_repeat (result, repeat);
+
+	if (pict->alphaMap)
+	{
+	    pixman_image_t *alpha_map = image_from_pict (pict->alphaMap);
+
+	    pixman_image_set_alpha_map (
+		result, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
+
+	    pixman_image_unref (alpha_map);
+	}
+
+	pixman_image_set_component_alpha (result, pict->componentAlpha);
+
+	switch (pict->filter)
+	{
+	default:
+	case PictFilterNearest:
+	case PictFilterFast:
+	    filter = PIXMAN_FILTER_NEAREST;
+	    break;
+
+	case PictFilterBilinear:
+	case PictFilterGood:
+	    filter = PIXMAN_FILTER_BILINEAR;
+	    break;
+
+	case PictFilterConvolution:
+	    filter = PIXMAN_FILTER_CONVOLUTION;
+	    break;
+	}
+
+	pixman_image_set_filter (result, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
+    }
+    
+    return result;
+}
+
 static void
 fbCompositeRectWrapper  (CARD8	   op,
 			 PicturePtr pSrc,
@@ -965,6 +1159,41 @@ fbCompositeRectWrapper  (CARD8	   op,
 			 CARD16     width,
 			 CARD16     height)
 {
+    pixman_image_t *src = image_from_pict (pSrc);
+    pixman_image_t *dest = image_from_pict (pDst);
+    pixman_image_t *mask = image_from_pict (pMask);
+
+    if (!src || !dest || (pMask && !mask))
+	goto out;
+
+    pixman_image_composite_rect (op, src, mask, dest,
+				 xSrc, ySrc, xMask, yMask, xDst, yDst,
+				 width, height);
+    
+out:
+    if (src)
+	pixman_image_unref (src);
+    if (mask)
+	pixman_image_unref (mask);
+    if (dest)
+	pixman_image_unref (dest);
+}    
+
+#if 0
+static void
+oldfbCompositeRectWrapper  (CARD8	   op,
+			 PicturePtr pSrc,
+			 PicturePtr pMask,
+			 PicturePtr pDst,
+			 INT16      xSrc,
+			 INT16      ySrc,
+			 INT16      xMask,
+			 INT16      yMask,
+			 INT16      xDst,
+			 INT16      yDst,
+			 CARD16     width,
+			 CARD16     height)
+{
     CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
     CARD32 *scanline_buffer = _scanline_buffer;
     FbComposeData data;
@@ -990,6 +1219,7 @@ fbCompositeRectWrapper  (CARD8	   op,
     if (scanline_buffer != _scanline_buffer)
 	free(scanline_buffer);
 }
+#endif
 
 void
 fbWalkCompositeRegion (CARD8 op,
@@ -1030,7 +1260,7 @@ fbWalkCompositeRegion (CARD8 op,
     if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc, ySrc,
 				   xMask, yMask, xDst, yDst, width, height))
         return;
-
+    
     n = REGION_NUM_RECTS (&region);
     pbox = REGION_RECTS (&region);
     while (n--)
diff-tree 076d070e186afeb416976ae74fbfd50c86db10c5 (from 915563eba530c5e2fdc2456cf1c7c3cc09b3add0)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu May 17 20:24:18 2007 -0700

    Use Screen block handler for rotation to draw under DRI lock.
    
    DRI uses a non-screen block/wakeup handler which will be executed after the
    screen block handler finishes. To ensure that the rotation block handler is
    executed under the DRI lock, dynamically wrap the screen block handler for
    rotation.

diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 0c019e0..2d62600 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -562,6 +562,10 @@ typedef struct _xf86CrtcConfig {
     OptionInfoPtr	options;
 
     Bool		debug_modes;
+
+    /* wrap screen BlockHandler for rotation */
+    ScreenBlockHandlerProcPtr	BlockHandler;
+
 } xf86CrtcConfigRec, *xf86CrtcConfigPtr;
 
 extern int xf86CrtcConfigPrivateIndex;
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 359501e..1379939 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -264,7 +264,7 @@ xf86RotatePrepare (ScreenPtr pScreen)
     }
 }
 
-static void
+static Bool
 xf86RotateRedisplay(ScreenPtr pScreen)
 {
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
@@ -273,7 +273,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
     RegionPtr		region;
 
     if (!damage)
-	return;
+	return FALSE;
     xf86RotatePrepare (pScreen);
     region = DamageRegion(damage);
     if (REGION_NOTEMPTY(pScreen, region)) 
@@ -317,19 +317,25 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 	pScreen->SourceValidate = SourceValidate;
 	DamageEmpty(damage);
     }
+    return TRUE;
 }
 
 static void
-xf86RotateBlockHandler(pointer data, OSTimePtr pTimeout, pointer pRead)
+xf86RotateBlockHandler(int screenNum, pointer blockData,
+		       pointer pTimeout, pointer pReadmask)
 {
-    ScreenPtr pScreen = (ScreenPtr) data;
-
-    xf86RotateRedisplay(pScreen);
-}
+    ScreenPtr		pScreen = screenInfo.screens[screenNum];
+    ScrnInfoPtr		pScrn = xf86Screens[screenNum];
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 
-static void
-xf86RotateWakeupHandler(pointer data, int i, pointer LastSelectMask)
-{
+    pScreen->BlockHandler = xf86_config->BlockHandler;
+    (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
+    if (xf86RotateRedisplay(pScreen))
+    {
+	/* Re-wrap if rotation is still happening */
+	xf86_config->BlockHandler = pScreen->BlockHandler;
+	pScreen->BlockHandler = xf86RotateBlockHandler;
+    }
 }
 
 static void
@@ -367,10 +373,6 @@ xf86RotateDestroy (xf86CrtcPtr crtc)
 	}
 	DamageDestroy (xf86_config->rotation_damage);
 	xf86_config->rotation_damage = NULL;
-	/* Free block/wakeup handler */
-	RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler,
-				      xf86RotateWakeupHandler,
-				      (pointer) pScreen);
     }
 }
 
@@ -440,20 +442,12 @@ xf86CrtcRotate (xf86CrtcPtr crtc, Displa
 	    if (!xf86_config->rotation_damage)
 		goto bail2;
 	    
-	    /* Assign block/wakeup handler */
-	    if (!RegisterBlockAndWakeupHandlers (xf86RotateBlockHandler,
-						 xf86RotateWakeupHandler,
-						 (pointer) pScreen))
-	    {
-		goto bail3;
-	    }
+	    /* Wrap block handler */
+	    xf86_config->BlockHandler = pScreen->BlockHandler;
+	    pScreen->BlockHandler = xf86RotateBlockHandler;
 	}
 	if (0)
 	{
-bail3:
-	    DamageDestroy (xf86_config->rotation_damage);
-	    xf86_config->rotation_damage = NULL;
-	    
 bail2:
 	    if (shadow || shadowData)
 	    {
diff-tree 915563eba530c5e2fdc2456cf1c7c3cc09b3add0 (from 0375009a97c2ab7f0e0f0265463d45c0580388c6)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu May 17 20:22:43 2007 -0700

    Disable all outputs and crtcs at startup.
    
    Leaving devices enabled during server startup can cause problems during the
    initial mode setting in the server, especially when they are used for
    different purposes by the X server than by the BIOS. Disabling all of them
    before any mode setting is attempted provides a stable base upon which the
    remaining mode setting operations can be built.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 00ec56c..88c31af 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1723,8 +1723,26 @@ Bool
 xf86SetDesiredModes (ScrnInfoPtr scrn)
 {
     xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(scrn);
-    int			c;
+    int			c, o;
+
+    /*
+     * Turn off everything so mode setting is done
+     * with hardware in a consistent state
+     */
+    for (o = 0; o < config->num_output; o++) 
+    {
+	xf86OutputPtr  output = config->output[o];
+	(*output->funcs->dpms)(output, DPMSModeOff);
+    }
 
+    for (c = 0; c < config->num_crtc; c++) 
+    {
+	xf86CrtcPtr crtc = config->crtc[c];
+
+	crtc->funcs->dpms(crtc, DPMSModeOff);
+	memset(&crtc->mode, 0, sizeof(crtc->mode));
+    }
+    
     for (c = 0; c < config->num_crtc; c++)
     {
 	xf86CrtcPtr	crtc = config->crtc[c];
diff-tree 0375009a97c2ab7f0e0f0265463d45c0580388c6 (from 546465ee6aa6584780aec6357f32d205c807ae71)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Thu May 17 12:59:24 2007 -0400

    Remove excessive unrolling in fbCompositeSrc_x888x8x8888() and fix bug where
    the source alpha was used instead of 0xff.

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index a322bec..8a132f6 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -295,6 +295,14 @@ in (__m64 src,
     return pix_multiply (src, mask);
 }
 
+static inline __m64
+in_over_full_src_alpha (__m64 src, __m64 mask, __m64 dest)
+{
+    src = _mm_or_si64 (src, MC(full_alpha));
+
+    return over(in (src, mask), mask, dest);
+}
+
 #ifndef _MSC_VER
 static inline __m64
 in_over (__m64 src,
@@ -1299,7 +1307,7 @@ fbCompositeSrc_x888x8x8888mmx (CARD8	op,
 
 	while (w && (unsigned long)dst & 7)
 	{
-	    __m64 s = load8888 (*src);
+	    __m64 s = load8888 (*src | 0xff000000);
 	    __m64 d = load8888 (*dst);
 
 	    *dst = store8888 (in_over (s, srca, vmask, d));
@@ -1309,75 +1317,26 @@ fbCompositeSrc_x888x8x8888mmx (CARD8	op,
 	    src++;
 	}
 
-	while (w >= 16)
+	while (w >= 2)
 	{
-	    __m64 vd0 = *(__m64 *)(dst + 0);
-	    __m64 vd1 = *(__m64 *)(dst + 2);
-	    __m64 vd2 = *(__m64 *)(dst + 4);
-	    __m64 vd3 = *(__m64 *)(dst + 6);
-	    __m64 vd4 = *(__m64 *)(dst + 8);
-	    __m64 vd5 = *(__m64 *)(dst + 10);
-	    __m64 vd6 = *(__m64 *)(dst + 12);
-	    __m64 vd7 = *(__m64 *)(dst + 14);
-
-	    __m64 vs0 = *(__m64 *)(src + 0);
-	    __m64 vs1 = *(__m64 *)(src + 2);
-	    __m64 vs2 = *(__m64 *)(src + 4);
-	    __m64 vs3 = *(__m64 *)(src + 6);
-	    __m64 vs4 = *(__m64 *)(src + 8);
-	    __m64 vs5 = *(__m64 *)(src + 10);
-	    __m64 vs6 = *(__m64 *)(src + 12);
-	    __m64 vs7 = *(__m64 *)(src + 14);
+	    
+	    __m64 vd0 = *(__m64 *)(dst);
+	    __m64 vs0 = *(__m64 *)(src);
 
 	    vd0 = pack8888 (
-		in_over (expand8888 (vs0, 0), srca, vmask, expand8888 (vd0, 0)),
-		in_over (expand8888 (vs0, 1), srca, vmask, expand8888 (vd0, 1)));
+		in_over_full_src_alpha (expand8888 (vs0, 0), vmask, expand8888 (vd0, 0)),
+		in_over_full_src_alpha (expand8888 (vs0, 1), vmask, expand8888 (vd0, 1)));
+
+	    *(__m64 *)(dst) = vd0;
 
-	    vd1 = pack8888 (
-		in_over (expand8888 (vs1, 0), srca, vmask, expand8888 (vd1, 0)),
-		in_over (expand8888 (vs1, 1), srca, vmask, expand8888 (vd1, 1)));
-
-	    vd2 = pack8888 (
-		in_over (expand8888 (vs2, 0), srca, vmask, expand8888 (vd2, 0)),
-		in_over (expand8888 (vs2, 1), srca, vmask, expand8888 (vd2, 1)));
-
-	    vd3 = pack8888 (
-		in_over (expand8888 (vs3, 0), srca, vmask, expand8888 (vd3, 0)),
-		in_over (expand8888 (vs3, 1), srca, vmask, expand8888 (vd3, 1)));
-
-	    vd4 = pack8888 (
-		in_over (expand8888 (vs4, 0), srca, vmask, expand8888 (vd4, 0)),
-		in_over (expand8888 (vs4, 1), srca, vmask, expand8888 (vd4, 1)));
-
-	    vd5 = pack8888 (
-		in_over (expand8888 (vs5, 0), srca, vmask, expand8888 (vd5, 0)),
-		in_over (expand8888 (vs5, 1), srca, vmask, expand8888 (vd5, 1)));
-
-	    vd6 = pack8888 (
-		in_over (expand8888 (vs6, 0), srca, vmask, expand8888 (vd6, 0)),
-		in_over (expand8888 (vs6, 1), srca, vmask, expand8888 (vd6, 1)));
-
-	    vd7 = pack8888 (
-		in_over (expand8888 (vs7, 0), srca, vmask, expand8888 (vd7, 0)),
-		in_over (expand8888 (vs7, 1), srca, vmask, expand8888 (vd7, 1)));
-
-	    *(__m64 *)(dst + 0) = vd0;
-	    *(__m64 *)(dst + 2) = vd1;
-	    *(__m64 *)(dst + 4) = vd2;
-	    *(__m64 *)(dst + 6) = vd3;
-	    *(__m64 *)(dst + 8) = vd4;
-	    *(__m64 *)(dst + 10) = vd5;
-	    *(__m64 *)(dst + 12) = vd6;
-	    *(__m64 *)(dst + 14) = vd7;
-
-	    w -= 16;
-	    dst += 16;
-	    src += 16;
+	    w -= 2;
+	    dst += 2;
+	    src += 2;
 	}
 
 	while (w)
 	{
-	    __m64 s = load8888 (*src);
+	    __m64 s = load8888 (*src | 0xff000000);
 	    __m64 d = load8888 (*dst);
 
 	    *dst = store8888 (in_over (s, srca, vmask, d));
diff-tree 546465ee6aa6584780aec6357f32d205c807ae71 (from 0fcd17c9181901c419cc32bc24c07fe5a6934d81)
Author: Soren Sandmann Pedersen <sandmann at redhat.com>
Date:   Wed May 16 17:42:04 2007 -0400

    Make fbFetch_b8g8r8() actually write the read value to the buffer

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index dd2a2f0..465f7d3 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -180,6 +180,7 @@ fbFetch_b8g8r8 (const FbBits *bits, int 
         b |= (READ(pixel++) << 8);
         b |= (READ(pixel++));
 #endif
+	WRITE(buffer++, b);
     }
 }
 
diff-tree 0fcd17c9181901c419cc32bc24c07fe5a6934d81 (from f4c1d5fc28a5a7fe2592505350f9e2331f6049b7)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue May 15 17:59:13 2007 -0400

    Use pixman short formats, revert the gradient_stop change

diff --git a/render/picture.h b/render/picture.h
index fc50387..1719587 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -36,12 +36,7 @@ typedef struct _Picture		*PicturePtr;
  * sample implementation allows only packed RGB and GBR
  * representations for data to simplify software rendering,
  */
-#define PICT_FORMAT(bpp,type,a,r,g,b)	(((bpp) << 24) |  \
-					 ((type) << 16) | \
-					 ((a) << 12) | \
-					 ((r) << 8) | \
-					 ((g) << 4) | \
-					 ((b)))
+#define PICT_FORMAT(bpp,type,a,r,g,b)	PIXMAN_FORMAT(bpp, type, a, r, g, b)
 
 /*
  * gray/color formats use a visual index instead of argb
@@ -50,77 +45,77 @@ typedef struct _Picture		*PicturePtr;
 					 ((type) << 16) | \
 					 ((vi)))
 
-#define PICT_FORMAT_BPP(f)	(((f) >> 24)       )
-#define PICT_FORMAT_TYPE(f)	(((f) >> 16) & 0xff)
-#define PICT_FORMAT_A(f)	(((f) >> 12) & 0x0f)
-#define PICT_FORMAT_R(f)	(((f) >>  8) & 0x0f)
-#define PICT_FORMAT_G(f)	(((f) >>  4) & 0x0f)
-#define PICT_FORMAT_B(f)	(((f)      ) & 0x0f)
-#define PICT_FORMAT_RGB(f)	(((f)      ) & 0xfff)
-#define PICT_FORMAT_VIS(f)	(((f)      ) & 0xffff)
-
-#define PICT_TYPE_OTHER	0
-#define PICT_TYPE_A	1
-#define PICT_TYPE_ARGB	2
-#define PICT_TYPE_ABGR	3
-#define PICT_TYPE_COLOR	4
-#define PICT_TYPE_GRAY	5
+#define PICT_FORMAT_BPP(f)	PIXMAN_FORMAT_BPP(f)
+#define PICT_FORMAT_TYPE(f)	PIXMAN_FORMAT_TYPE(f)
+#define PICT_FORMAT_A(f)	PIXMAN_FORMAT_A(f)
+#define PICT_FORMAT_R(f)	PIXMAN_FORMAT_R(f)
+#define PICT_FORMAT_G(f)	PIXMAN_FORMAT_G(f)
+#define PICT_FORMAT_B(f)	PIXMAN_FORMAT_B(f)
+#define PICT_FORMAT_RGB(f)	PIXMAN_FORMAT_RGB(f)
+#define PICT_FORMAT_VIS(f)	PIXMAN_FORMAT_VIS(f)
+
+#define PICT_TYPE_OTHER		PIXMAN_TYPE_OTHER
+#define PICT_TYPE_A		PIXMAN_TYPE_A
+#define PICT_TYPE_ARGB		PIXMAN_TYPE_ARGB
+#define PICT_TYPE_ABGR		PIXMAN_TYPE_ABGR
+#define PICT_TYPE_COLOR		PIXMAN_TYPE_COLOR
+#define PICT_TYPE_GRAY		PIXMAN_TYPE_GRAY
 
-#define PICT_FORMAT_COLOR(f)	(PICT_FORMAT_TYPE(f) & 2)
+#define PICT_FORMAT_COLOR(f)	PIXMAN_FORMAT_COLOR(f)
 
 /* 32bpp formats */
 typedef enum _PictFormatShort {
-   PICT_a8r8g8b8 =	PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8),
-   PICT_x8r8g8b8 =	PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8),
-   PICT_a8b8g8r8 =	PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8),
-   PICT_x8b8g8r8 =	PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8),
+    PICT_a8r8g8b8 =	PIXMAN_a8r8g8b8,
+    PICT_x8r8g8b8 =	PIXMAN_x8r8g8b8,
+    PICT_a8b8g8r8 =	PIXMAN_a8b8g8r8,
+    PICT_x8b8g8r8 =	PIXMAN_x8b8g8r8,
 
 /* 24bpp formats */
-   PICT_r8g8b8 =	PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8),
-   PICT_b8g8r8 =	PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8),
+    PICT_r8g8b8 =	PIXMAN_r8g8b8,
+    PICT_b8g8r8 =	PIXMAN_b8g8r8,
 
 /* 16bpp formats */
-   PICT_r5g6b5 =	PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5),
-   PICT_b5g6r5 =	PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5),
+    PICT_r5g6b5 =	PIXMAN_r5g6b5,
+    PICT_b5g6r5 =	PIXMAN_b5g6r5,
 
-   PICT_a1r5g5b5 =	PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5),
-   PICT_x1r5g5b5 =	PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5),
-   PICT_a1b5g5r5 =	PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5),
-   PICT_x1b5g5r5 =	PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5),
-   PICT_a4r4g4b4 =	PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4),
-   PICT_x4r4g4b4 =	PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4),
-   PICT_a4b4g4r4 =	PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4),
-   PICT_x4b4g4r4 =	PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4),
+    PICT_a1r5g5b5 =	PIXMAN_a1r5g5b5,
+    PICT_x1r5g5b5 =	PIXMAN_x1r5g5b5,
+    PICT_a1b5g5r5 =	PIXMAN_a1b5g5r5,
+    PICT_x1b5g5r5 =	PIXMAN_x1b5g5r5,
+    PICT_a4r4g4b4 =	PIXMAN_a4r4g4b4,
+    PICT_x4r4g4b4 =	PIXMAN_x4r4g4b4,
+    PICT_a4b4g4r4 =	PIXMAN_a4b4g4r4,
+    PICT_x4b4g4r4 =	PIXMAN_x4b4g4r4,
 
 /* 8bpp formats */
-   PICT_a8 =		PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0),
-   PICT_r3g3b2 =	PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2),
-   PICT_b2g3r3 =	PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2),
-   PICT_a2r2g2b2 =	PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2),
-   PICT_a2b2g2r2 =	PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2),
+    PICT_a8 =		PIXMAN_a8,
+    PICT_r3g3b2 =	PIXMAN_r3g3b2,
+    PICT_b2g3r3 =	PIXMAN_b2g3r3,
+    PICT_a2r2g2b2 =	PIXMAN_a2r2g2b2,
+    PICT_a2b2g2r2 =	PIXMAN_a2b2g2r2,
 
-   PICT_c8 =		PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0),
-   PICT_g8 =		PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0),
+    PICT_c8 =		PIXMAN_c8,
+    PICT_g8 =		PIXMAN_g8,
 
-   PICT_x4a4 =		PICT_FORMAT(8,PICT_TYPE_A,4,0,0,0),
+    PICT_x4a4 =		PIXMAN_x4a4,
 				    
-   PICT_x4c4 =		PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0),
-   PICT_x4g4 =		PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0),
+    PICT_x4c4 =		PIXMAN_x4c4,
+    PICT_x4g4 =		PIXMAN_x4g4,
 
 /* 4bpp formats */
-   PICT_a4 =		PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0),
-   PICT_r1g2b1 =	PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1),
-   PICT_b1g2r1 =	PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1),
-   PICT_a1r1g1b1 =	PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1),
-   PICT_a1b1g1r1 =	PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1),
+    PICT_a4 =		PIXMAN_a4,
+    PICT_r1g2b1 =	PIXMAN_r1g2b1,
+    PICT_b1g2r1 =	PIXMAN_b1g2r1,
+    PICT_a1r1g1b1 =	PIXMAN_a1r1g1b1,
+    PICT_a1b1g1r1 =	PIXMAN_a1b1g1r1,
 				    
-   PICT_c4 =		PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0),
-   PICT_g4 =		PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0),
+    PICT_c4 =		PIXMAN_c4,
+    PICT_g4 =		PIXMAN_g4,
 
 /* 1bpp formats */
-   PICT_a1 =		PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0),
+    PICT_a1 =		PIXMAN_a1,
 
-   PICT_g1 =		PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0),
+    PICT_g1 =		PIXMAN_g1,
 } PictFormatShort;
 
 /*
diff --git a/render/picturestr.h b/render/picturestr.h
index 9259cad..9c41fc1 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -73,7 +73,10 @@ typedef struct _PictSolidFill {
     CARD32 color;
 } PictSolidFill, *PictSolidFillPtr;
 
-typedef struct pixman_gradient_stop PictGradientStop, *PictGradientStopPtr;
+typedef struct _PictGradientStop {
+    xFixed x;
+    xRenderColor color;
+} PictGradientStop, *PictGradientStopPtr;
 
 typedef struct _PictGradient {
     unsigned int type;
diff-tree f4c1d5fc28a5a7fe2592505350f9e2331f6049b7 (from f2e30e7d0a1d075e7e83c5b5ceca9e4752951138)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue May 15 17:12:22 2007 -0400

    Use pixman types for transforms and vectors

diff --git a/render/picturestr.h b/render/picturestr.h
index 6268768..9259cad 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -54,13 +54,8 @@ typedef struct _PictFormat {
     IndexFormatRec  index;
 } PictFormatRec;
 
-typedef struct _PictVector {
-    xFixed	    vector[3];
-} PictVector, *PictVectorPtr;
-
-typedef struct _PictTransform {
-    xFixed	    matrix[3][3];
-} PictTransform, *PictTransformPtr;
+typedef struct pixman_vector PictVector, *PictVectorPtr;
+typedef struct pixman_transform PictTransform, *PictTransformPtr;
 
 #define PICT_GRADIENT_STOPTABLE_SIZE 1024
 #define SourcePictTypeSolidFill 0
@@ -78,10 +73,7 @@ typedef struct _PictSolidFill {
     CARD32 color;
 } PictSolidFill, *PictSolidFillPtr;
 
-typedef struct _PictGradientStop {
-    xFixed x;
-    xRenderColor color;
-} PictGradientStop, *PictGradientStopPtr;
+typedef struct pixman_gradient_stop PictGradientStop, *PictGradientStopPtr;
 
 typedef struct _PictGradient {
     unsigned int type;
diff-tree f2e30e7d0a1d075e7e83c5b5ceca9e4752951138 (from 3da842bf930d7875599ca0c06cb4a09cfa987ac5)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue May 15 16:51:21 2007 -0400

    Use the pixman fixed point types and macros

diff --git a/render/picture.c b/render/picture.c
index 2022175..d0ae326 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -1879,9 +1879,6 @@ AddTraps (PicturePtr	pPicture,
     (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps);
 }
 
-#define MAX_FIXED_48_16	    ((xFixed_48_16) 0x7fffffff)
-#define MIN_FIXED_48_16	    (-((xFixed_48_16) 1 << 31))
-
 _X_EXPORT Bool
 PictureTransformPoint3d (PictTransformPtr transform,
                          PictVectorPtr	vector)
diff --git a/render/picture.h b/render/picture.h
index 1b62234..fc50387 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -25,6 +25,8 @@
 #ifndef _PICTURE_H_
 #define _PICTURE_H_
 
+#include <pixman/pixman.h>
+
 typedef struct _DirectFormat	*DirectFormatPtr;
 typedef struct _PictFormat	*PictFormatPtr;
 typedef struct _Picture		*PicturePtr;
@@ -171,54 +173,35 @@ extern int	RenderClientPrivateIndex;
 
 /* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
 
-#if defined(WIN32) && !defined(__GNUC__)
-typedef __int64		xFixed_32_32;
-#else
-#  if defined (_LP64) || \
-      defined(__alpha__) || defined(__alpha) || \
-      defined(ia64) || defined(__ia64__) || \
-      defined(__sparc64__) || \
-      defined(__s390x__) || \
-      defined(amd64) || defined (__amd64__) || \
-      (defined(sgi) && (_MIPS_SZLONG == 64))
-typedef long		xFixed_32_32;
-# else
-#  if defined(__GNUC__) && \
-    ((__GNUC__ > 2) || \
-     ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
-__extension__
-#  endif
-typedef long long int	xFixed_32_32;
-# endif
-#endif
-
-typedef xFixed_32_32	xFixed_48_16;
-
-#define MAX_FIXED_48_16	    ((xFixed_48_16) 0x7fffffff)
-#define MIN_FIXED_48_16	    (-((xFixed_48_16) 1 << 31))
-
-typedef CARD32		xFixed_1_31;
-typedef CARD32		xFixed_1_16;
-typedef INT32		xFixed_16_16;
+typedef pixman_fixed_32_32_t	xFixed_32_32;
+
+typedef pixman_fixed_48_16_t	xFixed_48_16;
+
+#define MAX_FIXED_48_16		pixman_max_fixed_48_16
+#define MIN_FIXED_48_16		pixman_min_fixed_48_16
+
+typedef pixman_fixed_1_31_t	xFixed_1_31;
+typedef pixman_fixed_1_16_t	xFixed_1_16;
+typedef pixman_fixed_16_16_t	xFixed_16_16;
 
 /*
  * An unadorned "xFixed" is the same as xFixed_16_16, 
  * (since it's quite common in the code) 
  */
-typedef	xFixed_16_16	xFixed;
+typedef	pixman_fixed_t	xFixed;
 #define XFIXED_BITS	16
 
-#define xFixedToInt(f)	(int) ((f) >> XFIXED_BITS)
-#define IntToxFixed(i)	((xFixed) (i) << XFIXED_BITS)
-#define xFixedE		((xFixed) 1)
-#define xFixed1		(IntToxFixed(1))
-#define xFixed1MinusE	(xFixed1 - xFixedE)
-#define xFixedFrac(f)	((f) & xFixed1MinusE)
-#define xFixedFloor(f)	((f) & ~xFixed1MinusE)
-#define xFixedCeil(f)	xFixedFloor((f) + xFixed1MinusE)
+#define xFixedToInt(f)	pixman_fixed_to_int(f)
+#define IntToxFixed(i)	pixman_int_to_fixed(i)
+#define xFixedE		pixman_fixed_e
+#define xFixed1		pixman_fixed_1
+#define xFixed1MinusE	pixman_fixed_1_minus_e
+#define xFixedFrac(f)	pixman_fixed_frac(f)
+#define xFixedFloor(f)	pixman_fixed_floor(f)
+#define xFixedCeil(f)	pixman_fixed_ceil(f)
 
-#define xFixedFraction(f)	((f) & xFixed1MinusE)
-#define xFixedMod2(f)		((f) & (xFixed1 | xFixed1MinusE))
+#define xFixedFraction(f)	pixman_fixed_fraction(f)
+#define xFixedMod2(f)		pixman_fixed_mod2(f)
 
 /* whether 't' is a well defined not obviously empty trapezoid */
 #define xTrapezoidValid(t)  ((t)->left.p1.y != (t)->left.p2.y && \
diff-tree 3da842bf930d7875599ca0c06cb4a09cfa987ac5 (from 1568b6b6a0d7337f29c7b87cc46ae64b3b0f8fdf)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue May 15 14:57:14 2007 -0400

    Revert various fast path functions to their pre-pixman-merge state
    since they fail rendercheck. Remove their associated macros.
    
    See bug 10903.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 7d94d00..1146e99 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -78,64 +78,6 @@ fbIn (CARD32 x, CARD8 y)
     return m|n|o|p;
 }
 
-#define genericCombine24(a,b,c,d) (((a)*(c)+(b)*(d)))
-
-/*
- * This macro does src IN mask OVER dst when src and dst are 0888.
- * If src has alpha, this will not work
- */
-#define inOver0888(alpha, source, destval, dest) { \
- 	CARD32 dstrb=destval&0xFF00FF; CARD32 dstag=(destval>>8)&0xFF00FF; \
- 	CARD32 drb=((source&0xFF00FF)-dstrb)*alpha; CARD32 dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \
-	WRITE(dest, ((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00))); \
-    }
-
-/*
- * This macro does src IN mask OVER dst when src and dst are 0565 and
- * mask is a 5-bit alpha value.  Again, if src has alpha, this will not
- * work.
- */
-#define inOver0565(alpha, source, destval, dest) { \
- 	CARD16 dstrb = destval & 0xf81f; CARD16 dstg  = destval & 0x7e0; \
- 	CARD32 drb = ((source&0xf81f)-dstrb)*alpha; CARD32 dg=((source & 0x7e0)-dstg)*alpha; \
-	WRITE(dest, ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5)  + dstg) & 0x7e0))); \
-    }
-
-
-#define inOver2x0565(alpha, source, destval, dest) { \
- 	CARD32 dstrb = destval & 0x07e0f81f; CARD32 dstg  = (destval & 0xf81f07e0)>>5; \
- 	CARD32 drb = ((source&0x07e0f81f)-dstrb)*alpha; CARD32 dg=(((source & 0xf81f07e0)>>5)-dstg)*alpha; \
-	WRITE(dest, ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5)  + dstg)<<5) & 0xf81f07e0))); \
-    }
-
-
-#if IMAGE_BYTE_ORDER == LSBFirst
-#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(long)where; \
-					temp=count&3; \
-					where-=temp; \
-					workingWhere=(CARD32 *)where; \
-                                        workingVal=READ(workingWhere++); \
-					count=4-temp; \
-					workingVal>>=(8*temp)
-        #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y = READ(z++); } where=(y)&0xff; (y)>>=8; (x)--;}
-	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
-	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
-        #define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; WRITE (wodst++, workingoDest); } 
-#else
-	#warning "I havn't tested fbCompositeTrans_0888xnx0888() on big endian yet!"
-	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(long)where; \
-					temp=count&3; \
-					where-=temp; \
-					workingWhere=(CARD32 *)where; \
-                                        workingVal=READ(workingWhere++); \
-					count=4-temp; \
-					workingVal<<=(8*temp)
-        #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y = READ(z++); } where=(y)>>24; (y)<<=8; (x)--;}
-	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
-	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
-        #define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; WRITE(wodst++, workingoDest); } 
-#endif
-
 /*
  * Naming convention:
  *
@@ -279,7 +221,6 @@ fbCompositeSolidMask_nx8888x8888C (CARD8
     fbFinishAccess (pDst->pDrawable);
 }
 
-#define srcAlphaCombine24(a,b) genericCombine24(a,b,srca,srcia)
 void
 fbCompositeSolidMask_nx8x0888 (CARD8      op,
 			       PicturePtr pSrc,
@@ -294,86 +235,53 @@ fbCompositeSolidMask_nx8x0888 (CARD8    
 			       CARD16     width,
 			       CARD16     height)
 {
-    CARD32	src, srca, srcia;
-    CARD8	*dstLine, *dst, *edst;
+    CARD32	src, srca;
+    CARD8	*dstLine, *dst;
+    CARD32	d;
     CARD8	*maskLine, *mask, m;
     FbStride	dstStride, maskStride;
     CARD16	w;
-    CARD32 rs,gs,bs,rd,gd,bd;
 
     fbComposeGetSolid(pSrc, src, pDst->format);
 
     srca = src >> 24;
-    srcia = 255-srca;
     if (src == 0)
 	return;
 
-    rs=src&0xff;
-    gs=(src>>8)&0xff;
-    bs=(src>>16)&0xff;
-      
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
 
     while (height--)
     {
-	/* fixme: cleanup unused */
-	unsigned long wt, wd;
-	CARD32 workingiDest;
-	CARD32 *widst;
- 	
-	edst = dst = dstLine;
+	dst = dstLine;
 	dstLine += dstStride;
 	mask = maskLine;
 	maskLine += maskStride;
 	w = width;
- 	
-#ifndef NO_MASKED_PACKED_READ
-	setupPackedReader(wd,wt,edst,widst,workingiDest);
-#endif
- 	
+
 	while (w--)
 	{
-#ifndef NO_MASKED_PACKED_READ
-	    readPackedDest(rd);
-	    readPackedDest(gd);
-	    readPackedDest(bd);
-#else
-	    rd = READ(edst++);
-	    gd = READ(edst++);
-	    bd = READ(edst++);
-#endif
 	    m = READ(mask++);
 	    if (m == 0xff)
 	    {
 		if (srca == 0xff)
-		{
-		    WRITE(dst++, rs);
-		    WRITE(dst++, gs);
-		    WRITE(dst++, bs);
-		}
+		    d = src;
 		else
 		{
-		    WRITE(dst++, (srcAlphaCombine24(rs, rd)>>8));
-		    WRITE(dst++, (srcAlphaCombine24(gs, gd)>>8));
-		    WRITE(dst++, (srcAlphaCombine24(bs, bd)>>8));
+		    d = Fetch24(dst);
+		    d = fbOver24 (src, d);
 		}
+		Store24(dst,d);
 	    }
 	    else if (m)
 	    {
-		int na=(srca*(int)m)>>8;
-		int nia=255-na;
-		WRITE(dst++, (genericCombine24(rs, rd, na, nia)>>8));
-		WRITE(dst++, (genericCombine24(gs, gd, na, nia)>>8));
-		WRITE(dst++, (genericCombine24(bs, bd, na, nia)>>8));
-	    }
-	    else
-	    {
-		dst+=3;
+		d = fbOver24 (fbIn(src,m), Fetch24(dst));
+		Store24(dst,d);
 	    }
+	    dst += 3;
 	}
     }
-    
+
     fbFinishAccess (pMask->pDrawable);
     fbFinishAccess (pDst->pDrawable);
 }
@@ -392,105 +300,21 @@ fbCompositeSolidMask_nx8x0565 (CARD8    
 				  CARD16     width,
 				  CARD16     height)
 {
-    CARD32	src, srca8, srca5;
+    CARD32	src, srca;
     CARD16	*dstLine, *dst;
-    CARD16	d;
-    CARD32	t;
+    CARD32	d;
     CARD8	*maskLine, *mask, m;
     FbStride	dstStride, maskStride;
-    CARD16	w,src16;
-    
-    fbComposeGetSolid(pSrc, src, pDst->format);
-    
-    if (src == 0)
-	return;
-      
-    srca8 = (src >> 24);
-    srca5 = (srca8 >> 3);
-    src16 = cvt8888to0565(src);
-     
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-    
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
- 
-	while (w--)
-	{
-	    m = READ(mask++);
-	    if (m == 0)
-		dst++;
-	    else if (srca5 == (0xff >> 3))
-	    {
-		if (m == 0xff)
-		    WRITE(dst++, src16);
-		else 
- 		{
-		    d = READ(dst);
-		    m >>= 3;
-		    inOver0565 (m, src16, d, dst++);
- 		}
-	    }
-	    else
-	    {
-		d = READ(dst);
-		if (m == 0xff) 
-		{
-		    t = fbOver24 (src, cvt0565to0888 (d));
-		}
-		else
-		{
-		    t = fbIn (src, m);
-		    t = fbOver (t, cvt0565to0888 (d));
-		}
-		WRITE(dst++, cvt8888to0565 (t));
-	    }
-	}
-    }
-    
-    fbFinishAccess (pMask->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-static void
-fbCompositeSolidMask_nx8888x0565 (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-				  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height)
-{
-    CARD32	src, srca8, srca5;
-    CARD16	*dstLine, *dst;
-    CARD16	d;
-    CARD32	*maskLine, *mask;
-    CARD32	t;
-    CARD8	m;
-    FbStride	dstStride, maskStride;
-    CARD16	w, src16;
+    CARD16	w;
 
     fbComposeGetSolid(pSrc, src, pDst->format);
 
+    srca = src >> 24;
     if (src == 0)
 	return;
 
-    srca8 = src >> 24;
-    srca5 = srca8 >> 3;
-    src16 = cvt8888to0565(src);
-
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
 
     while (height--)
     {
@@ -502,38 +326,30 @@ fbCompositeSolidMask_nx8888x0565 (CARD8 
 
 	while (w--)
 	{
-	    m = READ(mask++) >> 24;
-	    if (m == 0)
-		dst++;
-	    else if (srca5 == (0xff >> 3))
+	    m = READ(mask++);
+	    if (m == 0xff)
 	    {
-		if (m == 0xff)
-		    WRITE(dst++, src16);
+		if (srca == 0xff)
+		    d = src;
 		else
 		{
 		    d = READ(dst);
-		    m >>= 3;
-		    inOver0565 (m, src16, d, dst++);
+		    d = fbOver24 (src, cvt0565to0888(d));
 		}
+		WRITE(dst, cvt8888to0565(d));
 	    }
-	    else
+	    else if (m)
 	    {
-		if (m == 0xff) 
-		{
-		    d = READ(dst);
-		    t = fbOver24 (src, cvt0565to0888 (d));
-		    WRITE(dst++, cvt8888to0565 (t));
-		}
-		else
-		{
-		    d = READ(dst);
-		    t = fbIn (src, m);
-		    t = fbOver (t, cvt0565to0888 (d));
-		    WRITE(dst++, cvt8888to0565 (t));
-		}
+		d = READ(dst);
+		d = fbOver24 (fbIn(src,m), cvt0565to0888(d));
+		WRITE(dst, cvt8888to0565(d));
 	    }
+	    dst++;
 	}
     }
+
+    fbFinishAccess (pMask->pDrawable);
+    fbFinishAccess (pDst->pDrawable);
 }
 
 void
@@ -1060,295 +876,6 @@ fbCompositeSrcSrc_nxn  (CARD8	   op,
 			CARD16     width,
 			CARD16     height);
 
-static void
-fbCompositeTrans_0565xnx0565(CARD8      op,
-			     PicturePtr pSrc,
-			     PicturePtr pMask,
-			     PicturePtr pDst,
-			     INT16      xSrc,
-			     INT16      ySrc,
-			     INT16      xMask,
-			     INT16      yMask,
-			     INT16      xDst,
-			     INT16      yDst,
-			     CARD16     width,
-			     CARD16     height)
-{
-    CARD16	*dstLine, *dst;
-    CARD16	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    FbBits	mask;
-    CARD8	maskAlpha;
-    CARD16	s_16, d_16;
-    CARD32	s_32, d_32;
-    
-    fbComposeGetSolid (pMask, mask, pDst->format);
-    maskAlpha = mask >> 27;
-    
-    if (!maskAlpha)
-	return;
-    if (maskAlpha == 0xff)
-    {
-	fbCompositeSrcSrc_nxn (PictOpSrc, pSrc, pMask, pDst,
-			       xSrc, ySrc, xMask, yMask, xDst, yDst, 
-			       width, height);
-	return;
-    }
-
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1);
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-
-    while (height--)
-    {
-	CARD32 *isrc, *idst;
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-	
-	if(((long)src&1)==1)
-	{
-	    s_16 = READ(src++);
-	    d_16 = READ(dst);
-	    inOver0565(maskAlpha, s_16, d_16, dst++);
-	    w--;
-	}
-	isrc=(CARD32 *)src;
-	if(((long)dst&1)==0)
-	{
-	    idst=(CARD32 *)dst;
-	    while (w>1)
-	    {
-		s_32 = READ(isrc++);
-		d_32 = READ(idst);
-		inOver2x0565(maskAlpha, s_32, d_32, idst++);
-		w-=2;
-	    }
-	    dst=(CARD16 *)idst;
-	}
-	else
-	{
-	    while (w > 1)
-	    {
-		s_32 = READ(isrc++);
-#if IMAGE_BYTE_ORDER == LSBFirst
-		s_16=s_32&0xffff;
-#else
-		s_16=s_32>>16;
-#endif
-		d_16 = READ(dst);
-		inOver0565 (maskAlpha, s_16, d_16, dst++);
-#if IMAGE_BYTE_ORDER == LSBFirst
-		s_16=s_32>>16;
-#else
-		s_16=s_32&0xffff;
-#endif
-		d_16 = READ(dst);
-		inOver0565(maskAlpha, s_16, d_16, dst++);
-		w-=2;
-	    }
-	}
-	src=(CARD16 *)isrc;
-	if(w!=0)
-	{
-	    s_16 = READ(src);
-	    d_16 = READ(dst);
-	    inOver0565(maskAlpha, s_16, d_16, dst);
-	}
-    }
-    
-    fbFinishAccess (pSrc->pDrawable);
-    fbFinishAccess (pDst->pDrawable);
-}
-
-/* macros for "i can't believe it's not fast" packed pixel handling */
-#define alphamaskCombine24(a,b) genericCombine24(a,b,maskAlpha,maskiAlpha)
-
-static void
-fbCompositeTrans_0888xnx0888(CARD8      op,
- 			     PicturePtr pSrc,
- 			     PicturePtr pMask,
- 			     PicturePtr pDst,
- 			     INT16      xSrc,
- 			     INT16      ySrc,
- 			     INT16      xMask,
- 			     INT16      yMask,
- 			     INT16      xDst,
- 			     INT16      yDst,
- 			     CARD16     width,
- 			     CARD16     height)
-{
-    CARD8	*dstLine, *dst,*idst;
-    CARD8	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-    FbBits	mask;
-    CARD16	maskAlpha,maskiAlpha;
-    
-    fbComposeGetSolid (pMask, mask, pDst->format);
-    maskAlpha = mask >> 24;
-    maskiAlpha= 255-maskAlpha;
-    
-    if (!maskAlpha)
- 	return;
-    /*
-      if (maskAlpha == 0xff)
-      {
-      fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst,
-      xSrc, ySrc, xMask, yMask, xDst, yDst, 
-      width, height);
-      return;
-      }
-    */
-    
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3);
-    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
-    
-    {
-	unsigned long ws,wt;
-	CARD32 workingSource;
-	CARD32 *wsrc, *wdst, *widst;
-	CARD32 rs, rd, nd;
-	CARD8 *isrc;
-	
-	
-	/* are xSrc and xDst at the same alignment?  if not, we need to be complicated :) */
-	/* if(0==0) */
-	if ((((xSrc * 3) & 3) != ((xDst * 3) & 3)) ||
-	    ((srcStride & 3) != (dstStride & 3)))
-	{
-	    while (height--)
-	    {
-		dst = dstLine;
-		dstLine += dstStride;
-		isrc = src = srcLine;
-		srcLine += srcStride;
-		w = width*3;
-		
-		setupPackedReader(ws,wt,isrc,wsrc,workingSource);
-		
-		/* get to word aligned */
-		switch(~(long)dst&3)
-		{
-		case 1:
-		    readPackedSource(rs);
-		    /* *dst++=alphamaskCombine24(rs, *dst)>>8; */
-		    rd = READ(dst);  /* make gcc happy.  hope it doens't cost us too much performance*/
-		    WRITE(dst++, alphamaskCombine24(rs, rd) >> 8);
-		    w--; if(w==0) break;
-		case 2:
-		    readPackedSource(rs);
-		    rd = READ(dst);
-		    WRITE(dst++, alphamaskCombine24(rs, rd) >> 8);
-		    w--; if(w==0) break;
-		case 3:
-		    readPackedSource(rs);
-		    rd = READ(dst);
-		    WRITE(dst++,alphamaskCombine24(rs, rd) >> 8);
-		    w--; if(w==0) break;
-		}
-		wdst=(CARD32 *)dst;
-		while (w>3)
-		{
-		    rs=READ(wsrc++);
-		    /* FIXME: write a special readPackedWord macro, which knows how to 
-		     * halfword combine
-		     */
-#if IMAGE_BYTE_ORDER == LSBFirst
-		    rd=READ(wdst);
-		    readPackedSource(nd);
-		    readPackedSource(rs);
-		    nd|=rs<<8;
-		    readPackedSource(rs);
-		    nd|=rs<<16;
-		    readPackedSource(rs);
-		    nd|=rs<<24;
-#else
-		    readPackedSource(nd);
-		    nd<<=24;
-		    readPackedSource(rs);
-		    nd|=rs<<16;
-		    readPackedSource(rs);
-		    nd|=rs<<8;
-		    readPackedSource(rs);
-		    nd|=rs;
-#endif
-		    inOver0888(maskAlpha, nd, rd, wdst++);
-		    w-=4;
-		}
-		src=(CARD8 *)wdst;
-		switch(w)
-		{
-		case 3:
-		    readPackedSource(rs);
-		    rd=READ(dst);
-		    WRITE(dst++,alphamaskCombine24(rs, rd)>>8);
-		case 2:
-		    readPackedSource(rs);
-		    rd = READ(dst);  
-		    WRITE(dst++, alphamaskCombine24(rs, rd)>>8);
-		case 1:
-		    readPackedSource(rs);
-		    rd = READ(dst);  
-		    WRITE(dst++, alphamaskCombine24(rs, rd)>>8);
-		}
-	    }
-	}
-	else
-	{
-	    while (height--)
-	    {
-		idst=dst = dstLine;
-		dstLine += dstStride;
-		src = srcLine;
-		srcLine += srcStride;
-		w = width*3;
-		/* get to word aligned */
-		switch(~(long)src&3)
-		{
-		case 1:
-		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
-		    WRITE(dst++, rd);
-		    w--; if(w==0) break;
-		case 2:
-		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
-		    WRITE(dst++, rd);
-		    w--; if(w==0) break;
-		case 3:
-		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
-		    WRITE(dst++, rd);
-		    w--; if(w==0) break;
-		}
-		wsrc=(CARD32 *)src;
-		widst=(CARD32 *)dst;
-		while(w>3)
-		{
-		    rs = READ(wsrc++);
-		    rd = READ(widst);
-		    inOver0888 (maskAlpha, rs, rd, widst++);
-		    w-=4;
-		}
-		src=(CARD8 *)wsrc;
-		dst=(CARD8 *)widst;
-		switch(w)
-		{
-		case 3:
-		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
-		    WRITE(dst++, rd);
-		case 2:
-		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
-		    WRITE(dst++, rd);
-		case 1:
-		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
-		    WRITE(dst++, rd);
-		}
-	    }
-	}
-    }
-}
-
 /*
  * Simple bitblt
  */
@@ -1687,6 +1214,7 @@ fbComposite (CARD8      op,
 				break;
 			    }
 			}
+#if 0
 			else
 			{
 			    switch (pDst->format) {
@@ -1697,6 +1225,7 @@ fbComposite (CARD8      op,
 				break;
                             }
 			}
+#endif
 			break;
 		    case PICT_a8b8g8r8:
 			if (pMask->componentAlpha) {
@@ -1722,6 +1251,7 @@ fbComposite (CARD8      op,
 				break;
 			    }
 			}
+#if 0
 			else
 			{
 			    switch (pDst->format) {
@@ -1732,6 +1262,7 @@ fbComposite (CARD8      op,
 				break;
                             }
 			}
+#endif
 			break;
 		    case PICT_a1:
 			switch (pDst->format) {
@@ -1833,16 +1364,6 @@ fbComposite (CARD8      op,
 			 pMask->pDrawable->height == 1)
 		{
 		    switch (pSrc->format) {
-		    case PICT_r5g6b5:
-		    case PICT_b5g6r5:
-			if (pDst->format == pSrc->format)
-			    func = fbCompositeTrans_0565xnx0565;
-			break;
-		    case PICT_r8g8b8:
-		    case PICT_b8g8r8:
-			if (pDst->format == pSrc->format)
-			    func = fbCompositeTrans_0888xnx0888;
-			break;
 #ifdef USE_MMX
 		    case PICT_x8r8g8b8:
 			if ((pDst->format == PICT_a8r8g8b8 ||
diff-tree 1568b6b6a0d7337f29c7b87cc46ae64b3b0f8fdf (from dde0ceac4ea7639d0096bfd26f37c5851778854c)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Sat May 12 20:33:23 2007 -0400

    Port large amounts of the region code to pixman

diff --git a/mi/miregion.c b/mi/miregion.c
index 4bfe9c7..28d38a2 100644
--- a/mi/miregion.c
+++ b/mi/miregion.c
@@ -225,6 +225,37 @@ InitRegions (void)
     pixman_region_set_static_pointers (&miEmptyBox, &miEmptyData, &miBrokenData);
 }
 
+/*****************************************************************
+ *   RegionCreate(rect, size)
+ *     This routine does a simple malloc to make a structure of
+ *     REGION of "size" number of rectangles.
+ *****************************************************************/
+
+_X_EXPORT RegionPtr
+miRegionCreate(rect, size)
+    BoxPtr rect;
+    int size;
+{
+    RegionPtr pReg;
+   
+    pReg = (RegionPtr)xalloc(sizeof(RegionRec));
+    if (!pReg)
+	return &miBrokenRegion;
+
+    miRegionInit (pReg, rect, size);
+    
+    return(pReg);
+}
+
+_X_EXPORT void
+miRegionDestroy(pReg)
+    RegionPtr pReg;
+{
+    pixman_region_fini (pReg);
+    if (pReg != &miBrokenRegion)
+	xfree(pReg);
+}
+
 _X_EXPORT void
 miPrintRegion(rgn)
     RegionPtr rgn;
@@ -250,26 +281,7 @@ miRegionEqual(reg1, reg2)
     RegionPtr reg1;
     RegionPtr reg2;
 {
-    int i, num;
-    BoxPtr rects1, rects2;
-
-    if (reg1->extents.x1 != reg2->extents.x1) return FALSE;
-    if (reg1->extents.x2 != reg2->extents.x2) return FALSE;
-    if (reg1->extents.y1 != reg2->extents.y1) return FALSE;
-    if (reg1->extents.y2 != reg2->extents.y2) return FALSE;
-
-    num = REGION_NUM_RECTS(reg1);
-    if (num != REGION_NUM_RECTS(reg2)) return FALSE;
-    
-    rects1 = REGION_RECTS(reg1);
-    rects2 = REGION_RECTS(reg2);
-    for (i = 0; i != num; i++) {
-	if (rects1[i].x1 != rects2[i].x1) return FALSE;
-	if (rects1[i].x2 != rects2[i].x2) return FALSE;
-	if (rects1[i].y1 != rects2[i].y1) return FALSE;
-	if (rects1[i].y2 != rects2[i].y2) return FALSE;
-    }
-    return TRUE;
+    return pixman_region_equal (reg1, reg2);
 }
 
 #ifdef DEBUG
@@ -278,7 +290,7 @@ miValidRegion(reg)
     RegionPtr reg;
 {
     int i, numRects;
-
+    
     if ((reg->extents.x1 > reg->extents.x2) ||
 	(reg->extents.y1 > reg->extents.y2))
 	return FALSE;
@@ -293,7 +305,7 @@ miValidRegion(reg)
     {
 	BoxPtr pboxP, pboxN;
 	BoxRec box;
-
+	
 	pboxP = REGION_RECTS(reg);
 	box = *pboxP;
 	box.y2 = pboxP[numRects-1].y2;
@@ -304,7 +316,7 @@ miValidRegion(reg)
 		(pboxN->y1 >= pboxN->y2))
 		return FALSE;
 	    if (pboxN->x1 < box.x1)
-	        box.x1 = pboxN->x1;
+		box.x1 = pboxN->x1;
 	    if (pboxN->x2 > box.x2)
 		box.x2 = pboxN->x2;
 	    if ((pboxN->y1 < pboxP->y1) ||
@@ -318,45 +330,8 @@ miValidRegion(reg)
 		(box.y2 == reg->extents.y2));
     }
 }
-
 #endif /* DEBUG */
 
-
-/*****************************************************************
- *   RegionCreate(rect, size)
- *     This routine does a simple malloc to make a structure of
- *     REGION of "size" number of rectangles.
- *****************************************************************/
-
-_X_EXPORT RegionPtr
-miRegionCreate(rect, size)
-    BoxPtr rect;
-    int size;
-{
-    RegionPtr pReg;
-   
-    pReg = (RegionPtr)xalloc(sizeof(RegionRec));
-    if (!pReg)
-	return &miBrokenRegion;
-    if (rect)
-    {
-	pReg->extents = *rect;
-	pReg->data = (RegDataPtr)NULL;
-    }
-    else
-    {
-	pReg->extents = miEmptyBox;
-	if ((size > 1) && (pReg->data = xallocData(size)))
-	{
-	    pReg->data->size = size;
-	    pReg->data->numRects = 0;
-	}
-	else
-	    pReg->data = &miEmptyData;
-    }
-    return(pReg);
-}
-
 /*****************************************************************
  *   RegionInit(pReg, rect, size)
  *     Outer region rect is statically allocated.
@@ -369,39 +344,16 @@ miRegionInit(pReg, rect, size)
     int size;
 {
     if (rect)
-    {
-	pReg->extents = *rect;
-	pReg->data = (RegDataPtr)NULL;
-    }
+	pixman_region_init_with_extents (pReg, rect);
     else
-    {
-	pReg->extents = miEmptyBox;
-	if ((size > 1) && (pReg->data = xallocData(size)))
-	{
-	    pReg->data->size = size;
-	    pReg->data->numRects = 0;
-	}
-	else
-	    pReg->data = &miEmptyData;
-    }
-}
-
-_X_EXPORT void
-miRegionDestroy(pReg)
-    RegionPtr pReg;
-{
-    good(pReg);
-    xfreeData(pReg);
-    if (pReg != &miBrokenRegion)
-	xfree(pReg);
+	pixman_region_init (pReg);
 }
 
 _X_EXPORT void
 miRegionUninit(pReg)
     RegionPtr pReg;
 {
-    good(pReg);
-    xfreeData(pReg);
+    pixman_region_fini (pReg);
 }
 
 Bool
@@ -460,32 +412,9 @@ miRegionCopy(dst, src)
     RegionPtr dst;
     RegionPtr src;
 {
-    good(dst);
-    good(src);
-    if (dst == src)
-	return TRUE;
-    dst->extents = src->extents;
-    if (!src->data || !src->data->size)
-    {
-	xfreeData(dst);
-	dst->data = src->data;
-	return TRUE;
-    }
-    if (!dst->data || (dst->data->size < src->data->numRects))
-    {
-	xfreeData(dst);
-	dst->data = xallocData(src->data->numRects);
-	if (!dst->data)
-	    return miRegionBreak (dst);
-	dst->data->size = src->data->numRects;
-    }
-    dst->data->numRects = src->data->numRects;
-    memmove((char *)REGION_BOXPTR(dst),(char *)REGION_BOXPTR(src), 
-	  dst->data->numRects * sizeof(BoxRec));
-    return TRUE;
+    return pixman_region_copy (dst, src);
 }
 
-
 /*======================================================================
  *	    Generic Region Operator
  *====================================================================*/
@@ -916,8 +845,7 @@ miRegionOp(
  *-----------------------------------------------------------------------
  */
 static void
-miSetExtents (pReg)
-    RegionPtr pReg;
+miSetExtents (RegionPtr pReg)
 {
     BoxPtr pBox, pBoxEnd;
 
@@ -974,113 +902,13 @@ miSetExtents (pReg)
  *-----------------------------------------------------------------------
  */
 /*ARGSUSED*/
-static Bool
-miIntersectO (
-    RegionPtr	pReg,
-    BoxPtr	r1,
-    BoxPtr  	  	r1End,
-    BoxPtr	r2,
-    BoxPtr  	  	r2End,
-    short    	  	y1,
-    short    	  	y2,
-    Bool		*pOverlap)
-{
-    int  	x1;
-    int  	x2;
-    BoxPtr	pNextRect;
-
-    pNextRect = REGION_TOP(pReg);
-
-    assert(y1 < y2);
-    assert(r1 != r1End && r2 != r2End);
-
-    do {
-	x1 = max(r1->x1, r2->x1);
-	x2 = min(r1->x2, r2->x2);
-
-	/*
-	 * If there's any overlap between the two rectangles, add that
-	 * overlap to the new region.
-	 */
-	if (x1 < x2)
-	    NEWRECT(pReg, pNextRect, x1, y1, x2, y2);
-
-	/*
-	 * Advance the pointer(s) with the leftmost right side, since the next
-	 * rectangle on that list may still overlap the other region's
-	 * current rectangle.
-	 */
-	if (r1->x2 == x2) {
-	    r1++;
-	}
-	if (r2->x2 == x2) {
-	    r2++;
-	}
-    } while ((r1 != r1End) && (r2 != r2End));
-
-    return TRUE;
-}
-
-
 _X_EXPORT Bool
 miIntersect(newReg, reg1, reg2)
     RegionPtr 	newReg;     /* destination Region */
     RegionPtr 	reg1;
     RegionPtr	reg2;       /* source regions     */
 {
-    good(reg1);
-    good(reg2);
-    good(newReg);
-   /* check for trivial reject */
-    if (REGION_NIL(reg1)  || REGION_NIL(reg2) ||
-	!EXTENTCHECK(&reg1->extents, &reg2->extents))
-    {
-	/* Covers about 20% of all cases */
-	xfreeData(newReg);
-	newReg->extents.x2 = newReg->extents.x1;
-	newReg->extents.y2 = newReg->extents.y1;
-	if (REGION_NAR(reg1) || REGION_NAR(reg2))
-	{
-	    newReg->data = &miBrokenData;
-	    return FALSE;
-	}
-	else
-	    newReg->data = &miEmptyData;
-    }
-    else if (!reg1->data && !reg2->data)
-    {
-	/* Covers about 80% of cases that aren't trivially rejected */
-	newReg->extents.x1 = max(reg1->extents.x1, reg2->extents.x1);
-	newReg->extents.y1 = max(reg1->extents.y1, reg2->extents.y1);
-	newReg->extents.x2 = min(reg1->extents.x2, reg2->extents.x2);
-	newReg->extents.y2 = min(reg1->extents.y2, reg2->extents.y2);
-	xfreeData(newReg);
-	newReg->data = (RegDataPtr)NULL;
-    }
-    else if (!reg2->data && SUBSUMES(&reg2->extents, &reg1->extents))
-    {
-	return miRegionCopy(newReg, reg1);
-    }
-    else if (!reg1->data && SUBSUMES(&reg1->extents, &reg2->extents))
-    {
-	return miRegionCopy(newReg, reg2);
-    }
-    else if (reg1 == reg2)
-    {
-	return miRegionCopy(newReg, reg1);
-    }
-    else
-    {
-	/* General purpose intersection */
-	Bool overlap; /* result ignored */
-	if (!miRegionOp(newReg, reg1, reg2, miIntersectO, FALSE, FALSE,
-			&overlap))
-	    return FALSE;
-	miSetExtents(newReg);
-    }
-
-    good(newReg);
-    return(TRUE);
+    return pixman_region_intersect (newReg, reg1, reg2);
 }
 
 #define MERGERECT(r)						\
@@ -1183,78 +1011,9 @@ miUnion(newReg, reg1, reg2)
     RegionPtr 	reg1;
     RegionPtr	reg2;             /* source regions     */
 {
-    Bool overlap; /* result ignored */
-
-    /* Return TRUE if some overlap between reg1, reg2 */
-    good(reg1);
-    good(reg2);
-    good(newReg);
-    /*  checks all the simple cases */
-
-    /*
-     * Region 1 and 2 are the same
-     */
-    if (reg1 == reg2)
-    {
-	return miRegionCopy(newReg, reg1);
-    }
-
-    /*
-     * Region 1 is empty
-     */
-    if (REGION_NIL(reg1))
-    {
-	if (REGION_NAR(reg1))
-	    return miRegionBreak (newReg);
-        if (newReg != reg2)
-	    return miRegionCopy(newReg, reg2);
-        return TRUE;
-    }
-
-    /*
-     * Region 2 is empty
-     */
-    if (REGION_NIL(reg2))
-    {
-	if (REGION_NAR(reg2))
-	    return miRegionBreak (newReg);
-        if (newReg != reg1)
-	    return miRegionCopy(newReg, reg1);
-        return TRUE;
-    }
-
-    /*
-     * Region 1 completely subsumes region 2
-     */
-    if (!reg1->data && SUBSUMES(&reg1->extents, &reg2->extents))
-    {
-        if (newReg != reg1)
-	    return miRegionCopy(newReg, reg1);
-        return TRUE;
-    }
-
-    /*
-     * Region 2 completely subsumes region 1
-     */
-    if (!reg2->data && SUBSUMES(&reg2->extents, &reg1->extents))
-    {
-        if (newReg != reg2)
-	    return miRegionCopy(newReg, reg2);
-        return TRUE;
-    }
-
-    if (!miRegionOp(newReg, reg1, reg2, miUnionO, TRUE, TRUE, &overlap))
-	return FALSE;
-
-    newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1);
-    newReg->extents.y1 = min(reg1->extents.y1, reg2->extents.y1);
-    newReg->extents.x2 = max(reg1->extents.x2, reg2->extents.x2);
-    newReg->extents.y2 = max(reg1->extents.y2, reg2->extents.y2);
-    good(newReg);
-    return TRUE;
+    return pixman_region_union (newReg, reg1, reg2);
 }
 
-
 /*======================================================================
  *	    Batch Rectangle Union
  *====================================================================*/
@@ -1659,6 +1418,7 @@ miRectsToRegion(nrects, prect, ctype)
     xRectangle		*prect;
     int			ctype;
 {
+    
     RegionPtr		pRgn;
     RegDataPtr		pData;
     BoxPtr		pBox;
@@ -1754,116 +1514,7 @@ miRectsToRegion(nrects, prect, ctype)
  *-----------------------------------------------------------------------
  */
 /*ARGSUSED*/
-static Bool
-miSubtractO (
-    RegionPtr	pReg,
-    BoxPtr	r1,
-    BoxPtr  	r1End,
-    BoxPtr	r2,
-    BoxPtr  	r2End,
-    short  	y1,
-    short  	y2,
-    Bool	*pOverlap)
-{
-    BoxPtr	pNextRect;
-    int  	x1;
-
-    x1 = r1->x1;
-    
-    assert(y1<y2);
-    assert(r1 != r1End && r2 != r2End);
-
-    pNextRect = REGION_TOP(pReg);
-
-    do
-    {
-	if (r2->x2 <= x1)
-	{
-	    /*
-	     * Subtrahend entirely to left of minuend: go to next subtrahend.
-	     */
-	    r2++;
-	}
-	else if (r2->x1 <= x1)
-	{
-	    /*
-	     * Subtrahend preceeds minuend: nuke left edge of minuend.
-	     */
-	    x1 = r2->x2;
-	    if (x1 >= r1->x2)
-	    {
-		/*
-		 * Minuend completely covered: advance to next minuend and
-		 * reset left fence to edge of new minuend.
-		 */
-		r1++;
-		if (r1 != r1End)
-		    x1 = r1->x1;
-	    }
-	    else
-	    {
-		/*
-		 * Subtrahend now used up since it doesn't extend beyond
-		 * minuend
-		 */
-		r2++;
-	    }
-	}
-	else if (r2->x1 < r1->x2)
-	{
-	    /*
-	     * Left part of subtrahend covers part of minuend: add uncovered
-	     * part of minuend to region and skip to next subtrahend.
-	     */
-	    assert(x1<r2->x1);
-	    NEWRECT(pReg, pNextRect, x1, y1, r2->x1, y2);
-
-	    x1 = r2->x2;
-	    if (x1 >= r1->x2)
-	    {
-		/*
-		 * Minuend used up: advance to new...
-		 */
-		r1++;
-		if (r1 != r1End)
-		    x1 = r1->x1;
-	    }
-	    else
-	    {
-		/*
-		 * Subtrahend used up
-		 */
-		r2++;
-	    }
-	}
-	else
-	{
-	    /*
-	     * Minuend used up: add any remaining piece before advancing.
-	     */
-	    if (r1->x2 > x1)
-		NEWRECT(pReg, pNextRect, x1, y1, r1->x2, y2);
-	    r1++;
-	    if (r1 != r1End)
-		x1 = r1->x1;
-	}
-    } while ((r1 != r1End) && (r2 != r2End));
 
-
-    /*
-     * Add remaining minuend rectangles to region.
-     */
-    while (r1 != r1End)
-    {
-	assert(x1<r1->x2);
-	NEWRECT(pReg, pNextRect, x1, y1, r1->x2, y2);
-	r1++;
-	if (r1 != r1End)
-	    x1 = r1->x1;
-    }
-    return TRUE;
-}
-	
 /*-
  *-----------------------------------------------------------------------
  * miSubtract --
@@ -1884,44 +1535,7 @@ miSubtract(regD, regM, regS)
     RegionPtr 	regM;
     RegionPtr	regS;          
 {
-    Bool overlap; /* result ignored */
-
-    good(regM);
-    good(regS);
-    good(regD);
-   /* check for trivial rejects */
-    if (REGION_NIL(regM) || REGION_NIL(regS) ||
-	!EXTENTCHECK(&regM->extents, &regS->extents))
-    {
-	if (REGION_NAR (regS))
-	    return miRegionBreak (regD);
-	return miRegionCopy(regD, regM);
-    }
-    else if (regM == regS)
-    {
-	xfreeData(regD);
-	regD->extents.x2 = regD->extents.x1;
-	regD->extents.y2 = regD->extents.y1;
-	regD->data = &miEmptyData;
-	return TRUE;
-    }
- 
-    /* Add those rectangles in region 1 that aren't in region 2,
-       do yucky substraction for overlaps, and
-       just throw away rectangles in region 2 that aren't in region 1 */
-    if (!miRegionOp(regD, regM, regS, miSubtractO, TRUE, FALSE, &overlap))
-	return FALSE;
-
-    /*
-     * Can't alter RegD's extents before we call miRegionOp because
-     * it might be one of the source regions and miRegionOp depends
-     * on the extents of those regions being unaltered. Besides, this
-     * way there's no checking against rectangles that will be nuked
-     * due to coalescing, so we have to examine fewer rectangles.
-     */
-    miSetExtents(regD);
-    good(regD);
-    return TRUE;
+    return pixman_region_subtract (regD, regM, regS);
 }
 
 /*======================================================================
@@ -1949,150 +1563,14 @@ miInverse(newReg, reg1, invRect)
     RegionPtr 	  reg1;         /* Region to invert */
     BoxPtr     	  invRect; 	/* Bounding box for inversion */
 {
-    RegionRec	  invReg;   	/* Quick and dirty region made from the
-				 * bounding box */
-    Bool	  overlap;	/* result ignored */
-
-    good(reg1);
-    good(newReg);
-   /* check for trivial rejects */
-    if (REGION_NIL(reg1) || !EXTENTCHECK(invRect, &reg1->extents))
-    {
-	if (REGION_NAR(reg1))
-	    return miRegionBreak (newReg);
-	newReg->extents = *invRect;
-	xfreeData(newReg);
-	newReg->data = (RegDataPtr)NULL;
-        return TRUE;
-    }
-
-    /* Add those rectangles in region 1 that aren't in region 2,
-       do yucky substraction for overlaps, and
-       just throw away rectangles in region 2 that aren't in region 1 */
-    invReg.extents = *invRect;
-    invReg.data = (RegDataPtr)NULL;
-    if (!miRegionOp(newReg, &invReg, reg1, miSubtractO, TRUE, FALSE, &overlap))
-	return FALSE;
-
-    /*
-     * Can't alter newReg's extents before we call miRegionOp because
-     * it might be one of the source regions and miRegionOp depends
-     * on the extents of those regions being unaltered. Besides, this
-     * way there's no checking against rectangles that will be nuked
-     * due to coalescing, so we have to examine fewer rectangles.
-     */
-    miSetExtents(newReg);
-    good(newReg);
-    return TRUE;
+    return pixman_region_inverse (newReg, reg1, invRect);
 }
-
-/*
- *   RectIn(region, rect)
- *   This routine takes a pointer to a region and a pointer to a box
- *   and determines if the box is outside/inside/partly inside the region.
- *
- *   The idea is to travel through the list of rectangles trying to cover the
- *   passed box with them. Anytime a piece of the rectangle isn't covered
- *   by a band of rectangles, partOut is set TRUE. Any time a rectangle in
- *   the region covers part of the box, partIn is set TRUE. The process ends
- *   when either the box has been completely covered (we reached a band that
- *   doesn't overlap the box, partIn is TRUE and partOut is false), the
- *   box has been partially covered (partIn == partOut == TRUE -- because of
- *   the banding, the first time this is true we know the box is only
- *   partially in the region) or is outside the region (we reached a band
- *   that doesn't overlap the box at all and partIn is false)
- */
-
 _X_EXPORT int
 miRectIn(region, prect)
     RegionPtr  region;
     BoxPtr     prect;
 {
-    int		x;
-    int		y;
-    BoxPtr	pbox;
-    BoxPtr	pboxEnd;
-    int		partIn, partOut;
-    int		numRects;
-
-    good(region);
-    numRects = REGION_NUM_RECTS(region);
-    /* useful optimization */
-    if (!numRects || !EXTENTCHECK(&region->extents, prect))
-        return(rgnOUT);
-
-    if (numRects == 1)
-    {
-	/* We know that it must be rgnIN or rgnPART */
-	if (SUBSUMES(&region->extents, prect))
-	    return(rgnIN);
-	else
-	    return(rgnPART);
-    }
-
-    partOut = FALSE;
-    partIn = FALSE;
-
-    /* (x,y) starts at upper left of rect, moving to the right and down */
-    x = prect->x1;
-    y = prect->y1;
-
-    /* can stop when both partOut and partIn are TRUE, or we reach prect->y2 */
-    for (pbox = REGION_BOXPTR(region), pboxEnd = pbox + numRects;
-         pbox != pboxEnd;
-         pbox++)
-    {
-
-        if (pbox->y2 <= y)
-           continue;    /* getting up to speed or skipping remainder of band */
-
-        if (pbox->y1 > y)
-        {
-           partOut = TRUE;      /* missed part of rectangle above */
-           if (partIn || (pbox->y1 >= prect->y2))
-              break;
-           y = pbox->y1;        /* x guaranteed to be == prect->x1 */
-        }
-
-        if (pbox->x2 <= x)
-           continue;            /* not far enough over yet */
-
-        if (pbox->x1 > x)
-        {
-           partOut = TRUE;      /* missed part of rectangle to left */
-           if (partIn)
-              break;
-        }
-
-        if (pbox->x1 < prect->x2)
-        {
-            partIn = TRUE;      /* definitely overlap */
-            if (partOut)
-               break;
-        }
-
-        if (pbox->x2 >= prect->x2)
-        {
-           y = pbox->y2;        /* finished with this band */
-           if (y >= prect->y2)
-              break;
-           x = prect->x1;       /* reset x out to left again */
-        }
-	else
-	{
-	    /*
-	     * Because boxes in a band are maximal width, if the first box
-	     * to overlap the rectangle doesn't completely cover it in that
-	     * band, the rectangle must be partially out, since some of it
-	     * will be uncovered in that band. partIn will have been set true
-	     * by now...
-	     */
-	    partOut = TRUE;
-	    break;
-	}
-    }
-
-    return(partIn ? ((y < prect->y2) ? rgnPART : rgnIN) : rgnOUT);
+    return pixman_region_contains_rectangle (region, prect);
 }
 
 /* TranslateRegion(pReg, x, y)
@@ -2105,83 +1583,7 @@ miTranslateRegion(pReg, x, y)
     int x;
     int y;
 {
-    int x1, x2, y1, y2;
-    int nbox;
-    BoxPtr pbox;
-
-    good(pReg);
-    pReg->extents.x1 = x1 = pReg->extents.x1 + x;
-    pReg->extents.y1 = y1 = pReg->extents.y1 + y;
-    pReg->extents.x2 = x2 = pReg->extents.x2 + x;
-    pReg->extents.y2 = y2 = pReg->extents.y2 + y;
-    if (((x1 - MINSHORT)|(y1 - MINSHORT)|(MAXSHORT - x2)|(MAXSHORT - y2)) >= 0)
-    {
-	if (pReg->data && (nbox = pReg->data->numRects))
-	{
-	    for (pbox = REGION_BOXPTR(pReg); nbox--; pbox++)
-	    {
-		pbox->x1 += x;
-		pbox->y1 += y;
-		pbox->x2 += x;
-		pbox->y2 += y;
-	    }
-	}
-	return;
-    }
-    if (((x2 - MINSHORT)|(y2 - MINSHORT)|(MAXSHORT - x1)|(MAXSHORT - y1)) <= 0)
-    {
-	pReg->extents.x2 = pReg->extents.x1;
-	pReg->extents.y2 = pReg->extents.y1;
-	xfreeData(pReg);
-	pReg->data = &miEmptyData;
-	return;
-    }
-    if (x1 < MINSHORT)
-	pReg->extents.x1 = MINSHORT;
-    else if (x2 > MAXSHORT)
-	pReg->extents.x2 = MAXSHORT;
-    if (y1 < MINSHORT)
-	pReg->extents.y1 = MINSHORT;
-    else if (y2 > MAXSHORT)
-	pReg->extents.y2 = MAXSHORT;
-    if (pReg->data && (nbox = pReg->data->numRects))
-    {
-	BoxPtr pboxout;
-
-	for (pboxout = pbox = REGION_BOXPTR(pReg); nbox--; pbox++)
-	{
-	    pboxout->x1 = x1 = pbox->x1 + x;
-	    pboxout->y1 = y1 = pbox->y1 + y;
-	    pboxout->x2 = x2 = pbox->x2 + x;
-	    pboxout->y2 = y2 = pbox->y2 + y;
-	    if (((x2 - MINSHORT)|(y2 - MINSHORT)|
-		 (MAXSHORT - x1)|(MAXSHORT - y1)) <= 0)
-	    {
-		pReg->data->numRects--;
-		continue;
-	    }
-	    if (x1 < MINSHORT)
-		pboxout->x1 = MINSHORT;
-	    else if (x2 > MAXSHORT)
-		pboxout->x2 = MAXSHORT;
-	    if (y1 < MINSHORT)
-		pboxout->y1 = MINSHORT;
-	    else if (y2 > MAXSHORT)
-		pboxout->y2 = MAXSHORT;
-	    pboxout++;
-	}
-	if (pboxout != pbox)
-	{
-	    if (pReg->data->numRects == 1)
-	    {
-		pReg->extents = *REGION_BOXPTR(pReg);
-		xfreeData(pReg);
-		pReg->data = (RegDataPtr)NULL;
-	    }
-	    else
-		miSetExtents(pReg);
-	}
-    }
+    pixman_region_translate (pReg, x, y);
 }
 
 _X_EXPORT void
@@ -2189,12 +1591,7 @@ miRegionReset(pReg, pBox)
     RegionPtr pReg;
     BoxPtr pBox;
 {
-    good(pReg);
-    assert(pBox->x1<=pBox->x2);
-    assert(pBox->y1<=pBox->y2);
-    pReg->extents = *pBox;
-    xfreeData(pReg);
-    pReg->data = (RegDataPtr)NULL;
+    pixman_region_reset (pReg, pBox);
 }
 
 _X_EXPORT Bool
@@ -2203,40 +1600,14 @@ miPointInRegion(pReg, x, y, box)
     int x, y;
     BoxPtr box;     /* "return" value */
 {
-    BoxPtr pbox, pboxEnd;
-    int numRects;
-
-    good(pReg);
-    numRects = REGION_NUM_RECTS(pReg);
-    if (!numRects || !INBOX(&pReg->extents, x, y))
-        return(FALSE);
-    if (numRects == 1)
-    {
-	*box = pReg->extents;
-	return(TRUE);
-    }
-    for (pbox = REGION_BOXPTR(pReg), pboxEnd = pbox + numRects;
-	 pbox != pboxEnd;
-	 pbox++)
-    {
-        if (y >= pbox->y2)
-	   continue;		/* not there yet */
-	if ((y < pbox->y1) || (x < pbox->x1))
-	   break;		/* missed it */
-	if (x >= pbox->x2)
-	   continue;		/* not there yet */
-	*box = *pbox;
-	return(TRUE);
-    }
-    return(FALSE);
+    return pixman_region_contains_point (pReg, x, y, box);
 }
 
 _X_EXPORT Bool
 miRegionNotEmpty(pReg)
     RegionPtr pReg;
 {
-    good(pReg);
-    return(!REGION_NIL(pReg));
+    return pixman_region_not_empty (pReg);
 }
 
 Bool
diff-tree dde0ceac4ea7639d0096bfd26f37c5851778854c (from e037052ac522150786abf44d3a04c813cc490050)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Sat May 12 17:41:47 2007 -0400

    Add new InitRegions() function called from dix/main

diff --git a/dix/main.c b/dix/main.c
index 9a67ed9..623ce9c 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -253,6 +253,7 @@ main(int argc, char *argv[], char *envp[
     display = "0";
 
     InitGlobals();
+    InitRegions();
 #ifdef XPRINT
     PrinterInitGlobals();
 #endif
diff --git a/include/regionstr.h b/include/regionstr.h
index 8d47c02..f44cab7 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -225,6 +225,8 @@ extern RegDataRec miBrokenData;
 
 /* moved from mi.h */
 
+extern void InitRegions (void);
+
 extern RegionPtr miRegionCreate(
     BoxPtr /*rect*/,
     int /*size*/);
diff --git a/mi/miregion.c b/mi/miregion.c
index 0eab662..4bfe9c7 100644
--- a/mi/miregion.c
+++ b/mi/miregion.c
@@ -85,6 +85,7 @@ Equipment Corporation.
 #include "gc.h"
 #include "mi.h"
 #include "mispans.h"
+#include <pixman/pixman.h>
 
 #undef assert
 #ifdef DEBUG
@@ -218,6 +219,12 @@ _X_EXPORT RegDataRec miEmptyData = {0, 0
 RegDataRec  miBrokenData = {0, 0};
 static RegionRec   miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData };
 
+extern void
+InitRegions (void)
+{
+    pixman_region_set_static_pointers (&miEmptyBox, &miEmptyData, &miBrokenData);
+}
+
 _X_EXPORT void
 miPrintRegion(rgn)
     RegionPtr rgn;
diff-tree e037052ac522150786abf44d3a04c813cc490050 (from 8e56f5be4b70773c899f01b9ccd2e88d523327e4)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Sat May 12 16:58:54 2007 -0400

    Turn boxes and regions into typedefs for pixman types

diff --git a/include/misc.h b/include/misc.h
index 2be1d66..e6a5e9e 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -239,7 +239,7 @@ extern int Ones(
     unsigned long /*mask*/);
 
 typedef struct _xPoint *DDXPointPtr;
-typedef struct _Box *BoxPtr;
+typedef struct pixman_box16 *BoxPtr;
 typedef struct _xEvent *xEventPtr;
 typedef struct _xRectangle *xRectanglePtr;
 typedef struct _GrabRec *GrabPtr;
diff --git a/include/miscstruct.h b/include/miscstruct.h
index c39f03c..4f5b1d5 100644
--- a/include/miscstruct.h
+++ b/include/miscstruct.h
@@ -51,12 +51,11 @@ SOFTWARE.
 #include "misc.h"
 #include <X11/Xprotostr.h>
 #include "gc.h"
+#include <pixman/pixman.h>
 
 typedef xPoint DDXPointRec;
 
-typedef struct _Box {
-    short x1, y1, x2, y2;
-} BoxRec;
+typedef struct pixman_box16 BoxRec;
 
 typedef union _DevUnion {
     pointer		ptr;
diff --git a/include/regionstr.h b/include/regionstr.h
index e6882e7..8d47c02 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -48,7 +48,7 @@ SOFTWARE.
 #ifndef REGIONSTRUCT_H
 #define REGIONSTRUCT_H
 
-typedef struct _Region RegionRec, *RegionPtr;
+typedef struct pixman_region16 RegionRec, *RegionPtr;
 
 #include "miscstruct.h"
 
@@ -64,16 +64,7 @@ typedef struct _Region RegionRec, *Regio
  *   clip region
  */
 
-typedef struct _RegData {
-    long	size;
-    long 	numRects;
-/*  BoxRec	rects[size];   in memory but not explicitly declared */
-} RegDataRec, *RegDataPtr;
-
-struct _Region {
-    BoxRec 	extents;
-    RegDataPtr	data;
-};
+typedef struct pixman_region16_data RegDataRec, *RegDataPtr;
 
 extern BoxRec miEmptyBox;
 extern RegDataRec miEmptyData;
diff-tree 8e56f5be4b70773c899f01b9ccd2e88d523327e4 (from a277f04ab08514462b7f10b4dd92eb326af85501)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri May 11 11:45:37 2007 -0400

    Add dependency on pixman 0.9.0

diff --git a/configure.ac b/configure.ac
index ffb1b85..d7d00e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -623,9 +623,11 @@ XEXT_INC='-I$(top_srcdir)/Xext'
 XEXT_LIB='$(top_builddir)/Xext/libXext.la'
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
+PIXMAN="[pixman >= 0.9.0]"
+
 dnl Core modules for most extensions, et al.
 REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
-REQUIRED_LIBS="xfont xau fontenc"
+REQUIRED_LIBS="xfont xau fontenc $PIXMAN"
 
 if test "x$DBUS" = xauto; then
        PKG_CHECK_MODULES(DBUS, dbus-1, [DBUS=yes], [DBUS=no])
@@ -1103,7 +1105,7 @@ dnl ------------------------------------
 dnl DMX DDX
 
 AC_MSG_CHECKING([whether to build Xdmx DDX])
-PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfixes xfont xi dmxproto xau $XDMCP_MODULES], [have_dmx=yes], [have_dmx=no])
+PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfixes xfont xi dmxproto xau $XDMCP_MODULES $PIXMAN], [have_dmx=yes], [have_dmx=no])
 if test "x$DMX" = xauto; then
 	DMX="$have_dmx"
 fi
diff-tree a277f04ab08514462b7f10b4dd92eb326af85501 (from 20c5250e487e032d392e2e4624021fccb1bfb72c)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed May 9 22:03:12 2007 -0400

    Remove mfb and cfb from include paths where they're not needed.

diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index 1581019..06e6d40 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -45,9 +45,6 @@ fontsmodule_LTLIBRARIES = libfreetype.la
 
 AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
 INCLUDES = @XORG_INCS@ \
-           -I$(top_srcdir)/afb \
-           -I$(top_srcdir)/cfb \
-           -I$(top_srcdir)/mfb \
            -I$(top_srcdir)/dbe \
            -I$(top_srcdir)/hw/xfree86/loader \
            -I$(top_srcdir)/miext/shadow \
diff --git a/hw/xfree86/dixmods/afbmodule.c b/hw/xfree86/dixmods/afbmodule.c
index ee8cf20..b0aea6d 100644
--- a/hw/xfree86/dixmods/afbmodule.c
+++ b/hw/xfree86/dixmods/afbmodule.c
@@ -29,7 +29,6 @@
 #endif
 
 #include "xf86Module.h"
-#include "afb.h"
 
 static MODULESETUPPROTO(afbSetup);
 
diff --git a/hw/xfree86/dixmods/cfb32module.c b/hw/xfree86/dixmods/cfb32module.c
index 1451594..23708e4 100644
--- a/hw/xfree86/dixmods/cfb32module.c
+++ b/hw/xfree86/dixmods/cfb32module.c
@@ -28,10 +28,7 @@
 #include <xorg-config.h>
 #endif
 
-#define PSZ 32
-
 #include "xf86Module.h"
-#include "cfb.h"
 
 static MODULESETUPPROTO(cfb32Setup);
 
diff --git a/hw/xfree86/dixmods/cfbmodule.c b/hw/xfree86/dixmods/cfbmodule.c
index 693fd61..07074c1 100644
--- a/hw/xfree86/dixmods/cfbmodule.c
+++ b/hw/xfree86/dixmods/cfbmodule.c
@@ -28,10 +28,7 @@
 #include <xorg-config.h>
 #endif
 
-#define PSZ 8
-
 #include "xf86Module.h"
-#include "cfb.h"
 
 static MODULESETUPPROTO(cfbSetup);
 
diff --git a/mi/Makefile.am b/mi/Makefile.am
index 06ce15a..7d76929 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -67,5 +67,3 @@ libmi_la_SOURCES = 	\
 	mizerarc.h	\
 	mizerclip.c	\
 	mizerline.c
-
-INCLUDES = -I$(top_srcdir)/mfb
diff-tree 20c5250e487e032d392e2e4624021fccb1bfb72c (from 8dcc37520d5e8c8b52cee81faa67fd5205548377)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed May 9 21:49:44 2007 -0400

    Use system copy of cbrt() if available.
    
    Also move the replacement inline into miarc.c, since that's the only user.

diff --git a/configure.ac b/configure.ac
index c8b40a1..ffb1b85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,7 @@ AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP
 
 dnl Find the math libary
 AC_CHECK_LIB(m, sqrt)
+AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function]))
 
 AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h])
 
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 62e109b..919da60 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -102,6 +102,9 @@
 /* Define to 1 if you have the <byteswap.h> header file. */
 #undef HAVE_BYTESWAP_H
 
+/* Define to 1 if you have cbrt */
+#undef HAVE_CBRT
+
 /* Define to 1 if you have the <dbm.h> header file. */
 #undef HAVE_DBM_H
 
diff --git a/mi/Makefile.am b/mi/Makefile.am
index f262f4b..06ce15a 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -9,7 +9,6 @@ endif
 AM_CFLAGS = $(DIX_CFLAGS)
 
 libmi_la_SOURCES = 	\
-	cbrt.c		\
 	mi.h		\
 	miarc.c		\
 	mibank.c	\
diff --git a/mi/cbrt.c b/mi/cbrt.c
deleted file mode 100644
index c703fd9..0000000
--- a/mi/cbrt.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-
-Copyright 1990, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-
-*/
-
-/* simple cbrt, in case your math library doesn't have a good one */
-
-/*
- * Would normally include <math.h> for this, but for the sake of compiler
- * warnings, we don't want to get duplicate declarations for cbrt().
- */
-
-double pow(double, double);
-double cbrt(double);
-
-double
-cbrt(double x)
-{
-    if (x > 0.0)
-	return pow(x, 1.0/3.0);
-    else
-	return -pow(-x, 1.0/3.0);
-}
diff --git a/mi/miarc.c b/mi/miarc.c
index 69c5acd..3b77ce7 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -51,14 +51,7 @@ SOFTWARE.
 #include <dix-config.h>
 #endif
 
-#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__) \
-	|| (defined(sun) && defined(__SVR4))
 #include <math.h>
-#else
-#define _XOPEN_SOURCE	/* to get prototype for hypot on some systems */
-#include <math.h>
-#undef _XOPEN_SOURCE
-#endif
 #include <X11/X.h>
 #include <X11/Xprotostr.h>
 #include "misc.h"
@@ -75,7 +68,17 @@ static double miDsin(double a);
 static double miDcos(double a);
 static double miDasin(double v);
 static double miDatan2(double dy, double dx);
-double	cbrt(double);
+
+#ifndef HAVE_CBRT
+static double
+cbrt(double x)
+{
+    if (x > 0.0)
+	return pow(x, 1.0/3.0);
+    else
+	return -pow(-x, 1.0/3.0);
+}
+#endif
 
 /*
  * some interesting sematic interpretation of the protocol:
diff-tree 8dcc37520d5e8c8b52cee81faa67fd5205548377 (from 6ff239cb4e67c0a2ea497a1714e5585c1d941af3)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed May 9 18:57:05 2007 -0400

    Use _X_INLINE instead of ad-hoc #defines.

diff --git a/mi/miarc.c b/mi/miarc.c
index 17b7891..69c5acd 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -100,37 +100,16 @@ double	cbrt(double);
 #undef max
 #undef min
 
-#if defined (__GNUC__) && !defined (__STRICT_ANSI__)
-#define USE_INLINE
-#endif
-
-#ifdef USE_INLINE
-inline static int max (const int x, const int y)
+_X_INLINE static int max (const int x, const int y)
 {
 	return x>y? x:y;
 }
 
-inline static int min (const int x, const int y)
+_X_INLINE static int min (const int x, const int y)
 {
 	return x<y? x:y;
 }
 
-#else
-
-static int
-max (int x, int y)
-{
-	return x>y? x:y;
-}
-
-static int
-min (int x, int y)
-{
-	return x<y? x:y;
-}
-
-#endif
-
 struct bound {
 	double	min, max;
 };
diff --git a/mi/miregion.c b/mi/miregion.c
index e980ad1..0eab662 100644
--- a/mi/miregion.c
+++ b/mi/miregion.c
@@ -81,16 +81,11 @@ Equipment Corporation.
 
 #include "regionstr.h"
 #include <X11/Xprotostr.h>
+#include <X11/Xfuncproto.h>
 #include "gc.h"
 #include "mi.h"
 #include "mispans.h"
 
-#if defined (__GNUC__) && !defined (NO_INLINES)
-#define INLINE	__inline
-#else
-#define INLINE
-#endif
-
 #undef assert
 #ifdef DEBUG
 #define assert(expr) {if (!(expr)) \
@@ -506,7 +501,7 @@ miRegionCopy(dst, src)
  *
  *-----------------------------------------------------------------------
  */
-INLINE static int
+_X_INLINE static int
 miCoalesce (
     RegionPtr	pReg,	    	/* Region to coalesce		     */
     int	    	  	prevStart,  	/* Index of start of previous band   */
@@ -590,7 +585,7 @@ miCoalesce (
  *-----------------------------------------------------------------------
  */
 
-INLINE static Bool
+_X_INLINE static Bool
 miAppendNonO (
     RegionPtr	pReg,
     BoxPtr	r,
diff-tree 6ff239cb4e67c0a2ea497a1714e5585c1d941af3 (from 178d426311bb3c7160f72b5d95b0a137eda09ba9)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed May 9 18:38:33 2007 -0400

    Make the use of ICEIL slightly less ugly.

diff --git a/hw/xfree86/xaa/xaaWideLine.c b/hw/xfree86/xaa/xaaWideLine.c
index 9479b0d..a684d66 100644
--- a/hw/xfree86/xaa/xaaWideLine.c
+++ b/hw/xfree86/xaa/xaaWideLine.c
@@ -32,10 +32,6 @@ Original mi code written by Keith Packar
 #include "xaa.h"
 #include "xaalocal.h"
 
-#ifdef ICEILTEMPDECL
-ICEILTEMPDECL
-#endif
-
 #define DRAW_POINT(pScrn, x, y) \
   if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \
   else XAAPointHelper(pScrn, x, y)
diff --git a/mi/miarc.c b/mi/miarc.c
index 2bbbb0e..17b7891 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -77,10 +77,6 @@ static double miDasin(double v);
 static double miDatan2(double dy, double dx);
 double	cbrt(double);
 
-#ifdef ICEILTEMPDECL
-ICEILTEMPDECL
-#endif
-
 /*
  * some interesting sematic interpretation of the protocol:
  *
diff --git a/mi/mifpoly.h b/mi/mifpoly.h
index 8f05076..7bd77b3 100644
--- a/mi/mifpoly.h
+++ b/mi/mifpoly.h
@@ -48,6 +48,8 @@ SOFTWARE.
 #ifndef __MIFPOLY_H__
 #define __MIFPOLY_H__
 
+#include <X11/Xfuncproto.h>
+
 #define EPSILON	0.000001
 #define ISEQUAL(a,b) (Fabs((a) - (b)) <= EPSILON)
 #define UNEQUAL(a,b) (Fabs((a) - (b)) > EPSILON)
@@ -66,20 +68,11 @@ SOFTWARE.
 #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - for 11o miter cutoff */
 #define D2SECANT 5.21671526231167 /* 1/2*sin(11/2) - max extension per width */
 
-#ifdef NOINLINEICEIL
-#define ICEIL(x) ((int)ceil(x))
-#else
-#ifdef __GNUC__
-static __inline int ICEIL(double x)
+static _X_INLINE int ICEIL(double x)
 {
     int _cTmp = x;
     return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1;
 }
-#else
-#define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1)
-#define ICEILTEMPDECL static int _cTmp;
-#endif
-#endif
 
 /* Point with sub-pixel positioning.  In this case we use doubles, but
  * see mifpolycon.c for other suggestions 
diff --git a/mi/mifpolycon.c b/mi/mifpolycon.c
index 7bc1bb2..f851971 100644
--- a/mi/mifpolycon.c
+++ b/mi/mifpolycon.c
@@ -58,10 +58,6 @@ SOFTWARE.
 static int GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans,
 			   int *by, int *ty);
 
-#ifdef ICEILTEMPDECL
-ICEILTEMPDECL
-#endif
-
 /*
  *	Written by Todd Newman; April. 1987.
  *
diff --git a/mi/miwideline.c b/mi/miwideline.c
index 08e4aa3..8c6022f 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -52,10 +52,6 @@ from The Open Group.
 #include "miwideline.h"
 #include "mi.h"
 
-#ifdef ICEILTEMPDECL
-ICEILTEMPDECL
-#endif
-
 static void miLineArc(DrawablePtr pDraw, GCPtr pGC,
 		      unsigned long pixel, SpanDataPtr spanData,
 		      LineFacePtr leftFace,
diff-tree 178d426311bb3c7160f72b5d95b0a137eda09ba9 (from ebaa6c920c82401952a0ccc991b94574306449bd)
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date:   Fri May 11 10:08:42 2007 +0100

    Missing piece from bug 9808

diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 47875b4..0a7579b 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -38,6 +38,7 @@
 #include "winmultiwindowclass.h"
 #include "winprefs.h"
 #include "winmsg.h"
+#include "inputstr.h"
 
 /*
  * External global variables
@@ -494,8 +495,8 @@ winTopLevelWindowProc (HWND hwnd, UINT m
 	break;
 
       /* Has the mouse pointer crossed screens? */
-      if (s_pScreen != miPointerCurrentScreen ())
-	miPointerSetNewScreen (s_pScreenInfo->dwScreen,
+      if (s_pScreen != miPointerGetScreen(inputInfo.pointer))
+	miPointerSetScreen (inputInfo.pointer, s_pScreenInfo->dwScreen,
 			       ptMouse.x - s_pScreenInfo->dwXOffset,
 			       ptMouse.y - s_pScreenInfo->dwYOffset);
 
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index ffa8493..859aafd 100755
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -41,6 +41,7 @@
 #include <X11/Xatom.h>
 #include "winmultiwindowclass.h"
 #include "winmsg.h"
+#include "inputstr.h"
 
 
 /*
@@ -534,8 +535,8 @@ winMWExtWMWindowProc (HWND hwnd, UINT me
 	break;
 
       /* Has the mouse pointer crossed screens? */
-      if (pScreen != miPointerCurrentScreen ())
-	miPointerSetNewScreen (pScreenInfo->dwScreen,
+      if (pScreen != miPointerGetScreen(inputInfo.pointer))
+	miPointerSetScreen (inputInfo.pointer, pScreenInfo->dwScreen,
 			       ptMouse.x - pScreenInfo->dwXOffset,
 			       ptMouse.y - pScreenInfo->dwYOffset);
 
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index 2974c41..29ea81f 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -40,6 +40,7 @@
 #include "winprefs.h"
 #include "winconfig.h"
 #include "winmsg.h"
+#include "inputstr.h"
 
 #ifdef XKB
 extern BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam);
@@ -723,8 +724,8 @@ winWindowProc (HWND hwnd, UINT message, 
 	break;
 
       /* Has the mouse pointer crossed screens? */
-      if (s_pScreen != miPointerCurrentScreen ())
-	miPointerSetNewScreen (s_pScreenInfo->dwScreen,
+      if (s_pScreen != miPointerGetScreen(inputInfo.pointer))
+	miPointerSetScreen (inputInfo.pointer, s_pScreenInfo->dwScreen,
 			       GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
 			       GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
 
diff-tree ebaa6c920c82401952a0ccc991b94574306449bd (from 86c4941727f7c673ae6bb88c67443fa25935c7f5)
Author: Matthias Hopf <mhopf at suse.de>
Date:   Thu May 10 15:25:31 2007 +0200

    Disable Simba PCI bridge routing code (Bug #8020).
    
    The code in hw/xfree86/os-support/bus/sparcPci.c:simbaCheckBus()
    is trying to mimmick VGA routing by disabling I/O space responses
    behind the Simba PCI-PCI controller.
    
    Unfortunately, doing this also happens to disable access to the
    IDE controller I/O space registers, thus crashing the system.  The
    granularity of the I/O disabling in the Simba controller is not
    fine enough to disable VGA without also disabling the IDE controller
    registers.

diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index 7cc882d..f0cb916 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -327,7 +327,7 @@
 #  define INCLUDE_XF86_MAP_PCI_MEM
 #  define INCLUDE_XF86_NO_DOMAIN
 # endif
-# if !defined(__FreeBSD__)
+# if !defined(__FreeBSD__) && !defined(linux)
 #  define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
 # endif
 #elif defined(__amd64__) || defined(__amd64)
diff-tree 86c4941727f7c673ae6bb88c67443fa25935c7f5 (from be44018a3c6172caf3e91c36ea321420d104e79f)
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date:   Wed May 9 16:55:27 2007 +0100

    fix an occasional crash in GetWindowName() (bug: 9798)

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 1918e54..5401ecd 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -445,10 +445,7 @@ GetWindowName (Display *pDisplay, Window
     }
   else
     {
-      XmbTextPropertyToTextList (pDisplay, &xtpName, &ppList, &nNum);
-
-      /* */
-      if (nNum && ppList && *ppList)
+      if (XmbTextPropertyToTextList (pDisplay, &xtpName, &ppList, &nNum) >= Success && nNum > 0 && *ppList)
 	{
 	  *ppName = strdup (*ppList);
 	  XFreeStringList (ppList);
diff-tree be44018a3c6172caf3e91c36ea321420d104e79f (from d3248b66a650c6c629cd66240e25004869217d2e)
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date:   Wed May 9 16:55:09 2007 +0100

    Fix bad use of hwnd (bug: 9808)

diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 0df896d..47875b4 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -444,7 +444,7 @@ winTopLevelWindowProc (HWND hwnd, UINT m
       /* Avoid the BitBlt's if the PAINTSTRUCT is bogus */
       if (ps.rcPaint.right==0 && ps.rcPaint.bottom==0 && ps.rcPaint.left==0 && ps.rcPaint.top==0)
       {
-	EndPaint (hwndScreen, &ps);
+	EndPaint (hwnd, &ps);
 	return 0;
       }
 
@@ -474,7 +474,7 @@ winTopLevelWindowProc (HWND hwnd, UINT m
 	}
 
       /* EndPaint frees the DC */
-      EndPaint (hwndScreen, &ps);
+      EndPaint (hwnd, &ps);
       return 0;
 
     case WM_MOUSEMOVE:
diff-tree d3248b66a650c6c629cd66240e25004869217d2e (from 021e5df85d7c9373a2fed55512751d16e08128db)
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date:   Wed May 9 16:54:46 2007 +0100

    Migrate some code to the new mi apis

diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index f0092e9..1507dd3 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -100,9 +100,10 @@ winMouseProc (DeviceIntPtr pDeviceInt, i
       InitPointerDeviceStruct (pDevice,
 			       map,
 			       lngMouseButtons + lngWheelEvents,
-			       miPointerGetMotionEvents,
+			       GetMotionHistory,
 			       winMouseCtrl,
-			       miPointerGetMotionBufferSize ());
+			       GetMotionHistorySize(),
+			       2);
       free(map);
 
 #if defined(XFree86Server) && defined(XINPUT)
diff-tree 021e5df85d7c9373a2fed55512751d16e08128db (from 1b3a0508a7aee1c7b14cd62216b4727fcc9181d4)
Author: David Nusinow <dnusinow at debian.org>
Date:   Mon May 7 21:03:40 2007 -0400

    Add more informative logging for module default loading
    
    When the modules section is parsed, if a module is set to be loaded by
    default, this will be logged. If it is redundantly specified in xorg.conf,
    this will also be noted. None of this logging will happen if the xorg.conf
    lacks a modules section.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index f44f042..7f1105f 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -290,6 +290,7 @@ xf86ModulelistFromConfig(pointer **optli
             modp = xf86configptr->conf_modules->mod_load_lst;
             while (modp) {
                 if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
+                    xf86Msg(X_INFO, "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n", ModuleDefaults[i].name);
                     found = TRUE;
                     break;
                 }
@@ -299,6 +300,7 @@ xf86ModulelistFromConfig(pointer **optli
                 modp = xf86configptr->conf_modules->mod_disable_lst;
                 while (modp) {
                     if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
+                        xf86Msg(X_INFO, "\"%s\" will be loaded even though the default is to disable it.\n", ModuleDefaults[i].name);
                         found = TRUE;
                         break;
                     }
@@ -308,6 +310,7 @@ xf86ModulelistFromConfig(pointer **optli
             if (found == FALSE) {
 	            XF86ConfModulePtr ptr = xf86configptr->conf_modules;
 	            ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
+                xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n", ModuleDefaults[i].name);
             }
          }
     } else {
diff-tree 1b3a0508a7aee1c7b14cd62216b4727fcc9181d4 (from 030a578391c634bc68add6ada3f251cf3f8c3069)
Author: Jesse Barnes <jbarnes at jbarnes-mobile.amr.corp.intel.com>
Date:   Sun May 6 01:30:59 2007 -0700

    Fix documentation for Copy hook -- it can copy memory to the scanout
    buffer too.

diff --git a/exa/exa.h b/exa/exa.h
index 6c39a8f..cd90bbc 100644
--- a/exa/exa.h
+++ b/exa/exa.h
@@ -229,7 +229,7 @@ typedef struct _ExaDriver {
      * @{
      */
     /**
-     * PrepareCopy() sets up the driver for doing a copy within offscreen
+     * PrepareCopy() sets up the driver for doing a copy within video 
      * memory.
      *
      * @param pSrcPixmap source pixmap
diff-tree 030a578391c634bc68add6ada3f251cf3f8c3069 (from e91b9ddc7aa95abc2d4d314e8db204860771a099)
Author: David Nusinow <dnusinow at debian.org>
Date:   Thu May 3 22:51:07 2007 -0400

    Provide UseDefaultFontPath option
    
    This provides a new option, UseDefaultFontPath. This option is enabled by
    default, and causes the X server to always append the default font path
    (defined at compile time) to the font path for the server. This will allow
    people to specify additional font paths if they want without breaking
    their font path, thus hopefully avoiding ye olde "fixed front" problem.
    
    Because this option is a ServerFlag option, the ServerFlags need to be
    processed before the files section of the config file, so swap the order
    that they are processed.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 301b17c..f44f042 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -604,16 +604,24 @@ configFiles(XF86ConfFilesPtr fileconf)
   char *log_buf;
 
   /* FontPath */
-
   /* Try XF86Config FontPath first */
   if (!xf86fpFlag) {
    if (fileconf) {
     if (fileconf->file_fontpath) {
       char *f = xf86ValidateFontPath(fileconf->file_fontpath);
       pathFrom = X_CONFIG;
-      if (*f)
-        defaultFontPath = f;
-      else {
+      if (*f) {
+        if (xf86Info.useDefaultFontPath) {
+          xf86Msg(X_WARNING, "Including the default font path %s.\n", defaultFontPath);
+          char *g = xnfalloc(strlen(defaultFontPath) + strlen(f) + 3);
+          strcpy(g, f);
+          strcat(g, ",");
+          defaultFontPath = strcat(g, defaultFontPath);
+          xfree(f);
+        } else {
+          defaultFontPath = f;
+        }
+      } else {
 	xf86Msg(X_WARNING,
 	    "FontPath is completely invalid.  Using compiled-in default.\n");
         fontPath = NULL;
@@ -781,6 +789,7 @@ typedef enum {
     FLAG_AIGLX,
     FLAG_IGNORE_ABI,
     FLAG_ALLOW_EMPTY_INPUT,
+    FLAG_USE_DEFAULT_FONT_PATH
 } FlagValues;
    
 static OptionInfoRec FlagOptions[] = {
@@ -856,6 +865,8 @@ static OptionInfoRec FlagOptions[] = {
         {0}, FALSE },
   { FLAG_IGNORE_ABI,			"IgnoreABI",			OPTV_BOOLEAN,
 	{0}, FALSE },
+  { FLAG_USE_DEFAULT_FONT_PATH,  "UseDefaultFontPath",			OPTV_BOOLEAN,
+	{0}, FALSE },
   { -1,				NULL,				OPTV_NONE,
 	{0}, FALSE },
 };
@@ -1055,6 +1066,13 @@ configServerFlags(XF86ConfFlagsPtr flags
     if (xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &value))
         xf86Info.allowEmptyInput = TRUE;
 
+    xf86Info.useDefaultFontPath = TRUE;
+    xf86Info.useDefaultFontPathFrom = X_DEFAULT;
+    if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
+	xf86Info.useDefaultFontPath = value;
+	xf86Info.useDefaultFontPathFrom = X_CONFIG;
+    }
+
 /* Make sure that timers don't overflow CARD32's after multiplying */
 #define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
 
@@ -2490,9 +2508,9 @@ xf86HandleConfigFile(Bool autoconfig)
 
     /* Now process everything else */
 
-    if (!configFiles(xf86configptr->conf_files) ||
-        !configServerFlags(xf86configptr->conf_flags,
+    if (!configServerFlags(xf86configptr->conf_flags,
 			   xf86ConfigLayout.options) ||
+         !configFiles(xf86configptr->conf_files) ||
 	!configExtensions(xf86configptr->conf_extensions)
 #ifdef XF86DRI
 	|| !configDRI(xf86configptr->conf_dri)
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 659e566..7ca0669 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -120,6 +120,8 @@ typedef struct {
     MessageType		randRFrom;
     Bool		aiglx;
     MessageType		aiglxFrom;
+    Bool		useDefaultFontPath;
+    MessageType		useDefaultFontPathFrom;
     Bool        ignoreABI;
     struct {
 	Bool		disabled;		/* enable/disable deactivating
diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index f964282..f2cb5ef 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -604,6 +604,11 @@ the builtin handler will be used.
 .BI "Option \*qAIGLX\*q \*q" boolean \*q
 enable or disable AIGLX. AIGLX is enabled by default.
 .TP 7
+.BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q
+Include the default font path even if other paths are specified in
+xorg.conf. If enabled, other font paths are included as well. Enabled by
+default.
+.TP 7
 .BI "Option \*qIgnoreABI\*q \*q" boolean \*q
 Allow modules built for a different, potentially incompatible version of
 the X server to load. Disabled by default.
diff-tree e91b9ddc7aa95abc2d4d314e8db204860771a099 (from d2f813f7db157fc83abc4b3726821c36ee7e40b1)
Author: David Nusinow <dnusinow at debian.org>
Date:   Thu May 3 22:00:23 2007 -0400

    Improve modules loading defaults
    
    Provide default modules that may be overrided easily. Previously the
    server would load a set of default modules, but only if none were
    specified in the xorg.conf, or if you didn't have a xorg.conf at all. This
    patch provides a default set and you can add only the "Load" instructions
    to xorg.conf that you want without losing the defaults. Similarly, if you
    don't want to load a module that's loaded by default, you can add "Disable
    modulename" to your xorg.conf (see man xorg.conf in this release for
    details). This allows for a minimal "Modules" section, where the user only
    need specify what they want to be different. See bug #10541 for more.
    
    The list of default modules is taken from the set loaded by default when
    there was a xorg.conf containing no "Modules" section.
    
    A potential problem for some users is that some users disable a module,
    most notably DRI, by commenting out the "Load" line in their xorg.conf.
    This needs to be changed to an uncommented "Disable" line, as DRI is
    loaded by default.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 0421bf9..301b17c 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -254,6 +254,7 @@ xf86ModulelistFromConfig(pointer **optli
     char *ignore[] = { "GLcore", "speedo", "bitmap", "drm", NULL };
     pointer *optarray;
     XF86LoadPtr modp;
+    Bool found;
     
     /*
      * make sure the config file has been parsed and that we have a
@@ -266,35 +267,73 @@ xf86ModulelistFromConfig(pointer **optli
     }
     
     if (xf86configptr->conf_modules) {
-	/*
-	 * Walk the list of modules in the "Module" section to determine how
-	 * many we have.
-	 */
-	modp = xf86configptr->conf_modules->mod_load_lst;
-	while (modp) {
-            for (i = 0; ignore[i]; i++) {
-                if (strcmp(modp->load_name, ignore[i]) == 0)
-                    modp->ignore = 1;
+        /* Walk the disable list and let people know what we've parsed to
+         * not be loaded 
+         */
+        modp = xf86configptr->conf_modules->mod_disable_lst;
+        while (modp) {
+            xf86Msg(X_WARNING, "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n", modp->load_name);
+	        modp = (XF86LoadPtr) modp->list.next;
+        }
+        /*
+         * Walk the default settings table. For each module listed to be
+         * loaded, make sure it's in the mod_load_lst. If it's not, make
+         * sure it's not in the mod_no_load_lst. If it's not disabled,
+         * append it to mod_load_lst
+         */
+         for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
+            if (ModuleDefaults[i].toLoad == FALSE) {
+                xf86Msg(X_WARNING, "\"%s\" is not to be loaded by default. Skipping.\n", ModuleDefaults[i].name);
+                continue;
             }
-            if (!modp->ignore)
-	        count++;
-	    modp = (XF86LoadPtr) modp->list.next;
-	}
+            found = FALSE;
+            modp = xf86configptr->conf_modules->mod_load_lst;
+            while (modp) {
+                if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
+                    found = TRUE;
+                    break;
+                }
+	        modp = (XF86LoadPtr) modp->list.next;
+            }
+            if (found == FALSE) {
+                modp = xf86configptr->conf_modules->mod_disable_lst;
+                while (modp) {
+                    if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
+                        found = TRUE;
+                        break;
+                    }
+	                modp = (XF86LoadPtr) modp->list.next;
+                }
+            }
+            if (found == FALSE) {
+	            XF86ConfModulePtr ptr = xf86configptr->conf_modules;
+	            ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
+            }
+         }
     } else {
 	xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec));
+	for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
+	    if (ModuleDefaults[i].toLoad == TRUE) {
+		XF86ConfModulePtr ptr = xf86configptr->conf_modules;
+		ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
+	    }
+	}
     }
 
-    if (count == 0) {
-	XF86ConfModulePtr ptr = xf86configptr->conf_modules;
-	ptr = xf86addNewLoadDirective(ptr, "extmod", XF86_LOAD_MODULE, NULL);
-	ptr = xf86addNewLoadDirective(ptr, "dbe", XF86_LOAD_MODULE, NULL);
-	ptr = xf86addNewLoadDirective(ptr, "glx", XF86_LOAD_MODULE, NULL);
-	ptr = xf86addNewLoadDirective(ptr, "freetype", XF86_LOAD_MODULE, NULL);
-	ptr = xf86addNewLoadDirective(ptr, "type1", XF86_LOAD_MODULE, NULL);
-	ptr = xf86addNewLoadDirective(ptr, "record", XF86_LOAD_MODULE, NULL);
-	ptr = xf86addNewLoadDirective(ptr, "dri", XF86_LOAD_MODULE, NULL);
-	count = 7;
-    }
+	    /*
+	     * Walk the list of modules in the "Module" section to determine how
+	     * many we have.
+	    */
+	    modp = xf86configptr->conf_modules->mod_load_lst;
+	    while (modp) {
+                for (i = 0; ignore[i]; i++) {
+                    if (strcmp(modp->load_name, ignore[i]) == 0)
+                        modp->ignore = 1;
+                }
+                if (!modp->ignore)
+	            count++;
+	        modp = (XF86LoadPtr) modp->list.next;
+	    }
 
     /*
      * allocate the memory and walk the list again to fill in the pointers
@@ -303,22 +342,22 @@ xf86ModulelistFromConfig(pointer **optli
     optarray = xnfalloc((count + 1) * sizeof(pointer));
     count = 0;
     if (xf86configptr->conf_modules) {
-	modp = xf86configptr->conf_modules->mod_load_lst;
-	while (modp) {
+	    modp = xf86configptr->conf_modules->mod_load_lst;
+	    while (modp) {
             if (!modp->ignore) {
-	        modulearray[count] = modp->load_name;
-	        optarray[count] = modp->load_opt;
-	        count++;
+	            modulearray[count] = modp->load_name;
+	            optarray[count] = modp->load_opt;
+	            count++;
             }
-	    modp = (XF86LoadPtr) modp->list.next;
-	}
+	        modp = (XF86LoadPtr) modp->list.next;
+	    }
     }
     modulearray[count] = NULL;
     optarray[count] = NULL;
     if (optlist)
-	*optlist = optarray;
+	    *optlist = optarray;
     else
-	xfree(optarray);
+	    xfree(optarray);
     return modulearray;
 }
 
diff --git a/hw/xfree86/common/xf86Config.h b/hw/xfree86/common/xf86Config.h
index 3787ba2..7fc161d 100644
--- a/hw/xfree86/common/xf86Config.h
+++ b/hw/xfree86/common/xf86Config.h
@@ -33,6 +33,8 @@
 #ifndef _xf86_config_h
 #define _xf86_config_h
 
+#include "xf86Optrec.h"
+
 #ifdef HAVE_PARSER_DECLS
 /*
  * global structure that holds the result of parsing the config file
@@ -46,6 +48,23 @@ typedef enum _ConfigStatus {
     CONFIG_NOFILE
 } ConfigStatus;
 
+typedef struct _ModuleDefault {
+    char *name;
+    Bool toLoad;
+    XF86OptionPtr load_opt;
+} ModuleDefault;
+
+static ModuleDefault ModuleDefaults[] = {
+    {.name = "extmod",   .toLoad = TRUE,    .load_opt=NULL},
+    {.name = "dbe",      .toLoad = TRUE,    .load_opt=NULL},
+    {.name = "glx",      .toLoad = TRUE,    .load_opt=NULL},
+    {.name = "freetype", .toLoad = TRUE,    .load_opt=NULL},
+    {.name = "type1",    .toLoad = TRUE,    .load_opt=NULL},
+    {.name = "record",   .toLoad = TRUE,    .load_opt=NULL},
+    {.name = "dri",      .toLoad = TRUE,    .load_opt=NULL},
+    {.name = NULL,       .toLoad = FALSE,   .load_opt=NULL}
+};
+
 /*
  * prototypes
  */
diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 19315c0..f964282 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -639,6 +639,20 @@ Example: the Type 1 font rasteriser can 
 .B "Load \*qtype1\*q"
 .RE
 .RE
+.TP 7
+.BI "Disable  \*q" modulename \*q
+This instructs the server to not load the module called
+.IR modulename .
+Some modules are loaded by default in the server, and this overrides that
+default. If a
+.B Load
+instruction is given for the same module, it overrides the 
+.B Disable
+instruction and the module is loaded. The module name given should be the
+module's standard name, not the module file name. As with the
+.B Load
+instruction, the standard name is case-sensitive, and does not include the
+"lib" prefix, or the ".a", ".o", or ".so" suffixes.
 .PP
 The second form of entry is a
 .BR SubSection,
diff --git a/hw/xfree86/parser/Module.c b/hw/xfree86/parser/Module.c
index 81eff18..2012ce6 100644
--- a/hw/xfree86/parser/Module.c
+++ b/hw/xfree86/parser/Module.c
@@ -76,6 +76,7 @@ static xf86ConfigSymTabRec ModuleTab[] =
 {
 	{ENDSECTION, "endsection"},
 	{LOAD, "load"},
+    {DISABLE, "disable"}, 
 	{LOAD_DRIVER, "loaddriver"},
 	{SUBSECTION, "subsection"},
 	{-1, ""},
@@ -141,6 +142,13 @@ xf86parseModuleSection (void)
 				xf86addNewLoadDirective (ptr->mod_load_lst, val.str,
 									 XF86_LOAD_MODULE, NULL);
 			break;
+		case DISABLE:
+			if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
+				Error (QUOTE_MSG, "Disable");
+			ptr->mod_disable_lst =
+				xf86addNewLoadDirective (ptr->mod_disable_lst, val.str,
+									 XF86_DISABLE_MODULE, NULL);
+			break;
 		case LOAD_DRIVER:
 			if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
 				Error (QUOTE_MSG, "LoadDriver");
@@ -257,6 +265,15 @@ xf86freeModules (XF86ConfModulePtr ptr)
 		lptr = lptr->list.next;
 		xf86conffree (prev);
 	}
+	lptr = ptr->mod_disable_lst;
+	while (lptr)
+	{
+		TestFree (lptr->load_name);
+		TestFree (lptr->load_comment);
+		prev = lptr;
+		lptr = lptr->list.next;
+		xf86conffree (prev);
+	}
 	TestFree (ptr->mod_comment);
 	xf86conffree (ptr);
 }
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index 89de97b..dc30823 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -82,6 +82,7 @@ XF86ConfFilesRec, *XF86ConfFilesPtr;
 /* Values for load_type */
 #define XF86_LOAD_MODULE	0
 #define XF86_LOAD_DRIVER	1
+#define XF86_DISABLE_MODULE	2
 
 typedef struct
 {
@@ -97,6 +98,7 @@ XF86LoadRec, *XF86LoadPtr;
 typedef struct
 {
 	XF86LoadPtr mod_load_lst;
+    XF86LoadPtr mod_disable_lst;
 	char *mod_comment;
 }
 XF86ConfModuleRec, *XF86ConfModulePtr;
diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h
index d5948dd..822bbb9 100644
--- a/hw/xfree86/parser/xf86tokens.h
+++ b/hw/xfree86/parser/xf86tokens.h
@@ -170,6 +170,7 @@ typedef enum {
     /* Module tokens */
     LOAD,
     LOAD_DRIVER,
+    DISABLE,
     
     /* Device tokens */
     DRIVER,
diff-tree d2f813f7db157fc83abc4b3726821c36ee7e40b1 (from e0959adcd8df2c61e98e76e708fceef9c7cd54eb)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed May 2 19:10:22 2007 -0400

    New fbWalkCompositeRegion() function
    
    This new function walks the composite region and calls a rectangle
    compositing function on each compositing rectangle. Previously there
    were buggy duplicates of this code in fbcompose.c and
    miext/rootles/safealpha/safeAlphaPicture.c.

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 6e49893..dd2a2f0 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -4308,107 +4308,9 @@ fbCompositeGeneral (CARD8	op,
 		    CARD16	width,
 		    CARD16	height)
 {
-    RegionRec	    region;
-    int		    n;
-    BoxPtr	    pbox;
-    Bool	    srcRepeat = FALSE;
-    Bool	    maskRepeat = FALSE;
-    int		    w, h;
-    CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH*3];
-    CARD32 *scanline_buffer = _scanline_buffer;
-    FbComposeData compose_data;
-    
-    if (pSrc->pDrawable)
-        srcRepeat = pSrc->repeatType == RepeatNormal && !pSrc->transform
-	    && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1);
-
-    if (pMask && pMask->pDrawable)
-	maskRepeat = pMask->repeatType == RepeatNormal && !pMask->transform
-	    && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1);
-
-    if (op == PictOpOver && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format) && !pSrc->alphaMap)
-        op = PictOpSrc;
-
-    if (!miComputeCompositeRegion (&region,
-				   pSrc,
-				   pMask,
-				   pDst,
-				   xSrc,
-				   ySrc,
-				   xMask,
-				   yMask,
-				   xDst,
-				   yDst,
-				   width,
-				   height))
-	return;
-
-    compose_data.op = op;
-    compose_data.src = pSrc;
-    compose_data.mask = pMask;
-    compose_data.dest = pDst;
-    if (width > SCANLINE_BUFFER_LENGTH)
-        scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32));
-
-    n = REGION_NUM_RECTS (&region);
-    pbox = REGION_RECTS (&region);
-    while (n--)
-    {
-	h = pbox->y2 - pbox->y1;
-	compose_data.ySrc = pbox->y1 - yDst + ySrc;
-	compose_data.yMask = pbox->y1 - yDst + yMask;
-	compose_data.yDest = pbox->y1;
-	while (h)
-	{
-	    compose_data.height = h;
-	    w = pbox->x2 - pbox->x1;
-	    compose_data.xSrc = pbox->x1 - xDst + xSrc;
-	    compose_data.xMask = pbox->x1 - xDst + xMask;
-	    compose_data.xDest = pbox->x1;
-	    if (maskRepeat)
-	    {
-		compose_data.yMask = mod (compose_data.yMask, pMask->pDrawable->height);
-		if (compose_data.height > pMask->pDrawable->height - compose_data.yMask)
-		    compose_data.height = pMask->pDrawable->height - compose_data.yMask;
-	    }
-	    if (srcRepeat)
-	    {
-		compose_data.ySrc = mod (compose_data.ySrc, pSrc->pDrawable->height);
-		if (compose_data.height > pSrc->pDrawable->height - compose_data.ySrc)
-		    compose_data.height = pSrc->pDrawable->height - compose_data.ySrc;
-	    }
-	    while (w)
-	    {
-		compose_data.width = w;
-		if (maskRepeat)
-		{
-		    compose_data.xMask = mod (compose_data.xMask, pMask->pDrawable->width);
-		    if (compose_data.width > pMask->pDrawable->width - compose_data.xMask)
-			compose_data.width = pMask->pDrawable->width - compose_data.xMask;
-		}
-		if (srcRepeat)
-		{
-		    compose_data.xSrc = mod (compose_data.xSrc, pSrc->pDrawable->width);
-		    if (compose_data.width > pSrc->pDrawable->width - compose_data.xSrc)
-			compose_data.width = pSrc->pDrawable->width - compose_data.xSrc;
-		}
-		fbCompositeRect(&compose_data, scanline_buffer);
-		w -= compose_data.width;
-		compose_data.xSrc += compose_data.width;
-		compose_data.xMask += compose_data.width;
-		compose_data.xDest += compose_data.width;
-	    }
-	    h -= compose_data.height;
-	    compose_data.ySrc += compose_data.height;
-	    compose_data.yMask += compose_data.height;
-	    compose_data.yDest += compose_data.height;
-	}
-	pbox++;
-    }
-    REGION_UNINIT (pDst->pDrawable->pScreen, &region);
-
-    if (scanline_buffer != _scanline_buffer)
-        free(scanline_buffer);
+    return fbComposite (op, pSrc, pMask, pDst,
+			xSrc, ySrc, xMask, yMask, xDst, yDst,
+			width, height);
 }
 
 #endif
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 819d21a..7d94d00 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -37,19 +37,6 @@
 #include "fbpict.h"
 #include "fbmmx.h"
 
-typedef void	(*CompositeFunc) (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-                                  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height);
-
 CARD32
 fbOver (CARD32 x, CARD32 y)
 {
@@ -1478,6 +1465,110 @@ fbCompositeRectWrapper  (CARD8	   op,
 }
 
 void
+fbWalkCompositeRegion (CARD8 op,
+		       PicturePtr pSrc,
+		       PicturePtr pMask,
+		       PicturePtr pDst,
+		       INT16 xSrc,
+		       INT16 ySrc,
+		       INT16 xMask,
+		       INT16 yMask,
+		       INT16 xDst,
+		       INT16 yDst,
+		       CARD16 width,
+		       CARD16 height,
+		       Bool srcRepeat,
+		       Bool maskRepeat,
+		       CompositeFunc compositeRect)
+{
+    RegionRec	    region;
+    int		    n;
+    BoxPtr	    pbox;
+    int		    w, h, w_this, h_this;
+    int		    x_msk, y_msk, x_src, y_src, x_dst, y_dst;
+    
+    xDst += pDst->pDrawable->x;
+    yDst += pDst->pDrawable->y;
+    if (pSrc->pDrawable)
+    {
+        xSrc += pSrc->pDrawable->x;
+        ySrc += pSrc->pDrawable->y;
+    }
+    if (pMask && pMask->pDrawable)
+    {
+	xMask += pMask->pDrawable->x;
+	yMask += pMask->pDrawable->y;
+    }
+
+    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc, ySrc,
+				   xMask, yMask, xDst, yDst, width, height))
+        return;
+
+    n = REGION_NUM_RECTS (&region);
+    pbox = REGION_RECTS (&region);
+    while (n--)
+    {
+	h = pbox->y2 - pbox->y1;
+	y_src = pbox->y1 - yDst + ySrc;
+	y_msk = pbox->y1 - yDst + yMask;
+	y_dst = pbox->y1;
+	while (h)
+	{
+	    h_this = h;
+	    w = pbox->x2 - pbox->x1;
+	    x_src = pbox->x1 - xDst + xSrc;
+	    x_msk = pbox->x1 - xDst + xMask;
+	    x_dst = pbox->x1;
+	    if (maskRepeat)
+	    {
+		y_msk = mod (y_msk - pMask->pDrawable->y, pMask->pDrawable->height);
+		if (h_this > pMask->pDrawable->height - y_msk)
+		    h_this = pMask->pDrawable->height - y_msk;
+		y_msk += pMask->pDrawable->y;
+	    }
+	    if (srcRepeat)
+	    {
+		y_src = mod (y_src - pSrc->pDrawable->y, pSrc->pDrawable->height);
+		if (h_this > pSrc->pDrawable->height - y_src)
+		    h_this = pSrc->pDrawable->height - y_src;
+		y_src += pSrc->pDrawable->y;
+	    }
+	    while (w)
+	    {
+		w_this = w;
+		if (maskRepeat)
+		{
+		    x_msk = mod (x_msk - pMask->pDrawable->x, pMask->pDrawable->width);
+		    if (w_this > pMask->pDrawable->width - x_msk)
+			w_this = pMask->pDrawable->width - x_msk;
+		    x_msk += pMask->pDrawable->x;
+		}
+		if (srcRepeat)
+		{
+		    x_src = mod (x_src - pSrc->pDrawable->x, pSrc->pDrawable->width);
+		    if (w_this > pSrc->pDrawable->width - x_src)
+			w_this = pSrc->pDrawable->width - x_src;
+		    x_src += pSrc->pDrawable->x;
+		}
+		(*compositeRect) (op, pSrc, pMask, pDst,
+				  x_src, y_src, x_msk, y_msk, x_dst, y_dst,
+				  w_this, h_this);
+		w -= w_this;
+		x_src += w_this;
+		x_msk += w_this;
+		x_dst += w_this;
+	    }
+	    h -= h_this;
+	    y_src += h_this;
+	    y_msk += h_this;
+	    y_dst += h_this;
+	}
+	pbox++;
+    }
+    REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+}
+
+void
 fbComposite (CARD8      op,
 	     PicturePtr pSrc,
 	     PicturePtr pMask,
@@ -1491,10 +1582,6 @@ fbComposite (CARD8      op,
 	     CARD16     width,
 	     CARD16     height)
 {
-    RegionRec	    region;
-    int		    n;
-    BoxPtr	    pbox;
-    CompositeFunc   func = NULL;
     Bool	    srcRepeat = pSrc->pDrawable && pSrc->repeatType == RepeatNormal;
     Bool	    maskRepeat = FALSE;
     Bool	    srcTransform = pSrc->transform != 0;
@@ -1502,8 +1589,7 @@ fbComposite (CARD8      op,
     Bool	    srcAlphaMap = pSrc->alphaMap != 0;
     Bool	    maskAlphaMap = FALSE;
     Bool	    dstAlphaMap = pDst->alphaMap != 0;
-    int		    x_msk, y_msk, x_src, y_src, x_dst, y_dst;
-    int		    w, h, w_this, h_this;
+    CompositeFunc   func = NULL;
 
 #ifdef USE_MMX
     static Bool mmx_setup = FALSE;
@@ -1513,13 +1599,6 @@ fbComposite (CARD8      op,
     }
 #endif
 
-    xDst += pDst->pDrawable->x;
-    yDst += pDst->pDrawable->y;
-    if (pSrc->pDrawable) {
-        xSrc += pSrc->pDrawable->x;
-        ySrc += pSrc->pDrawable->y;
-    }
-
     if (srcRepeat && srcTransform &&
 	pSrc->pDrawable->width == 1 &&
 	pSrc->pDrawable->height == 1)
@@ -1527,8 +1606,6 @@ fbComposite (CARD8      op,
     
     if (pMask && pMask->pDrawable)
     {
-	xMask += pMask->pDrawable->x;
-	yMask += pMask->pDrawable->y;
 	maskRepeat = pMask->repeatType == RepeatNormal;
 
 	if (pMask->filter == PictFilterConvolution)
@@ -1688,7 +1765,8 @@ fbComposite (CARD8      op,
 	    else if (!srcRepeat) /* has mask and non-repeating source */
 	    {
 		if (pSrc->pDrawable == pMask->pDrawable &&
-		    xSrc == xMask && ySrc == yMask &&
+		    xSrc + pSrc->pDrawable->x == xMask + pMask->pDrawable->x &&
+		    ySrc + pSrc->pDrawable->y == yMask + pMask->pDrawable->y &&
 		    !pMask->componentAlpha && !maskRepeat)
 		{
 		    /* source == mask: non-premultiplied data */
@@ -2091,73 +2169,10 @@ fbComposite (CARD8      op,
 	srcRepeat = FALSE;
     if (maskTransform)
 	maskRepeat = FALSE;
-    
-    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc, ySrc,
-				   xMask, yMask, xDst, yDst, width, height))
-        return;
 
-    n = REGION_NUM_RECTS (&region);
-    pbox = REGION_RECTS (&region);
-    while (n--)
-    {
-	h = pbox->y2 - pbox->y1;
-	y_src = pbox->y1 - yDst + ySrc;
-	y_msk = pbox->y1 - yDst + yMask;
-	y_dst = pbox->y1;
-	while (h)
-	{
-	    h_this = h;
-	    w = pbox->x2 - pbox->x1;
-	    x_src = pbox->x1 - xDst + xSrc;
-	    x_msk = pbox->x1 - xDst + xMask;
-	    x_dst = pbox->x1;
-	    if (maskRepeat)
-	    {
-		y_msk = mod (y_msk - pMask->pDrawable->y, pMask->pDrawable->height);
-		if (h_this > pMask->pDrawable->height - y_msk)
-		    h_this = pMask->pDrawable->height - y_msk;
-		y_msk += pMask->pDrawable->y;
-	    }
-	    if (srcRepeat)
-	    {
-		y_src = mod (y_src - pSrc->pDrawable->y, pSrc->pDrawable->height);
-		if (h_this > pSrc->pDrawable->height - y_src)
-		    h_this = pSrc->pDrawable->height - y_src;
-		y_src += pSrc->pDrawable->y;
-	    }
-	    while (w)
-	    {
-		w_this = w;
-		if (maskRepeat)
-		{
-		    x_msk = mod (x_msk - pMask->pDrawable->x, pMask->pDrawable->width);
-		    if (w_this > pMask->pDrawable->width - x_msk)
-			w_this = pMask->pDrawable->width - x_msk;
-		    x_msk += pMask->pDrawable->x;
-		}
-		if (srcRepeat)
-		{
-		    x_src = mod (x_src - pSrc->pDrawable->x, pSrc->pDrawable->width);
-		    if (w_this > pSrc->pDrawable->width - x_src)
-			w_this = pSrc->pDrawable->width - x_src;
-		    x_src += pSrc->pDrawable->x;
-		}
-		(*func) (op, pSrc, pMask, pDst,
-			 x_src, y_src, x_msk, y_msk, x_dst, y_dst,
-			 w_this, h_this);
-		w -= w_this;
-		x_src += w_this;
-		x_msk += w_this;
-		x_dst += w_this;
-	    }
-	    h -= h_this;
-	    y_src += h_this;
-	    y_msk += h_this;
-	    y_dst += h_this;
-	}
-	pbox++;
-    }
-    REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+    fbWalkCompositeRegion (op, pSrc, pMask, pDst, xSrc, ySrc,
+			   xMask, yMask, xDst, yDst, width, height,
+			   srcRepeat, maskRepeat, func);
 }
 
 #endif /* RENDER */
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 86f271e..11cab3d 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -630,6 +630,36 @@ fbComposite (CARD8      op,
 	     CARD16     width,
 	     CARD16     height);
 
+typedef void	(*CompositeFunc) (CARD8      op,
+				  PicturePtr pSrc,
+				  PicturePtr pMask,
+				  PicturePtr pDst,
+				  INT16      xSrc,
+				  INT16      ySrc,
+				  INT16      xMask,
+                                  INT16      yMask,
+				  INT16      xDst,
+				  INT16      yDst,
+				  CARD16     width,
+				  CARD16     height);
+
+void
+fbWalkCompositeRegion (CARD8 op,
+		       PicturePtr pSrc,
+		       PicturePtr pMask,
+		       PicturePtr pDst,
+		       INT16 xSrc,
+		       INT16 ySrc,
+		       INT16 xMask,
+		       INT16 yMask,
+		       INT16 xDst,
+		       INT16 yDst,
+		       CARD16 width,
+		       CARD16 height,
+		       Bool srcRepeat,
+		       Bool maskRepeat,
+		       CompositeFunc compositeRect);
+
 /* fbtrap.c */
 
 void
diff --git a/miext/rootless/safeAlpha/safeAlphaPicture.c b/miext/rootless/safeAlpha/safeAlphaPicture.c
index 6ccc05a..0ed2f3e 100644
--- a/miext/rootless/safeAlpha/safeAlphaPicture.c
+++ b/miext/rootless/safeAlpha/safeAlphaPicture.c
@@ -46,22 +46,6 @@
 #include "fbpict.h"
 #include "safeAlpha.h"
 #include "rootlessCommon.h"
-# define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
-
-
-typedef void	(*CompositeFunc) (CARD8      op,
-				  PicturePtr pSrc,
-				  PicturePtr pMask,
-				  PicturePtr pDst,
-				  INT16      xSrc,
-				  INT16      ySrc,
-				  INT16      xMask,
-                                  INT16      yMask,
-				  INT16      xDst,
-				  INT16      yDst,
-				  CARD16     width,
-				  CARD16     height);
-
 
 /* Optimized version of fbCompositeSolidMask_nx8x8888 */
 void
@@ -148,46 +132,22 @@ SafeAlphaCompositeSolidMask_nx8x8888(
 }
 
 void
-SafeAlphaComposite (CARD8      op,
-    PicturePtr      pSrc,
-    PicturePtr      pMask,
-    PicturePtr      pDst,
-    INT16           xSrc,
-    INT16           ySrc,
-    INT16           xMask,
-    INT16           yMask,
-    INT16           xDst,
-    INT16           yDst,
-    CARD16          width,
-    CARD16          height)
+SafeAlphaComposite (CARD8           op,
+		    PicturePtr      pSrc,
+		    PicturePtr      pMask,
+		    PicturePtr      pDst,
+		    INT16           xSrc,
+		    INT16           ySrc,
+		    INT16           xMask,
+		    INT16           yMask,
+		    INT16           xDst,
+		    INT16           yDst,
+		    CARD16          width,
+		    CARD16          height)
 {
-    RegionRec	    region;
-    int		    n;
-    BoxPtr	    pbox;
-    CompositeFunc   func = 0;
-    Bool	    srcRepeat = pSrc->repeat;
-    Bool	    maskRepeat = FALSE;
-    Bool            srcAlphaMap = pSrc->alphaMap != 0;
-    Bool	    maskAlphaMap = FALSE;
-    Bool            dstAlphaMap = pDst->alphaMap != 0;
-    int		    x_msk, y_msk, x_src, y_src, x_dst, y_dst;
-    int		    w, h, w_this, h_this;
-    int		    dstDepth = pDst->pDrawable->depth;
-    int		    oldFormat = pDst->format;
-
-    xDst += pDst->pDrawable->x;
-    yDst += pDst->pDrawable->y;
-    xSrc += pSrc->pDrawable->x;
-    ySrc += pSrc->pDrawable->y;
-    if (pMask)
-    {
-	xMask += pMask->pDrawable->x;
-	yMask += pMask->pDrawable->y;
-	maskRepeat = pMask->repeat;
-	maskAlphaMap = pMask->alphaMap != 0;
-    }
-
-
+    int oldDepth = pDst->pDrawable->depth;
+    int oldFormat = pDst->format;
+    
     /*
      * We can use the more optimized fbpict code, but it sets bits above
      * the depth to zero. Temporarily adjust destination depth if needed.
@@ -198,6 +158,7 @@ SafeAlphaComposite (CARD8      op,
     {
 	pDst->pDrawable->depth = 32;
     }
+    
     /* For rootless preserve the alpha in x8r8g8b8 which really is
      * a8r8g8b8
      */
@@ -205,441 +166,34 @@ SafeAlphaComposite (CARD8      op,
     {
         pDst->format = PICT_a8r8g8b8;
     }
-
-
-
-    if (!pSrc->transform && !(pMask && pMask->transform))
-    if (!maskAlphaMap && !srcAlphaMap && !dstAlphaMap)
-    switch (op) {
-    case PictOpSrc:
-#ifdef USE_MMX
-	if (!pMask && pSrc->format == pDst->format &&
-	    pSrc->pDrawable != pDst->pDrawable)
-	{
-	    func = fbCompositeCopyAreammx;
-	}
-#endif
-	break;
-    case PictOpOver:
-	if (pMask)
-	{
-	    if (srcRepeat && 
-		pSrc->pDrawable->width == 1 &&
-		pSrc->pDrawable->height == 1)
-	    {
-		srcRepeat = FALSE;
-		if (PICT_FORMAT_COLOR(pSrc->format)) {
-		    switch (pMask->format) {
-		    case PICT_a8:
-			switch (pDst->format) {
-			case PICT_r5g6b5:
-			case PICT_b5g6r5:
-#ifdef USE_MMX
-			    if (fbHaveMMX())
-				func = fbCompositeSolidMask_nx8x0565mmx;
-			    else
-#endif
-			    func = fbCompositeSolidMask_nx8x0565;
-			    break;
-			case PICT_r8g8b8:
-			case PICT_b8g8r8:
-			    func = fbCompositeSolidMask_nx8x0888;
-			    break;
-			case PICT_a8r8g8b8:
-			case PICT_x8r8g8b8:
-			case PICT_a8b8g8r8:
-			case PICT_x8b8g8r8:
-			    func = SafeAlphaCompositeSolidMask_nx8x8888;
-			    break;
-			}
-			break;
-		    case PICT_a8r8g8b8:
-			if (pMask->componentAlpha) {
-			    switch (pDst->format) {
-			    case PICT_a8r8g8b8:
-			    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x8888Cmmx;
-				else
-#endif
-				func = fbCompositeSolidMask_nx8888x8888C;
-				break;
-			    case PICT_r5g6b5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x0565Cmmx;
-				else
-#endif
-				func = fbCompositeSolidMask_nx8888x0565C;
-				break;
-			    }
-			}
-			break;
-		    case PICT_a8b8g8r8:
-			if (pMask->componentAlpha) {
-			    switch (pDst->format) {
-			    case PICT_a8b8g8r8:
-			    case PICT_x8b8g8r8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x8888Cmmx;
-				else
-#endif
-				func = fbCompositeSolidMask_nx8888x8888C;
-				break;
-			    case PICT_b5g6r5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSolidMask_nx8888x0565Cmmx;
-				else
-#endif
-				func = fbCompositeSolidMask_nx8888x0565C;
-				break;
-			    }
-			}
-			break;
-		    case PICT_a1:
-			switch (pDst->format) {
-			case PICT_r5g6b5:
-			case PICT_b5g6r5:
-			case PICT_r8g8b8:
-			case PICT_b8g8r8:
-			case PICT_a8r8g8b8:
-			case PICT_x8r8g8b8:
-			case PICT_a8b8g8r8:
-			case PICT_x8b8g8r8:
-			    func = fbCompositeSolidMask_nx1xn;
-			    break;
-			}
-			break;
-		    }
-		}
-	    }
-	    else /* has mask and non-repeating source */
-	    {
-		if (pSrc->pDrawable == pMask->pDrawable &&
-		    xSrc == xMask && ySrc == yMask &&
-		    !pMask->componentAlpha)
-		{
-		    /* source == mask: non-premultiplied data */
-		    switch (pSrc->format) {
-		    case PICT_x8b8g8r8:
-			switch (pMask->format) {
-			case PICT_a8r8g8b8:
-			case PICT_a8b8g8r8:
-			    switch (pDst->format) {
-			    case PICT_a8r8g8b8:
-			    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx8888mmx;
-#endif
-				break;
-			    case PICT_r5g6b5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx0565mmx;
-#endif
-				break;
-			    }
-			    break;
-			}
-			break;
-		    case PICT_x8r8g8b8:
-			switch (pMask->format) {
-			case PICT_a8r8g8b8:
-			case PICT_a8b8g8r8:
-			    switch (pDst->format) {
-			    case PICT_a8b8g8r8:
-			    case PICT_x8b8g8r8:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx8888mmx;
-#endif
-				break;
-			    case PICT_r5g6b5:
-#ifdef USE_MMX
-				if (fbHaveMMX())
-				    func = fbCompositeSrc_8888RevNPx0565mmx;
-#endif
-				break;
-			    }
-			    break;
-			}
-			break;
-		    }
-		    break;
-	}
-	else
-	{
-		    /* non-repeating source, repeating mask => translucent window */
-		    if (maskRepeat &&
-			pMask->pDrawable->width == 1 &&
-			pMask->pDrawable->height == 1)
-		    {
-			if (pSrc->format == PICT_x8r8g8b8 &&
-			    pDst->format == PICT_x8r8g8b8 &&
-			    pMask->format == PICT_a8)
-			{
-#ifdef USE_MMX
-			    if (fbHaveMMX())
-				func = fbCompositeSrc_8888x8x8888mmx;
-#endif
-			}
-		    }
-		}
-	    }
-	}
-	else /* no mask */
-	{
-	    if (srcRepeat &&
-		pSrc->pDrawable->width == 1 &&
-		pSrc->pDrawable->height == 1)
-	    {
-		/* no mask and repeating source */
-	    switch (pSrc->format) {
-	    case PICT_a8r8g8b8:
-		    switch (pDst->format) {
-		    case PICT_a8r8g8b8:
-	    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			{
-			    srcRepeat = FALSE;
-			    func = fbCompositeSolid_nx8888mmx;
-			}
-#endif
-			break;
-		    case PICT_r5g6b5:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			{
-			    srcRepeat = FALSE;
-			    func = fbCompositeSolid_nx0565mmx;
-			}
-#endif
-			break;
-		    }
-		    break;
-		}
-	    }
-	    else
-	    {
-		switch (pSrc->format) {
-		case PICT_a8r8g8b8:
-		switch (pDst->format) {
-		case PICT_a8r8g8b8:
-		case PICT_x8r8g8b8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeSrc_8888x8888mmx;
-			else
-#endif
-		    func = fbCompositeSrc_8888x8888;
-		    break;
-		case PICT_r8g8b8:
-		    func = fbCompositeSrc_8888x0888;
-		    break;
-		case PICT_r5g6b5:
-		    func = fbCompositeSrc_8888x0565;
-		    break;
-		}
-		break;
-		case PICT_x8r8g8b8:
-		    switch (pDst->format) {
-		    case PICT_a8r8g8b8:
-		    case PICT_x8r8g8b8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeCopyAreammx;
-#endif
-			break;
-		    }
-		case PICT_x8b8g8r8:
-		    switch (pDst->format) {
-	    case PICT_a8b8g8r8:
-	    case PICT_x8b8g8r8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeCopyAreammx;
-#endif
-			break;
-		    }
-		    break;
-		case PICT_a8b8g8r8:
-		switch (pDst->format) {
-		case PICT_a8b8g8r8:
-		case PICT_x8b8g8r8:
-#ifdef USE_MMX
-			if (fbHaveMMX())
-			    func = fbCompositeSrc_8888x8888mmx;
-			else
-#endif
-		    func = fbCompositeSrc_8888x8888;
-		    break;
-		case PICT_b8g8r8:
-		    func = fbCompositeSrc_8888x0888;
-		    break;
-		case PICT_b5g6r5:
-		    func = fbCompositeSrc_8888x0565;
-		    break;
-		}
-		break;
-	    case PICT_r5g6b5:
-		switch (pDst->format) {
-		case PICT_r5g6b5:
-		    func = fbCompositeSrc_0565x0565;
-		    break;
-		}
-		break;
-	    case PICT_b5g6r5:
-		switch (pDst->format) {
-		case PICT_b5g6r5:
-		    func = fbCompositeSrc_0565x0565;
-		    break;
-		}
-		break;
-	    }
-	}
-	}
-	break;
-    case PictOpAdd:
-	if (pMask == 0)
-	{
-	    switch (pSrc->format) {
-	    case PICT_a8r8g8b8:
-		switch (pDst->format) {
-		case PICT_a8r8g8b8:
-#ifdef USE_MMX
-		    if (fbHaveMMX())
-			func = fbCompositeSrcAdd_8888x8888mmx;
-		    else
-#endif
-		    func = fbCompositeSrcAdd_8888x8888;
-		    break;
-		}
-		break;
-	    case PICT_a8b8g8r8:
-		switch (pDst->format) {
-		case PICT_a8b8g8r8:
-#ifdef USE_MMX
-		    if (fbHaveMMX())
-			func = fbCompositeSrcAdd_8888x8888mmx;
-		    else
-#endif
-		    func = fbCompositeSrcAdd_8888x8888;
-		    break;
-		}
-		break;
-	    case PICT_a8:
-		switch (pDst->format) {
-		case PICT_a8:
-#ifdef USE_MMX
-		    if (fbHaveMMX())
-			func = fbCompositeSrcAdd_8000x8000mmx;
-		    else
-#endif
-		    func = fbCompositeSrcAdd_8000x8000;
-		    break;
-		}
-		break;
-	    case PICT_a1:
-		switch (pDst->format) {
-		case PICT_a1:
-		    func = fbCompositeSrcAdd_1000x1000;
-		    break;
-		}
-		break;
-	    }
-	}
-	break;
-    }
-
-    if (!func) {
-        /* no fast path, use the general code */
-        fbCompositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
-        // Reset destination depth and format to their true value
-        pDst->pDrawable->depth = dstDepth;
-        pDst->format = oldFormat;
-        return;
+    
+    if (pSrc->pDrawable && pMask->pDrawable &&
+	!pSrc->transform && !pMask->transform &&
+	!pSrc->alphaMap && !pMask->alphaMap &&
+	!pMask->repeat && !pMask->componentAlpha && !pDst->alphaMap &&
+	pMask->format == PICT_a8 &&
+	pSrc->repeatType == RepeatNormal && 
+	pSrc->pDrawable->width == 1 &&
+	pSrc->pDrawable->height == 1 &&
+	(pDst->format == PICT_a8r8g8b8 ||
+	 pDst->format == PICT_x8r8g8b8 ||
+	 pDst->format == PICT_a8b8g8r8 ||
+	 pDst->format == PICT_x8b8g8r8))
+    {
+	fbWalkCompositeRegion (op, pSrc, pMask, pDst,
+			       xSrc, ySrc, xMask, yMask, xDst, yDst,
+			       width, height,
+			       TRUE /* srcRepeat */,
+			       FALSE /* maskRepeat */,
+			       SafeAlphaCompositeSolidMask_nx8x8888);
     }
-
-    if (!miComputeCompositeRegion (&region,
- 				   pSrc,
- 				   pMask,
- 				   pDst,
- 				   xSrc,
- 				   ySrc,
- 				   xMask,
- 				   yMask,
- 				   xDst,
- 				   yDst,
- 				   width,
-                                   height))
-        return;
-
-    n = REGION_NUM_RECTS (&region);
-    pbox = REGION_RECTS (&region);
-    while (n--)
+    else
     {
-	h = pbox->y2 - pbox->y1;
-	y_src = pbox->y1 - yDst + ySrc;
-	y_msk = pbox->y1 - yDst + yMask;
-	y_dst = pbox->y1;
-	while (h)
-	{
-	    h_this = h;
-	    w = pbox->x2 - pbox->x1;
-	    x_src = pbox->x1 - xDst + xSrc;
-	    x_msk = pbox->x1 - xDst + xMask;
-	    x_dst = pbox->x1;
-	    if (maskRepeat)
-	    {
-		y_msk = mod (y_msk, pMask->pDrawable->height);
-		if (h_this > pMask->pDrawable->height - y_msk)
-		    h_this = pMask->pDrawable->height - y_msk;
-	    }
-	    if (srcRepeat)
-	    {
-		y_src = mod (y_src, pSrc->pDrawable->height);
-		if (h_this > pSrc->pDrawable->height - y_src)
-		    h_this = pSrc->pDrawable->height - y_src;
-	    }
-	    while (w)
-	    {
-		w_this = w;
-		if (maskRepeat)
-		{
-		    x_msk = mod (x_msk, pMask->pDrawable->width);
-		    if (w_this > pMask->pDrawable->width - x_msk)
-			w_this = pMask->pDrawable->width - x_msk;
-		}
-		if (srcRepeat)
-		{
-		    x_src = mod (x_src, pSrc->pDrawable->width);
-		    if (w_this > pSrc->pDrawable->width - x_src)
-			w_this = pSrc->pDrawable->width - x_src;
-		}
-		(*func) (op, pSrc, pMask, pDst,
-			 x_src, y_src, x_msk, y_msk, x_dst, y_dst,
-			 w_this, h_this);
-		w -= w_this;
-		x_src += w_this;
-		x_msk += w_this;
-		x_dst += w_this;
-	    }
-	    h -= h_this;
-	    y_src += h_this;
-	    y_msk += h_this;
-	    y_dst += h_this;
-	}
-	pbox++;
+	fbComposite (op, pSrc, pMask, pDst,
+		     xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
     }
-    REGION_UNINIT (pDst->pDrawable->pScreen, &region);
 
-    // Reset destination depth/format to its true value
-    pDst->pDrawable->depth = dstDepth;
+    pDst->pDrawable->depth = oldDepth;
     pDst->format = oldFormat;
 }
 
diff-tree e0959adcd8df2c61e98e76e708fceef9c7cd54eb (from c1e1d6b98a6708860e5b5f6e21d8d5b1d8ce9075)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue May 1 13:41:48 2007 -0400

    Add fbCompositeRect() as another special case in the switch of doom in fbpict.c
    
    This is phase one of getting the two region walkers in fbcompose.c and
    fbpict.c merged together.

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 24b552e..6e49893 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -4027,7 +4027,7 @@ static void fbStoreExternalAlpha(Picture
 typedef void (*scanStoreProc)(PicturePtr , int , int , int , CARD32 *);
 typedef void (*scanFetchProc)(PicturePtr , int , int , int , CARD32 * , CARD32 *, CARD32);
 
-static void
+void
 fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer)
 {
     CARD32 *src_buffer = scanline_buffer;
diff --git a/fb/fbpict.c b/fb/fbpict.c
index a735967..819d21a 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1018,14 +1018,6 @@ fbCompositeSolidMask_nx1xn (CARD8      o
     FbBits	src;
 
     fbComposeGetSolid(pSrc, src, pDst->format);
-
-    if ((src & 0xff000000) != 0xff000000)
-    {
-	fbCompositeGeneral  (op, pSrc, pMask, pDst,
-			     xSrc, ySrc, xMask, yMask, xDst, yDst,
-			     width, height);
-	return;
-    }
     fbGetStipDrawable (pMask->pDrawable, maskBits, maskStride, maskBpp, maskXoff, maskYoff);
     fbGetDrawable (pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
 
@@ -1443,6 +1435,48 @@ fbCompositeSolidSrc_nxn  (CARD8	op,
 }
  */
 
+#define SCANLINE_BUFFER_LENGTH 2048
+ 
+static void
+fbCompositeRectWrapper  (CARD8	   op,
+			 PicturePtr pSrc,
+			 PicturePtr pMask,
+			 PicturePtr pDst,
+			 INT16      xSrc,
+			 INT16      ySrc,
+			 INT16      xMask,
+			 INT16      yMask,
+			 INT16      xDst,
+			 INT16      yDst,
+			 CARD16     width,
+			 CARD16     height)
+{
+    CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
+    CARD32 *scanline_buffer = _scanline_buffer;
+    FbComposeData data;
+
+    data.op = op;
+    data.src = pSrc;
+    data.mask = pMask;
+    data.dest = pDst;
+    data.xSrc = xSrc;
+    data.ySrc = ySrc;
+    data.xMask = xMask;
+    data.yMask = yMask;
+    data.xDest = xDst;
+    data.yDest = yDst;
+    data.width = width;
+    data.height = height;
+
+    if (width > SCANLINE_BUFFER_LENGTH)
+        scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32));
+
+    fbCompositeRect (&data, scanline_buffer);
+
+    if (scanline_buffer != _scanline_buffer)
+	free(scanline_buffer);
+}
+
 void
 fbComposite (CARD8      op,
 	     PicturePtr pSrc,
@@ -1632,8 +1666,14 @@ fbComposite (CARD8      op,
 			case PICT_x8r8g8b8:
 			case PICT_a8b8g8r8:
 			case PICT_x8b8g8r8:
-			    func = fbCompositeSolidMask_nx1xn;
+			{
+			    FbBits src;
+
+			    fbComposeGetSolid(pSrc, src, pDst->format);
+			    if ((src & 0xff000000) == 0xff000000)
+				func = fbCompositeSolidMask_nx1xn;
 			    break;
+			}
 			default:
 			    break;
 			}
@@ -1642,7 +1682,7 @@ fbComposite (CARD8      op,
 			break;
 		    }
 		}
-		if (func != fbCompositeGeneral)
+		if (func)
 		    srcRepeat = FALSE;
 	    }
 	    else if (!srcRepeat) /* has mask and non-repeating source */
@@ -1755,7 +1795,7 @@ fbComposite (CARD8      op,
 			break;
 		    }
 		    
-		    if (func != fbCompositeGeneral)
+		    if (func)
 			maskRepeat = FALSE;
 		}
 	    }
@@ -2043,9 +2083,7 @@ fbComposite (CARD8      op,
     }
 
     if (!func) {
-         /* no fast path, use the general code */
-         fbCompositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
-         return;
+	func = fbCompositeRectWrapper;
     }
 
     /* if we are transforming, we handle repeats in fbFetchTransformed */
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 5246cd5..86f271e 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -383,6 +383,9 @@ typedef struct _FbComposeData {
     CARD16	height;
 } FbComposeData;
 
+void
+fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer);
+
 typedef FASTCALL void (*CombineMaskU) (CARD32 *src, const CARD32 *mask, int width);
 typedef FASTCALL void (*CombineFuncU) (CARD32 *dest, const CARD32 *src, int width);
 typedef FASTCALL void (*CombineFuncC) (CARD32 *dest, CARD32 *src, CARD32 *mask, int width);
diff-tree c1e1d6b98a6708860e5b5f6e21d8d5b1d8ce9075 (from bd0abb2844ef9faf28703e592cfebb886004234c)
Author: Brian <brian at yutani.localnet.net>
Date:   Wed May 2 15:55:40 2007 -0600

    In __glXCreateARGBConfig(), insert the new GL mode at the _end_ of the linked list.
    
    Previously, the new mode was added at the head of the list.  This caused the
    positional correspondence between modes and the XMesaVisuals array to be off
    by one.  The net result was GLX clients failing when they tried to use the
    last GLX mode/visual.
    
    We still have the problem of DRI drivers not being able to use the extra
    mode/visual introduced by __glXCreateARGBConfig().  glXCreateContext fails
    with BadAlloc if it's attempted.  This is also the source of the often-
    seen warning "libGL warning: 3D driver claims to not support visual xxx"
    Look into fixing that someday...

diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c
index 6273edc..932878f 100644
--- a/GL/glx/glxcmds.c
+++ b/GL/glx/glxcmds.c
@@ -1019,6 +1019,7 @@ __glXCreateARGBConfig(__GLXscreen *scree
     VisualPtr visual;
     int i;
 
+    /* search for a 32-bit visual */
     visual = NULL;
     for (i = 0; i < screen->pScreen->numVisuals; i++) 
 	if (screen->pScreen->visuals[i].nplanes == 32) {
@@ -1037,8 +1038,22 @@ __glXCreateARGBConfig(__GLXscreen *scree
     if (modes == NULL)
 	return;
 
-    modes->next = screen->modes;
-    screen->modes = modes;
+    /* Insert this new mode at the TAIL of the linked list.
+     * Previously, the mode was incorrectly inserted at the head of the
+     * list, causing find_mesa_visual() to be off by one.  This would
+     * GLX clients to blow up if they attempted to use the last mode
+     * in the list!
+     */
+    {
+        __GLcontextModes *prev = NULL, *m;
+        for (m = screen->modes; m; m = m->next)
+            prev = m;
+        if (prev)
+            prev->next = modes;
+        else
+            screen->modes = modes;
+    }
+
     screen->numUsableVisuals++;
     screen->numVisuals++;
 
@@ -1104,6 +1119,9 @@ int DoGetFBConfigs(__GLXclientState *cl,
     }
     pGlxScreen = __glXActiveScreens[screen];
 
+    /* Create the "extra" 32bpp ARGB visual, if not already added.
+     * XXX This is questionable place to do so!  Re-examine this someday.
+     */
     __glXCreateARGBConfig(pGlxScreen);
 
     reply.numFBConfigs = pGlxScreen->numUsableVisuals;
diff-tree bd0abb2844ef9faf28703e592cfebb886004234c (from 71fc5b3e9309182978ead676965d65ca93a4e3b9)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Wed May 2 17:20:48 2007 +0200

    Bug #10823: Fixed default OSNAME value.
    
    We try to get OSNAME from uname by default now.

diff --git a/configure.ac b/configure.ac
index 9d4a50a..c8b40a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -374,11 +374,6 @@ fi
 AC_MSG_RESULT([$mmx_capable])
 AM_CONDITIONAL(MMX_CAPABLE, [test "x$mmx_capable" = xyes])
 
-
-OSNAME=`uname -srm`
-AC_DEFINE_UNQUOTED(OSNAME, "$OSNAME", 
-	[Define to OS Name string to display for build OS in Xorg log])
-
 DEFAULT_VENDOR_NAME="The X.Org Foundation"
 DEFAULT_VENDOR_NAME_SHORT="X.Org"
 DEFAULT_VERSION_MAJOR=7
@@ -444,9 +439,9 @@ AC_ARG_WITH(builder-addr,    AS_HELP_STR
 				  [Builder address (default: xorg at lists.freedesktop.org)]),
 				[ BUILDERADDR="$withval" ],
 				[ BUILDERADDR="xorg at lists.freedesktop.org" ])
-AC_ARG_WITH(os-name,         AS_HELP_STRING([--with-os-name=OSNAME], [Name of OS (default: UNKNOWN)]),
+AC_ARG_WITH(os-name,         AS_HELP_STRING([--with-os-name=OSNAME], [Name of OS (default: output of "uname -srm")]),
 				[ OSNAME="$withval" ],
-				[ OSNAME="UNKNOWN" ])
+				[ OSNAME=`uname -srm` ])
 AC_ARG_WITH(os-vendor,       AS_HELP_STRING([--with-os-vendor=OSVENDOR], [Name of OS vendor]),
 				[ OSVENDOR="$withval" ],
 				[ OSVENDOR="" ])
@@ -948,6 +943,11 @@ AC_DEFINE_UNQUOTED(XORG_RELEASE, ["$VEND
 AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
 AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
 AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])
+
+if test -z "$OSNAME"; then
+    OSNAME="UNKNOWN"
+fi
+
 AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name])
 AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor])
 AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string])
diff-tree 71fc5b3e9309182978ead676965d65ca93a4e3b9 (from 873ef75b1e8c94d39670c981c4d830ab8bcc018b)
Author: Keith Packard <keithp at keithp.com>
Date:   Wed May 2 11:41:11 2007 +0200

    Fix for a divide by zero that can be triggered by a malicious client.
    
    Problem reported by Derek Abdine of rapid7.com. Thanks.

diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index 4c67bcd..478a80f 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -117,6 +117,9 @@ fbRasterizeTrapezoid (PicturePtr    pPic
     RenderEdge	l, r;
     xFixed	t, b;
     
+    if (!xTrapezoidValid (trap))
+	return;
+
     fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
 
     width = pPicture->pDrawable->width;
diff --git a/render/renderedge.c b/render/renderedge.c
index 199ec22..c2ffabe 100644
--- a/render/renderedge.c
+++ b/render/renderedge.c
@@ -143,6 +143,7 @@ RenderEdgeInit (RenderEdge	*e,
     dx = x_bot - x_top;
     dy = y_bot - y_top;
     e->dy = dy;
+    e->dx = 0;
     if (dy)
     {
 	if (dx >= 0)
diff-tree 873ef75b1e8c94d39670c981c4d830ab8bcc018b (from 6b33459bf5aac23c3ecc7002d091c02f327d907a)
Author: Colin Guthrie <gmane at colin.guthr.ie>
Date:   Mon Apr 30 10:33:12 2007 -0600

    fix __glXErrorCallBack() proto

diff --git a/hw/dmx/glxProxy/glxext.h b/hw/dmx/glxProxy/glxext.h
index 8572aa4..0113937 100644
--- a/hw/dmx/glxProxy/glxext.h
+++ b/hw/dmx/glxProxy/glxext.h
@@ -67,7 +67,7 @@ extern void __glXFreeGLXPixmap( __GLXpix
 
 extern void __glXNoSuchRenderOpcode(GLbyte*);
 extern int __glXNoSuchSingleOpcode(__GLXclientState*, GLbyte*);
-extern void __glXErrorCallBack(__GLinterface *gc, GLenum code);
+extern void __glXErrorCallBack(GLenum code);
 extern void __glXClearErrorOccured(void);
 extern GLboolean __glXErrorOccured(void);
 extern void __glXResetLargeCommandStatus(__GLXclientState*);
diff-tree 6b33459bf5aac23c3ecc7002d091c02f327d907a (from parents)
Merge: 18252a515d4989b983a3b7389636045e06d0f246 3c91a993e8c752002adf85c317216e1487c20780
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 30 10:26:19 2007 -0600

    Merge branch 'master' of git+ssh://brianp@git.freedesktop.org/git/xorg/xserver

diff-tree 3c91a993e8c752002adf85c317216e1487c20780 (from a261e1325057974d58440812b93c00c0caa4423a)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:49:41 2007 +0200

    EXA: Fix OffscreenValidate build with DEBUG_OFFSCREEN enabled.

diff --git a/exa/exa_offscreen.c b/exa/exa_offscreen.c
index 38ad58f..6fe646a 100644
--- a/exa/exa_offscreen.c
+++ b/exa/exa_offscreen.c
@@ -54,7 +54,7 @@ ExaOffscreenValidate (ScreenPtr pScreen)
 	assert (area->offset >= area->base_offset &&
 		area->offset < (area->base_offset + area->size));
 	if (prev)
-	    assert (prev->base_offset + prev->area.size == area->base_offset);
+	    assert (prev->base_offset + prev->size == area->base_offset);
 	prev = area;
     }
     assert (prev->base_offset + prev->size == pExaScr->info->memorySize);
diff-tree a261e1325057974d58440812b93c00c0caa4423a (from b1b6674a919943a8ac37e54d02e8d0d23a642b1d)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:49:35 2007 +0200

    EXA: Remove DrawableDirty.
    
    Convert the remaining callers to PixmapDirty.

diff --git a/exa/exa.c b/exa/exa.c
index 3d77800..c5b5a66 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -172,29 +172,6 @@ exaPixmapDirty (PixmapPtr pPix, int x1, 
     REGION_UNINIT(pScreen, &region);
 }
 
-/**
- * exaDrawableDirty() marks a pixmap backing a drawable as dirty, allowing for
- * optimizations in pixmap migration when no changes have occurred.
- */
-void
-exaDrawableDirty (DrawablePtr pDrawable, int x1, int y1, int x2, int y2)
-{
-    PixmapPtr pPix = exaGetDrawablePixmap(pDrawable);
-    int xoff, yoff;
-
-    x1 = max(x1, pDrawable->x);
-    y1 = max(y1, pDrawable->y);
-    x2 = min(x2, pDrawable->x + pDrawable->width);
-    y2 = min(y2, pDrawable->y + pDrawable->height);
-
-    if (x1 >= x2 || y1 >= y2)
-	return;
-
-    exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);
-
-    exaPixmapDirty(pPix, x1 + xoff, y1 + yoff, x2 + xoff, y2 + yoff);
-}
-
 static Bool
 exaDestroyPixmap (PixmapPtr pPixmap)
 {
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index b976082..ece5898 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -351,9 +351,6 @@ void
 exaGetDrawableDeltas (DrawablePtr pDrawable, PixmapPtr pPixmap,
 		      int *xp, int *yp);
 
-void
-exaDrawableDirty(DrawablePtr pDrawable, int x1, int y1, int x2, int y2);
-
 Bool
 exaDrawableIsOffscreen (DrawablePtr pDrawable);
 
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 06881e3..5e7c67f 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -764,6 +764,7 @@ exaRasterizeTrapezoid (PicturePtr pPictu
 {
     DrawablePtr pDraw = pPicture->pDrawable;
     ExaMigrationRec pixmaps[1];
+    int xoff, yoff;
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = TRUE;
@@ -772,8 +773,10 @@ exaRasterizeTrapezoid (PicturePtr pPictu
 
     exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
     fbRasterizeTrapezoid(pPicture, trap, x_off, y_off);
-    exaDrawableDirty(pDraw, pDraw->x, pDraw->y,
-		     pDraw->x + pDraw->width, pDraw->y + pDraw->height);
+    exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff);
+    exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff,
+		   pDraw->x + xoff + pDraw->width,
+		   pDraw->y + yoff + pDraw->height);
     exaFinishAccess(pDraw, EXA_PREPARE_DEST);
 }
 
@@ -787,6 +790,7 @@ exaAddTriangles (PicturePtr pPicture, IN
 {
     DrawablePtr pDraw = pPicture->pDrawable;
     ExaMigrationRec pixmaps[1];
+    int xoff, yoff;
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = TRUE;
@@ -795,8 +799,10 @@ exaAddTriangles (PicturePtr pPicture, IN
 
     exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
     fbAddTriangles(pPicture, x_off, y_off, ntri, tris);
-    exaDrawableDirty(pDraw, pDraw->x, pDraw->y,
-		     pDraw->x + pDraw->width, pDraw->y + pDraw->height);
+    exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff);
+    exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff,
+		   pDraw->x + xoff + pDraw->width,
+		   pDraw->y + yoff + pDraw->height);
     exaFinishAccess(pDraw, EXA_PREPARE_DEST);
 }
 
diff-tree b1b6674a919943a8ac37e54d02e8d0d23a642b1d (from 584697a2231ac782f362a925e1489c15483a8791)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:49:28 2007 +0200

    EXA: FillSpans improvements.
    
    * Don't need to track damage.
    * Always migrate for fallbacks.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 4aa2d63..bf63f2c 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -74,6 +74,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPt
 					 pGC->planemask,
 					 pGC->fgPixel))
     {
+	exaDoMigration (pixmaps, 1, FALSE);
 	ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
 	return;
     }
@@ -109,8 +110,6 @@ exaFillSpans(DrawablePtr pDrawable, GCPt
 	    (*pExaScr->info->Solid) (pPixmap,
 				     fullX1 + off_x, fullY1 + off_y,
 				     fullX2 + off_x, fullY1 + 1 + off_y);
-	    exaPixmapDirty (pPixmap, fullX1 + off_x, fullY1 + off_y,
-			    fullX2 + off_x, fullY1 + 1 + off_y);
 	}
 	else
 	{
@@ -129,8 +128,6 @@ exaFillSpans(DrawablePtr pDrawable, GCPt
 			(*pExaScr->info->Solid) (pPixmap,
 						 partX1 + off_x, fullY1 + off_y,
 						 partX2 + off_x, fullY1 + 1 + off_y);
-			exaPixmapDirty (pPixmap, partX1 + off_x, fullY1 + off_y,
-					partX2 + off_x, fullY1 + 1 + off_y);
 		    }
 		}
 		pbox++;
diff-tree 584697a2231ac782f362a925e1489c15483a8791 (from 982d7c2c0b948ba04c8eefa475d660981e6ed9f9)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:49:09 2007 +0200

    EXA: SolidBoxClipped improvements.
    
    * Centralize handling of fallbacks and damage tracking.
    * Always migrate for fallbacks.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 800c4f0..4aa2d63 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -826,20 +826,19 @@ exaSolidBoxClipped (DrawablePtr	pDrawabl
 	pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY)
     {
-	exaDoMigration (pixmaps, 1, FALSE);
-	goto fallback;
+	fallback = TRUE;
     } else {
 	exaDoMigration (pixmaps, 1, TRUE);
     }
 
-    pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
+    exaGetDrawableDeltas (pDrawable, pPixmap, &xoff, &yoff);
 
-    if (!pPixmap ||
+    if (fallback || !exaPixmapIsOffscreen(pPixmap) ||
 	!(*pExaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg))
     {
-fallback:
 	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
 		      exaDrawableLocation(pDrawable)));
+	exaDoMigration (pixmaps, 1, FALSE);
 	fallback = TRUE;
 	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 	fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
@@ -878,10 +877,10 @@ fallback:
 	    (*pExaScr->info->Solid) (pPixmap,
 				     partX1 + xoff, partY1 + yoff,
 				     partX2 + xoff, partY2 + yoff);
-	    exaPixmapDirty (pPixmap, partX1 + xoff, partY1 + yoff,
-			    partX2 + xoff, partY2 + yoff);
-	} else
-	    exaDrawableDirty (pDrawable, partX1, partY1, partX2, partY2);
+	}
+
+	exaPixmapDirty (pPixmap, partX1 + xoff, partY1 + yoff, partX2 + xoff,
+			partY2 + yoff);
     }
 
     if (fallback)
diff-tree 982d7c2c0b948ba04c8eefa475d660981e6ed9f9 (from d2245386eed200e77a8c84bdda36ab29e39fd593)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:48:59 2007 +0200

    EXA: CopyNtoN improvements.
    
    * Centralize handling of fallbacks and damage tracking.
    * Always migrate for fallbacks.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 6a0fbb7..800c4f0 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -390,6 +390,7 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
     int	    src_off_x, src_off_y;
     int	    dst_off_x, dst_off_y;
     ExaMigrationRec pixmaps[2];
+    Bool fallback = FALSE;
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
@@ -407,62 +408,64 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
 	pDstPixmap->drawable.width > pExaScr->info->maxX ||
 	pDstPixmap->drawable.height > pExaScr->info->maxY)
     {
-	exaDoMigration (pixmaps, 2, FALSE);
-	goto fallback;
+	fallback = TRUE;
     } else {
 	exaDoMigration (pixmaps, 2, TRUE);
     }
 
     /* Mixed directions must be handled specially if the card is lame */
-    if (pExaScr->info->flags & EXA_TWO_BITBLT_DIRECTIONS &&
+    if (!fallback && (pExaScr->info->flags & EXA_TWO_BITBLT_DIRECTIONS) &&
 	reverse != upsidedown) {
-	if (!exaCopyNtoNTwoDir(pSrcDrawable, pDstDrawable, pGC, pbox, nbox,
+	if (exaCopyNtoNTwoDir(pSrcDrawable, pDstDrawable, pGC, pbox, nbox,
 			       dx, dy))
-	    goto fallback;
-	return;
+	    return;
+	fallback = TRUE;
     }
 
-    if ((pSrcPixmap = exaGetOffscreenPixmap (pSrcDrawable, &src_off_x, &src_off_y)) &&
-	(pDstPixmap = exaGetOffscreenPixmap (pDstDrawable, &dst_off_x, &dst_off_y)) &&
-	(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap,
-				       reverse ? -1 : 1, upsidedown ? -1 : 1,
-				       pGC ? pGC->alu : GXcopy,
-				       pGC ? pGC->planemask : FB_ALLONES))
+    pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable);
+    pDstPixmap = exaGetDrawablePixmap (pDstDrawable);
+
+    exaGetDrawableDeltas (pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
+    exaGetDrawableDeltas (pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
+
+    if (fallback || !exaPixmapIsOffscreen(pSrcPixmap) ||
+	!exaPixmapIsOffscreen(pDstPixmap) ||
+	!(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, reverse ? -1 : 1,
+					upsidedown ? -1 : 1,
+					pGC ? pGC->alu : GXcopy,
+					pGC ? pGC->planemask : FB_ALLONES)) {
+	fallback = TRUE;
+	EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
+		      exaDrawableLocation(pSrcDrawable),
+		      exaDrawableLocation(pDstDrawable)));
+	exaDoMigration (pixmaps, 2, FALSE);
+	exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST);
+	exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
+	fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
+		    pbox, nbox, dx, dy, reverse, upsidedown,
+		    bitplane, closure);
+	exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC);
+	exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST);
+    }
+
+    while (nbox--)
     {
-	while (nbox--)
-	{
+	if (!fallback)
 	    (*pExaScr->info->Copy) (pDstPixmap,
 				    pbox->x1 + dx + src_off_x,
 				    pbox->y1 + dy + src_off_y,
 				    pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
-				    pbox->x2 - pbox->x1,
-				    pbox->y2 - pbox->y1);
-	    exaPixmapDirty (pDstPixmap,
-			    pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
-			    pbox->x2 + dst_off_x, pbox->y2 + dst_off_y);
-	    pbox++;
-	}
-	(*pExaScr->info->DoneCopy) (pDstPixmap);
-	exaMarkSync(pDstDrawable->pScreen);
-	return;
-    }
-
-fallback:
-    EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
-		  exaDrawableLocation(pSrcDrawable),
-		  exaDrawableLocation(pDstDrawable)));
-    exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST);
-    exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
-    fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
-		pbox, nbox, dx, dy, reverse, upsidedown,
-		bitplane, closure);
-    exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC);
-    exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST);
-    while (nbox--)
-    {
-	exaDrawableDirty (pDstDrawable, pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+				    pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
+	exaPixmapDirty (pDstPixmap, pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
+			pbox->x2  + dst_off_x, pbox->y2 + dst_off_y);
 	pbox++;
     }
+
+    if (fallback)
+	return;
+
+    (*pExaScr->info->DoneCopy) (pDstPixmap);
+    exaMarkSync (pDstDrawable->pScreen);
 }
 
 RegionPtr
diff-tree d2245386eed200e77a8c84bdda36ab29e39fd593 (from 0880aaac9c83019fec2e3d32871f74c7a407f8b3)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:48:31 2007 +0200

    EXA: GetImage improvements.
    
    Only migrate when appropriate. In particular, don't migrate to offscreen in the
    no-fallback case as copying from system memory should usually be as fast if not
    faster than DownloadFromScreen, in particular if the bits need to be uploaded
    to offscreen first.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index dd02fef..6a0fbb7 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1330,27 +1330,22 @@ exaGetImage (DrawablePtr pDrawable, int 
     int xoff, yoff;
     Bool ok;
 
-    if (pExaScr->swappedOut || pExaScr->info->DownloadFromScreen == NULL)
-	goto fallback;
+    if (pExaScr->info->DownloadFromScreen == NULL)
+	goto migrate_and_fallback;
 
     /* Only cover the ZPixmap, solid copy case. */
     if (format != ZPixmap || !EXA_PM_IS_SOLID(pDrawable, planeMask))
-	goto fallback;
+	goto migrate_and_fallback;
 
     /* Only try to handle the 8bpp and up cases, since we don't want to think
      * about <8bpp.
      */
     if (pDrawable->bitsPerPixel < 8)
+	goto migrate_and_fallback;
+
+    if (pExaScr->swappedOut)
 	goto fallback;
 
-    /* Migrate, but assume that we could accelerate the download. It is up to
-     * the migration scheme to ensure that this case doesn't result in bad
-     * moving of pixmaps.
-     */
-    pixmaps[0].as_dst = FALSE;
-    pixmaps[0].as_src = TRUE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
-    exaDoMigration (pixmaps, 1, TRUE);
     pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
     if (pPix == NULL)
 	goto fallback;
@@ -1365,12 +1360,12 @@ exaGetImage (DrawablePtr pDrawable, int 
 	return;
     }
 
-fallback:
+migrate_and_fallback:
     pixmaps[0].as_dst = FALSE;
     pixmaps[0].as_src = TRUE;
     pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
     exaDoMigration (pixmaps, 1, FALSE);
-
+fallback:
     ExaCheckGetImage (pDrawable, x, y, w, h, format, planeMask, d);
 }
 
diff-tree 0880aaac9c83019fec2e3d32871f74c7a407f8b3 (from 7fca16901187ade48e83e6a2684ef464b1912357)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:48:19 2007 +0200

    EXA: PutImage improvements.
    
    * Migrate for fallbacks when appropriate.
    * Add damage tracking in ExaCheckPutImage.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index fc1f3d7..dd02fef 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -154,8 +154,9 @@ exaPutImage (DrawablePtr pDrawable, GCPt
     int xoff, yoff;
     int src_stride, bpp = pDrawable->bitsPerPixel;
 
-    if (pExaScr->swappedOut || pExaScr->info->UploadToScreen == NULL)
-	goto migrate_and_fallback;
+    pixmaps[0].as_dst = TRUE;
+    pixmaps[0].as_src = FALSE;
+    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
 
     /* Don't bother with under 8bpp, XYPixmaps. */
     if (format != ZPixmap || bpp < 8)
@@ -165,10 +166,14 @@ exaPutImage (DrawablePtr pDrawable, GCPt
     if (!EXA_PM_IS_SOLID(pDrawable, pGC->planemask) || pGC->alu != GXcopy)
 	goto migrate_and_fallback;
 
-    pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = FALSE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
+    if (pExaScr->swappedOut)
+	goto fallback;
+
     exaDoMigration (pixmaps, 1, TRUE);
+
+    if (pExaScr->info->UploadToScreen == NULL)
+	goto fallback;
+
     pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
 
     if (pPix == NULL)
@@ -221,25 +226,23 @@ exaPutImage (DrawablePtr pDrawable, GCPt
 
 	    fbBltStip((FbStip *)bits + (y1 - y) * (src_stride / sizeof(FbStip)),
 		      src_stride / sizeof(FbStip),
-		      (x1 - x) * bpp,
-		      dst + (y1 + yoff) * dst_stride,
+		      (x1 - x) * dstBpp,
+		      dst + (y1 + dstYoff) * dst_stride,
 		      dst_stride,
-		      (x1 + xoff) * bpp,
-		      (x2 - x1) * bpp,
+		      (x1 + dstXoff) * dstBpp,
+		      (x2 - x1) * dstBpp,
 		      y2 - y1,
-		      GXcopy, FB_ALLONES, bpp);
+		      GXcopy, FB_ALLONES, dstBpp);
 
 	    exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
 	}
+
 	exaPixmapDirty(pPix, x1 + xoff, y1 + yoff, x2 + xoff, y2 + yoff);
     }
 
     return;
 
 migrate_and_fallback:
-    pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = FALSE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
     exaDoMigration (pixmaps, 1, FALSE);
 
 fallback:
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index a7f9398..708d1ea 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -88,10 +88,15 @@ ExaCheckPutImage (DrawablePtr pDrawable,
 		 int x, int y, int w, int h, int leftPad, int format,
 		 char *bits)
 {
+    PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
+    int xoff, yoff;
+
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
     fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
+    exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
+    exaPixmapDirty(pPixmap, x + xoff, y + yoff, x + xoff + w, y + yoff + h);
 }
 
 RegionPtr
diff-tree 7fca16901187ade48e83e6a2684ef464b1912357 (from a8d6ebdf9338dc2f6ff9a532e6fec460a70d3b1e)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:48:11 2007 +0200

    EXA: ImageGlyphBlt improvements.
    
    * Don't waste effort on invisible glyphs.
    * Only track damage for bounding box instead of each glyph separately.
    * Always migrate for fallbacks.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 721882b..fc1f3d7 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -915,12 +915,36 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     int		    dstBpp;
     int		    dstXoff, dstYoff;
     FbBits	    depthMask;
+    PixmapPtr	    pPixmap = exaGetDrawablePixmap(pDrawable);
+    ExaMigrationRec pixmaps[1];
+    int		    xBack, widthBack, yBack, heightBack;
+
+    for (ppci = ppciInit, n = nglyph, widthBack = 0; n; n--)
+	widthBack += (*ppci++)->metrics.characterWidth;
+
+    xBack = x;
+    if (widthBack < 0)
+    {
+	xBack += widthBack;
+	widthBack = -widthBack;
+    }
+    yBack = y - FONTASCENT(pGC->font);
+    heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+
+    if (xBack >= pDrawable->width || yBack >= pDrawable->height ||
+	(xBack + widthBack) <= 0 || (yBack + heightBack) <= 0)
+	return;
+
+    pixmaps[0].as_dst = TRUE;
+    pixmaps[0].as_src = TRUE;
+    pixmaps[0].pPix = pPixmap;
 
     depthMask = FbFullMask(pDrawable->depth);
     if ((pGC->planemask & depthMask) != depthMask)
     {
+	exaDoMigration(pixmaps, 1, FALSE);
 	ExaCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
-	return;
+	goto damage;
     }
     glyph = NULL;
     switch (pDrawable->bitsPerPixel) {
@@ -932,6 +956,8 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
 
     x += pDrawable->x;
     y += pDrawable->y;
+    xBack += pDrawable->x;
+    yBack += pDrawable->y;
 
     if (TERMINALFONT (pGC->font) && !glyph)
     {
@@ -939,23 +965,6 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     }
     else
     {
-	int		xBack, widthBack;
-	int		yBack, heightBack;
-
-	ppci = ppciInit;
-	n = nglyph;
-	widthBack = 0;
-	while (n--)
-	    widthBack += (*ppci++)->metrics.characterWidth;
-
-        xBack = x;
-	if (widthBack < 0)
-	{
-	    xBack += widthBack;
-	    widthBack = -widthBack;
-	}
-	yBack = y - FONTASCENT(pGC->font);
-	heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
         exaSolidBoxClipped (pDrawable,
 			    fbGetCompositeClip(pGC),
 			    pGC->planemask,
@@ -968,74 +977,50 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     }
 
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
+    exaDoMigration(pixmaps, 1, FALSE);
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
     exaPrepareAccessGC (pGC);
 
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
-    ppci = ppciInit;
-    while (nglyph--)
+    for (ppci = ppciInit; nglyph; nglyph--, x += pci->metrics.characterWidth)
     {
 	pci = *ppci++;
-	pglyph = FONTGLYPHBITS(pglyphBase, pci);
 	gWidth = GLYPHWIDTHPIXELS(pci);
 	gHeight = GLYPHHEIGHTPIXELS(pci);
-	if (gWidth && gHeight)
-	{
-	    gx = x + pci->metrics.leftSideBearing;
-	    gy = y - pci->metrics.ascent;
-	    if (glyph && gWidth <= sizeof (FbStip) * 8 &&
-		fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
-	    {
-		(*glyph) (dst + (gy + dstYoff) * dstStride,
-			  dstStride,
-			  dstBpp,
-			  (FbStip *) pglyph,
-			  pPriv->fg,
-			  gx + dstXoff,
-			  gHeight);
-		exaDrawableDirty (pDrawable, gx, gy, gx + gWidth, gy + gHeight);
-	    }
-	    else
-	    {
-		RegionPtr pClip = fbGetCompositeClip(pGC);
-		int nbox;
-		BoxPtr pbox;
-
-		gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
-		fbPutXYImage (pDrawable,
-			      pClip,
-			      pPriv->fg,
-			      pPriv->bg,
-			      pPriv->pm,
-			      GXcopy,
-			      opaque,
-
-			      gx,
-			      gy,
-			      gWidth, gHeight,
-
-			      (FbStip *) pglyph,
-			      gStride,
-			      0);
-
-		for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
-		     nbox--; pbox++) {
-		    int x1 = max(gx, pbox->x1), x2 = min(gx + gWidth, pbox->x2);
-		    int y1 = max(gy, pbox->y1), y2 = min(gy + gHeight, pbox->y2);
+	gx = x + pci->metrics.leftSideBearing;
+	gy = y - pci->metrics.ascent;
 
-		    if (x1 >= x2 || y1 >= y2)
-			continue;
+	if (!gWidth || !gHeight || (gx + gWidth) <= xBack ||
+	    (gy + gHeight) <= yBack || gx >= (xBack + widthBack) ||
+	    gy >= (yBack + heightBack))
+	    continue;
 
-		    exaDrawableDirty (pDrawable, gx, gy, gx + gWidth,
-				      gy + gHeight);
-		}
-	    }
+	pglyph = FONTGLYPHBITS(pglyphBase, pci);
+
+	if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+	    fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+	{
+	    (*glyph) (dst + (gy + dstYoff) * dstStride, dstStride, dstBpp,
+		      (FbStip *) pglyph, pPriv->fg, gx + dstXoff, gHeight);
+	}
+	else
+	{
+	    RegionPtr pClip = fbGetCompositeClip(pGC);
+
+	    gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+	    fbPutXYImage (pDrawable, pClip, pPriv->fg, pPriv->bg, pPriv->pm,
+			  GXcopy, opaque, gx, gy, gWidth, gHeight,
+			  (FbStip *) pglyph, gStride, 0);
 	}
-	x += pci->metrics.characterWidth;
     }
     exaFinishAccessGC (pGC);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
+
+damage:
+    exaGetDrawableDeltas(pDrawable, pPixmap, &dstXoff, &dstYoff);
+    exaPixmapDirty(pPixmap, xBack + dstXoff, yBack + dstYoff,
+		   xBack + dstXoff + widthBack, yBack + dstYoff + heightBack);
 }
 
 const GCOps exaOps = {
diff-tree a8d6ebdf9338dc2f6ff9a532e6fec460a70d3b1e (from 81b055605c34b5823f6c5f63cc0f92f43c6b7252)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:47:53 2007 +0200

    EXA: Defer to FillRegionTiled in Composite when possible.
    
    Committed separately as this case is hard to hit and has only been tested
    lightly.

diff --git a/exa/exa_render.c b/exa/exa_render.c
index 63a412c..06881e3 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -651,6 +651,45 @@ exaComposite(CARD8	op,
 		REGION_UNINIT(pDst->pDrawable->pScreen, &region);
 		goto done;
 	    }
+	    else if (pSrcPixmap && !pSrc->transform &&
+		     pSrc->repeatType == RepeatNormal)
+	    {
+		RegionRec region;
+		DDXPointRec srcOrg;
+
+		/* Let's see if the driver can do the repeat in one go */
+		if (pExaScr->info->PrepareComposite && !pSrc->alphaMap &&
+		    !pDst->alphaMap)
+		{
+		    ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc,
+						ySrc, xMask, yMask, xDst, yDst,
+						width, height);
+		    if (ret == 1)
+			goto done;
+		}
+
+		/* Now see if we can use exaFillRegionTiled() */
+		xDst += pDst->pDrawable->x;
+		yDst += pDst->pDrawable->y;
+		xSrc += pSrc->pDrawable->x;
+		ySrc += pSrc->pDrawable->y;
+
+		if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc,
+					       ySrc, xMask, yMask, xDst, yDst,
+					       width, height))
+		    goto done;
+
+		srcOrg.x = (xSrc - xDst) % pSrcPixmap->drawable.width;
+		srcOrg.y = (ySrc - yDst) % pSrcPixmap->drawable.height;
+
+		ret = exaFillRegionTiled(pDst->pDrawable, &region, pSrcPixmap,
+					 &srcOrg, FB_ALLONES, GXcopy);
+
+		REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+
+		if (ret)
+		    goto done;
+	    }
 	}
     }
 
diff-tree 81b055605c34b5823f6c5f63cc0f92f43c6b7252 (from ce317a5b76c053f449122c46e1372bf8e067cb4c)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:47:43 2007 +0200

    EXA: Composite improvements.
    
    * Defer to simpler hooks in more cases (inspired by XAA behaviour).
    * Move damage tracking from lower to higher level functions.
    * Always migrate for fallbacks.

diff --git a/exa/exa_render.c b/exa/exa_render.c
index 2234cdb..63a412c 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -297,15 +297,15 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
 
     nbox = REGION_NUM_RECTS(&region);
     pbox = REGION_RECTS(&region);
+
     while (nbox--)
     {
 	(*pExaScr->info->Solid) (pDstPix,
 				 pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
 				 pbox->x2 + dst_off_x, pbox->y2 + dst_off_y);
-	exaPixmapDirty (pDstPix, pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
-			pbox->x2 + dst_off_x, pbox->y2 + dst_off_y);
 	pbox++;
     }
+
     (*pExaScr->info->DoneSolid) (pDstPix);
     exaMarkSync(pDst->pDrawable->pScreen);
 
@@ -446,8 +446,6 @@ exaTryDriverComposite(CARD8		op,
 				     pbox->y1 + dst_off_y,
 				     pbox->x2 - pbox->x1,
 				     pbox->y2 - pbox->y1);
-	exaPixmapDirty (pDstPix, pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
-			pbox->x2 + dst_off_x, pbox->y2 + dst_off_y);
 	pbox++;
     }
     (*pExaScr->info->DoneComposite) (pDstPix);
@@ -521,6 +519,9 @@ exaTryMagicTwoPassCompositeHelper(CARD8 
 				  CARD16 height)
 {
     ExaScreenPriv (pDst->pDrawable->pScreen);
+    DrawablePtr pDstDraw = pDst->pDrawable;
+    PixmapPtr pDstPixmap = exaGetDrawablePixmap(pDstDraw);
+    int xoff, yoff;
 
     assert(op == PictOpOver);
 
@@ -539,6 +540,12 @@ exaTryMagicTwoPassCompositeHelper(CARD8 
     exaComposite(PictOpOutReverse, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
 		 xDst, yDst, width, height);
 
+    exaGetDrawableDeltas(pDstDraw, pDstPixmap, &xoff, &yoff);
+    xoff += pDstDraw->x;
+    yoff += pDstDraw->y;
+    exaPixmapDirty(pDstPixmap, xDst + xoff, yDst + yoff, xDst + xoff + width,
+		   yDst + yoff + height);
+
     /* Then, add in the source value times the destination alpha factors (1.0).
      */
     exaComposite(PictOpAdd, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
@@ -565,6 +572,28 @@ exaComposite(CARD8	op,
     int ret = -1;
     Bool saveSrcRepeat = pSrc->repeat;
     Bool saveMaskRepeat = pMask ? pMask->repeat : 0;
+    ExaMigrationRec pixmaps[3];
+    int npixmaps = 1;
+    PixmapPtr pSrcPixmap = NULL;
+
+    pixmaps[0].as_dst = TRUE;
+    pixmaps[0].as_src = exaOpReadsDestination(op);
+    pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
+
+    if (pSrc->pDrawable) {
+	pSrcPixmap = exaGetDrawablePixmap (pSrc->pDrawable);
+	pixmaps[npixmaps].as_dst = FALSE;
+	pixmaps[npixmaps].as_src = TRUE;
+	pixmaps[npixmaps].pPix = pSrcPixmap;
+	npixmaps++;
+    }
+
+    if (pMask && pMask->pDrawable) {
+	pixmaps[npixmaps].as_dst = FALSE;
+	pixmaps[npixmaps].as_src = TRUE;
+	pixmaps[npixmaps].pPix = exaGetDrawablePixmap (pMask->pDrawable);
+	npixmaps++;
+    }
 
     /* We currently don't support acceleration of gradients, or other pictures
      * with a NULL pDrawable.
@@ -583,19 +612,24 @@ exaComposite(CARD8	op,
 
     if (!pMask)
     {
-	if (op == PictOpSrc)
+      if ((op == PictOpSrc &&
+	   ((pSrc->format == pDst->format) ||
+	    (pSrc->format==PICT_a8r8g8b8 && pDst->format==PICT_x8r8g8b8) ||
+	    (pSrc->format==PICT_a8b8g8r8 && pDst->format==PICT_x8b8g8r8))) ||
+	  (op == PictOpOver && !pSrc->alphaMap && !pDst->alphaMap &&
+	   pSrc->format == pDst->format &&
+	   (pSrc->format==PICT_x8r8g8b8 || pSrc->format==PICT_x8b8g8r8)))
 	{
 	    if (pSrc->pDrawable->width == 1 &&
-		pSrc->pDrawable->height == 1 && pSrc->repeat &&
-		pSrc->repeatType == RepeatNormal)
+		pSrc->pDrawable->height == 1 &&
+		pSrc->repeat)
 	    {
 		ret = exaTryDriverSolidFill(pSrc, pDst, xSrc, ySrc, xDst, yDst,
 					    width, height);
 		if (ret == 1)
 		    goto done;
 	    }
-	    else if (!pSrc->repeat && !pSrc->transform &&
-		     pSrc->format == pDst->format)
+	    else if (pSrcPixmap && !pSrc->repeat && !pSrc->transform)
 	    {
 		RegionRec	region;
 
@@ -660,39 +694,14 @@ exaComposite(CARD8	op,
 	}
     }
 
-    if (ret != 0) {
-	ExaMigrationRec pixmaps[3];
-	/* failure to accelerate was not due to pixmaps being in the wrong
-	 * locations.
-	 */
-	pixmaps[0].as_dst = TRUE;
-	pixmaps[0].as_src = exaOpReadsDestination(op);
-	pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
-	pixmaps[1].as_dst = FALSE;
-	pixmaps[1].as_src = TRUE;
-	pixmaps[1].pPix = exaGetDrawablePixmap (pSrc->pDrawable);
-	if (pMask) {
-	    pixmaps[2].as_dst = FALSE;
-	    pixmaps[2].as_src = TRUE;
-	    pixmaps[2].pPix = exaGetDrawablePixmap (pMask->pDrawable);
-	    exaDoMigration(pixmaps, 3, FALSE);
-	} else {
-	    exaDoMigration(pixmaps, 2, FALSE);
-	}
-    }
-
 fallback:
 #if DEBUG_TRACE_FALL
     exaPrintCompositeFallback (op, pSrc, pMask, pDst);
 #endif
 
+    exaDoMigration(pixmaps, npixmaps, FALSE);
     ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc,
 		      xMask, yMask, xDst, yDst, width, height);
-    exaDrawableDirty(pDst->pDrawable,
-		     pDst->pDrawable->x + xDst,
-		     pDst->pDrawable->y + yDst,
-		     pDst->pDrawable->x + xDst + width,
-		     pDst->pDrawable->y + yDst + height);
 
 done:
     pSrc->repeat = saveSrcRepeat;
diff-tree ce317a5b76c053f449122c46e1372bf8e067cb4c (from 0c8905ebc91cf654facef84ee52231a358deec5c)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:47:16 2007 +0200

    EXA: Glyphs improvements.
    
    * Don't waste effort on invisible glyphs.
    * Add damage tracking where necessary.
    * Always migrate for fallbacks.

diff --git a/exa/exa_render.c b/exa/exa_render.c
index d48a142..2234cdb 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -845,10 +845,11 @@ exaGlyphs (CARD8	op,
     PixmapPtr	pPixmap = NULL;
     PicturePtr	pPicture;
     PixmapPtr   pMaskPixmap = NULL;
+    PixmapPtr   pDstPixmap = exaGetDrawablePixmap(pDst->pDrawable);
     PicturePtr  pMask;
     ScreenPtr   pScreen = pDst->pDrawable->pScreen;
     int		width = 0, height = 0;
-    int		x, y;
+    int		x, y, x1, y1, xoff, yoff;
     int		xDst = list->xOff, yDst = list->yOff;
     int		n;
     int		error;
@@ -892,7 +893,12 @@ exaGlyphs (CARD8	op,
 	xRectangle  rect;
 	
 	miGlyphExtents (nlist, list, glyphs, &extents);
-	
+
+	extents.x1 = max(extents.x1, 0);
+	extents.y1 = max(extents.y1, 0);
+	extents.x2 = min(extents.x2, pDst->pDrawable->width);
+	extents.y2 = min(extents.y2, pDst->pDrawable->height);
+
 	if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
 	    return;
 	width = extents.x2 - extents.x1;
@@ -918,6 +924,7 @@ exaGlyphs (CARD8	op,
 	rect.width = width;
 	rect.height = height;
 	(*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
+	exaPixmapDirty(pMaskPixmap, 0, 0, width, height);
 	FreeScratchGC (pGC);
 	x = -extents.x1;
 	y = -extents.y1;
@@ -929,6 +936,8 @@ exaGlyphs (CARD8	op,
 	y = 0;
     }
 
+    exaGetDrawableDeltas(pDst->pDrawable, pDstPixmap, &xoff, &yoff);
+
     while (nlist--)
     {
 	GCPtr pGC = NULL;
@@ -983,13 +992,21 @@ exaGlyphs (CARD8	op,
 	pixmaps[0].as_dst = TRUE;
 	pixmaps[0].as_src = TRUE;
 	pixmaps[0].pPix = pPixmap;
-	exaDoMigration (pixmaps, 1, TRUE);
+	exaDoMigration (pixmaps, 1, pExaScr->info->PrepareComposite != NULL);
 
 	while (n--)
 	{
 	    GlyphPtr glyph = *glyphs++;
 	    pointer glyphdata = (pointer) (glyph + 1);
-	    
+	    DrawablePtr pCmpDrw = (maskFormat ? pMask : pDst)->pDrawable;
+
+	    x1 = x - glyph->info.x;
+	    y1 = y - glyph->info.y;
+
+	    if (x1 >= pCmpDrw->width || y1 >= pCmpDrw->height ||
+		(x1 + glyph->info.width) <= 0 || (y1 + glyph->info.height) <= 0)
+		goto nextglyph;
+
 	    (*pScreen->ModifyPixmapHeader) (pScratchPixmap, 
 					    glyph->info.width,
 					    glyph->info.height,
@@ -1048,17 +1065,22 @@ exaGlyphs (CARD8	op,
 	    if (maskFormat)
 	    {
 		exaComposite (PictOpAdd, pPicture, NULL, pMask, 0, 0, 0, 0,
-			      x - glyph->info.x, y - glyph->info.y,
-			      glyph->info.width, glyph->info.height);
+			      x1, y1, glyph->info.width, glyph->info.height);
+		exaPixmapDirty(pMaskPixmap, x1, y1, x1 + glyph->info.width,
+			       y1 + glyph->info.height);
 	    }
 	    else
 	    {
 		exaComposite (op, pSrc, pPicture, pDst,
-			      xSrc + (x - glyph->info.x) - xDst,
-			      ySrc + (y - glyph->info.y) - yDst,
-			      0, 0, x - glyph->info.x, y - glyph->info.y,
-			      glyph->info.width, glyph->info.height);
+			      xSrc + x1 - xDst, ySrc + y1 - yDst,
+			      0, 0, x1, y1, glyph->info.width,
+			      glyph->info.height);
+		x1 += pDst->pDrawable->x + xoff;
+		y1 += pDst->pDrawable->y + yoff;
+		exaPixmapDirty(pDstPixmap, x1, y1, x1 + glyph->info.width,
+			       y1 + glyph->info.height);
 	    }
+nextglyph:
 	    x += glyph->info.xOff;
 	    y += glyph->info.yOff;
 	}
diff-tree 0c8905ebc91cf654facef84ee52231a358deec5c (from 567f18a09bfb05f448be40c7ebe0f210f955601c)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:47:08 2007 +0200

    EXA: PolyFillRect improvements.
    
    * Convert rects to region and use it for damage tracking.
    * When possible, defer to exaFillRegion{Solid,Tiled} using converted region.
    * Always migrate for fallbacks.
    * Move damage tracking out of ExaCheckPolyFillRect.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 95084fc..721882b 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -618,6 +618,9 @@ exaPolySegment (DrawablePtr pDrawable, G
     DEALLOCATE_LOCAL(prect);
 }
 
+static Bool exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion,
+				Pixel pixel, CARD32 planemask, CARD32 alu);
+
 static void
 exaPolyFillRect(DrawablePtr pDrawable,
 		GCPtr	    pGC,
@@ -626,7 +629,7 @@ exaPolyFillRect(DrawablePtr pDrawable,
 {
     ExaScreenPriv (pDrawable->pScreen);
     RegionPtr	    pClip = fbGetCompositeClip(pGC);
-    PixmapPtr	    pPixmap;
+    PixmapPtr	    pPixmap = exaGetDrawablePixmap(pDrawable);
     register BoxPtr pbox;
     BoxPtr	    pextent;
     int		    extentX1, extentX2, extentY1, extentY2;
@@ -635,39 +638,80 @@ exaPolyFillRect(DrawablePtr pDrawable,
     int		    xoff, yoff;
     int		    xorg, yorg;
     int		    n;
-    ExaMigrationRec pixmaps[1];
+    ExaMigrationRec pixmaps[2];
+    RegionPtr pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
+    RegionPtr pDamageReg = DamageRegion(ExaGetPixmapPriv(pPixmap)->pDamage);
+
+    /* Compute intersection of rects and clip region */
+    REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
+    REGION_INTERSECT(pScreen, pReg, pClip, pReg);
+
+    if (!REGION_NUM_RECTS(pReg)) {
+	REGION_DESTROY(pScreen, pReg);
+	return;
+    }
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
-    pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
+    pixmaps[0].pPix = pPixmap;
  
+    exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
+
     if (pExaScr->swappedOut ||
-	pGC->fillStyle != FillSolid ||
 	pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY)
     {
-	exaDoMigration (pixmaps, 1, FALSE);
-	ExaCheckPolyFillRect (pDrawable, pGC, nrect, prect);
-	while (nrect-- >= 0) {
-	    exaDrawableDirty(pDrawable,
-			     pDrawable->x + prect->x,
-			     pDrawable->y + prect->y,
-			     pDrawable->x + prect->x + prect->width,
-			     pDrawable->y + prect->y + prect->height);
-	    prect++;
+	goto fallback;
+    }
+
+    /* For ROPs where overlaps don't matter, convert rectangles to region and
+     * call exaFillRegion{Solid,Tiled}.
+     */
+    if ((pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) &&
+	(pGC->alu == GXcopy || pGC->alu == GXclear || pGC->alu == GXnoop ||
+	 pGC->alu == GXcopyInverted || pGC->alu == GXset)) {
+	if (((pGC->fillStyle == FillSolid || pGC->tileIsPixel) &&
+	     exaFillRegionSolid(pDrawable, pReg, pGC->fillStyle == FillSolid ?
+				pGC->fgPixel : pGC->tile.pixel,	pGC->planemask,
+				pGC->alu)) ||
+	    (pGC->fillStyle == FillTiled && !pGC->tileIsPixel &&
+	     exaFillRegionTiled(pDrawable, pReg, pGC->tile.pixmap, &pGC->patOrg,
+				pGC->planemask, pGC->alu))) {
+	    goto damage;
 	}
-	return;
-    } else {
-	exaDoMigration (pixmaps, 1, TRUE);
     }
 
-    if (!(pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||
+    if (pGC->fillStyle != FillSolid &&
+	!(pGC->tileIsPixel && pGC->fillStyle == FillTiled))
+    {
+	goto fallback;
+    }
+
+    exaDoMigration (pixmaps, 1, TRUE);
+
+    if (!exaPixmapIsOffscreen (pPixmap) ||
 	!(*pExaScr->info->PrepareSolid) (pPixmap,
 					 pGC->alu,
 					 pGC->planemask,
 					 pGC->fgPixel))
     {
+fallback:
+	if (pGC->fillStyle == FillTiled && !pGC->tileIsPixel) {
+	    pixmaps[1].as_dst = FALSE;
+	    pixmaps[1].as_src = TRUE;
+	    pixmaps[1].pPix = pGC->tile.pixmap;
+	    exaDoMigration (pixmaps, 2, FALSE);
+	} else {
+	    exaDoMigration (pixmaps, 1, FALSE);
+	}
+
 	ExaCheckPolyFillRect (pDrawable, pGC, nrect, prect);
+
+damage:
+	REGION_TRANSLATE(pScreen, pReg, xoff, yoff);
+	REGION_UNION(pScreen, pDamageReg, pReg, pDamageReg);
+	REGION_DESTROY(pScreen, pReg);
+
 	return;
     }
 
@@ -715,7 +759,8 @@ exaPolyFillRect(DrawablePtr pDrawable,
 	    pbox = REGION_RECTS(pClip);
 	    /*
 	     * clip the rectangle to each box in the clip region
-	     * this is logically equivalent to calling Intersect()
+	     * this is logically equivalent to calling Intersect(),
+	     * but rectangles may overlap each other here.
 	     */
 	    while(n--)
 	    {
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 7713a08..a7f9398 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -201,32 +201,11 @@ ExaCheckPolyFillRect (DrawablePtr pDrawa
 {
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
 
-    if (nrect) {
-	int x1 = max(prect->x, 0), y1 = max(prect->y, 0);
-	int x2 = min(prect->x + prect->width, pDrawable->width);
-	int y2 = min(prect->y + prect->height, pDrawable->height);
-
-	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
-	exaPrepareAccessGC (pGC);
-	fbPolyFillRect (pDrawable, pGC, nrect, prect);
-	exaFinishAccessGC (pGC);
-	exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
-
-	/* Only track bounding box of damage, as this path can degenerate to
-	 * zillions of damage boxes
-	 */
-	while (--nrect)
-	{
-	    prect++;
-	    x1 = min(x1, prect->x);
-	    x2 = max(x2, prect->x + prect->width);
-	    y1 = min(y1, prect->y);
-	    y2 = max(y2, prect->y + prect->height);
-	}
-
-	exaDrawableDirty (pDrawable, pDrawable->x + x1, pDrawable->y + y1,
-			  pDrawable->x + x2, pDrawable->y + y2);
-    }
+    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+    exaPrepareAccessGC (pGC);
+    fbPolyFillRect (pDrawable, pGC, nrect, prect);
+    exaFinishAccessGC (pGC);
+    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 }
 
 void
diff-tree 567f18a09bfb05f448be40c7ebe0f210f955601c (from e869573b52fac69fb88cea120daaeec59c7a3461)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:46:49 2007 +0200

    EXA: FillRegion{Solid,Tiled} improvements.
    
    * Support planemasks, different ALUs and arbitrary tile origin.
    * Leave damage tracking and non-trivial fallbacks to callers.
    * Always migrate for fallbacks.
    
    This is in preparation for using these from more other functions.

diff --git a/exa/exa.c b/exa/exa.c
index 23fe555..3d77800 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -126,7 +126,7 @@ exaGetDrawablePixmap(DrawablePtr pDrawab
  * the backing drawable. These coordinates are nonzero only for redirected
  * windows.
  */
-static void
+void
 exaGetDrawableDeltas (DrawablePtr pDrawable, PixmapPtr pPixmap,
 		      int *xp, int *yp)
 {
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index e633d80..95084fc 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1043,10 +1043,12 @@ exaCopyWindow(WindowPtr pWin, DDXPointRe
     REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 }
 
-static void
+static Bool
 exaFillRegionSolid (DrawablePtr	pDrawable,
 		    RegionPtr	pRegion,
-		    Pixel	pixel)
+		    Pixel	pixel,
+		    CARD32	planemask,
+		    CARD32	alu)
 {
     ExaScreenPriv(pDrawable->pScreen);
     PixmapPtr pPixmap;
@@ -1062,22 +1064,19 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
     if (pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY)
     {
-	exaDoMigration (pixmaps, 1, FALSE);
 	goto fallback;
     } else {
 	exaDoMigration (pixmaps, 1, TRUE);
     }
 
     if ((pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) &&
-	(*pExaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel))
+	(*pExaScr->info->PrepareSolid) (pPixmap, alu, planemask, pixel))
     {
 	while (nbox--)
 	{
 	    (*pExaScr->info->Solid) (pPixmap,
 				     pBox->x1 + xoff, pBox->y1 + yoff,
 				     pBox->x2 + xoff, pBox->y2 + yoff);
-	    exaPixmapDirty (pPixmap, pBox->x1 + xoff, pBox->y1 + yoff,
-			    pBox->x2 + xoff, pBox->y2 + yoff);
 	    pBox++;
 	}
 	(*pExaScr->info->DoneSolid) (pPixmap);
@@ -1086,27 +1085,30 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
     else
     {
 fallback:
+	if (alu != GXcopy || planemask != FB_ALLONES)
+	    return FALSE;
 	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
 		      exaDrawableLocation(pDrawable)));
+	exaDoMigration (pixmaps, 1, FALSE);
 	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 	fbFillRegionSolid (pDrawable, pRegion, 0,
 			   fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
 	exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
-	while (nbox--)
-	{
-	    exaDrawableDirty (pDrawable, pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-	    pBox++;
-	}
     }
+
+    return TRUE;
 }
 
 /* Try to do an accelerated tile of the pTile into pRegion of pDrawable.
  * Based on fbFillRegionTiled(), fbTile().
  */
-static void
+Bool
 exaFillRegionTiled (DrawablePtr	pDrawable,
 		    RegionPtr	pRegion,
-		    PixmapPtr	pTile)
+		    PixmapPtr	pTile,
+		    DDXPointPtr pPatOrg,
+		    CARD32	planemask,
+		    CARD32	alu)
 {
     ExaScreenPriv(pDrawable->pScreen);
     PixmapPtr pPixmap;
@@ -1122,10 +1124,10 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
     /* If we're filling with a solid color, grab it out and go to
      * FillRegionSolid, saving numerous copies.
      */
-    if (tileWidth == 1 && tileHeight == 1) {
-	exaFillRegionSolid(pDrawable, pRegion, exaGetPixmapFirstPixel (pTile));
-	return;
-    }
+    if (tileWidth == 1 && tileHeight == 1)
+	return exaFillRegionSolid(pDrawable, pRegion,
+				  exaGetPixmapFirstPixel (pTile), planemask,
+				  alu);
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
@@ -1139,7 +1141,6 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 	tileWidth > pExaScr->info->maxX ||
 	tileHeight > pExaScr->info->maxY)
     {
-	exaDoMigration (pixmaps, 2, FALSE);
 	goto fallback;
     } else {
 	exaDoMigration (pixmaps, 2, TRUE);
@@ -1153,8 +1154,9 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
     if (!exaPixmapIsOffscreen(pTile))
 	goto fallback;
 
-    if ((*pExaScr->info->PrepareCopy) (exaGetOffscreenPixmap((DrawablePtr)pTile, &tileXoff, &tileYoff), pPixmap, 0, 0, GXcopy,
-				       FB_ALLONES))
+    if ((*pExaScr->info->PrepareCopy) (exaGetOffscreenPixmap((DrawablePtr)pTile,
+							     &tileXoff, &tileYoff),
+				       pPixmap, 0, 0, alu, planemask))
     {
 	while (nbox--)
 	{
@@ -1162,7 +1164,7 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 	    int dstY = pBox->y1;
 	    int tileY;
 
-	    tileY = (dstY - pDrawable->y) % tileHeight;
+	    tileY = (dstY - pDrawable->y - pPatOrg->y) % tileHeight;
 	    while (height > 0) {
 		int width = pBox->x2 - pBox->x1;
 		int dstX = pBox->x1;
@@ -1173,7 +1175,7 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 		    h = height;
 		height -= h;
 
-		tileX = (dstX - pDrawable->x) % tileWidth;
+		tileX = (dstX - pDrawable->x - pPatOrg->x) % tileWidth;
 		while (width > 0) {
 		    int w = tileWidth - tileX;
 		    if (w > width)
@@ -1190,38 +1192,44 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 		dstY += h;
 		tileY = 0;
 	    }
-	    exaPixmapDirty (pPixmap, pBox->x1 + xoff, pBox->y1 + yoff,
-			    pBox->x2 + xoff, pBox->y2 + yoff);
 	    pBox++;
 	}
 	(*pExaScr->info->DoneCopy) (pPixmap);
 	exaMarkSync(pDrawable->pScreen);
-	return;
+	return TRUE;
     }
 
 fallback:
+    if (alu != GXcopy || planemask != FB_ALLONES)
+	return FALSE;
     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable,
 		  exaDrawableLocation(&pTile->drawable),
 		  exaDrawableLocation(pDrawable)));
+    exaDoMigration (pixmaps, 2, FALSE);
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
     exaPrepareAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
     fbFillRegionTiled (pDrawable, pRegion, pTile);
     exaFinishAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
-    while (nbox--)
-    {
-	exaDrawableDirty (pDrawable, pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-	pBox++;
-    }
+
+    return TRUE;
 }
 
 void
 exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
 {
     ExaScreenPriv (pWin->drawable.pScreen);
-    if (!REGION_NUM_RECTS(pRegion))
+    PixmapPtr pPixmap = exaGetDrawablePixmap((DrawablePtr)pWin);
+    int xoff, yoff;
+    BoxPtr pBox;
+    int nbox = REGION_NUM_RECTS(pRegion);
+
+    if (!nbox)
 	return;
+
     if (!pExaScr->swappedOut) {
+	DDXPointRec zeros = { 0, 0 };
+
         switch (what) {
         case PW_BACKGROUND:
             switch (pWin->backgroundState) {
@@ -1235,25 +1243,41 @@ exaPaintWindow(WindowPtr pWin, RegionPtr
                                                                  what);
                 return;
             case BackgroundPixel:
-                exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel);
-                return;
+		exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel,
+				   FB_ALLONES, GXcopy);
+                goto damage;
             case BackgroundPixmap:
-                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap);
-                return;
+                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap,
+				   &zeros, FB_ALLONES, GXcopy);
+                goto damage;
             }
             break;
         case PW_BORDER:
             if (pWin->borderIsPixel) {
-                exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel);
-                return;
+                exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel,
+				   FB_ALLONES, GXcopy);
+                goto damage;
             } else {
-                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap);
-                return;
+                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap,
+				   &zeros, FB_ALLONES, GXcopy);
+                goto damage;
             }
             break;
         }
     }
     ExaCheckPaintWindow (pWin, pRegion, what);
+
+damage:
+    exaGetDrawableDeltas((DrawablePtr)pWin, pPixmap, &xoff, &yoff);
+
+    pBox = REGION_RECTS(pRegion);
+
+    while (nbox--)
+    {
+	exaPixmapDirty (pPixmap, pBox->x1 + xoff, pBox->y1 + yoff,
+			pBox->x2 + xoff, pBox->y2 + yoff);
+	pBox++;
+    }
 }
 
 /**
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 382f059..b976082 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -288,6 +288,10 @@ exaGetPixmapFirstPixel (PixmapPtr pPixma
 void
 exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
 
+Bool
+exaFillRegionTiled (DrawablePtr	pDrawable, RegionPtr pRegion, PixmapPtr pTile,
+		    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu);
+
 void
 exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
 
@@ -344,6 +348,10 @@ void
 exaPixmapDirty(PixmapPtr pPix, int x1, int y1, int x2, int y2);
 
 void
+exaGetDrawableDeltas (DrawablePtr pDrawable, PixmapPtr pPixmap,
+		      int *xp, int *yp);
+
+void
 exaDrawableDirty(DrawablePtr pDrawable, int x1, int y1, int x2, int y2);
 
 Bool
diff-tree e869573b52fac69fb88cea120daaeec59c7a3461 (from d3f8667341bfe6dc7d0258c4ad69377f37d88d95)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:45:48 2007 +0200

    EXA: exaAssertNotDirty improvements.
    
    * Return early if the valid region is empty or the pixmap is pinned.
    * Fix loop for several cliprects.

diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index eedc5fd..70d8e12 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -464,12 +464,10 @@ exaAssertNotDirty (PixmapPtr pPixmap)
     BoxPtr pBox = REGION_RECTS(pValidReg);
     Bool ret = TRUE;
 
-    if (pExaPixmap == NULL || pExaPixmap->fb_ptr == NULL)
+    if (!nbox || exaPixmapIsPinned(pPixmap) || pExaPixmap->fb_ptr == NULL)
 	return ret;
 
-    dst = pExaPixmap->sys_ptr;
     dst_pitch = pExaPixmap->sys_pitch;
-    src = pExaPixmap->fb_ptr;
     src_pitch = pExaPixmap->fb_pitch;
     cpp = pPixmap->drawable.bitsPerPixel / 8;
 
@@ -486,21 +484,18 @@ exaAssertNotDirty (PixmapPtr pPixmap)
 		continue;
 
 	    rowbytes = (pBox->x2 - pBox->x1) * cpp;
-	    src += pBox->y1 * src_pitch + pBox->x1 * cpp;
-	    dst += pBox->y1 * dst_pitch + pBox->x1 * cpp;
+	    src = pExaPixmap->fb_ptr + pBox->y1 * src_pitch + pBox->x1 * cpp;
+	    dst = pExaPixmap->sys_ptr + pBox->y1 * dst_pitch + pBox->x1 * cpp;
 
-	    for (y = pBox->y2 - pBox->y1; y; y--) {
-		if (memcmp(dst + pBox->y1 * dst_pitch + pBox->x1 * cpp,
-			   src + pBox->y1 * src_pitch + pBox->x1 * cpp,
-			   (pBox->x2 - pBox->x1) * cpp) != 0) {
+	    for (y = pBox->y1; y < pBox->y2;
+		 y++, src += src_pitch, dst += dst_pitch) {
+		if (memcmp(dst, src, rowbytes) != 0) {
 		    ret = FALSE;
+		    exaPixmapDirty(pPixmap, pBox->x1, pBox->y1, pBox->x2,
+				   pBox->y2);
 		    break;
 		}
-		src += src_pitch;
-		dst += dst_pitch;
 	    }
-	    src -= pBox->y1 * src_pitch + pBox->x1 * cpp;
-	    dst -= pBox->y1 * dst_pitch + pBox->x1 * cpp;
     }
     exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
 
diff-tree d3f8667341bfe6dc7d0258c4ad69377f37d88d95 (from 5e4b3232dafe3b0dec65bf639bebaba4774210b7)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:44:27 2007 +0200

    EXA: Fix exaEnableDisableFBAccess for nested disables and enables.

diff --git a/exa/exa_offscreen.c b/exa/exa_offscreen.c
index 7708dd7..38ad58f 100644
--- a/exa/exa_offscreen.c
+++ b/exa/exa_offscreen.c
@@ -341,13 +341,15 @@ exaEnableDisableFBAccess (int index, Boo
     ScreenPtr pScreen = screenInfo.screens[index];
     ExaScreenPriv (pScreen);
 
-    if (!enable) {
+    if (!enable && pExaScr->disableFbCount++ == 0) {
 	if (pExaScr->info->exa_minor < 1)
 	    ExaOffscreenSwapOut (pScreen);
 	else
 	    ExaOffscreenEjectPixmaps (pScreen);
 	pExaScr->swappedOut = TRUE;
-    } else {
+    }
+    
+    if (enable && --pExaScr->disableFbCount == 0) {
 	if (pExaScr->info->exa_minor < 1)
 	    ExaOffscreenSwapIn (pScreen);
 	pExaScr->swappedOut = FALSE;
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 984cb66..382f059 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -113,6 +113,7 @@ typedef struct {
     enum ExaMigrationHeuristic	 migration;
     Bool			 hideOffscreenPixmapData;
     Bool			 checkDirtyCorrectness;
+    unsigned			 disableFbCount;
 } ExaScreenPrivRec, *ExaScreenPrivPtr;
 
 /*
diff-tree 5e4b3232dafe3b0dec65bf639bebaba4774210b7 (from 2866e0bac9b8dd3892c5e68abcfc6c97cebaf88a)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:38:22 2007 +0200

    Fix fbCompositeTrans_0888xnx0888 build for wfb on big endian.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 2c10398..a735967 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -140,7 +140,7 @@ fbIn (CARD32 x, CARD8 y)
 					temp=count&3; \
 					where-=temp; \
 					workingWhere=(CARD32 *)where; \
-                                        workingVal=READ(workingWhere)++; \
+                                        workingVal=READ(workingWhere++); \
 					count=4-temp; \
 					workingVal<<=(8*temp)
         #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y = READ(z++); } where=(y)>>24; (y)<<=8; (x)--;}
diff-tree 2866e0bac9b8dd3892c5e68abcfc6c97cebaf88a (from 78a20455356ccc310f73cfc65ad65a7677eee7e5)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Apr 29 23:38:13 2007 +0200

    Fix a couple of picture repeat fields incorrectly compared to RepeatNormal.

diff --git a/exa/exa_render.c b/exa/exa_render.c
index b78d728..d48a142 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -627,8 +627,8 @@ exaComposite(CARD8	op,
 	    pMask->repeat = 0;
 
     if (pExaScr->info->PrepareComposite &&
-	(!pSrc->repeat || pSrc->repeat == RepeatNormal) &&
-	(!pMask || !pMask->repeat || pMask->repeat == RepeatNormal) &&
+	(!pSrc->repeat || pSrc->repeatType == RepeatNormal) &&
+	(!pMask || !pMask->repeat || pMask->repeatType == RepeatNormal) &&
 	!pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap)
     {
 	Bool isSrcSolid;
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 0a08aff..2c10398 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1495,7 +1495,7 @@ fbComposite (CARD8      op,
     {
 	xMask += pMask->pDrawable->x;
 	yMask += pMask->pDrawable->y;
-	maskRepeat = pMask->repeat == RepeatNormal;
+	maskRepeat = pMask->repeatType == RepeatNormal;
 
 	if (pMask->filter == PictFilterConvolution)
 	    maskTransform = TRUE;
diff --git a/hw/xgl/xglcompose.c b/hw/xgl/xglcompose.c
index d2aead0..34f7a0c 100644
--- a/hw/xgl/xglcompose.c
+++ b/hw/xgl/xglcompose.c
@@ -177,7 +177,7 @@ xglCompositeGeneral (CARD8	     op,
     {
 	if (!pSrc->transform && pSrc->filter != PictFilterConvolution)
 	{
-	    if (pSrc->pDrawable && pSrc->repeat == RepeatNormal)
+	    if (pSrc->pDrawable && pSrc->repeatType == RepeatNormal)
 	    {
 		XGL_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
 
diff-tree 78a20455356ccc310f73cfc65ad65a7677eee7e5 (from 6c4f1826bf2c5f30f5fe6e489a02b6375478b380)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 27 15:20:24 2007 -0400

    Pixman merging
    
    More msvc++ porting

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index cea8ad9..a322bec 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -1700,7 +1700,9 @@ fbSolidFillmmx (DrawablePtr	pDraw,
     CARD8	*byte_line;
     FbBits      *bits;
     int		xoff, yoff;
+#ifdef __GNUC__
     __m64	v1, v2, v3, v4, v5, v6, v7;
+#endif
     
     CHECKPOINT();
     
@@ -1730,6 +1732,7 @@ fbSolidFillmmx (DrawablePtr	pDraw,
     fill = ((ullong)xor << 32) | xor;
     vfill = (__m64)fill;
     
+#ifdef __GNUC__
     __asm__ (
 	"movq		%7,	%0\n"
 	"movq		%7,	%1\n"
@@ -1741,6 +1744,7 @@ fbSolidFillmmx (DrawablePtr	pDraw,
 	: "=y" (v1), "=y" (v2), "=y" (v3),
 	  "=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
 	: "y" (vfill));
+#endif
     
     while (height--)
     {
@@ -1766,6 +1770,7 @@ fbSolidFillmmx (DrawablePtr	pDraw,
 
 	while (w >= 64)
 	{
+#ifdef __GNUC__
 	    __asm__ (
 		"movq	%1,	  (%0)\n"
 		"movq	%2,	 8(%0)\n"
@@ -1780,7 +1785,16 @@ fbSolidFillmmx (DrawablePtr	pDraw,
 		  "y" (vfill), "y" (v1), "y" (v2), "y" (v3),
 		  "y" (v4), "y" (v5), "y" (v6), "y" (v7)
 		: "memory");
-	    
+#else
+	    *(__m64*) (d +  0) = vfill;
+	    *(__m64*) (d +  8) = vfill;
+	    *(__m64*) (d + 16) = vfill;
+	    *(__m64*) (d + 24) = vfill;
+	    *(__m64*) (d + 32) = vfill;
+	    *(__m64*) (d + 40) = vfill;
+	    *(__m64*) (d + 48) = vfill;
+	    *(__m64*) (d + 56) = vfill;
+#endif    
 	    w -= 64;
 	    d += 64;
 	}
@@ -2823,6 +2837,7 @@ fbCopyAreammx (DrawablePtr	pSrc,
 	
 	while (w >= 64)
 	{
+#ifdef __GNUC__
 	    __asm__ (
 		"movq	  (%1),	  %%mm0\n"
 		"movq	 8(%1),	  %%mm1\n"
@@ -2846,6 +2861,24 @@ fbCopyAreammx (DrawablePtr	pSrc,
 		: "memory",
 		  "%mm0", "%mm1", "%mm2", "%mm3",
 		  "%mm4", "%mm5", "%mm6", "%mm7");
+#else
+	    __m64 v0 = *(__m64 *)(s + 0);
+	    __m64 v1 = *(__m64 *)(s + 8);
+	    __m64 v2 = *(__m64 *)(s + 16);
+	    __m64 v3 = *(__m64 *)(s + 24);
+	    __m64 v4 = *(__m64 *)(s + 32);
+	    __m64 v5 = *(__m64 *)(s + 40);
+	    __m64 v6 = *(__m64 *)(s + 48);
+	    __m64 v7 = *(__m64 *)(s + 56);
+	    *(__m64 *)(d + 0)  = v0;
+	    *(__m64 *)(d + 8)  = v1;
+	    *(__m64 *)(d + 16) = v2;
+	    *(__m64 *)(d + 24) = v3;
+	    *(__m64 *)(d + 32) = v4;
+	    *(__m64 *)(d + 40) = v5;
+	    *(__m64 *)(d + 48) = v6;
+	    *(__m64 *)(d + 56) = v7;
+#endif	    
 	    
 	    w -= 64;
 	    s += 64;
diff-tree 6c4f1826bf2c5f30f5fe6e489a02b6375478b380 (from ae04f2cb0a068cdc1e519627bf745de0c9e4a85a)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 27 08:13:08 2007 -0400

    Bug fix in fbCompositeIn_nx8x8888
    
    Make sure both halves of the dst word is set to zero when the masks
    are both 0.

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 0e90746..cea8ad9 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -1900,7 +1900,7 @@ fbCompositeSolidMaskSrc_nx8x8888mmx (CAR
 	    }
 	    else
 	    {
-		*dst = 0;
+		*(ullong *)dst = 0;
 	    }
 
 	    mask += 2;
diff-tree ae04f2cb0a068cdc1e519627bf745de0c9e4a85a (from 6c8152d6ee9eeb21a68a8bbfed1540939e5bcd1f)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Thu Apr 26 15:28:04 2007 -0400

    Fix the 'relink' target for kdrive servers.

diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
index e078049..267d772 100644
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -23,14 +23,20 @@ if KDRIVELINUX
 LINUX_SUBDIRS = linux
 endif
 
-SUBDIRS =			\
-	src			\
-	$(LINUX_SUBDIRS)	\
+SERVER_SUBDIRS = 		\
 	$(XSDL_SUBDIRS)		\
 	$(FBDEV_SUBDIRS)	\
 	$(VESA_SUBDIRS)		\
 	$(XEPHYR_SUBDIRS)       \
 	$(XFAKE_SUBDIRS)
 
+SUBDIRS =			\
+	src			\
+	$(LINUX_SUBDIRS)	\
+	$(SERVER_SUBDIRS)
+
 DIST_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
                smi via fbdev sdl ephyr src linux fake sis300
+
+relink:
+	@for i in $(SERVER_SUBDIRS) ; do make -C $$i relink ; done
diff --git a/hw/kdrive/ati/Makefile.am b/hw/kdrive/ati/Makefile.am
index 76635fb..61c1c84 100644
--- a/hw/kdrive/ati/Makefile.am
+++ b/hw/kdrive/ati/Makefile.am
@@ -62,3 +62,6 @@ Xati_LDADD = \
 	$(ATI_LIBS)			\
 	@KDRIVE_LIBS@			\
 	@XSERVER_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/chips/Makefile.am b/hw/kdrive/chips/Makefile.am
index 2f8a88d..a0a10d7 100644
--- a/hw/kdrive/chips/Makefile.am
+++ b/hw/kdrive/chips/Makefile.am
@@ -24,3 +24,6 @@ Xchips_LDADD = \
 	$(CHIPS_LIBS)				\
 	@KDRIVE_LIBS@                           \
 	@XSERVER_LIBS@				
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index c201fe9..1e820c0 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -29,3 +29,6 @@ Xephyr_LDADD = 						\
 	../../../exa/libexa.la				\
 	@KDRIVE_LIBS@					\
         @XEPHYR_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/epson/Makefile.am b/hw/kdrive/epson/Makefile.am
index a5bc70b..d36230a 100644
--- a/hw/kdrive/epson/Makefile.am
+++ b/hw/kdrive/epson/Makefile.am
@@ -24,3 +24,6 @@ Xepson_LDADD = \
 	$(EPSON_LIBS)			       \
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@				
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/fake/Makefile.am b/hw/kdrive/fake/Makefile.am
index d7ebfc2..69fdf59 100644
--- a/hw/kdrive/fake/Makefile.am
+++ b/hw/kdrive/fake/Makefile.am
@@ -20,3 +20,6 @@ Xfake_LDADD = 						\
 	libfake.a					\
 	@KDRIVE_LIBS@					\
         @XSERVER_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/fbdev/Makefile.am b/hw/kdrive/fbdev/Makefile.am
index cb71801..b7a863b 100644
--- a/hw/kdrive/fbdev/Makefile.am
+++ b/hw/kdrive/fbdev/Makefile.am
@@ -18,4 +18,7 @@ Xfbdev_LDADD = 						\
 	libfbdev.a					\
 	@KDRIVE_LIBS@					\
 	@XSERVER_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
 endif
diff --git a/hw/kdrive/i810/Makefile.am b/hw/kdrive/i810/Makefile.am
index 5039585..79093da 100644
--- a/hw/kdrive/i810/Makefile.am
+++ b/hw/kdrive/i810/Makefile.am
@@ -27,3 +27,6 @@ Xi810_LDADD = \
 	$(I810_LIBS)					\
 	@KDRIVE_LIBS@                                  \
 	@XSERVER_LIBS@					
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/mach64/Makefile.am b/hw/kdrive/mach64/Makefile.am
index 67712e2..b4d9a4e 100644
--- a/hw/kdrive/mach64/Makefile.am
+++ b/hw/kdrive/mach64/Makefile.am
@@ -31,3 +31,6 @@ Xmach64_LDADD = 					\
 	$(MACH64_LIBS)					\
 	@KDRIVE_LIBS@					\
 	@XSERVER_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/mga/Makefile.am b/hw/kdrive/mga/Makefile.am
index ee07989..db1a956 100644
--- a/hw/kdrive/mga/Makefile.am
+++ b/hw/kdrive/mga/Makefile.am
@@ -26,3 +26,6 @@ Xmga_LDADD = \
 	$(MGA_LIBS)					\
 	@KDRIVE_LIBS@                                  \
 	@XSERVER_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/neomagic/Makefile.am b/hw/kdrive/neomagic/Makefile.am
index 9a1af99..33bc3a9 100644
--- a/hw/kdrive/neomagic/Makefile.am
+++ b/hw/kdrive/neomagic/Makefile.am
@@ -38,3 +38,6 @@ Xneomagic_LDADD = \
 	$(NEOMAGIC_LIBS)            \
 	@KDRIVE_LIBS@               \
 	@XSERVER_LIBS@		  
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/nvidia/Makefile.am b/hw/kdrive/nvidia/Makefile.am
index 67eff69..79d2738 100644
--- a/hw/kdrive/nvidia/Makefile.am
+++ b/hw/kdrive/nvidia/Makefile.am
@@ -27,3 +27,6 @@ Xnvidia_LDADD = \
 	$(NVIDIA_LIBS)				\
 	@KDRIVE_LIBS@				\
 	@XSERVER_LIBS@			
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/pm2/Makefile.am b/hw/kdrive/pm2/Makefile.am
index a7b0f00..ec70276 100644
--- a/hw/kdrive/pm2/Makefile.am
+++ b/hw/kdrive/pm2/Makefile.am
@@ -25,3 +25,6 @@ Xpm2_LDADD = \
 	$(PM2_LIBS)				\
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@			
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/r128/Makefile.am b/hw/kdrive/r128/Makefile.am
index eab80cc..1ca1a60 100644
--- a/hw/kdrive/r128/Makefile.am
+++ b/hw/kdrive/r128/Makefile.am
@@ -24,3 +24,6 @@ Xr128_LDADD = \
 	$(R128_LIBS)				\
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@					
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/sdl/Makefile.am b/hw/kdrive/sdl/Makefile.am
index f5abb86..fa09640 100644
--- a/hw/kdrive/sdl/Makefile.am
+++ b/hw/kdrive/sdl/Makefile.am
@@ -11,3 +11,6 @@ Xsdl_LDADD = @KDRIVE_PURE_LIBS@				\
 	@KDRIVE_LIBS@                                  \
 	@XSERVER_LIBS@					\
 	@XSDL_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/sis300/Makefile.am b/hw/kdrive/sis300/Makefile.am
index 9802074..62f3266 100644
--- a/hw/kdrive/sis300/Makefile.am
+++ b/hw/kdrive/sis300/Makefile.am
@@ -38,3 +38,6 @@ Xsis_LDADD = \
 	$(SIS_LIBS)				\
 	@KDRIVE_LIBS@                          \
 	$(TSLIB_FLAG)
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/smi/Makefile.am b/hw/kdrive/smi/Makefile.am
index 0fd9729..a6ac474 100644
--- a/hw/kdrive/smi/Makefile.am
+++ b/hw/kdrive/smi/Makefile.am
@@ -29,3 +29,6 @@ Xsmi_LDADD = \
 	$(SMI_LIBS)				\
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@					
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/vesa/Makefile.am b/hw/kdrive/vesa/Makefile.am
index 54a6f47..e062fe7 100644
--- a/hw/kdrive/vesa/Makefile.am
+++ b/hw/kdrive/vesa/Makefile.am
@@ -23,3 +23,6 @@ Xvesa_LDADD = \
 	libvesa.a 				\
 	@KDRIVE_LIBS@				\
 	@XSERVER_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/via/Makefile.am b/hw/kdrive/via/Makefile.am
index 0ea8881..1c57969 100644
--- a/hw/kdrive/via/Makefile.am
+++ b/hw/kdrive/via/Makefile.am
@@ -25,3 +25,6 @@ Xvia_LDADD =						\
 	$(VIA_LIBS)					\
 	@KDRIVE_LIBS@					\
 	@XSERVER_LIBS@
+
+relink:
+	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff-tree 6c8152d6ee9eeb21a68a8bbfed1540939e5bcd1f (from 2208c6087d6bffcb24a30891a56430e28735874c)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Thu Apr 26 14:59:04 2007 -0400

    Remove old edid_modes.c, it lives in hw/xfree86/modes/ now.

diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c
deleted file mode 100644
index 926bc89..0000000
--- a/hw/xfree86/ddc/edid_modes.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright 2006 Luc Verhaegen.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86DDC.h"
-#include <X11/Xatom.h>
-#include "property.h"
-#include "propertyst.h"
-#include "xf86DDC.h"
-
-/*
- * TODO:
- *  - for those with access to the VESA DMT standard; review please.
- */
-#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DRIVER
-#define MODESUFFIX   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
-
-DisplayModeRec DDCEstablishedModes[17] = {
-    { MODEPREFIX("800x600"),    40000,  800,  840,  968, 1056, 0,  600,  601,  605,  628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 60Hz */
-    { MODEPREFIX("800x600"),    36000,  800,  824,  896, 1024, 0,  600,  601,  603,  625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 56Hz */
-    { MODEPREFIX("640x480"),    31500,  640,  656,  720,  840, 0,  480,  481,  484,  500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 75Hz */
-    { MODEPREFIX("640x480"),    31500,  640,  664,  704,  832, 0,  480,  489,  491,  520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 72Hz */
-    { MODEPREFIX("640x480"),    30240,  640,  704,  768,  864, 0,  480,  483,  486,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 67Hz */
-    { MODEPREFIX("640x480"),    25200,  640,  656,  752,  800, 0,  480,  490,  492,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 60Hz */
-    { MODEPREFIX("720x400"),    35500,  720,  738,  846,  900, 0,  400,  421,  423,  449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400 at 88Hz */
-    { MODEPREFIX("720x400"),    28320,  720,  738,  846,  900, 0,  400,  412,  414,  449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400 at 70Hz */
-    { MODEPREFIX("1280x1024"), 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024 at 75Hz */
-    { MODEPREFIX("1024x768"),   78800, 1024, 1040, 1136, 1312, 0,  768,  769,  772,  800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768 at 75Hz */
-    { MODEPREFIX("1024x768"),   75000, 1024, 1048, 1184, 1328, 0,  768,  771,  777,  806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768 at 70Hz */
-    { MODEPREFIX("1024x768"),   65000, 1024, 1048, 1184, 1344, 0,  768,  771,  777,  806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768 at 60Hz */
-    { MODEPREFIX("1024x768"),   44900, 1024, 1032, 1208, 1264, 0,  768,  768,  776,  817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768 at 43Hz */
-    { MODEPREFIX("832x624"),    57284,  832,  864,  928, 1152, 0,  624,  625,  628,  667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624 at 75Hz */
-    { MODEPREFIX("800x600"),    49500,  800,  816,  896, 1056, 0,  600,  601,  604,  625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 75Hz */
-    { MODEPREFIX("800x600"),    50000,  800,  856,  976, 1040, 0,  600,  637,  643,  666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 72Hz */
-    { MODEPREFIX("1152x864"),  108000, 1152, 1216, 1344, 1600, 0,  864,  865,  868,  900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864 at 75Hz */
-};
-
-static DisplayModePtr
-DDCModesFromEstablished(int scrnIndex, struct established_timings *timing)
-{
-    DisplayModePtr Modes = NULL, Mode = NULL;
-    CARD32 bits = (timing->t1) | (timing->t2 << 8) |
-        ((timing->t_manu & 0x80) << 9);
-    int i;
-
-    for (i = 0; i < 17; i++) {
-        if (bits & (0x01 << i)) {
-            Mode = xf86DuplicateMode(&DDCEstablishedModes[i]);
-            Modes = xf86ModesAdd(Modes, Mode);
-        }
-    }
-
-    return Modes;
-}
-
-/*
- *
- */
-static DisplayModePtr
-DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing)
-{
-    DisplayModePtr Modes = NULL, Mode = NULL;
-    int i;
-
-    for (i = 0; i < STD_TIMINGS; i++) {
-        if (timing[i].hsize && timing[i].vsize && timing[i].refresh) {
-            Mode =  xf86CVTMode(timing[i].hsize, timing[i].vsize,
-                                timing[i].refresh, FALSE, FALSE);
-	    Mode->type = M_T_DRIVER;
-            Modes = xf86ModesAdd(Modes, Mode);
-        }
-    }
-
-    return Modes;
-}
-
-/*
- *
- */
-static DisplayModePtr
-DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
-			  int preferred)
-{
-    DisplayModePtr Mode;
-
-    /*
-     * Refuse to create modes that are insufficiently large.  64 is a random
-     * number, maybe the spec says something about what the minimum is.  In
-     * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe
-     * our parser is just being too aggresive there.
-     */
-    if (timing->h_active < 64 || timing->v_active < 64) {
-	xf86DrvMsg(scrnIndex, X_INFO,
-		   "%s: Ignoring tiny %dx%d mode\n", __func__,
-		   timing->h_active, timing->v_active);
-	return NULL;
-    }
-
-    /* We don't do stereo */
-    if (timing->stereo) {
-        xf86DrvMsg(scrnIndex, X_INFO,
-		   "%s: Ignoring: We don't handle stereo.\n", __func__);
-        return NULL;
-    }
-
-    /* We only do seperate sync currently */
-    if (timing->sync != 0x03) {
-         xf86DrvMsg(scrnIndex, X_INFO,
-		    "%s: %dx%d Warning: We only handle seperate"
-                    " sync.\n", __func__, timing->h_active, timing->v_active);
-    }
-
-    Mode = xnfalloc(sizeof(DisplayModeRec));
-    memset(Mode, 0, sizeof(DisplayModeRec));
-
-    Mode->type = M_T_DRIVER;
-    if (preferred)
-	Mode->type |= M_T_PREFERRED;
-
-    Mode->Clock = timing->clock / 1000.0;
-
-    Mode->HDisplay = timing->h_active;
-    Mode->HSyncStart = timing->h_active + timing->h_sync_off;
-    Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width;
-    Mode->HTotal = timing->h_active + timing->h_blanking;
-
-    Mode->VDisplay = timing->v_active;
-    Mode->VSyncStart = timing->v_active + timing->v_sync_off;
-    Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
-    Mode->VTotal = timing->v_active + timing->v_blanking;
-
-    xf86SetModeDefaultName(Mode);
-
-    /* We ignore h/v_size and h/v_border for now. */
-
-    if (timing->interlaced)
-        Mode->Flags |= V_INTERLACE;
-
-    if (timing->misc & 0x02)
-        Mode->Flags |= V_PHSYNC;
-    else
-        Mode->Flags |= V_NHSYNC;
-
-    if (timing->misc & 0x01)
-        Mode->Flags |= V_PVSYNC;
-    else
-        Mode->Flags |= V_NVSYNC;
-
-    return Mode;
-}
-
-/*
- *
- */
-static void
-DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
-{
-    DisplayModePtr Mode = Modes;
-
-    if (!Monitor || !Modes)
-        return;
-
-    /* set up the ranges for scanning through the modes */
-    Monitor->nHsync = 1;
-    Monitor->hsync[0].lo = 1024.0;
-    Monitor->hsync[0].hi = 0.0;
-
-    Monitor->nVrefresh = 1;
-    Monitor->vrefresh[0].lo = 1024.0;
-    Monitor->vrefresh[0].hi = 0.0;
-
-    while (Mode) {
-        if (!Mode->HSync)
-            Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
-
-        if (!Mode->VRefresh)
-            Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / 
-                ((float) (Mode->HTotal * Mode->VTotal));
-
-        if (Mode->HSync < Monitor->hsync[0].lo)
-            Monitor->hsync[0].lo = Mode->HSync;
-
-        if (Mode->HSync > Monitor->hsync[0].hi)
-            Monitor->hsync[0].hi = Mode->HSync;
-
-        if (Mode->VRefresh < Monitor->vrefresh[0].lo)
-            Monitor->vrefresh[0].lo = Mode->VRefresh;
-
-        if (Mode->VRefresh > Monitor->vrefresh[0].hi)
-            Monitor->vrefresh[0].hi = Mode->VRefresh;
-
-        Mode = Mode->next;
-    }
-}
-
-DisplayModePtr
-xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
-{
-    int preferred, i;
-    DisplayModePtr Modes = NULL, Mode;
-
-    preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
-
-    /* Add established timings */
-    Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1);
-    Modes = xf86ModesAdd(Modes, Mode);
-
-    /* Add standard timings */
-    Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2);
-    Modes = xf86ModesAdd(Modes, Mode);
-
-    for (i = 0; i < DET_TIMINGS; i++) {
-	struct detailed_monitor_section *det_mon = &DDC->det_mon[i];
-
-        switch (det_mon->type) {
-        case DT:
-            Mode = DDCModeFromDetailedTiming(scrnIndex,
-                                             &det_mon->section.d_timings,
-					     preferred);
-	    preferred = 0;
-            Modes = xf86ModesAdd(Modes, Mode);
-            break;
-        case DS_STD_TIMINGS:
-            Mode = DDCModesFromStandardTiming(scrnIndex,
-					      det_mon->section.std_t);
-            Modes = xf86ModesAdd(Modes, Mode);
-            break;
-        default:
-            break;
-        }
-    }
-
-    return Modes;
-}
-
-/*
- * Fill out MonPtr with xf86MonPtr information.
- */
-void
-xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
-{
-    DisplayModePtr Modes = NULL, Mode;
-    int i, clock;
-    Bool have_hsync = FALSE, have_vrefresh = FALSE;
-
-    if (!Monitor || !DDC)
-        return;
-
-    Monitor->DDC = DDC;
-
-    Monitor->widthmm = 10 * DDC->features.hsize;
-    Monitor->heightmm = 10 * DDC->features.vsize;
-
-    /* If this is a digital display, then we can use reduced blanking */
-    if (DDC->features.input_type)
-        Monitor->reducedblanking = TRUE;
-    /* Allow the user to also enable this through config */
-
-    Modes = xf86DDCGetModes(scrnIndex, DDC);
-
-    /* Skip EDID ranges if they were specified in the config file */
-    have_hsync = (Monitor->nHsync != 0);
-    have_vrefresh = (Monitor->nVrefresh != 0);
-
-    /* Go through the detailed monitor sections */
-    for (i = 0; i < DET_TIMINGS; i++) {
-        switch (DDC->det_mon[i].type) {
-        case DS_RANGES:
-	    if (!have_hsync) {
-		if (!Monitor->nHsync)
-		    xf86DrvMsg(scrnIndex, X_INFO,
-			    "Using EDID range info for horizontal sync\n");
-		Monitor->hsync[Monitor->nHsync].lo =
-		    DDC->det_mon[i].section.ranges.min_h;
-		Monitor->hsync[Monitor->nHsync].hi =
-		    DDC->det_mon[i].section.ranges.max_h;
-		Monitor->nHsync++;
-	    } else {
-		xf86DrvMsg(scrnIndex, X_INFO,
-			"Using hsync ranges from config file\n");
-	    }
-
-	    if (!have_vrefresh) {
-		if (!Monitor->nVrefresh)
-		    xf86DrvMsg(scrnIndex, X_INFO,
-			    "Using EDID range info for vertical refresh\n");
-		Monitor->vrefresh[Monitor->nVrefresh].lo =
-		    DDC->det_mon[i].section.ranges.min_v;
-		Monitor->vrefresh[Monitor->nVrefresh].hi =
-		    DDC->det_mon[i].section.ranges.max_v;
-		Monitor->nVrefresh++;
-	    } else {
-		xf86DrvMsg(scrnIndex, X_INFO,
-			"Using vrefresh ranges from config file\n");
-	    }
-
-	    clock = DDC->det_mon[i].section.ranges.max_clock * 1000;
-	    if (clock > Monitor->maxPixClock)
-		Monitor->maxPixClock = clock;
-
-            break;
-        default:
-            break;
-        }
-    }
-
-    if (Modes) {
-        /* Print Modes */
-        xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n");
-
-        Mode = Modes;
-        while (Mode) {
-            xf86PrintModeline(scrnIndex, Mode);
-            Mode = Mode->next;
-        }
-
-        /* Do we still need ranges to be filled in? */
-        if (!Monitor->nHsync || !Monitor->nVrefresh)
-            DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
-
-        /* look for last Mode */
-        Mode = Modes;
-
-        while (Mode->next)
-            Mode = Mode->next;
-
-        /* add to MonPtr */
-        if (Monitor->Modes) {
-            Monitor->Last->next = Modes;
-            Modes->prev = Monitor->Last;
-            Monitor->Last = Mode;
-        } else {
-            Monitor->Modes = Modes;
-            Monitor->Last = Mode;
-        }
-    }
-}
diff-tree 2208c6087d6bffcb24a30891a56430e28735874c (from a300ef84cee26febfbe08c497d0d063588130bdd)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 14:40:30 2007 -0400

    Change expand_alpha_rev to expand_alpha in mmxSaturateU

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 164776a..0e90746 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -640,7 +640,7 @@ mmxCombineSaturateU (CARD32 *dest, const
 
         if (sa > da) {
             __m64 msa = load8888(FbIntDiv(da, sa) << 24);
-            msa = expand_alpha_rev(msa);
+            msa = expand_alpha(msa);
             ms = pix_multiply(ms, msa);
         }
         md = pix_add(md, ms);
diff-tree a300ef84cee26febfbe08c497d0d063588130bdd (from 0ebe48be59368b55c618f60d4656300bd7f52ed9)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 14:37:53 2007 -0400

    Fix typo in previous commit

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 7f1a7b1..164776a 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -639,7 +639,7 @@ mmxCombineSaturateU (CARD32 *dest, const
         CARD32 da = ~d >> 24;
 
         if (sa > da) {
-            __m64 msa = load8888(FbIntDiv(da, sa))<<24;
+            __m64 msa = load8888(FbIntDiv(da, sa) << 24);
             msa = expand_alpha_rev(msa);
             ms = pix_multiply(ms, msa);
         }
diff-tree 0ebe48be59368b55c618f60d4656300bd7f52ed9 (from 4fe918b38553133c27e5ae672e5c43984a9bbaea)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 14:36:32 2007 -0400

    Pixman merge
    
    - Changes to support MS Visual C++
    
    - use inline instead of __inline__
    
    - Fix rounding errors (Billy Biggs, from xserver via pixman)

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 875fec0..7f1a7b1 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -85,30 +85,40 @@
 
 typedef unsigned long long ullong;
 
+#ifdef __GNUC__
+typedef ullong mmxdatafield;
+#endif
+#ifdef _MSC_VER
+typedef unsigned __int64 ullong;
+typedef __m64 mmxdatafield;
+#endif
+
 typedef struct
 {
-    ullong mmx_4x00ff;
-    ullong mmx_4x0080;
-    ullong mmx_565_rgb;
-    ullong mmx_565_unpack_multiplier;
-    ullong mmx_565_r;
-    ullong mmx_565_g;
-    ullong mmx_565_b;
-    ullong mmx_mask_0;
-    ullong mmx_mask_1;
-    ullong mmx_mask_2;
-    ullong mmx_mask_3;
-    ullong mmx_full_alpha;
-    ullong mmx_ffff0000ffff0000;
-    ullong mmx_0000ffff00000000;
-    ullong mmx_000000000000ffff;
+    mmxdatafield mmx_4x00ff;
+    mmxdatafield mmx_4x0080;
+    mmxdatafield mmx_565_rgb;
+    mmxdatafield mmx_565_unpack_multiplier;
+    mmxdatafield mmx_565_r;
+    mmxdatafield mmx_565_g;
+    mmxdatafield mmx_565_b;
+    mmxdatafield mmx_mask_0;
+    mmxdatafield mmx_mask_1;
+    mmxdatafield mmx_mask_2;
+    mmxdatafield mmx_mask_3;
+    mmxdatafield mmx_full_alpha;
+    mmxdatafield mmx_ffff0000ffff0000;
+    mmxdatafield mmx_0000ffff00000000;
+    mmxdatafield mmx_000000000000ffff;
 } MMXData;
 
 static const MMXData c =
 {
+#ifdef __GNUC__
     .mmx_4x00ff =			0x00ff00ff00ff00ffULL,
     .mmx_4x0080 =			0x0080008000800080ULL,
     .mmx_565_rgb =			0x000001f0003f001fULL,
+    .mmx_565_unpack_multiplier =	0x0000008404100840ULL,
     .mmx_565_r =			0x000000f800000000ULL,
     .mmx_565_g =			0x0000000000fc0000ULL,
     .mmx_565_b =			0x00000000000000f8ULL,
@@ -117,15 +127,42 @@ static const MMXData c =
     .mmx_mask_2 =			0xffff0000ffffffffULL,
     .mmx_mask_3 =			0x0000ffffffffffffULL,
     .mmx_full_alpha =			0x00ff000000000000ULL,
-    .mmx_565_unpack_multiplier =	0x0000008404100840ULL,
     .mmx_ffff0000ffff0000 =		0xffff0000ffff0000ULL,
     .mmx_0000ffff00000000 =		0x0000ffff00000000ULL,
     .mmx_000000000000ffff =		0x000000000000ffffULL,
+#endif
+#ifdef _MSC_VER
+    { 0x00ff00ff00ff00ffUI64 },
+    { 0x0080008000800080UI64 },
+    { 0x000001f0003f001fUI64 },
+    { 0x0000008404100840UI64 },
+    { 0x000000f800000000UI64 },
+    { 0x0000000000fc0000UI64 },
+    { 0x00000000000000f8UI64 },
+    { 0xffffffffffff0000UI64 },
+    { 0xffffffff0000ffffUI64 },
+    { 0xffff0000ffffffffUI64 },
+    { 0x0000ffffffffffffUI64 },
+    { 0x00ff000000000000UI64 },
+    { 0xffff0000ffff0000UI64 },
+    { 0x0000ffff00000000UI64 },
+    { 0x000000000000ffffUI64 },
+#endif
 };
 
+#ifdef _MSC_VER
+#undef inline
+#define inline __forceinline
+#endif
+
+#ifdef __GNUC__
 #define MC(x) ((__m64) c.mmx_##x)
+#endif
+#ifdef _MSC_VER
+#define MC(x) c.mmx_##x
+#endif
 
-static __inline__ __m64
+static inline __m64
 shift (__m64 v, int s)
 {
     if (s > 0)
@@ -136,13 +173,13 @@ shift (__m64 v, int s)
 	return v;
 }
 
-static __inline__ __m64
+static inline __m64
 negate (__m64 mask)
 {
     return _mm_xor_si64 (mask, MC(4x00ff));
 }
 
-static __inline__ __m64
+static inline __m64
 pix_multiply (__m64 a, __m64 b)
 {
     __m64 res;
@@ -155,7 +192,7 @@ pix_multiply (__m64 a, __m64 b)
     return res;
 }
 
-static __inline__ __m64
+static inline __m64
 pix_add (__m64 a, __m64 b)
 {
     return  _mm_adds_pu8 (a, b);
@@ -163,19 +200,19 @@ pix_add (__m64 a, __m64 b)
 
 #ifdef USE_SSE
 
-static __inline__ __m64
+static inline __m64
 expand_alpha (__m64 pixel)
 {
     return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 3, 3, 3));
 }
 
-static __inline__ __m64
+static inline __m64
 expand_alpha_rev (__m64 pixel)
 {
     return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(0, 0, 0, 0));
 }    
 
-static __inline__ __m64
+static inline __m64
 invert_colors (__m64 pixel)
 {
     return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 0, 1, 2));
@@ -183,7 +220,7 @@ invert_colors (__m64 pixel)
 
 #else
 
-static __inline__ __m64
+static inline __m64
 expand_alpha (__m64 pixel)
 {
     __m64 t1, t2;
@@ -197,7 +234,7 @@ expand_alpha (__m64 pixel)
     return t1;
 }
 
-static __inline__ __m64
+static inline __m64
 expand_alpha_rev (__m64 pixel)
 {
     __m64 t1, t2;
@@ -214,7 +251,7 @@ expand_alpha_rev (__m64 pixel)
     return t1;
 }
 
-static __inline__ __m64
+static inline __m64
 invert_colors (__m64 pixel)
 {
     __m64 x, y, z;
@@ -236,13 +273,13 @@ invert_colors (__m64 pixel)
 
 #endif
 
-static __inline__ __m64
+static inline __m64
 over (__m64 src, __m64 srca, __m64 dest)
 {
     return  _mm_adds_pu8 (src, pix_multiply(dest, negate(srca)));
 }
 
-static __inline__ __m64
+static inline __m64
 over_rev_non_pre (__m64 src, __m64 dest)
 {
     __m64 srca = expand_alpha (src);
@@ -251,14 +288,15 @@ over_rev_non_pre (__m64 src, __m64 dest)
     return over(pix_multiply(invert_colors(src), srcfaaa), srca, dest);
 }
 
-static __inline__ __m64
+static inline __m64
 in (__m64 src,
     __m64 mask)
 {
     return pix_multiply (src, mask);
 }
 
-static __inline__ __m64
+#ifndef _MSC_VER
+static inline __m64
 in_over (__m64 src,
 	 __m64 srca,
 	 __m64 mask,
@@ -266,20 +304,23 @@ in_over (__m64 src,
 {
     return over(in(src, mask), pix_multiply(srca, mask), dest);
 }
+#else
+#define in_over(src, srca, mask, dest) over(in(src, mask), pix_multiply(srca, mask), dest)
+#endif
 
-static __inline__ __m64
+static inline __m64
 load8888 (CARD32 v)
 {
     return _mm_unpacklo_pi8 (_mm_cvtsi32_si64 (v), _mm_setzero_si64());
 }
 
-static __inline__ __m64
+static inline __m64
 pack8888 (__m64 lo, __m64 hi)
 {
     return _mm_packs_pu16 (lo, hi);
 }
 
-static __inline__ CARD32
+static inline CARD32
 store8888 (__m64 v)
 {
     return _mm_cvtsi64_si32(pack8888(v, _mm_setzero_si64()));
@@ -299,7 +340,7 @@ store8888 (__m64 v)
  * Note the trick here - the top word is shifted by another nibble to
  * avoid it bumping into the middle word
  */
-static __inline__ __m64
+static inline __m64
 expand565 (__m64 pixel, int pos)
 {
     __m64 p = pixel;
@@ -319,7 +360,7 @@ expand565 (__m64 pixel, int pos)
     return _mm_srli_pi16 (pixel, 8);
 }
 
-static __inline__ __m64
+static inline __m64
 expand8888 (__m64 in, int pos)
 {
     if (pos == 0)
@@ -328,7 +369,7 @@ expand8888 (__m64 in, int pos)
 	return _mm_unpackhi_pi8 (in, _mm_setzero_si64());
 }
 
-static __inline__ __m64
+static inline __m64
 pack565 (__m64 pixel, __m64 target, int pos)
 {
     __m64 p = pixel;
@@ -358,20 +399,28 @@ pack565 (__m64 pixel, __m64 target, int 
     return _mm_or_si64 (b, p);
 }
 
-static __inline__ __m64
+#ifndef _MSC_VER
+static inline __m64
 pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b)
 {
-    x = _mm_mullo_pi16 (x, a);                  
-    y = _mm_mullo_pi16 (y, b);                  
-    x = _mm_srli_pi16(x, 1);                    
-    y = _mm_srli_pi16(y, 1);                    
-    x = _mm_adds_pu16 (x, y);                    
-    x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); 
+    x = _mm_mullo_pi16 (x, a);
+    y = _mm_mullo_pi16 (y, b);
     x = _mm_adds_pu16 (x, MC(4x0080));
-    x = _mm_srli_pi16 (x, 7);
+    x = _mm_adds_pu16 (x, y);
+    x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8));
+    x = _mm_srli_pi16 (x, 8);
 
     return x;
 }
+#else
+#define pix_add_mul(x, a, y, b) \
+( x = _mm_mullo_pi16 (x, a), \
+  y = _mm_mullo_pi16 (y, b), \
+  x = _mm_adds_pu16 (x, MC(4x0080)), \
+  x = _mm_adds_pu16 (x, y), \
+  x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)), \
+  _mm_srli_pi16 (x, 8) )
+#endif
 
 /* --------------- MMX code patch for fbcompose.c --------------------- */
 
@@ -590,7 +639,7 @@ mmxCombineSaturateU (CARD32 *dest, const
         CARD32 da = ~d >> 24;
 
         if (sa > da) {
-            __m64 msa = load8888(FbIntDiv(da, sa));
+            __m64 msa = load8888(FbIntDiv(da, sa))<<24;
             msa = expand_alpha_rev(msa);
             ms = pix_multiply(ms, msa);
         }
diff-tree 4fe918b38553133c27e5ae672e5c43984a9bbaea (from 0ff7c94fcf6497ee8575f81cf97eeeb3a857739e)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 12:41:01 2007 -0400

    Fix bug 8871 - scrolling corruption with a compositing manager
    
    Call miHandleExposures() in CopyArea/CopyPlane explicitly in cw to
    generate GraphicsExposes correctly.

diff --git a/miext/cw/cw_ops.c b/miext/cw/cw_ops.c
index 80b7280..82ec999 100644
--- a/miext/cw/cw_ops.c
+++ b/miext/cw/cw_ops.c
@@ -30,6 +30,7 @@
 #include "gcstruct.h"
 #include "pixmapstr.h"
 #include "cw.h"
+#include "mi.h"
 
 #define SETUP_BACKING_DST(_pDst, _pGC) \
     cwGCPtr pGCPrivate = getCwGC (_pGC); \
@@ -185,7 +186,7 @@ cwCopyArea(DrawablePtr pSrc, DrawablePtr
 	   int w, int h, int dstx, int dsty)
 {
     int		odstx, odsty;
-    RegionPtr	exposed = NULL;
+    int		osrcx, osrcy;
     SETUP_BACKING_DST(pDst, pGC);
     SETUP_BACKING_SRC(pSrc, pGC);
 
@@ -193,19 +194,20 @@ cwCopyArea(DrawablePtr pSrc, DrawablePtr
 
     odstx = dstx;
     odsty = dsty;
+    osrcx = srcx;
+    osrcy = srcy;
     CW_OFFSET_XY_DST(dstx, dsty);
     CW_OFFSET_XY_SRC(srcx, srcy);
 
-    exposed = (*pBackingGC->ops->CopyArea)(pBackingSrc, pBackingDst,
-					   pBackingGC, srcx, srcy, w, h,
-					   dstx, dsty);
-
-    if (exposed != NULL)
-	REGION_TRANSLATE(pDst->pScreen, exposed, odstx - dstx, odsty - dsty);
-
+    (*pBackingGC->ops->CopyArea)(pBackingSrc, pBackingDst,
+				 pBackingGC, srcx, srcy, w, h,
+				 dstx, dsty);
+    
     EPILOGUE(pGC);
 
-    return exposed;
+    return miHandleExposures(pSrc, pDst, pGC,
+			     osrcx, osrcy, w, h,
+			     odstx, odsty, 0);
 }
 
 static RegionPtr
@@ -213,7 +215,7 @@ cwCopyPlane(DrawablePtr pSrc, DrawablePt
 	    int w, int h, int dstx, int dsty, unsigned long plane)
 {
     int		odstx, odsty;
-    RegionPtr	exposed = NULL;
+    int		osrcx, osrcy;
     SETUP_BACKING_DST(pDst, pGC);
     SETUP_BACKING_SRC(pSrc, pGC);
 
@@ -221,19 +223,20 @@ cwCopyPlane(DrawablePtr pSrc, DrawablePt
 
     odstx = dstx;
     odsty = dsty;
+    osrcx = srcx;
+    osrcy = srcy;
     CW_OFFSET_XY_DST(dstx, dsty);
     CW_OFFSET_XY_SRC(srcx, srcy);
 
-    exposed = (*pBackingGC->ops->CopyPlane)(pBackingSrc, pBackingDst,
-					    pBackingGC, srcx, srcy, w, h,
-					    dstx, dsty, plane);
-
-    if (exposed != NULL)
-	REGION_TRANSLATE(pDst->pScreen, exposed, odstx - dstx, odsty - dsty);
+    (*pBackingGC->ops->CopyPlane)(pBackingSrc, pBackingDst,
+				  pBackingGC, srcx, srcy, w, h,
+				  dstx, dsty, plane);
 
     EPILOGUE(pGC);
 
-    return exposed;
+    return miHandleExposures(pSrc, pDst, pGC,
+			     osrcx, osrcy, w, h,
+			     odstx, odsty, plane);
 }
 
 static void
diff-tree 0ff7c94fcf6497ee8575f81cf97eeeb3a857739e (from 701ccb4a22cfd646ccb7f19b7b3a476aeb5ce2da)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 10:56:02 2007 -0400

    Pixman merge
    
    Make use of fbCompositeSrcAdd_8888x8x8mmx

diff --git a/fb/fbpict.c b/fb/fbpict.c
index ace19fd..0a08aff 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1962,7 +1962,12 @@ fbComposite (CARD8      op,
 		pDst->format == PICT_a8)
 	    {
 		srcRepeat = FALSE;
-		func = fbCompositeSrcAdd_8888x8x8;
+#ifdef USE_MMX
+		if (fbHaveMMX())
+		    func = fbCompositeSrcAdd_8888x8x8mmx;
+		else
+#endif
+		    func = fbCompositeSrcAdd_8888x8x8;
 	    }
 	}
 	break;
diff-tree 701ccb4a22cfd646ccb7f19b7b3a476aeb5ce2da (from a54ef54db19dcd36ed86b33cff2bc369f9690a15)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 10:49:06 2007 -0400

    Pixman merge
    
    - Remove stray default label
    
    - Integrate new MMX ops SolidMaskSrc_nx8x8888mmx, In_8x8mmx, and
      In_nx8x8mmx
    
    - Formatting changes to reduce diff noise

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 1932b3e..ace19fd 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1641,8 +1641,6 @@ fbComposite (CARD8      op,
 		    default:
 			break;
 		    }
-		default:
-		    break;
 		}
 		if (func != fbCompositeGeneral)
 		    srcRepeat = FALSE;
@@ -1969,19 +1967,73 @@ fbComposite (CARD8      op,
 	}
 	break;
     case PictOpSrc:
-#ifdef USE_MMX
-	if (!pMask && pSrc->format == pDst->format &&
-	    pSrc->format != PICT_a8 && pSrc->pDrawable != pDst->pDrawable)
+	if (pMask)
 	{
-	    func = fbCompositeCopyAreammx;
+#ifdef USE_MMX
+	    if (fbCanGetSolid (pSrc))
+	    {
+		if (pMask->format == PICT_a8)
+		{
+		    switch (pDst->format)
+		    {
+		    case PICT_a8r8g8b8:
+		    case PICT_x8r8g8b8:
+		    case PICT_a8b8g8r8:
+		    case PICT_x8b8g8r8:
+			if (fbHaveMMX())
+			{
+			    srcRepeat = FALSE;
+			    func = fbCompositeSolidMaskSrc_nx8x8888mmx;
+			}
+			break;
+		    default:
+			break;
+		    }
+		}
+	    }
+#endif
 	}
 	else
-#endif
-	    if (pMask == 0)
+	{
+	    if (pSrc->format == pDst->format)
 	    {
-		if (pSrc->format == pDst->format)
+#ifdef USE_MMX
+		if (pSrc->pDrawable != pDst->pDrawable && fbHaveMMX() &&
+		    (PICT_FORMAT_BPP (pSrc->format) == 16 ||
+		     PICT_FORMAT_BPP (pSrc->format) == 32))
+		    func = fbCompositeCopyAreammx;
+		else
+#endif
 		    func = fbCompositeSrcSrc_nxn;
 	    }
+	}
+	break;
+    case PictOpIn:
+#ifdef USE_MMX
+	if (pSrc->format == PICT_a8 &&
+	    pDst->format == PICT_a8 &&
+	    !pMask)
+	{
+	    if (fbHaveMMX())
+		func = fbCompositeIn_8x8mmx;
+	}
+	else if (srcRepeat && pMask && !pMask->componentAlpha &&
+		 (pSrc->format == PICT_a8r8g8b8 ||
+		  pSrc->format == PICT_a8b8g8r8)   &&
+		 (pMask->format == PICT_a8)        &&
+		 pDst->format == PICT_a8)
+	{
+	    if (fbHaveMMX())
+	    {
+		srcRepeat = FALSE;
+		func = fbCompositeIn_nx8x8mmx;
+	    }
+	}
+#else
+	func = NULL;
+#endif
+       break;
+    default:
 	break;
     }
 
@@ -1991,26 +2043,16 @@ fbComposite (CARD8      op,
          return;
     }
 
-    if (!miComputeCompositeRegion (&region,
- 				   pSrc,
- 				   pMask,
- 				   pDst,
- 				   xSrc,
- 				   ySrc,
- 				   xMask,
- 				   yMask,
- 				   xDst,
- 				   yDst,
- 				   width,
-                                   height))
-        return;
-
     /* if we are transforming, we handle repeats in fbFetchTransformed */
     if (srcTransform)
 	srcRepeat = FALSE;
     if (maskTransform)
 	maskRepeat = FALSE;
     
+    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, xSrc, ySrc,
+				   xMask, yMask, xDst, yDst, width, height))
+        return;
+
     n = REGION_NUM_RECTS (&region);
     pbox = REGION_RECTS (&region);
     while (n--)
diff-tree a54ef54db19dcd36ed86b33cff2bc369f9690a15 (from 3571b8e65b0857322d12e291305cfe29ea497c3c)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 10:24:25 2007 -0400

    Pixman merge
    
    Make sure fbCompositeSrc_x888x8x8888mmx and fbCompositeSrc_8888x8x8888mmx
    are used when possible.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 4fb949d..1932b3e 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1647,7 +1647,7 @@ fbComposite (CARD8      op,
 		if (func != fbCompositeGeneral)
 		    srcRepeat = FALSE;
 	    }
-	    else if (! srcRepeat) /* has mask and non-repeating source */
+	    else if (!srcRepeat) /* has mask and non-repeating source */
 	    {
 		if (pSrc->pDrawable == pMask->pDrawable &&
 		    xSrc == xMask && ySrc == yMask &&
@@ -1712,44 +1712,55 @@ fbComposite (CARD8      op,
 		    }
 		    break;
 		}
-		else
+		else if (maskRepeat &&
+			 pMask->pDrawable->width == 1 &&
+			 pMask->pDrawable->height == 1)
 		{
-		    /* non-repeating source, repeating mask => translucent window */
-		    if (fbCanGetSolid(pMask))
-		    {
-			if (pSrc->format == PICT_x8r8g8b8 &&
-			    pDst->format == PICT_x8r8g8b8 &&
-			    pMask->format == PICT_a8)
-			{
+		    switch (pSrc->format) {
+		    case PICT_r5g6b5:
+		    case PICT_b5g6r5:
+			if (pDst->format == pSrc->format)
+			    func = fbCompositeTrans_0565xnx0565;
+			break;
+		    case PICT_r8g8b8:
+		    case PICT_b8g8r8:
+			if (pDst->format == pSrc->format)
+			    func = fbCompositeTrans_0888xnx0888;
+			break;
 #ifdef USE_MMX
-			    if (fbHaveMMX())
-				func = fbCompositeSrc_8888x8x8888mmx;
+		    case PICT_x8r8g8b8:
+			if ((pDst->format == PICT_a8r8g8b8 ||
+			     pDst->format == PICT_x8r8g8b8) &&
+			    pMask->format == PICT_a8 && fbHaveMMX())
+			    func = fbCompositeSrc_x888x8x8888mmx;
+			break;
+		    case PICT_x8b8g8r8:
+			if ((pDst->format == PICT_a8b8g8r8 ||
+			     pDst->format == PICT_x8b8g8r8) &&
+			    pMask->format == PICT_a8 && fbHaveMMX())
+			    func = fbCompositeSrc_x888x8x8888mmx;
+			break;
+		    case PICT_a8r8g8b8:
+			if ((pDst->format == PICT_a8r8g8b8 ||
+			     pDst->format == PICT_x8r8g8b8) &&
+			    pMask->format == PICT_a8 && fbHaveMMX())
+			    func = fbCompositeSrc_8888x8x8888mmx;
+			break;
+		    case PICT_a8b8g8r8:
+			if ((pDst->format == PICT_a8b8g8r8 ||
+			     pDst->format == PICT_x8b8g8r8) &&
+			    pMask->format == PICT_a8 && fbHaveMMX())
+			    func = fbCompositeSrc_8888x8x8888mmx;
+			break;
 #endif
-			}
+		    default:
+			break;
 		    }
+		    
+		    if (func != fbCompositeGeneral)
+			maskRepeat = FALSE;
 		}
 	    }
-	    else if (maskRepeat &&
-		     pMask->pDrawable->width == 1 &&
-		     pMask->pDrawable->height == 1)
-	    {
-		switch (pSrc->format) {
-		case PICT_r5g6b5:
-		case PICT_b5g6r5:
-		    if (pDst->format == pSrc->format)
-		        func = fbCompositeTrans_0565xnx0565;
-		    break;
- 		case PICT_r8g8b8:
- 		case PICT_b8g8r8:
- 		    if (pDst->format == pSrc->format)
- 		        func = fbCompositeTrans_0888xnx0888;
- 		    break;
-		default:
-		    break;
-		}
-		if (func != fbCompositeGeneral)
-		    maskRepeat = FALSE;
-	    }
 	}
 	else /* no mask */
 	{
diff-tree 3571b8e65b0857322d12e291305cfe29ea497c3c (from c0346e57e6d3857994f7af76060c502c2fdea294)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 26 09:45:11 2007 -0400

    More pixman merging
    
    - Move some code around to minimize diff noise
    
    - Add mmx ops from pixman that never made it into X
    
    - Merge Jeff Muizelaar's bugfixes to fbCompositeSrc_8888x8x8888mmx and
      fbCompositeSrc_x888x8x8888mmx.

diff --git a/fb/fbmmx.c b/fb/fbmmx.c
index 5bbede1..875fec0 100644
--- a/fb/fbmmx.c
+++ b/fb/fbmmx.c
@@ -1140,23 +1140,22 @@ fbCompositeSrc_8888x8x8888mmx (CARD8	op,
 {
     CARD32	*dstLine, *dst;
     CARD32	*srcLine, *src;
-    CARD8	*maskLine;
     CARD32	mask;
     __m64	vmask;
-    FbStride	dstStride, srcStride, maskStride;
+    FbStride	dstStride, srcStride;
     CARD16	w;
     __m64  srca;
-    
+
     CHECKPOINT();
-    
+
     fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
     fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
 
-    mask = *maskLine << 24 | *maskLine << 16 | *maskLine << 8 | *maskLine;
+    fbComposeGetSolid (pMask, mask, pDst->format);
+    mask = mask | mask >> 8 | mask >> 16 | mask >> 24;
     vmask = load8888 (mask);
     srca = MC(4x00ff);
-    
+
     while (height--)
     {
 	dst = dstLine;
@@ -1169,9 +1168,93 @@ fbCompositeSrc_8888x8x8888mmx (CARD8	op,
 	{
 	    __m64 s = load8888 (*src);
 	    __m64 d = load8888 (*dst);
-	    
+
+	    *dst = store8888 (in_over (s, expand_alpha (s), vmask, d));
+
+	    w--;
+	    dst++;
+	    src++;
+	}
+
+	while (w >= 2)
+	{
+	    __m64 vs = *(__m64 *)src;
+	    __m64 vd = *(__m64 *)dst;
+	    __m64 vsrc0 = expand8888 (vs, 0);
+	    __m64 vsrc1 = expand8888 (vs, 1);
+
+	    *(__m64 *)dst = pack8888 (
+		in_over (vsrc0, expand_alpha (vsrc0), vmask, expand8888 (vd, 0)),
+		in_over (vsrc1, expand_alpha (vsrc1), vmask, expand8888 (vd, 1)));
+
+	    w -= 2;
+	    dst += 2;
+	    src += 2;
+	}
+
+	while (w)
+	{
+	    __m64 s = load8888 (*src);
+	    __m64 d = load8888 (*dst);
+
+	    *dst = store8888 (in_over (s, expand_alpha (s), vmask, d));
+
+	    w--;
+	    dst++;
+	    src++;
+	}
+    }
+
+    _mm_empty();
+}
+
+void
+fbCompositeSrc_x888x8x8888mmx (CARD8	op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16	xSrc,
+			       INT16	ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height)
+{
+    CARD32	*dstLine, *dst;
+    CARD32	*srcLine, *src;
+    CARD32	mask;
+    __m64	vmask;
+    FbStride	dstStride, srcStride;
+    CARD16	w;
+    __m64  srca;
+
+    CHECKPOINT();
+
+    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+    fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+    fbComposeGetSolid (pMask, mask, pDst->format);
+
+    mask = mask | mask >> 8 | mask >> 16 | mask >> 24;
+    vmask = load8888 (mask);
+    srca = MC(4x00ff);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	while (w && (unsigned long)dst & 7)
+	{
+	    __m64 s = load8888 (*src);
+	    __m64 d = load8888 (*dst);
+
 	    *dst = store8888 (in_over (s, srca, vmask, d));
-	    
+
 	    w--;
 	    dst++;
 	    src++;
@@ -1197,39 +1280,39 @@ fbCompositeSrc_8888x8x8888mmx (CARD8	op,
 	    __m64 vs6 = *(__m64 *)(src + 12);
 	    __m64 vs7 = *(__m64 *)(src + 14);
 
-	    vd0 = (__m64)pack8888 (
+	    vd0 = pack8888 (
 		in_over (expand8888 (vs0, 0), srca, vmask, expand8888 (vd0, 0)),
 		in_over (expand8888 (vs0, 1), srca, vmask, expand8888 (vd0, 1)));
-	
-	    vd1 = (__m64)pack8888 (
+
+	    vd1 = pack8888 (
 		in_over (expand8888 (vs1, 0), srca, vmask, expand8888 (vd1, 0)),
 		in_over (expand8888 (vs1, 1), srca, vmask, expand8888 (vd1, 1)));
-	
-	    vd2 = (__m64)pack8888 (
+
+	    vd2 = pack8888 (
 		in_over (expand8888 (vs2, 0), srca, vmask, expand8888 (vd2, 0)),
 		in_over (expand8888 (vs2, 1), srca, vmask, expand8888 (vd2, 1)));
-	
-	    vd3 = (__m64)pack8888 (
+
+	    vd3 = pack8888 (
 		in_over (expand8888 (vs3, 0), srca, vmask, expand8888 (vd3, 0)),
 		in_over (expand8888 (vs3, 1), srca, vmask, expand8888 (vd3, 1)));
-	
-	    vd4 = (__m64)pack8888 (
+
+	    vd4 = pack8888 (
 		in_over (expand8888 (vs4, 0), srca, vmask, expand8888 (vd4, 0)),
 		in_over (expand8888 (vs4, 1), srca, vmask, expand8888 (vd4, 1)));
-	
-	    vd5 = (__m64)pack8888 (
+
+	    vd5 = pack8888 (
 		in_over (expand8888 (vs5, 0), srca, vmask, expand8888 (vd5, 0)),
 		in_over (expand8888 (vs5, 1), srca, vmask, expand8888 (vd5, 1)));
-	
-	    vd6 = (__m64)pack8888 (
+
+	    vd6 = pack8888 (
 		in_over (expand8888 (vs6, 0), srca, vmask, expand8888 (vd6, 0)),
 		in_over (expand8888 (vs6, 1), srca, vmask, expand8888 (vd6, 1)));
-	
-	    vd7 = (__m64)pack8888 (
+
+	    vd7 = pack8888 (
 		in_over (expand8888 (vs7, 0), srca, vmask, expand8888 (vd7, 0)),
 		in_over (expand8888 (vs7, 1), srca, vmask, expand8888 (vd7, 1)));
 
-    	    *(__m64 *)(dst + 0) = vd0;
+	    *(__m64 *)(dst + 0) = vd0;
 	    *(__m64 *)(dst + 2) = vd1;
 	    *(__m64 *)(dst + 4) = vd2;
 	    *(__m64 *)(dst + 6) = vd3;
@@ -1237,26 +1320,26 @@ fbCompositeSrc_8888x8x8888mmx (CARD8	op,
 	    *(__m64 *)(dst + 10) = vd5;
 	    *(__m64 *)(dst + 12) = vd6;
 	    *(__m64 *)(dst + 14) = vd7;
-	
+
 	    w -= 16;
 	    dst += 16;
 	    src += 16;
 	}
-	
+
 	while (w)
 	{
 	    __m64 s = load8888 (*src);
 	    __m64 d = load8888 (*dst);
-	    
+
 	    *dst = store8888 (in_over (s, srca, vmask, d));
-	    
+
 	    w--;
 	    dst++;
 	    src++;
 	}
     }
 
-    _mm_empty(); 
+    _mm_empty();
 }
 
 void
@@ -1534,24 +1617,274 @@ fbCompositeSolidMask_nx8x8888mmx (CARD8 
 	while (w)
 	{
 	    ullong m = *mask;
-	    
+	    
+	    if (m)
+	    {
+		__m64 vdest = load8888(*dst);
+		vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), vdest);
+		*dst = store8888(vdest);
+	    }
+	    
+	    w--;
+	    mask++;
+	    dst++;
+	}
+    }
+    
+    _mm_empty();
+}
+
+
+Bool
+fbSolidFillmmx (DrawablePtr	pDraw,
+		int		x,
+		int		y,
+		int		width,
+		int		height,
+		FbBits		xor)
+{ 
+    FbStride	stride;
+    int		bpp;
+    ullong	fill;
+    __m64	vfill;
+    CARD32	byte_width;
+    CARD8	*byte_line;
+    FbBits      *bits;
+    int		xoff, yoff;
+    __m64	v1, v2, v3, v4, v5, v6, v7;
+    
+    CHECKPOINT();
+    
+    fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
+    
+    if (bpp == 16 && (xor >> 16 != (xor & 0xffff)))
+	return FALSE;
+    
+    if (bpp != 16 && bpp != 32)
+	return FALSE;
+    
+    if (bpp == 16)
+    {
+	stride = stride * sizeof (FbBits) / 2;
+	byte_line = (CARD8 *)(((CARD16 *)bits) + stride * (y + yoff) + (x + xoff));
+	byte_width = 2 * width;
+	stride *= 2;
+    }
+    else
+    {
+	stride = stride * sizeof (FbBits) / 4;
+	byte_line = (CARD8 *)(((CARD32 *)bits) + stride * (y + yoff) + (x + xoff));
+	byte_width = 4 * width;
+	stride *= 4;
+    }
+    
+    fill = ((ullong)xor << 32) | xor;
+    vfill = (__m64)fill;
+    
+    __asm__ (
+	"movq		%7,	%0\n"
+	"movq		%7,	%1\n"
+	"movq		%7,	%2\n"
+	"movq		%7,	%3\n"
+	"movq		%7,	%4\n"
+	"movq		%7,	%5\n"
+	"movq		%7,	%6\n"
+	: "=y" (v1), "=y" (v2), "=y" (v3),
+	  "=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
+	: "y" (vfill));
+    
+    while (height--)
+    {
+	int w;
+	CARD8 *d = byte_line;
+	byte_line += stride;
+	w = byte_width;
+	
+	while (w >= 2 && ((unsigned long)d & 3))
+	{
+	    *(CARD16 *)d = xor;
+	    w -= 2;
+	    d += 2;
+	}
+	
+	while (w >= 4 && ((unsigned long)d & 7))
+	{
+	    *(CARD32 *)d = xor;
+	    
+	    w -= 4;
+	    d += 4;
+	}
+
+	while (w >= 64)
+	{
+	    __asm__ (
+		"movq	%1,	  (%0)\n"
+		"movq	%2,	 8(%0)\n"
+		"movq	%3,	16(%0)\n"
+		"movq	%4,	24(%0)\n"
+		"movq	%5,	32(%0)\n"
+		"movq	%6,	40(%0)\n"
+		"movq	%7,	48(%0)\n"
+		"movq	%8,	56(%0)\n"
+		:
+		: "r" (d),
+		  "y" (vfill), "y" (v1), "y" (v2), "y" (v3),
+		  "y" (v4), "y" (v5), "y" (v6), "y" (v7)
+		: "memory");
+	    
+	    w -= 64;
+	    d += 64;
+	}
+	
+	while (w >= 4)
+	{
+	    *(CARD32 *)d = xor;
+	    
+	    w -= 4;
+	    d += 4;
+	}
+	if (w >= 2)
+	{
+	    *(CARD16 *)d = xor;
+	    w -= 2;
+	    d += 2;
+	}
+    }
+    
+    _mm_empty();
+    return TRUE;
+}
+
+void
+fbCompositeSolidMaskSrc_nx8x8888mmx (CARD8      op,
+				     PicturePtr pSrc,
+				     PicturePtr pMask,
+				     PicturePtr pDst,
+				     INT16      xSrc,
+				     INT16      ySrc,
+				     INT16      xMask,
+				     INT16      yMask,
+				     INT16      xDst,
+				     INT16      yDst,
+				     CARD16     width,
+				     CARD16     height)
+{
+    CARD32	src, srca;
+    CARD32	*dstLine, *dst;
+    CARD8	*maskLine, *mask;
+    FbStride	dstStride, maskStride;
+    CARD16	w;
+    __m64	vsrc, vsrca;
+    ullong	srcsrc;
+
+    CHECKPOINT();
+
+    fbComposeGetSolid(pSrc, src, pDst->format);
+
+    srca = src >> 24;
+    if (srca == 0)
+    {
+	fbSolidFillmmx (pDst->pDrawable, xDst, yDst, width, height, 0);
+	return;
+    }
+
+    srcsrc = (ullong)src << 32 | src;
+
+    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+    vsrc = load8888 (src);
+    vsrca = expand_alpha (vsrc);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	CHECKPOINT();
+
+	while (w && (unsigned long)dst & 7)
+	{
+	    ullong m = *mask;
+
+	    if (m)
+	    {
+		__m64 vdest = in(vsrc, expand_alpha_rev ((__m64)m));
+		*dst = store8888(vdest);
+	    }
+	    else
+	    {
+		*dst = 0;
+	    }
+
+	    w--;
+	    mask++;
+	    dst++;
+	}
+
+	CHECKPOINT();
+
+	while (w >= 2)
+	{
+	    ullong m0, m1;
+	    m0 = *mask;
+	    m1 = *(mask + 1);
+
+	    if (srca == 0xff && (m0 & m1) == 0xff)
+	    {
+		*(ullong *)dst = srcsrc;
+	    }
+	    else if (m0 | m1)
+	    {
+		__m64 vdest;
+		__m64 dest0, dest1;
+
+		vdest = *(__m64 *)dst;
+
+		dest0 = in(vsrc, expand_alpha_rev ((__m64)m0));
+		dest1 = in(vsrc, expand_alpha_rev ((__m64)m1));
+
+		*(__m64 *)dst = pack8888(dest0, dest1);
+	    }
+	    else
+	    {
+		*dst = 0;
+	    }
+
+	    mask += 2;
+	    dst += 2;
+	    w -= 2;
+	}
+
+	CHECKPOINT();
+
+	while (w)
+	{
+	    ullong m = *mask;
+
 	    if (m)
 	    {
 		__m64 vdest = load8888(*dst);
-		vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), vdest);
+		vdest = in(vsrc, expand_alpha_rev ((__m64)m));
 		*dst = store8888(vdest);
 	    }
-	    
+	    else
+	    {
+		*dst = 0;
+	    }
+
 	    w--;
 	    mask++;
 	    dst++;
 	}
     }
-    
+
     _mm_empty();
 }
 
-
 void
 fbCompositeSolidMask_nx8x0565mmx (CARD8      op,
 				  PicturePtr pSrc,
@@ -2003,6 +2336,232 @@ fbCompositeSolidMask_nx8888x0565Cmmx (CA
 }
 
 void
+fbCompositeIn_nx8x8mmx (CARD8	op,
+			PicturePtr pSrc,
+			PicturePtr pMask,
+			PicturePtr pDst,
+			INT16      xSrc,
+			INT16      ySrc,
+			INT16      xMask,
+			INT16      yMask,
+			INT16      xDst,
+			INT16      yDst,
+			CARD16     width,
+			CARD16     height)
+{
+    CARD8	*dstLine, *dst;
+    CARD8	*maskLine, *mask;
+    FbStride	dstStride, maskStride;
+    CARD16	w;
+    CARD32	src;
+    CARD8	sa;
+    __m64	vsrc, vsrca;
+
+    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
+    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+    fbComposeGetSolid(pSrc, src, pDst->format);
+
+    sa = src >> 24;
+    if (sa == 0)
+	return;
+
+    vsrc = load8888(src);
+    vsrca = expand_alpha(vsrc);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	if ((((unsigned long)pDst & 3) == 0) &&
+	    (((unsigned long)pSrc & 3) == 0))
+	{
+	    while (w >= 4)
+	    {
+		CARD32 m;
+		__m64 vmask;
+		__m64 vdest;
+
+		m = 0;
+
+		vmask = load8888 (*(CARD32 *)mask);
+		vdest = load8888 (*(CARD32 *)dst);
+
+		*(CARD32 *)dst = store8888 (in (in (vsrca, vmask), vdest));
+
+		dst += 4;
+		mask += 4;
+		w -= 4;
+	    }
+	}
+
+	while (w--)
+	{
+	    CARD16	tmp;
+	    CARD8	a;
+	    CARD32	m, d;
+	    CARD32	r;
+
+	    a = *mask++;
+	    d = *dst;
+
+	    m = FbInU (sa, 0, a, tmp);
+	    r = FbInU (m, 0, d, tmp);
+
+	    *dst++ = r;
+	}
+    }
+
+    _mm_empty();
+}
+
+void
+fbCompositeIn_8x8mmx (CARD8	op,
+		      PicturePtr pSrc,
+		      PicturePtr pMask,
+		      PicturePtr pDst,
+		      INT16      xSrc,
+		      INT16      ySrc,
+		      INT16      xMask,
+		      INT16      yMask,
+		      INT16      xDst,
+		      INT16      yDst,
+		      CARD16     width,
+		      CARD16     height)
+{
+    CARD8	*dstLine, *dst;
+    CARD8	*srcLine, *src;
+    FbStride	srcStride, dstStride;
+    CARD16	w;
+
+    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
+    fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	if ((((unsigned long)pDst & 3) == 0) &&
+	    (((unsigned long)pSrc & 3) == 0))
+	{
+	    while (w >= 4)
+	    {
+		CARD32 *s = (CARD32 *)src;
+		CARD32 *d = (CARD32 *)dst;
+
+		*d = store8888 (in (load8888 (*s), load8888 (*d)));
+
+		w -= 4;
+		dst += 4;
+		src += 4;
+	    }
+	}
+
+	while (w--)
+	{
+	    CARD8 s, d;
+	    CARD16 tmp;
+
+	    s = *src;
+	    d = *dst;
+
+	    *dst = FbInU (s, 0, d, tmp);
+
+	    src++;
+	    dst++;
+	}
+    }
+
+    _mm_empty ();
+}
+
+void
+fbCompositeSrcAdd_8888x8x8mmx (CARD8   op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16      xSrc,
+			       INT16      ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height)
+{
+    CARD8	*dstLine, *dst;
+    CARD8	*maskLine, *mask;
+    FbStride	dstStride, maskStride;
+    CARD16	w;
+    CARD32	src;
+    CARD8	sa;
+    __m64	vsrc, vsrca;
+
+    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
+    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+    fbComposeGetSolid(pSrc, src, pDst->format);
+
+    sa = src >> 24;
+    if (sa == 0)
+	return;
+
+    vsrc = load8888(src);
+    vsrca = expand_alpha(vsrc);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	if ((((unsigned long)pMask & 3) == 0) &&
+	    (((unsigned long)pDst  & 3) == 0))
+	{
+	    while (w >= 4)
+	    {
+		__m64 vmask = load8888 (*(CARD32 *)mask);
+		__m64 vdest = load8888 (*(CARD32 *)dst);
+
+		*(CARD32 *)dst = store8888 (_mm_adds_pu8 (in (vsrca, vmask), vdest));
+
+		w -= 4;
+		dst += 4;
+		mask += 4;
+	    }
+	}
+
+	while (w--)
+	{
+	    CARD16	tmp;
+	    CARD16	a;
+	    CARD32	m, d;
+	    CARD32	r;
+
+	    a = *mask++;
+	    d = *dst;
+
+	    m = FbInU (sa, 0, a, tmp);
+	    r = FbAdd (m, d, 0, tmp);
+
+	    *dst++ = r;
+	}
+    }
+
+    _mm_empty();
+}
+
+void
 fbCompositeSrcAdd_8000x8000mmx (CARD8	op,
 				PicturePtr pSrc,
 				PicturePtr pMask,
@@ -2135,126 +2694,6 @@ fbCompositeSrcAdd_8888x8888mmx (CARD8		o
 }
 
 Bool
-fbSolidFillmmx (DrawablePtr	pDraw,
-		int		x,
-		int		y,
-		int		width,
-		int		height,
-		FbBits		xor)
-{ 
-    FbStride	stride;
-    int		bpp;
-    ullong	fill;
-    __m64	vfill;
-    CARD32	byte_width;
-    CARD8	*byte_line;
-    FbBits      *bits;
-    int		xoff, yoff;
-    __m64	v1, v2, v3, v4, v5, v6, v7;
-    
-    CHECKPOINT();
-    
-    fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
-    
-    if (bpp == 16 && (xor >> 16 != (xor & 0xffff)))
-	return FALSE;
-    
-    if (bpp != 16 && bpp != 32)
-	return FALSE;
-    
-    if (bpp == 16)
-    {
-	stride = stride * sizeof (FbBits) / 2;
-	byte_line = (CARD8 *)(((CARD16 *)bits) + stride * (y + yoff) + (x + xoff));
-	byte_width = 2 * width;
-	stride *= 2;
-    }
-    else
-    {
-	stride = stride * sizeof (FbBits) / 4;
-	byte_line = (CARD8 *)(((CARD32 *)bits) + stride * (y + yoff) + (x + xoff));
-	byte_width = 4 * width;
-	stride *= 4;
-    }
-    
-    fill = ((ullong)xor << 32) | xor;
-    vfill = (__m64)fill;
-    
-    __asm__ (
-	"movq		%7,	%0\n"
-	"movq		%7,	%1\n"
-	"movq		%7,	%2\n"
-	"movq		%7,	%3\n"
-	"movq		%7,	%4\n"
-	"movq		%7,	%5\n"
-	"movq		%7,	%6\n"
-	: "=y" (v1), "=y" (v2), "=y" (v3),
-	  "=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
-	: "y" (vfill));
-    
-    while (height--)
-    {
-	int w;
-	CARD8 *d = byte_line;
-	byte_line += stride;
-	w = byte_width;
-	
-	while (w >= 2 && ((unsigned long)d & 3))
-	{
-	    *(CARD16 *)d = xor;
-	    w -= 2;
-	    d += 2;
-	}
-	
-	while (w >= 4 && ((unsigned long)d & 7))
-	{
-	    *(CARD32 *)d = xor;
-	    
-	    w -= 4;
-	    d += 4;
-	}
-
-	while (w >= 64)
-	{
-	    __asm__ (
-		"movq	%1,	  (%0)\n"
-		"movq	%2,	 8(%0)\n"
-		"movq	%3,	16(%0)\n"
-		"movq	%4,	24(%0)\n"
-		"movq	%5,	32(%0)\n"
-		"movq	%6,	40(%0)\n"
-		"movq	%7,	48(%0)\n"
-		"movq	%8,	56(%0)\n"
-		:
-		: "r" (d),
-		  "y" (vfill), "y" (v1), "y" (v2), "y" (v3),
-		  "y" (v4), "y" (v5), "y" (v6), "y" (v7)
-		: "memory");
-	    
-	    w -= 64;
-	    d += 64;
-	}
-	
-	while (w >= 4)
-	{
-	    *(CARD32 *)d = xor;
-	    
-	    w -= 4;
-	    d += 4;
-	}
-	if (w >= 2)
-	{
-	    *(CARD16 *)d = xor;
-	    w -= 2;
-	    d += 2;
-	}
-    }
-    
-    _mm_empty();
-    return TRUE;
-}
-
-Bool
 fbCopyAreammx (DrawablePtr	pSrc,
 	       DrawablePtr	pDst,
 	       int		src_x,
diff --git a/fb/fbmmx.h b/fb/fbmmx.h
index b3e4d71..ca9c7e7 100644
--- a/fb/fbmmx.h
+++ b/fb/fbmmx.h
@@ -82,6 +82,32 @@ void fbCompositeSrc_8888x8888mmx (CARD8	
 				  INT16		yDst,
 				  CARD16	width,
 				  CARD16	height);
+void
+fbCompositeSolidMaskSrc_nx8x8888mmx (CARD8      op,
+				     PicturePtr pSrc,
+				     PicturePtr pMask,
+				     PicturePtr pDst,
+				     INT16      xSrc,
+				     INT16      ySrc,
+				     INT16      xMask,
+				     INT16      yMask,
+				     INT16      xDst,
+				     INT16      yDst,
+				     CARD16     width,
+				     CARD16     height);
+void
+fbCompositeSrc_x888x8x8888mmx (CARD8	op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16	xSrc,
+			       INT16	ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height);
 void fbCompositeSolidMask_nx8888x8888Cmmx (CARD8	op,
 					   PicturePtr	pSrc,
 					   PicturePtr	pMask,
@@ -106,6 +132,42 @@ void fbCompositeSolidMask_nx8x8888mmx (C
 				       INT16      yDst,
 				       CARD16     width,
 				       CARD16     height);
+void fbCompositeIn_nx8x8mmx (CARD8	op,
+			PicturePtr pSrc,
+			PicturePtr pMask,
+			PicturePtr pDst,
+			INT16      xSrc,
+			INT16      ySrc,
+			INT16      xMask,
+			INT16      yMask,
+			INT16      xDst,
+			INT16      yDst,
+			CARD16     width,
+			CARD16     height);
+void fbCompositeIn_8x8mmx (CARD8	op,
+		      PicturePtr pSrc,
+		      PicturePtr pMask,
+		      PicturePtr pDst,
+		      INT16      xSrc,
+		      INT16      ySrc,
+		      INT16      xMask,
+		      INT16      yMask,
+		      INT16      xDst,
+		      INT16      yDst,
+		      CARD16     width,
+		      CARD16     height);
+void fbCompositeSrcAdd_8888x8x8mmx (CARD8   op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16      xSrc,
+			       INT16      ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height);
 void fbCompositeSrcAdd_8000x8000mmx (CARD8	op,
 				     PicturePtr pSrc,
 				     PicturePtr pMask,
diff-tree c0346e57e6d3857994f7af76060c502c2fdea294 (from 67347739b0571b2978468e8088480b105f505ad2)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Apr 26 12:02:45 2007 +0930

    Require inputproto 1.4.2.
    
    Requirement was introduced with c7e2ba0c9b9b1fc1aed8f91f86471c4c8e650b78.

diff --git a/configure.ac b/configure.ac
index 872f376..9d4a50a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -628,7 +628,7 @@ XEXT_LIB='$(top_builddir)/Xext/libXext.l
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
 dnl Core modules for most extensions, et al.
-REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4] [kbproto >= 1.0.3]"
+REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
 REQUIRED_LIBS="xfont xau fontenc"
 
 if test "x$DBUS" = xauto; then
diff-tree 67347739b0571b2978468e8088480b105f505ad2 (from c056ce95d89ef1df57edf47149fc34cd3925496e)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed Apr 25 14:19:39 2007 -0400

    Don't treat convolution filters as transformations.
    
    Some rearrangement of code to get it closer to pixman.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index f9f5368..4fb949d 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1461,9 +1461,9 @@ fbComposite (CARD8      op,
     int		    n;
     BoxPtr	    pbox;
     CompositeFunc   func = NULL;
-    Bool	    srcRepeat = pSrc->pDrawable && pSrc->repeat;
+    Bool	    srcRepeat = pSrc->pDrawable && pSrc->repeatType == RepeatNormal;
     Bool	    maskRepeat = FALSE;
-    Bool	    srcTransform = pSrc->pDrawable && pSrc->transform;
+    Bool	    srcTransform = pSrc->transform != 0;
     Bool	    maskTransform = FALSE;
     Bool	    srcAlphaMap = pSrc->alphaMap != 0;
     Bool	    maskAlphaMap = FALSE;
@@ -1479,9 +1479,6 @@ fbComposite (CARD8      op,
     }
 #endif
 
-    if (pSrc->filter == PictFilterConvolution)
-	srcTransform = TRUE;
-    
     xDst += pDst->pDrawable->x;
     yDst += pDst->pDrawable->y;
     if (pSrc->pDrawable) {
@@ -1517,21 +1514,6 @@ fbComposite (CARD8      op,
         && (pSrc->filter != PictFilterConvolution)
         && (!pMask || pMask->filter != PictFilterConvolution))
     switch (op) {
-    case PictOpSrc:
-#ifdef USE_MMX
-	if (!pMask && pSrc->format == pDst->format &&
-	    pSrc->format != PICT_a8 && pSrc->pDrawable != pDst->pDrawable)
-	{
-	    func = fbCompositeCopyAreammx;
-	}
-	else
-#endif
-	    if (pMask == 0)
-	    {
-		if (pSrc->format == pDst->format)
-		    func = fbCompositeSrcSrc_nxn;
-	    }
-	break;
     case PictOpOver:
 	if (pMask)
 	{
@@ -1975,6 +1957,21 @@ fbComposite (CARD8      op,
 	    }
 	}
 	break;
+    case PictOpSrc:
+#ifdef USE_MMX
+	if (!pMask && pSrc->format == pDst->format &&
+	    pSrc->format != PICT_a8 && pSrc->pDrawable != pDst->pDrawable)
+	{
+	    func = fbCompositeCopyAreammx;
+	}
+	else
+#endif
+	    if (pMask == 0)
+	    {
+		if (pSrc->format == pDst->format)
+		    func = fbCompositeSrcSrc_nxn;
+	    }
+	break;
     }
 
     if (!func) {
diff-tree c056ce95d89ef1df57edf47149fc34cd3925496e (from c19ece1d8c32dc81740a4036a642661f54064e75)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed Apr 25 13:21:47 2007 -0400

    Port MSVC++ CPU detection code from pixman. (Vladimir Vukicevic).

diff --git a/fb/fbpict.c b/fb/fbpict.c
index b4cddd7..f9f5368 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1509,7 +1509,6 @@ fbComposite (CARD8      op,
 	    pMask->pDrawable->width == 1 &&
 	    pMask->pDrawable->height == 1)
 	    maskTransform = FALSE;
-	    
     }
 
     if (pSrc->pDrawable && (!pMask || pMask->pDrawable)
@@ -2116,7 +2115,7 @@ enum CPUFeatures {
 
 static unsigned int detectCPUFeatures(void) {
     unsigned int features = 0;
-    unsigned int result;
+    unsigned int result = 0;
 
 #ifdef HAVE_GETISAX
     if (getisax(&result, 1)) {
@@ -2133,8 +2132,13 @@ static unsigned int detectCPUFeatures(vo
     }
 #else
     char vendor[13];
+#ifdef _MSC_VER
+    int vendor0 = 0, vendor1, vendor2;
+#endif
     vendor[0] = 0;
     vendor[12] = 0;
+
+#ifdef __GNUC__
     /* see p. 118 of amd64 instruction set manual Vol3 */
     /* We need to be careful about the handling of %ebx and
      * %esp here. We can't declare either one as clobbered
@@ -2153,7 +2157,7 @@ static unsigned int detectCPUFeatures(vo
              "pop %%eax\n"
              "mov $0x0, %%edx\n"
              "xor %%ecx, %%eax\n"
-             "jz 1\n"
+             "jz 1f\n"
 
              "mov $0x00000000, %%eax\n"
 	     "push %%ebx\n"
@@ -2177,6 +2181,45 @@ static unsigned int detectCPUFeatures(vo
              : "%eax", "%ecx", "%edx"
         );
 
+#elif defined (_MSC_VER)
+
+    _asm {
+      pushfd
+      pop eax
+      mov ecx, eax
+      xor eax, 00200000h
+      push eax
+      popfd
+      pushfd
+      pop eax
+      mov edx, 0
+      xor eax, ecx
+      jz nocpuid
+
+      mov eax, 0
+      push ebx
+      cpuid
+      mov eax, ebx
+      pop ebx
+      mov vendor0, eax
+      mov vendor1, edx
+      mov vendor2, ecx
+      mov eax, 1
+      push ebx
+      cpuid
+      pop ebx
+    nocpuid:
+      mov result, edx
+    }
+    memmove (vendor+0, &vendor0, 4);
+    memmove (vendor+4, &vendor1, 4);
+    memmove (vendor+8, &vendor2, 4);
+
+#else
+#   error unsupported compiler
+#endif
+    
+    features = 0;
     if (result) {
         /* result now contains the standard feature bits */
         if (result & (1 << 15))
@@ -2191,14 +2234,13 @@ static unsigned int detectCPUFeatures(vo
             (strcmp(vendor, "AuthenticAMD") == 0 ||
              strcmp(vendor, "Geode by NSC") == 0)) {
             /* check for AMD MMX extensions */
-
-            unsigned int result;            
+#ifdef __GNUC__
             __asm__("push %%ebx\n"
                     "mov $0x80000000, %%eax\n"
                     "cpuid\n"
                     "xor %%edx, %%edx\n"
                     "cmp $0x1, %%eax\n"
-                    "jge 2\n"
+                    "jge 2f\n"
                     "mov $0x80000001, %%eax\n"
                     "cpuid\n"
                     "2:\n"
@@ -2208,11 +2250,27 @@ static unsigned int detectCPUFeatures(vo
                     :
                     : "%eax", "%ecx", "%edx"
                 );
+#elif defined _MSC_VER
+            _asm {
+              push ebx
+              mov eax, 80000000h
+              cpuid
+              xor edx, edx
+              cmp eax, 1
+              jge notamd
+              mov eax, 80000001h
+              cpuid
+            notamd:
+              pop ebx
+              mov result, edx
+            }
+#endif
             if (result & (1<<22))
                 features |= MMX_Extensions;
         }
     }
 #endif /* HAVE_GETISAX */
+
     return features;
 }
 
diff-tree c19ece1d8c32dc81740a4036a642661f54064e75 (from 48c73dfc369fdf8f6023436ebe82bb604f76bb80)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed Apr 25 12:34:19 2007 -0400

    Integrate optimization from xserver from David Reveman where repeats
    
    get handled by fbFetchTransformed() rather than in the region walking
    code.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index b9c463a..b4cddd7 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1463,6 +1463,8 @@ fbComposite (CARD8      op,
     CompositeFunc   func = NULL;
     Bool	    srcRepeat = pSrc->pDrawable && pSrc->repeat;
     Bool	    maskRepeat = FALSE;
+    Bool	    srcTransform = pSrc->pDrawable && pSrc->transform;
+    Bool	    maskTransform = FALSE;
     Bool	    srcAlphaMap = pSrc->alphaMap != 0;
     Bool	    maskAlphaMap = FALSE;
     Bool	    dstAlphaMap = pDst->alphaMap != 0;
@@ -1476,23 +1478,42 @@ fbComposite (CARD8      op,
         mmx_setup = TRUE;
     }
 #endif
-        
+
+    if (pSrc->filter == PictFilterConvolution)
+	srcTransform = TRUE;
+    
     xDst += pDst->pDrawable->x;
     yDst += pDst->pDrawable->y;
     if (pSrc->pDrawable) {
         xSrc += pSrc->pDrawable->x;
         ySrc += pSrc->pDrawable->y;
     }
+
+    if (srcRepeat && srcTransform &&
+	pSrc->pDrawable->width == 1 &&
+	pSrc->pDrawable->height == 1)
+	srcTransform = FALSE;
+    
     if (pMask && pMask->pDrawable)
     {
 	xMask += pMask->pDrawable->x;
 	yMask += pMask->pDrawable->y;
 	maskRepeat = pMask->repeat == RepeatNormal;
+
+	if (pMask->filter == PictFilterConvolution)
+	    maskTransform = TRUE;
+
 	maskAlphaMap = pMask->alphaMap != 0;
+
+	if (maskRepeat && maskTransform &&
+	    pMask->pDrawable->width == 1 &&
+	    pMask->pDrawable->height == 1)
+	    maskTransform = FALSE;
+	    
     }
 
     if (pSrc->pDrawable && (!pMask || pMask->pDrawable)
-        && !pSrc->transform && !(pMask && pMask->transform)
+        && !srcTransform && !maskTransform
         && !maskAlphaMap && !srcAlphaMap && !dstAlphaMap
         && (pSrc->filter != PictFilterConvolution)
         && (!pMask || pMask->filter != PictFilterConvolution))
@@ -1977,6 +1998,12 @@ fbComposite (CARD8      op,
                                    height))
         return;
 
+    /* if we are transforming, we handle repeats in fbFetchTransformed */
+    if (srcTransform)
+	srcRepeat = FALSE;
+    if (maskTransform)
+	maskRepeat = FALSE;
+    
     n = REGION_NUM_RECTS (&region);
     pbox = REGION_RECTS (&region);
     while (n--)
diff-tree 48c73dfc369fdf8f6023436ebe82bb604f76bb80 (from 66ba3d758a368bf83d75bab8b08bdb6b34925e40)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed Apr 25 12:09:22 2007 -0400

    Add function fbCompositeSrcAdd_8888x8x8(), and fix a bug where
    
    srcRepeat = FALSE would be set in the wrong place.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index db70872..b9c463a 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -894,6 +894,61 @@ fbCompositeSrcAdd_8888x8888 (CARD8	op,
     fbFinishAccess (pSrc->pDrawable);
 }
 
+static void
+fbCompositeSrcAdd_8888x8x8 (CARD8      op,
+			    PicturePtr pSrc,
+			    PicturePtr pMask,
+			    PicturePtr pDst,
+			    INT16      xSrc,
+			    INT16      ySrc,
+			    INT16      xMask,
+			    INT16      yMask,
+			    INT16      xDst,
+			    INT16      yDst,
+			    CARD16     width,
+			    CARD16     height)
+{
+    CARD8	*dstLine, *dst;
+    CARD8	*maskLine, *mask;
+    FbStride	dstStride, maskStride;
+    CARD16	w;
+    CARD32	src;
+    CARD8	sa;
+
+    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
+    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+    fbComposeGetSolid (pSrc, src, pDst->format);
+    sa = (src >> 24);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	while (w--)
+	{
+	    CARD16	tmp;
+	    CARD16	a;
+	    CARD32	m, d;
+	    CARD32	r;
+
+	    a = READ(mask++);
+	    d = READ(dst);
+
+	    m = FbInU (sa, 0, a, tmp);
+	    r = FbAdd (m, d, 0, tmp);
+
+	    WRITE(dst++, r);
+	}
+    }
+    
+    fbFinishAccess(pDst->pDrawable);
+    fbFinishAccess(pMask->pDrawable);
+}
+
 void
 fbCompositeSrcAdd_1000x1000 (CARD8	op,
 			     PicturePtr pSrc,
@@ -1587,6 +1642,8 @@ fbComposite (CARD8      op,
 		default:
 		    break;
 		}
+		if (func != fbCompositeGeneral)
+		    srcRepeat = FALSE;
 	    }
 	    else if (! srcRepeat) /* has mask and non-repeating source */
 	    {
@@ -1669,8 +1726,6 @@ fbComposite (CARD8      op,
 			}
 		    }
 		}
-		if (func != fbCompositeGeneral)
-		    srcRepeat = FALSE;
 	    }
 	    else if (maskRepeat &&
 		     pMask->pDrawable->width == 1 &&
@@ -1887,6 +1942,18 @@ fbComposite (CARD8      op,
 		break;
 	    }
 	}
+	else
+	{
+	    if ((pSrc->format == PICT_a8r8g8b8	||
+		 pSrc->format == PICT_a8b8g8r8) &&
+		fbCanGetSolid (pSrc)		&&
+		pMask->format == PICT_a8	&&
+		pDst->format == PICT_a8)
+	    {
+		srcRepeat = FALSE;
+		func = fbCompositeSrcAdd_8888x8x8;
+	    }
+	}
 	break;
     }
 
diff-tree 66ba3d758a368bf83d75bab8b08bdb6b34925e40 (from c09e68ce30dabd6b7068b163b9d2382d85d0d0bc)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Wed Apr 25 10:31:38 2007 -0400

    Various fixes from xserver via pixman (Billy Biggs)

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 44bee1b..db70872 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -123,7 +123,7 @@ fbIn (CARD32 x, CARD8 y)
 
 
 #if IMAGE_BYTE_ORDER == LSBFirst
-#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
+#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(long)where; \
 					temp=count&3; \
 					where-=temp; \
 					workingWhere=(CARD32 *)where; \
@@ -136,7 +136,7 @@ fbIn (CARD32 x, CARD8 y)
         #define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; WRITE (wodst++, workingoDest); } 
 #else
 	#warning "I havn't tested fbCompositeTrans_0888xnx0888() on big endian yet!"
-	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
+	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(long)where; \
 					temp=count&3; \
 					where-=temp; \
 					workingWhere=(CARD32 *)where; \
@@ -331,7 +331,7 @@ fbCompositeSolidMask_nx8x0888 (CARD8    
     while (height--)
     {
 	/* fixme: cleanup unused */
-	unsigned int wt, wd;
+	unsigned long wt, wd;
 	CARD32 workingiDest;
 	CARD32 *widst;
  	
@@ -1074,7 +1074,7 @@ fbCompositeTrans_0565xnx0565(CARD8      
 	srcLine += srcStride;
 	w = width;
 	
-	if(((int)src&1)==1)
+	if(((long)src&1)==1)
 	{
 	    s_16 = READ(src++);
 	    d_16 = READ(dst);
@@ -1082,7 +1082,7 @@ fbCompositeTrans_0565xnx0565(CARD8      
 	    w--;
 	}
 	isrc=(CARD32 *)src;
-	if(((int)dst&1)==0)
+	if(((long)dst&1)==0)
 	{
 	    idst=(CARD32 *)dst;
 	    while (w>1)
@@ -1173,7 +1173,7 @@ fbCompositeTrans_0888xnx0888(CARD8      
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
     
     {
-	unsigned int ws,wt;
+	unsigned long ws,wt;
 	CARD32 workingSource;
 	CARD32 *wsrc, *wdst, *widst;
 	CARD32 rs, rd, nd;
@@ -1196,7 +1196,7 @@ fbCompositeTrans_0888xnx0888(CARD8      
 		setupPackedReader(ws,wt,isrc,wsrc,workingSource);
 		
 		/* get to word aligned */
-		switch(!(int)src&3)
+		switch(~(long)dst&3)
 		{
 		case 1:
 		    readPackedSource(rs);
@@ -1272,7 +1272,7 @@ fbCompositeTrans_0888xnx0888(CARD8      
 		srcLine += srcStride;
 		w = width*3;
 		/* get to word aligned */
-		switch(!(int)src&3)
+		switch(~(long)src&3)
 		{
 		case 1:
 		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
diff-tree c09e68ce30dabd6b7068b163b9d2382d85d0d0bc (from 9c80eda826448822328bb678a7d284cc43fffb17)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed Apr 25 16:46:26 2007 -0400

    Paper over a crash at exit during GLX teardown.

diff --git a/GL/glx/glxglcore.c b/GL/glx/glxglcore.c
index ecfa4d7..b50740c 100644
--- a/GL/glx/glxglcore.c
+++ b/GL/glx/glxglcore.c
@@ -258,12 +258,14 @@ __glXMesaScreenDestroy(__GLXscreen *scre
     __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
     int i;
 
-    for (i = 0; i < mesaScreen->num_vis; i++) {
-	if (mesaScreen->xm_vis[i])
-	    XMesaDestroyVisual(mesaScreen->xm_vis[i]);
-    }
+    if (mesaScreen->xm_vis) {
+	for (i = 0; i < mesaScreen->num_vis; i++) {
+	    if (mesaScreen->xm_vis[i])
+		XMesaDestroyVisual(mesaScreen->xm_vis[i]);
+	}
 
-    xfree(mesaScreen->xm_vis);
+	xfree(mesaScreen->xm_vis);
+    }
 
     __glXScreenDestroy(screen);
 
diff-tree 9c80eda826448822328bb678a7d284cc43fffb17 (from d322608dc929d5f8cda07a53143a4f28423e0460)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed Apr 25 16:35:04 2007 -0400

    Disable RANDR's fake Xinerama protocol when there's more than one screen.
    
    ... in the protocol sense.  Xinerama doesn't have any provision for more
    than one protocol screen each with its own geometry.
    
    Red Hat bug #231257.

diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 1db27f1..2a57e4e 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -428,6 +428,14 @@ RRXineramaExtensionInit(void)
 	return;
 #endif
 
+    /*
+     * Xinerama isn't capable enough to have multiple protocol screens each
+     * with their own output geometry.  So if there's more than one protocol
+     * screen, just don't even try.
+     */
+    if (screenInfo.numScreens > 1)
+	return;
+
     (void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0,
 			ProcRRXineramaDispatch,
 			SProcRRXineramaDispatch,
diff-tree d322608dc929d5f8cda07a53143a4f28423e0460 (from 3ba1e8ab6d69566e1a3f8f0eb4605631aeffc8e5)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed Apr 25 16:29:48 2007 -0400

    Fix a buffer overrun on machines with excessively large PCI busses.
    
    Formerly we sized an array with a compile time constant, then initialized
    its size to the same constant, but the Linux PCI init code would increase
    that "constant".  So if you happened to have more than 128 PCI devices,
    you'd happily scribble into whatever variables happened to be in .bss
    after that array.
    
    Only really fixed for Linux atm.  Other OSes will simply (still) fail to
    work on video devices above the 128th PCI device.

diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c
index b80371d..bc5e11f 100644
--- a/hw/xfree86/os-support/bus/Pci.c
+++ b/hw/xfree86/os-support/bus/Pci.c
@@ -232,14 +232,14 @@ _X_EXPORT int            pciNumBuses = 0
 int            pciMaxBusNum = MAX_PCI_BUSES;
 static Bool    inProbe = FALSE;
 
-static pciConfigPtr pci_devp[MAX_PCI_DEVICES + 1] = {NULL, };
+static pciConfigPtr *pci_devp = NULL;
 
 static int readPciBios( PCITAG Tag, CARD8* tmp, ADDRESS hostbase,
 			unsigned char * buf, int len, PciBiosType BiosType );
 
 static int (*pciOSHandleBIOS)(PCITAG Tag, int basereg, unsigned char *buf, int len);
 
-int xf86MaxPciDevs = MAX_PCI_DEVICES;
+int xf86MaxPciDevs = 0;
 
 /*
  * Platform specific PCI function pointers.
@@ -272,6 +272,14 @@ pciInit()
 	if (pciNumBuses <= 0)
 	    ARCH_PCI_OS_INIT();
 #endif
+	if (xf86MaxPciDevs == 0) {
+	    xf86Msg(X_WARNING,
+		    "OS did not count PCI devices, guessing wildly\n");
+	    xf86MaxPciDevs = MAX_PCI_DEVICES;
+	}
+	if (pci_devp)
+	    xfree(pci_devp);
+	pci_devp = xnfcalloc(xf86MaxPciDevs + 1, sizeof(pciConfigPtr));
 }
 
 void pciSetOSBIOSPtr(int (*bios_fn)(PCITAG Tag, int basereg, unsigned char * buf, int len))
@@ -920,7 +928,7 @@ xf86scanpci(int flags)
      * result in an endless recursion if platform/OS specific PCI
      * bus probing code calls this function from with in it.
      */
-    if (done || pci_devp[0])
+    if (done || pci_devp)
 	return pci_devp;
 
     done = TRUE;
diff-tree 3ba1e8ab6d69566e1a3f8f0eb4605631aeffc8e5 (from 0a2fe443d25b1ca25349aba3f748df986952e20f)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Apr 24 17:20:14 2007 -0700

    Include xf86Rename.h in xf86RandR12.h.

diff --git a/hw/xfree86/modes/xf86RandR12.h b/hw/xfree86/modes/xf86RandR12.h
index 0d3346a..4fd855c 100644
--- a/hw/xfree86/modes/xf86RandR12.h
+++ b/hw/xfree86/modes/xf86RandR12.h
@@ -24,6 +24,9 @@
 #define _XF86_RANDR_H_
 #include <randrstr.h>
 #include <X11/extensions/render.h>
+#if XF86_MODES_RENAME
+#include "xf86Rename.h"
+#endif
 
 Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen);
 Bool xf86RandR12Init(ScreenPtr pScreen);
diff-tree 0a2fe443d25b1ca25349aba3f748df986952e20f (from 7e16da7b78c422f96387502b9cc29eaa1741543f)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue Apr 24 19:02:44 2007 -0400

    Use READ/WRITE macros for new functions introduced in previous commits.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 8ca7336..44bee1b 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -100,7 +100,7 @@ fbIn (CARD32 x, CARD8 y)
 #define inOver0888(alpha, source, destval, dest) { \
  	CARD32 dstrb=destval&0xFF00FF; CARD32 dstag=(destval>>8)&0xFF00FF; \
  	CARD32 drb=((source&0xFF00FF)-dstrb)*alpha; CARD32 dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \
-	dest =((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
+	WRITE(dest, ((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00))); \
     }
 
 /*
@@ -111,42 +111,42 @@ fbIn (CARD32 x, CARD8 y)
 #define inOver0565(alpha, source, destval, dest) { \
  	CARD16 dstrb = destval & 0xf81f; CARD16 dstg  = destval & 0x7e0; \
  	CARD32 drb = ((source&0xf81f)-dstrb)*alpha; CARD32 dg=((source & 0x7e0)-dstg)*alpha; \
-	dest = ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5)  + dstg) & 0x7e0)); \
+	WRITE(dest, ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5)  + dstg) & 0x7e0))); \
     }
 
 
 #define inOver2x0565(alpha, source, destval, dest) { \
  	CARD32 dstrb = destval & 0x07e0f81f; CARD32 dstg  = (destval & 0xf81f07e0)>>5; \
  	CARD32 drb = ((source&0x07e0f81f)-dstrb)*alpha; CARD32 dg=(((source & 0xf81f07e0)>>5)-dstg)*alpha; \
-	dest = ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5)  + dstg)<<5) & 0xf81f07e0)); \
+	WRITE(dest, ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5)  + dstg)<<5) & 0xf81f07e0))); \
     }
 
 
 #if IMAGE_BYTE_ORDER == LSBFirst
-	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
+#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
 					temp=count&3; \
 					where-=temp; \
 					workingWhere=(CARD32 *)where; \
-					workingVal=*workingWhere++; \
+                                        workingVal=READ(workingWhere++); \
 					count=4-temp; \
 					workingVal>>=(8*temp)
-	#define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)&0xff; (y)>>=8; (x)--;}
+        #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y = READ(z++); } where=(y)&0xff; (y)>>=8; (x)--;}
 	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
 	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
-	#define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; *wodst++=workingoDest; } 
+        #define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; WRITE (wodst++, workingoDest); } 
 #else
 	#warning "I havn't tested fbCompositeTrans_0888xnx0888() on big endian yet!"
 	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
 					temp=count&3; \
 					where-=temp; \
 					workingWhere=(CARD32 *)where; \
-					workingVal=*workingWhere++; \
+                                        workingVal=READ(workingWhere)++; \
 					count=4-temp; \
 					workingVal<<=(8*temp)
-	#define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)>>24; (y)<<=8; (x)--;}
+        #define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y = READ(z++); } where=(y)>>24; (y)<<=8; (x)--;}
 	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
 	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
-	#define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; *wodst++=workingoDest; } 
+        #define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; WRITE(wodst++, workingoDest); } 
 #endif
 
 /*
@@ -328,65 +328,65 @@ fbCompositeSolidMask_nx8x0888 (CARD8    
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
 
-     while (height--)
-  	{
-	        /* fixme: cleanup unused */
- 		unsigned int wt,wd;
- 		CARD32 workingiDest;
- 		CARD32 *widst;
- 		
- 		edst=dst = dstLine;
- 		dstLine += dstStride;
- 		mask = maskLine;
- 		maskLine += maskStride;
- 		w = width;
- 		
+    while (height--)
+    {
+	/* fixme: cleanup unused */
+	unsigned int wt, wd;
+	CARD32 workingiDest;
+	CARD32 *widst;
+ 	
+	edst = dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+ 	
 #ifndef NO_MASKED_PACKED_READ
- 		setupPackedReader(wd,wt,edst,widst,workingiDest);
+	setupPackedReader(wd,wt,edst,widst,workingiDest);
 #endif
- 				
- 		while (w--)
- 		{
+ 	
+	while (w--)
+	{
 #ifndef NO_MASKED_PACKED_READ
- 			readPackedDest(rd);
- 			readPackedDest(gd);
- 			readPackedDest(bd);
+	    readPackedDest(rd);
+	    readPackedDest(gd);
+	    readPackedDest(bd);
 #else
- 			rd= *edst++;
- 			gd= *edst++;
- 			bd= *edst++;
-#endif
- 			m = *mask++;
- 			if (m == 0xff)
- 			{
- 				if (srca == 0xff)
- 				{
- 					*dst++=rs;
- 					*dst++=gs;
- 					*dst++=bs;
- 				}
- 				else
- 				{
- 					*dst++=(srcAlphaCombine24(rs, rd)>>8);
- 					*dst++=(srcAlphaCombine24(gs, gd)>>8);
- 					*dst++=(srcAlphaCombine24(bs, bd)>>8);
-				}
- 			}
- 			else if (m)
- 			{
- 				int na=(srca*(int)m)>>8;
- 				int nia=255-na;
- 				*dst++=(genericCombine24(rs, rd, na, nia)>>8);
- 				*dst++=(genericCombine24(gs, gd, na, nia)>>8);
- 				*dst++=(genericCombine24(bs, bd, na, nia)>>8);
- 			}
- 			else
- 			{
- 				dst+=3;
- 			}
+	    rd = READ(edst++);
+	    gd = READ(edst++);
+	    bd = READ(edst++);
+#endif
+	    m = READ(mask++);
+	    if (m == 0xff)
+	    {
+		if (srca == 0xff)
+		{
+		    WRITE(dst++, rs);
+		    WRITE(dst++, gs);
+		    WRITE(dst++, bs);
 		}
+		else
+		{
+		    WRITE(dst++, (srcAlphaCombine24(rs, rd)>>8));
+		    WRITE(dst++, (srcAlphaCombine24(gs, gd)>>8));
+		    WRITE(dst++, (srcAlphaCombine24(bs, bd)>>8));
+		}
+	    }
+	    else if (m)
+	    {
+		int na=(srca*(int)m)>>8;
+		int nia=255-na;
+		WRITE(dst++, (genericCombine24(rs, rd, na, nia)>>8));
+		WRITE(dst++, (genericCombine24(gs, gd, na, nia)>>8));
+		WRITE(dst++, (genericCombine24(bs, bd, na, nia)>>8));
+	    }
+	    else
+	    {
+		dst+=3;
+	    }
 	}
-
+    }
+    
     fbFinishAccess (pMask->pDrawable);
     fbFinishAccess (pDst->pDrawable);
 }
@@ -414,8 +414,6 @@ fbCompositeSolidMask_nx8x0565 (CARD8    
     CARD16	w,src16;
     
     fbComposeGetSolid(pSrc, src, pDst->format);
-
-    
     
     if (src == 0)
 	return;
@@ -437,23 +435,23 @@ fbCompositeSolidMask_nx8x0565 (CARD8    
  
 	while (w--)
 	{
-	    m = *mask++;
+	    m = READ(mask++);
 	    if (m == 0)
 		dst++;
 	    else if (srca5 == (0xff >> 3))
 	    {
 		if (m == 0xff)
-		    *dst++ = src16;
+		    WRITE(dst++, src16);
 		else 
  		{
-		    d = *dst;
+		    d = READ(dst);
 		    m >>= 3;
-		    inOver0565 (m, src16, d, *dst++);
+		    inOver0565 (m, src16, d, dst++);
  		}
 	    }
 	    else
 	    {
-		d = *dst;
+		d = READ(dst);
 		if (m == 0xff) 
 		{
 		    t = fbOver24 (src, cvt0565to0888 (d));
@@ -463,7 +461,7 @@ fbCompositeSolidMask_nx8x0565 (CARD8    
 		    t = fbIn (src, m);
 		    t = fbOver (t, cvt0565to0888 (d));
 		}
-		*dst++ = cvt8888to0565 (t);
+		WRITE(dst++, cvt8888to0565 (t));
 	    }
 	}
     }
@@ -517,34 +515,34 @@ fbCompositeSolidMask_nx8888x0565 (CARD8 
 
 	while (w--)
 	{
-	    m = *mask++ >> 24;
+	    m = READ(mask++) >> 24;
 	    if (m == 0)
 		dst++;
 	    else if (srca5 == (0xff >> 3))
 	    {
 		if (m == 0xff)
-		    *dst++ = src16;
+		    WRITE(dst++, src16);
 		else
 		{
-		    d = *dst;
+		    d = READ(dst);
 		    m >>= 3;
-		    inOver0565 (m, src16, d, *dst++);
+		    inOver0565 (m, src16, d, dst++);
 		}
 	    }
 	    else
 	    {
 		if (m == 0xff) 
 		{
-		    d = *dst;
+		    d = READ(dst);
 		    t = fbOver24 (src, cvt0565to0888 (d));
-		    *dst++ = cvt8888to0565 (t);
+		    WRITE(dst++, cvt8888to0565 (t));
 		}
 		else
 		{
-		    d = *dst;
+		    d = READ(dst);
 		    t = fbIn (src, m);
 		    t = fbOver (t, cvt0565to0888 (d));
-		    *dst++ = cvt8888to0565 (t);
+		    WRITE(dst++, cvt8888to0565 (t));
 		}
 	    }
 	}
@@ -1078,9 +1076,9 @@ fbCompositeTrans_0565xnx0565(CARD8      
 	
 	if(((int)src&1)==1)
 	{
-	    s_16 = *src++;
-	    d_16 = *dst;
-	    inOver0565(maskAlpha, s_16, d_16, *dst++);
+	    s_16 = READ(src++);
+	    d_16 = READ(dst);
+	    inOver0565(maskAlpha, s_16, d_16, dst++);
 	    w--;
 	}
 	isrc=(CARD32 *)src;
@@ -1089,9 +1087,9 @@ fbCompositeTrans_0565xnx0565(CARD8      
 	    idst=(CARD32 *)dst;
 	    while (w>1)
 	    {
-		s_32 = *isrc++;
-		d_32 = *idst;
-		inOver2x0565(maskAlpha, s_32, d_32, *idst++);
+		s_32 = READ(isrc++);
+		d_32 = READ(idst);
+		inOver2x0565(maskAlpha, s_32, d_32, idst++);
 		w-=2;
 	    }
 	    dst=(CARD16 *)idst;
@@ -1100,30 +1098,30 @@ fbCompositeTrans_0565xnx0565(CARD8      
 	{
 	    while (w > 1)
 	    {
-		s_32 = *isrc++;
+		s_32 = READ(isrc++);
 #if IMAGE_BYTE_ORDER == LSBFirst
 		s_16=s_32&0xffff;
 #else
 		s_16=s_32>>16;
 #endif
-		d_16 = *dst;
-		inOver0565 (maskAlpha, s_16, d_16, *dst++);
+		d_16 = READ(dst);
+		inOver0565 (maskAlpha, s_16, d_16, dst++);
 #if IMAGE_BYTE_ORDER == LSBFirst
 		s_16=s_32>>16;
 #else
 		s_16=s_32&0xffff;
 #endif
-		d_16 = *dst;
-		inOver0565(maskAlpha, s_16, d_16, *dst++);
+		d_16 = READ(dst);
+		inOver0565(maskAlpha, s_16, d_16, dst++);
 		w-=2;
 	    }
 	}
 	src=(CARD16 *)isrc;
 	if(w!=0)
 	{
-	    s_16 = *src;
-	    d_16 = *dst;
-	    inOver0565(maskAlpha, s_16, d_16, *dst);
+	    s_16 = READ(src);
+	    d_16 = READ(dst);
+	    inOver0565(maskAlpha, s_16, d_16, dst);
 	}
     }
     
@@ -1133,6 +1131,7 @@ fbCompositeTrans_0565xnx0565(CARD8      
 
 /* macros for "i can't believe it's not fast" packed pixel handling */
 #define alphamaskCombine24(a,b) genericCombine24(a,b,maskAlpha,maskiAlpha)
+
 static void
 fbCompositeTrans_0888xnx0888(CARD8      op,
  			     PicturePtr pSrc,
@@ -1146,175 +1145,175 @@ fbCompositeTrans_0888xnx0888(CARD8      
  			     INT16      yDst,
  			     CARD16     width,
  			     CARD16     height)
- {
-     CARD8	*dstLine, *dst,*idst;
-     CARD8	*srcLine, *src;
-     FbStride	dstStride, srcStride;
-     CARD16	w;
-     FbBits	mask;
-     CARD16	maskAlpha,maskiAlpha;
-     
-     fbComposeGetSolid (pMask, mask, pDst->format);
-     maskAlpha = mask >> 24;
- 	maskiAlpha= 255-maskAlpha;
-     
-     if (!maskAlpha)
- 	return;
-     /*
-     if (maskAlpha == 0xff)
-     {
- 	fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst,
- 				  xSrc, ySrc, xMask, yMask, xDst, yDst, 
- 				  width, height);
+{
+    CARD8	*dstLine, *dst,*idst;
+    CARD8	*srcLine, *src;
+    FbStride	dstStride, srcStride;
+    CARD16	w;
+    FbBits	mask;
+    CARD16	maskAlpha,maskiAlpha;
+    
+    fbComposeGetSolid (pMask, mask, pDst->format);
+    maskAlpha = mask >> 24;
+    maskiAlpha= 255-maskAlpha;
+    
+    if (!maskAlpha)
  	return;
-     }
-     */
- 	
-     fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3);
-     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
-  
-  	{
- 		unsigned int ws,wt;
- 		CARD32 workingSource;
-		CARD32 *wsrc, *wdst, *widst;
-		CARD32 rs, rd, nd;
-		CARD8 *isrc;
-
- 
- 		/* are xSrc and xDst at the same alignment?  if not, we need to be complicated :) */
- 		/* if(0==0) */
-		if( (((xSrc*3)&3)!=((xDst*3)&3)) || ((srcStride&3)!=(dstStride&3)))
- 		{
- 			while (height--)
- 			{
-			        dst = dstLine;
- 				dstLine += dstStride;
- 				isrc = src = srcLine;
- 				srcLine += srcStride;
- 				w = width*3;
- 				
-				setupPackedReader(ws,wt,isrc,wsrc,workingSource);
-				
- 				/* get to word aligned */
- 				switch(!(int)src&3)
- 				{
- 					case 1:
-					        readPackedSource(rs);
-						/* *dst++=alphamaskCombine24(rs, *dst)>>8; */
-						rd=*dst;  /* make gcc happy.  hope it doens't cost us too much performance*/
-						*dst++=alphamaskCombine24(rs, rd)>>8;
-						w--; if(w==0) break;
- 					case 2:
-					        readPackedSource(rs);
-						rd=*dst;  
-						*dst++=alphamaskCombine24(rs, rd)>>8;
- 						w--; if(w==0) break;
- 					case 3:
-					        readPackedSource(rs);
-						rd=*dst;  
-						*dst++=alphamaskCombine24(rs, rd)>>8;
- 						w--; if(w==0) break;
- 				}
- 				wdst=(CARD32 *)dst;
-				while (w>3)
-				{
- 					rs=*wsrc++;
-					/* FIXME: write a special readPackedWord macro, which knows how to 
-					 * halfword combine
-					 */
- #if IMAGE_BYTE_ORDER == LSBFirst
-					rd=*wdst;
-					readPackedSource(nd);
-					readPackedSource(rs);
-					nd|=rs<<8;
-					readPackedSource(rs);
-					nd|=rs<<16;
-					readPackedSource(rs);
-					nd|=rs<<24;
+    /*
+      if (maskAlpha == 0xff)
+      {
+      fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst,
+      xSrc, ySrc, xMask, yMask, xDst, yDst, 
+      width, height);
+      return;
+      }
+    */
+    
+    fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3);
+    fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
+    
+    {
+	unsigned int ws,wt;
+	CARD32 workingSource;
+	CARD32 *wsrc, *wdst, *widst;
+	CARD32 rs, rd, nd;
+	CARD8 *isrc;
+	
+	
+	/* are xSrc and xDst at the same alignment?  if not, we need to be complicated :) */
+	/* if(0==0) */
+	if ((((xSrc * 3) & 3) != ((xDst * 3) & 3)) ||
+	    ((srcStride & 3) != (dstStride & 3)))
+	{
+	    while (height--)
+	    {
+		dst = dstLine;
+		dstLine += dstStride;
+		isrc = src = srcLine;
+		srcLine += srcStride;
+		w = width*3;
+		
+		setupPackedReader(ws,wt,isrc,wsrc,workingSource);
+		
+		/* get to word aligned */
+		switch(!(int)src&3)
+		{
+		case 1:
+		    readPackedSource(rs);
+		    /* *dst++=alphamaskCombine24(rs, *dst)>>8; */
+		    rd = READ(dst);  /* make gcc happy.  hope it doens't cost us too much performance*/
+		    WRITE(dst++, alphamaskCombine24(rs, rd) >> 8);
+		    w--; if(w==0) break;
+		case 2:
+		    readPackedSource(rs);
+		    rd = READ(dst);
+		    WRITE(dst++, alphamaskCombine24(rs, rd) >> 8);
+		    w--; if(w==0) break;
+		case 3:
+		    readPackedSource(rs);
+		    rd = READ(dst);
+		    WRITE(dst++,alphamaskCombine24(rs, rd) >> 8);
+		    w--; if(w==0) break;
+		}
+		wdst=(CARD32 *)dst;
+		while (w>3)
+		{
+		    rs=READ(wsrc++);
+		    /* FIXME: write a special readPackedWord macro, which knows how to 
+		     * halfword combine
+		     */
+#if IMAGE_BYTE_ORDER == LSBFirst
+		    rd=READ(wdst);
+		    readPackedSource(nd);
+		    readPackedSource(rs);
+		    nd|=rs<<8;
+		    readPackedSource(rs);
+		    nd|=rs<<16;
+		    readPackedSource(rs);
+		    nd|=rs<<24;
 #else
-					readPackedSource(nd);
-					nd<<=24;
-					readPackedSource(rs);
-					nd|=rs<<16;
-					readPackedSource(rs);
-					nd|=rs<<8;
-					readPackedSource(rs);
-					nd|=rs;
-#endif
-					inOver0888(maskAlpha, nd, rd, *wdst++);
- 					w-=4;
- 				}
- 				src=(CARD8 *)wdst;
- 				switch(w)
- 				{
- 					case 3:
-						readPackedSource(rs);
-						rd=*dst;  
-						*dst++=alphamaskCombine24(rs, rd)>>8;
- 					case 2:
-					        readPackedSource(rs);
-						rd=*dst;  
-						*dst++=alphamaskCombine24(rs, rd)>>8;
- 					case 1:
-                                               readPackedSource(rs);
-                                               rd=*dst;  
-                                               *dst++=alphamaskCombine24(rs, rd)>>8;
- 				}
- 			}
- 		}
- 		else
- 		{
- 			while (height--)
- 			{
- 				idst=dst = dstLine;
- 				dstLine += dstStride;
- 				src = srcLine;
- 				srcLine += srcStride;
- 				w = width*3;
- 				/* get to word aligned */
- 				switch(!(int)src&3)
- 				{
-					case 1:
- 						rd=alphamaskCombine24(*src++, *dst)>>8;
- 						*dst++=rd;
- 						w--; if(w==0) break;
- 					case 2:
- 						rd=alphamaskCombine24(*src++, *dst)>>8;
- 						*dst++=rd;
- 						w--; if(w==0) break;
-					case 3:
- 						rd=alphamaskCombine24(*src++, *dst)>>8;
- 						*dst++=rd;
- 						w--; if(w==0) break;
- 				}
- 				wsrc=(CARD32 *)src;
- 				widst=(CARD32 *)dst;
- 				while(w>3)
- 				{
- 					rs = *wsrc++;
- 					rd = *widst;
- 					inOver0888 (maskAlpha, rs, rd, *widst++);
- 					w-=4;
- 				}
-				src=(CARD8 *)wsrc;
- 				dst=(CARD8 *)widst;
- 				switch(w)
- 				{
- 					case 3:
- 						rd=alphamaskCombine24(*src++, *dst)>>8;
- 						*dst++=rd;
- 					case 2:
-						rd=alphamaskCombine24(*src++, *dst)>>8;
- 						*dst++=rd;
- 					case 1:
- 						rd=alphamaskCombine24(*src++, *dst)>>8;
- 						*dst++=rd;
- 				}
- 			}
- 		}
- 	}
-  }
-
+		    readPackedSource(nd);
+		    nd<<=24;
+		    readPackedSource(rs);
+		    nd|=rs<<16;
+		    readPackedSource(rs);
+		    nd|=rs<<8;
+		    readPackedSource(rs);
+		    nd|=rs;
+#endif
+		    inOver0888(maskAlpha, nd, rd, wdst++);
+		    w-=4;
+		}
+		src=(CARD8 *)wdst;
+		switch(w)
+		{
+		case 3:
+		    readPackedSource(rs);
+		    rd=READ(dst);
+		    WRITE(dst++,alphamaskCombine24(rs, rd)>>8);
+		case 2:
+		    readPackedSource(rs);
+		    rd = READ(dst);  
+		    WRITE(dst++, alphamaskCombine24(rs, rd)>>8);
+		case 1:
+		    readPackedSource(rs);
+		    rd = READ(dst);  
+		    WRITE(dst++, alphamaskCombine24(rs, rd)>>8);
+		}
+	    }
+	}
+	else
+	{
+	    while (height--)
+	    {
+		idst=dst = dstLine;
+		dstLine += dstStride;
+		src = srcLine;
+		srcLine += srcStride;
+		w = width*3;
+		/* get to word aligned */
+		switch(!(int)src&3)
+		{
+		case 1:
+		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
+		    WRITE(dst++, rd);
+		    w--; if(w==0) break;
+		case 2:
+		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
+		    WRITE(dst++, rd);
+		    w--; if(w==0) break;
+		case 3:
+		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
+		    WRITE(dst++, rd);
+		    w--; if(w==0) break;
+		}
+		wsrc=(CARD32 *)src;
+		widst=(CARD32 *)dst;
+		while(w>3)
+		{
+		    rs = READ(wsrc++);
+		    rd = READ(widst);
+		    inOver0888 (maskAlpha, rs, rd, widst++);
+		    w-=4;
+		}
+		src=(CARD8 *)wsrc;
+		dst=(CARD8 *)widst;
+		switch(w)
+		{
+		case 3:
+		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
+		    WRITE(dst++, rd);
+		case 2:
+		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
+		    WRITE(dst++, rd);
+		case 1:
+		    rd=alphamaskCombine24(READ(src++), READ(dst))>>8;
+		    WRITE(dst++, rd);
+		}
+	    }
+	}
+    }
+}
 
 /*
  * Simple bitblt
diff-tree 7e16da7b78c422f96387502b9cc29eaa1741543f (from 2d9a7a768747ca39a800475f12c424c298018dc6)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue Apr 24 18:15:34 2007 -0400

    Remove #if 0'ed blocks

diff --git a/fb/fbpict.c b/fb/fbpict.c
index d027e35..8ca7336 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -783,47 +783,6 @@ fbCompositeSrc_8888x0565 (CARD8      op,
     fbFinishAccess (pSrc->pDrawable);
 }
 
-#if 0
-void
-fbCompositeSrc_0565x0565 (CARD8      op,
-			  PicturePtr pSrc,
-			  PicturePtr pMask,
-			  PicturePtr pDst,
-			  INT16      xSrc,
-			  INT16      ySrc,
-			  INT16      xMask,
-			  INT16      yMask,
-			  INT16      xDst,
-			  INT16      yDst,
-			  CARD16     width,
-			  CARD16     height)
-{
-    CARD16	*dstLine, *dst;
-    CARD16	*srcLine, *src;
-    FbStride	dstStride, srcStride;
-    CARD16	w;
-
-    fbComposeGetStart (pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1);
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w--)
-	    WRITE(dst, READ(src++));
-    }
-
-    fbFinishAccess (pDst->pDrawable);
-    fbFinishAccess (pSrc->pDrawable);
-}
-#endif
-
 void
 fbCompositeSrcAdd_8000x8000 (CARD8	op,
 			     PicturePtr pSrc,
diff-tree 18252a515d4989b983a3b7389636045e06d0f246 (from ce099a9b78195540ec251a6a3dbe26019c1a686d)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 24 14:10:09 2007 -0600

    bump release date to reflect input code updates

diff --git a/hw/dmx/dmx-config.h b/hw/dmx/dmx-config.h
index 9647448..18a0535 100644
--- a/hw/dmx/dmx-config.h
+++ b/hw/dmx/dmx-config.h
@@ -66,7 +66,7 @@
     ((year-2000) *     10000) + \
     ((month)     *       100) + \
     ((day)       *         1)
-#define VENDOR_RELEASE  DMX_VENDOR_RELEASE(1,2,2004,6,30)
+#define VENDOR_RELEASE  DMX_VENDOR_RELEASE(1,2,2007,4,24)
 #define VENDOR_STRING   "DMX Project"
 
 /* Enable the DMX extension */
diff-tree 2d9a7a768747ca39a800475f12c424c298018dc6 (from fde4a5adf02d3067a064ebf6bdd666aa5784cfe9)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue Apr 24 14:46:59 2007 -0400

    From pixman (Jeff Muizelaar)
    
        Fix up the fast-path compositing operators; those are useful for
        sources without alpha, but can't be used for sources with
        alpha. Also, replaced fbCompositeSrcSrc_nxn with call to fbBlt as
        this function must handle 1, 4, 8, 16, 24, 32 bpp objects. Would
        be nice to optimize fbBlt for common cases involving 8, 16, 24 and
        32bpp.
    
        From Keith Packard.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 660112c..d027e35 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -64,20 +64,6 @@ fbOver (CARD32 x, CARD32 y)
     return m|n|o|p;
 }
 
-static CARD32
-fbIn24 (CARD32 x, CARD8 y)
-{
-    CARD16  a = y;
-    CARD16  t;
-    CARD32  m,n,o,p;
-
-    m = FbInU(x,0,a,t);
-    n = FbInU(x,8,a,t);
-    o = FbInU(x,16,a,t);
-    p = (y << 24);
-    return m|n|o|p;
-}
-
 CARD32
 fbOver24 (CARD32 x, CARD32 y)
 {
@@ -107,22 +93,34 @@ fbIn (CARD32 x, CARD8 y)
 
 #define genericCombine24(a,b,c,d) (((a)*(c)+(b)*(d)))
 
-#define fastcombine32(alpha, source, destval, destptr, dstrb, dstag, drb, dag) \
-	dstrb=destval&0xFF00FF; dstag=(destval>>8)&0xFF00FF; \
-	drb=((source&0xFF00FF)-dstrb)*alpha; dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \
-	*destptr++=((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
-
-#define fastcombine32(alpha, source, destval, destptr, dstrb, dstag, drb, dag) \
-	dstrb=destval&0xFF00FF; dstag=(destval>>8)&0xFF00FF; \
-	drb=((source&0xFF00FF)-dstrb)*alpha; dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \
-	*destptr++=((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
-	
-// Note: this macro expects 6 bits of alpha, not 8!
-#define fastCombine0565(alpha, source, destval, destptr) { \
-	CARD16 dstrb = destval & 0xf81f; CARD16 dstg  = destval & 0x7e0; \
-	CARD32 drb = ((source&0xf81f)-dstrb)*alpha; CARD32 dg=((source & 0x7e0)-dstg)*alpha; \
-	destptr= ((((drb>>6) + dstrb)&0xf81f) | (((dg>>6)  + dstg) & 0x7e0)); \
-	}
+/*
+ * This macro does src IN mask OVER dst when src and dst are 0888.
+ * If src has alpha, this will not work
+ */
+#define inOver0888(alpha, source, destval, dest) { \
+ 	CARD32 dstrb=destval&0xFF00FF; CARD32 dstag=(destval>>8)&0xFF00FF; \
+ 	CARD32 drb=((source&0xFF00FF)-dstrb)*alpha; CARD32 dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \
+	dest =((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
+    }
+
+/*
+ * This macro does src IN mask OVER dst when src and dst are 0565 and
+ * mask is a 5-bit alpha value.  Again, if src has alpha, this will not
+ * work.
+ */
+#define inOver0565(alpha, source, destval, dest) { \
+ 	CARD16 dstrb = destval & 0xf81f; CARD16 dstg  = destval & 0x7e0; \
+ 	CARD32 drb = ((source&0xf81f)-dstrb)*alpha; CARD32 dg=((source & 0x7e0)-dstg)*alpha; \
+	dest = ((((drb>>5) + dstrb)&0xf81f) | (((dg>>5)  + dstg) & 0x7e0)); \
+    }
+
+
+#define inOver2x0565(alpha, source, destval, dest) { \
+ 	CARD32 dstrb = destval & 0x07e0f81f; CARD32 dstg  = (destval & 0xf81f07e0)>>5; \
+ 	CARD32 drb = ((source&0x07e0f81f)-dstrb)*alpha; CARD32 dg=(((source & 0xf81f07e0)>>5)-dstg)*alpha; \
+	dest = ((((drb>>5) + dstrb)&0x07e0f81f) | ((((dg>>5)  + dstg)<<5) & 0xf81f07e0)); \
+    }
+
 
 #if IMAGE_BYTE_ORDER == LSBFirst
 	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
@@ -150,6 +148,7 @@ fbIn (CARD32 x, CARD8 y)
 	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
 	#define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; *wodst++=workingoDest; } 
 #endif
+
 /*
  * Naming convention:
  *
@@ -310,7 +309,6 @@ fbCompositeSolidMask_nx8x0888 (CARD8    
 {
     CARD32	src, srca, srcia;
     CARD8	*dstLine, *dst, *edst;
-    CARD32	d;
     CARD8	*maskLine, *mask, m;
     FbStride	dstStride, maskStride;
     CARD16	w;
@@ -332,7 +330,7 @@ fbCompositeSolidMask_nx8x0888 (CARD8    
 
      while (height--)
   	{
- 		// fixme: cleanup unused
+	        /* fixme: cleanup unused */
  		unsigned int wt,wd;
  		CARD32 workingiDest;
  		CARD32 *widst;
@@ -407,61 +405,152 @@ fbCompositeSolidMask_nx8x0565 (CARD8    
 				  CARD16     width,
 				  CARD16     height)
 {
-     CARD32	src, srca,na, rsrca;
-     CARD16	*dstLine, *dst;
-     CARD16	d;
-     CARD8	*maskLine, *mask, m;
-     FbStride	dstStride, maskStride;
-     CARD16	w,src16;
-  
-     fbComposeGetSolid(pSrc, src, pDst->format);
-     src16 = cvt8888to0565(src);
-      
-     rsrca = src >> 24;
-     srca=rsrca>>2;
-      if (src == 0)
- 		return;
+    CARD32	src, srca8, srca5;
+    CARD16	*dstLine, *dst;
+    CARD16	d;
+    CARD32	t;
+    CARD8	*maskLine, *mask, m;
+    FbStride	dstStride, maskStride;
+    CARD16	w,src16;
+    
+    fbComposeGetSolid(pSrc, src, pDst->format);
+
+    
+    
+    if (src == 0)
+	return;
       
-      fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-      fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+    srca8 = (src >> 24);
+    srca5 = (srca8 >> 3);
+    src16 = cvt8888to0565(src);
+     
+    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
     
- 	while (height--)
-  	{
- 		dst = dstLine;
- 		dstLine += dstStride;
- 		mask = maskLine;
- 		maskLine += maskStride;
- 		w = width;
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
  
- 		while (w--)
-  		{
- 			m = *mask++;
- 			if (m == 0xff)
- 			{
- 				if (srca == 0xff)
- 				{
- 					*dst=src16;
- 				}
- 				else
- 				{
- 					d = *dst;
- 					fastCombine0565(srca, src16, d, *dst++);
- 				}
- 			}
- 			else if (m)
- 			{
- 				na=(rsrca*(int)m)>>10;
- 				d = *dst;
- 				fastCombine0565(na, src16, d, *dst++);
- 			}
- 			else
- 				dst++;
-  		}
-  	}
+	while (w--)
+	{
+	    m = *mask++;
+	    if (m == 0)
+		dst++;
+	    else if (srca5 == (0xff >> 3))
+	    {
+		if (m == 0xff)
+		    *dst++ = src16;
+		else 
+ 		{
+		    d = *dst;
+		    m >>= 3;
+		    inOver0565 (m, src16, d, *dst++);
+ 		}
+	    }
+	    else
+	    {
+		d = *dst;
+		if (m == 0xff) 
+		{
+		    t = fbOver24 (src, cvt0565to0888 (d));
+		}
+		else
+		{
+		    t = fbIn (src, m);
+		    t = fbOver (t, cvt0565to0888 (d));
+		}
+		*dst++ = cvt8888to0565 (t);
+	    }
+	}
+    }
+    
     fbFinishAccess (pMask->pDrawable);
     fbFinishAccess (pDst->pDrawable);
 }
 
+static void
+fbCompositeSolidMask_nx8888x0565 (CARD8      op,
+				  PicturePtr pSrc,
+				  PicturePtr pMask,
+				  PicturePtr pDst,
+				  INT16      xSrc,
+				  INT16      ySrc,
+				  INT16      xMask,
+				  INT16      yMask,
+				  INT16      xDst,
+				  INT16      yDst,
+				  CARD16     width,
+				  CARD16     height)
+{
+    CARD32	src, srca8, srca5;
+    CARD16	*dstLine, *dst;
+    CARD16	d;
+    CARD32	*maskLine, *mask;
+    CARD32	t;
+    CARD8	m;
+    FbStride	dstStride, maskStride;
+    CARD16	w, src16;
+
+    fbComposeGetSolid(pSrc, src, pDst->format);
+
+    if (src == 0)
+	return;
+
+    srca8 = src >> 24;
+    srca5 = srca8 >> 3;
+    src16 = cvt8888to0565(src);
+
+    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+    fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	while (w--)
+	{
+	    m = *mask++ >> 24;
+	    if (m == 0)
+		dst++;
+	    else if (srca5 == (0xff >> 3))
+	    {
+		if (m == 0xff)
+		    *dst++ = src16;
+		else
+		{
+		    d = *dst;
+		    m >>= 3;
+		    inOver0565 (m, src16, d, *dst++);
+		}
+	    }
+	    else
+	    {
+		if (m == 0xff) 
+		{
+		    d = *dst;
+		    t = fbOver24 (src, cvt0565to0888 (d));
+		    *dst++ = cvt8888to0565 (t);
+		}
+		else
+		{
+		    d = *dst;
+		    t = fbIn (src, m);
+		    t = fbOver (t, cvt0565to0888 (d));
+		    *dst++ = cvt8888to0565 (t);
+		}
+	    }
+	}
+    }
+}
+
 void
 fbCompositeSolidMask_nx8888x0565C (CARD8      op,
 				   PicturePtr pSrc,
@@ -516,14 +605,14 @@ fbCompositeSolidMask_nx8888x0565C (CARD8
 		else
 		{
 		    d = READ(dst);
-		    d = fbOver24 (src, cvt0565to8888(d));
+		    d = fbOver24 (src, cvt0565to0888(d));
 		    WRITE(dst, cvt8888to0565(d));
 		}
 	    }
 	    else if (ma)
 	    {
 		d = READ(dst);
-		d = cvt0565to8888(d);
+		d = cvt0565to0888(d);
 		FbInOverC (src, srca, ma, d, 0, m);
 		FbInOverC (src, srca, ma, d, 8, n);
 		FbInOverC (src, srca, ma, d, 16, o);
@@ -682,7 +771,7 @@ fbCompositeSrc_8888x0565 (CARD8      op,
 		else
 		{
 		    d = READ(dst);
-		    d = fbOver24 (s, cvt0565to8888(d));
+		    d = fbOver24 (s, cvt0565to0888(d));
 		}
 		WRITE(dst, cvt8888to0565(d));
 	    }
@@ -694,6 +783,7 @@ fbCompositeSrc_8888x0565 (CARD8      op,
     fbFinishAccess (pSrc->pDrawable);
 }
 
+#if 0
 void
 fbCompositeSrc_0565x0565 (CARD8      op,
 			  PicturePtr pSrc,
@@ -732,6 +822,7 @@ fbCompositeSrc_0565x0565 (CARD8      op,
     fbFinishAccess (pDst->pDrawable);
     fbFinishAccess (pSrc->pDrawable);
 }
+#endif
 
 void
 fbCompositeSrcAdd_8000x8000 (CARD8	op,
@@ -964,6 +1055,19 @@ fbCompositeSolidMask_nx1xn (CARD8      o
 /*
  * Apply a constant alpha value in an over computation
  */
+static void
+fbCompositeSrcSrc_nxn  (CARD8	   op,
+			PicturePtr pSrc,
+			PicturePtr pMask,
+			PicturePtr pDst,
+			INT16      xSrc,
+			INT16      ySrc,
+			INT16      xMask,
+			INT16      yMask,
+			INT16      xDst,
+			INT16      yDst,
+			CARD16     width,
+			CARD16     height);
 
 static void
 fbCompositeTrans_0565xnx0565(CARD8      op,
@@ -985,19 +1089,19 @@ fbCompositeTrans_0565xnx0565(CARD8      
     CARD16	w;
     FbBits	mask;
     CARD8	maskAlpha;
-    CARD16	s_16, d_16, r_16;
-    CARD32	s_32, d_32, i_32, r_32;
+    CARD16	s_16, d_16;
+    CARD32	s_32, d_32;
     
     fbComposeGetSolid (pMask, mask, pDst->format);
-    maskAlpha = mask >> 26;
+    maskAlpha = mask >> 27;
     
     if (!maskAlpha)
 	return;
     if (maskAlpha == 0xff)
     {
-	fbCompositeSrc_0565x0565 (op, pSrc, pMask, pDst,
-				  xSrc, ySrc, xMask, yMask, xDst, yDst, 
-				  width, height);
+	fbCompositeSrcSrc_nxn (PictOpSrc, pSrc, pMask, pDst,
+			       xSrc, ySrc, xMask, yMask, xDst, yDst, 
+			       width, height);
 	return;
     }
 
@@ -1005,55 +1109,70 @@ fbCompositeTrans_0565xnx0565(CARD8      
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
 
     while (height--)
- 	{
- 		CARD32 *isrc;
- 		dst = dstLine;
- 		dstLine += dstStride;
- 		src = srcLine;
- 		srcLine += srcStride;
- 		w = width;
- 		
- 		if(((int)src&1)==1)
- 		{
- 			s_16 = *src++;
- 			d_16 = *dst;
- 			fastCombine0565(maskAlpha, s_16, d_16, *dst++);
- 			w--;
- 		}
- 		isrc=(CARD32 *)src;
- 		while (w>1)
- 		{
- 			s_32=*isrc++;
+    {
+	CARD32 *isrc, *idst;
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+	
+	if(((int)src&1)==1)
+	{
+	    s_16 = *src++;
+	    d_16 = *dst;
+	    inOver0565(maskAlpha, s_16, d_16, *dst++);
+	    w--;
+	}
+	isrc=(CARD32 *)src;
+	if(((int)dst&1)==0)
+	{
+	    idst=(CARD32 *)dst;
+	    while (w>1)
+	    {
+		s_32 = *isrc++;
+		d_32 = *idst;
+		inOver2x0565(maskAlpha, s_32, d_32, *idst++);
+		w-=2;
+	    }
+	    dst=(CARD16 *)idst;
+	}
+	else
+	{
+	    while (w > 1)
+	    {
+		s_32 = *isrc++;
 #if IMAGE_BYTE_ORDER == LSBFirst
- 			s_16=s_32&0xffff;
+		s_16=s_32&0xffff;
 #else
-			s_16=s_32>>16;
+		s_16=s_32>>16;
 #endif
- 			d_16 = *dst;
- 			fastCombine0565(maskAlpha, s_16, d_16, *dst++);
- #if IMAGE_BYTE_ORDER == LSBFirst
- 			s_16=s_32>>16;
- #else
- 			s_16=s_32&0xffff;
- #endif
- 			d_16 = *dst;
- 			fastCombine0565(maskAlpha, s_16, d_16, *dst++);
- 			w-=2;
- 		}
- 		src=(CARD16 *)isrc;
- 		if(w!=0)
- 		{
- 			s_16 = *src;
- 			d_16 = *dst;
- 			fastCombine0565(maskAlpha, s_16, d_16, *dst);
- 		}
- 	}
-
+		d_16 = *dst;
+		inOver0565 (maskAlpha, s_16, d_16, *dst++);
+#if IMAGE_BYTE_ORDER == LSBFirst
+		s_16=s_32>>16;
+#else
+		s_16=s_32&0xffff;
+#endif
+		d_16 = *dst;
+		inOver0565(maskAlpha, s_16, d_16, *dst++);
+		w-=2;
+	    }
+	}
+	src=(CARD16 *)isrc;
+	if(w!=0)
+	{
+	    s_16 = *src;
+	    d_16 = *dst;
+	    inOver0565(maskAlpha, s_16, d_16, *dst);
+	}
+    }
+    
     fbFinishAccess (pSrc->pDrawable);
     fbFinishAccess (pDst->pDrawable);
 }
 
-// macros for "i can't believe it's not fast" packed pixel handling
+/* macros for "i can't believe it's not fast" packed pixel handling */
 #define alphamaskCombine24(a,b) genericCombine24(a,b,maskAlpha,maskiAlpha)
 static void
 fbCompositeTrans_0888xnx0888(CARD8      op,
@@ -1082,140 +1201,105 @@ fbCompositeTrans_0888xnx0888(CARD8      
      
      if (!maskAlpha)
  	return;
-     //if (maskAlpha == 0xff)
-     //{
- 	//fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst,
- 	//			  xSrc, ySrc, xMask, yMask, xDst, yDst, 
- 	//			  width, height);
- 	//return;
-     //}
+     /*
+     if (maskAlpha == 0xff)
+     {
+ 	fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst,
+ 				  xSrc, ySrc, xMask, yMask, xDst, yDst, 
+ 				  width, height);
+ 	return;
+     }
+     */
  	
      fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3);
      fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
   
   	{
- 		unsigned int ws,wt,wd,ww;
+ 		unsigned int ws,wt;
  		CARD32 workingSource;
- 		CARD32 *wsrc;
- 		CARD32 rs,gs,bs;
- 		CARD32 rd,gd,bd;
- 
- 		CARD32 workingiDest,workingoDest;
- 		CARD32 *widst,*wodst;
- 
+		CARD32 *wsrc, *wdst, *widst;
+		CARD32 rs, rd, nd;
+		CARD8 *isrc;
+
  
- 		// are xSrc and xDst at the same alignment?  if not, we need to be complicated :)
- 		//if(0==0)
- 		if( (((xSrc*3)&3)!=((xDst*3)&3)) || (srcStride&3)!=0 || (dstStride&3)!=0)
+ 		/* are xSrc and xDst at the same alignment?  if not, we need to be complicated :) */
+ 		/* if(0==0) */
+		if( (((xSrc*3)&3)!=((xDst*3)&3)) || ((srcStride&3)!=(dstStride&3)))
  		{
  			while (height--)
  			{
- 				idst=dst = dstLine;
+			        dst = dstLine;
  				dstLine += dstStride;
- 				src = srcLine;
+ 				isrc = src = srcLine;
  				srcLine += srcStride;
  				w = width*3;
  				
- 				setupPackedReader(wd,wt,idst,widst,workingiDest);
- 				ww=(int)dst;
- 				wt=ww&3;
- 				dst-=wt; 
- 				wodst=(CARD32 *)dst; 
- 				workingoDest=*wodst; 
- 				ww=4-wt;
-#if IMAGE_BYTE_ORDER == LSBFirst
- 				workingoDest<<=(8*(ww+1));
-#else
- 				workingoDest>>=(8*(ww+1));
-#endif
- 
- 				// get to word aligned
+				setupPackedReader(ws,wt,isrc,wsrc,workingSource);
+				
+ 				/* get to word aligned */
  				switch(!(int)src&3)
  				{
  					case 1:
- 						readPackedDest(rd);
- 						rd=alphamaskCombine24(*src++, rd)>>8;
- 						writePacked(rd);
- 						w--; if(w==0) break;
+					        readPackedSource(rs);
+						/* *dst++=alphamaskCombine24(rs, *dst)>>8; */
+						rd=*dst;  /* make gcc happy.  hope it doens't cost us too much performance*/
+						*dst++=alphamaskCombine24(rs, rd)>>8;
+						w--; if(w==0) break;
  					case 2:
- 						readPackedDest(rd);
- 						rd=alphamaskCombine24(*src++, rd)>>8;
- 						writePacked(rd);
+					        readPackedSource(rs);
+						rd=*dst;  
+						*dst++=alphamaskCombine24(rs, rd)>>8;
  						w--; if(w==0) break;
  					case 3:
- 						readPackedDest(rd);
- 						rd=alphamaskCombine24(*src++, rd)>>8;
- 						writePacked(rd);
+					        readPackedSource(rs);
+						rd=*dst;  
+						*dst++=alphamaskCombine24(rs, rd)>>8;
  						w--; if(w==0) break;
  				}
- 				wsrc=(CARD32 *)src;
+ 				wdst=(CARD32 *)dst;
 				while (w>3)
 				{
  					rs=*wsrc++;
- 					// FIXME: write a version of readPackedDest() which
- 					// can collect 4 bytes at once if we're on a boundry (which we're
- 					// actually guarenteed not to be in this version, but do it anyhow), and can
- 					// collect as 2 16bit words on a 2byte boundry, and then use the 32bit combine here
+					/* FIXME: write a special readPackedWord macro, which knows how to 
+					 * halfword combine
+					 */
  #if IMAGE_BYTE_ORDER == LSBFirst
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24(rs&0xff, rd)>>8;
- 					writePacked(rd);
- 
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24((rs>>8)&0xff, rd)>>8;
- 					writePacked(rd);
- 					
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24((rs>>16)&0xff, rd)>>8;
- 					writePacked(rd);
- 					
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24(rs>>24, rd)>>8;
- 					writePacked(rd);
- #else
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24(rs>>24, rd)>>8;
- 					writePacked(rd);
- 					
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24((rs>>16)&0xff, rd)>>8;
- 					writePacked(rd);
- 					
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24((rs>>8)&0xff, rd)>>8;
- 					writePacked(rd);
- 
- 					readPackedDest(rd);
- 					rd=alphamaskCombine24(rs&0xff, rd)>>8;
- 					writePacked(rd);
- #endif
+					rd=*wdst;
+					readPackedSource(nd);
+					readPackedSource(rs);
+					nd|=rs<<8;
+					readPackedSource(rs);
+					nd|=rs<<16;
+					readPackedSource(rs);
+					nd|=rs<<24;
+#else
+					readPackedSource(nd);
+					nd<<=24;
+					readPackedSource(rs);
+					nd|=rs<<16;
+					readPackedSource(rs);
+					nd|=rs<<8;
+					readPackedSource(rs);
+					nd|=rs;
+#endif
+					inOver0888(maskAlpha, nd, rd, *wdst++);
  					w-=4;
  				}
- 				src=(CARD8 *)wsrc;
+ 				src=(CARD8 *)wdst;
  				switch(w)
  				{
  					case 3:
- 						readPackedDest(rd);
- 						rd=alphamaskCombine24(*src++, rd)>>8;
- 						writePacked(rd);
+						readPackedSource(rs);
+						rd=*dst;  
+						*dst++=alphamaskCombine24(rs, rd)>>8;
  					case 2:
- 						readPackedDest(rd);
- 						rd=alphamaskCombine24(*src++, rd)>>8;
- 						writePacked(rd);
+					        readPackedSource(rs);
+						rd=*dst;  
+						*dst++=alphamaskCombine24(rs, rd)>>8;
  					case 1:
- 						readPackedDest(rd);
- 						rd=alphamaskCombine24(*src++, rd)>>8;
- 						writePacked(rd);
- 				}
- 				dst=(CARD8 *)wodst;
- 				switch(ww)
- 				{
- 					case 1:
- 						dst[2]=(workingoDest>>8)&0xff;
- 					case 2:
- 						dst[1]=(workingoDest>>16)&0xff;
- 					case 3:
- 						dst[0]=workingoDest>>24;
+                                               readPackedSource(rs);
+                                               rd=*dst;  
+                                               *dst++=alphamaskCombine24(rs, rd)>>8;
  				}
  			}
  		}
@@ -1228,7 +1312,7 @@ fbCompositeTrans_0888xnx0888(CARD8      
  				src = srcLine;
  				srcLine += srcStride;
  				w = width*3;
- 				// get to word aligned
+ 				/* get to word aligned */
  				switch(!(int)src&3)
  				{
 					case 1:
@@ -1246,13 +1330,11 @@ fbCompositeTrans_0888xnx0888(CARD8      
  				}
  				wsrc=(CARD32 *)src;
  				widst=(CARD32 *)dst;
- 
-				register CARD32 t1, t2, t3, t4;
  				while(w>3)
  				{
  					rs = *wsrc++;
  					rd = *widst;
- 					fastcombine32(maskAlpha, rs, rd, widst, t1, t2, t3, t4);
+ 					inOver0888 (maskAlpha, rs, rd, *widst++);
  					w-=4;
  				}
 				src=(CARD8 *)wsrc;
@@ -1300,80 +1382,29 @@ fbCompositeSrcSrc_nxn  (CARD8	   op,
     int		dstXoff, dstYoff;
     int		srcBpp;
     int		dstBpp;
-    // these need to be signed now!
-    int 	iwidth=width;
-    int 	iheight=height;
     Bool	reverse = FALSE;
     Bool	upsidedown = FALSE;
-    int initialWidth=width;
-    int initialX=xDst;
- 
- 	// FIXME: this is possibly the worst piece of code I've ever written.
- 	// My main objection to it, is that it is incrfedibly slow in a few cases, due to the
- 	// call-per-repeat structure of it - the *correct* solution is to implement
- 	// repeat into fbBlt(), but that's a nontrivial job, and it's far more 
- 	// important to get the "requireRepeat" stuff implented functionally
-	// first, *then* make it fast.
- 	//  -- jj
-    Bool srcRepeat=pSrc->repeat;
-    CARD32 srcHeight=pSrc->pDrawable->height;
-    CARD32 srcWidth=pSrc->pDrawable->width;
+    
+    fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
+    fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
+	
+    fbBlt (src + (ySrc + srcYoff) * srcStride,
+	   srcStride,
+	   (xSrc + srcXoff) * srcBpp,
  
- 	fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
- 	fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
+	   dst + (yDst + dstYoff) * dstStride,
+	   dstStride,
+	   (xDst + dstXoff) * dstBpp,
 
- 	if(srcRepeat)
- 	{
- 		xSrc%=srcWidth;
- 		ySrc%=srcHeight;
- 	}
- 	
- 	while(iheight>0)
-	{
- 		int wheight=iheight;
- 		if(wheight>(srcHeight-ySrc))
- 			wheight=(srcHeight-ySrc);
- 		iwidth=initialWidth;
- 		xDst=initialX;
- 		while(iwidth>0)
- 		{
-			int wwidth=iwidth;
- 			if(wwidth>(srcWidth-xSrc))
- 				wwidth=(srcWidth-xSrc);
- 
- 			fbBlt (src + (ySrc + srcYoff) * srcStride,
- 					srcStride,
- 					(xSrc + srcXoff) * srcBpp,
- 
-					dst + (yDst + dstYoff) * dstStride,
- 					dstStride,
- 					(xDst + dstXoff) * dstBpp,
- 
- 					(wwidth) * dstBpp,
- 					(wheight),
- 
- 					GXcopy,
-					FB_ALLONES,
- 					dstBpp,
- 
- 					reverse,
- 					upsidedown);
- 			if(!srcRepeat)
- 				iwidth=0;
- 			else
-			{
- 				xDst+=wwidth;
- 				iwidth-=wwidth;
- 			}
- 		}
- 		if(!srcRepeat)
- 			iheight=0;
- 		else
- 		{
- 			yDst+=wheight;
- 			iheight-=wheight;
- 		}
- 	}
+	   (width) * dstBpp,
+	   (height),
+
+	   GXcopy,
+	   FB_ALLONES,
+	   dstBpp,
+
+	   reverse,
+	   upsidedown);
     
     fbFinishAccess(pSrc->pDrawable);
     fbFinishAccess(pDst->pDrawable);
@@ -1530,6 +1561,16 @@ fbComposite (CARD8      op,
 				break;
 			    }
 			}
+			else
+			{
+			    switch (pDst->format) {
+                            case PICT_r5g6b5:
+                                func = fbCompositeSolidMask_nx8888x0565;
+                                break;
+			    default:
+				break;
+                            }
+			}
 			break;
 		    case PICT_a8b8g8r8:
 			if (pMask->componentAlpha) {
@@ -1555,6 +1596,16 @@ fbComposite (CARD8      op,
 				break;
 			    }
 			}
+			else
+			{
+			    switch (pDst->format) {
+                            case PICT_b5g6r5:
+                                func = fbCompositeSolidMask_nx8888x0565;
+                                break;
+			    default:
+				break;
+                            }
+			}
 			break;
 		    case PICT_a1:
 			switch (pDst->format) {
@@ -1722,7 +1773,20 @@ fbComposite (CARD8      op,
 	    }
 	    else if (! srcRepeat)
 	    {
-		switch (pSrc->format) {
+		/*
+		 * Formats without alpha bits are just Copy with Over
+		 */
+		if (pSrc->format == pDst->format && !PICT_FORMAT_A(pSrc->format))
+		{
+#ifdef USE_MMX
+		    if (fbHaveMMX() &&
+			(pSrc->format == PICT_x8r8g8b8 || pSrc->format == PICT_x8b8g8r8))
+			func = fbCompositeCopyAreammx;
+		    else
+#endif
+			func = fbCompositeSrcSrc_nxn;
+		}
+		else switch (pSrc->format) {
 		case PICT_a8r8g8b8:
 		    switch (pDst->format) {
 		    case PICT_a8r8g8b8:
@@ -1800,24 +1864,6 @@ fbComposite (CARD8      op,
 			break;
 		    }
 		    break;
-		case PICT_r5g6b5:
-		    switch (pDst->format) {
-		    case PICT_r5g6b5:
-			func = fbCompositeSrc_0565x0565;
-			break;
-		    default:
-			break;
-		    }
-		    break;
-		case PICT_b5g6r5:
-		    switch (pDst->format) {
-		    case PICT_b5g6r5:
-			func = fbCompositeSrc_0565x0565;
-			break;
-		    default:
-			break;
-		    }
-		    break;
 		default:
 		    break;
 		}
@@ -1908,14 +1954,6 @@ fbComposite (CARD8      op,
 
     n = REGION_NUM_RECTS (&region);
     pbox = REGION_RECTS (&region);
-    // FIXME: this is bascially a "white list" of composites that work
-    // with repeat until they are all implented.  Once that's done, we
-    // remove the checks below entirely
-    if(func==fbCompositeSrcSrc_nxn)
-    {
-	    srcRepeat=maskRepeat=FALSE;
-    }
-
     while (n--)
     {
 	h = pbox->y2 - pbox->y1;
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 76cab5b..5246cd5 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -121,7 +121,7 @@ fbCanGetSolid(PicturePtr pict)
 	break; \
     case 16: \
 	(bits) = READ((CARD16 *) __bits__); \
-	(bits) = cvt0565to8888(bits); \
+	(bits) = cvt0565to0888(bits); \
 	break; \
     case 8: \
 	(bits) = READ((CARD8 *) __bits__); \
@@ -161,7 +161,7 @@ fbCanGetSolid(PicturePtr pict)
 #define cvt8888to0565(s)    ((((s) >> 3) & 0x001f) | \
 			     (((s) >> 5) & 0x07e0) | \
 			     (((s) >> 8) & 0xf800))
-#define cvt0565to8888(s)    (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+#define cvt0565to0888(s)    (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
 			     ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
 			     ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
 
diff-tree fde4a5adf02d3067a064ebf6bdd666aa5784cfe9 (from 13e1d5ea55b0a3b7729316c8e37d3d8fca2075b5)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue Apr 24 13:30:43 2007 -0400

    From xserver via pixman (Jeff Muizelaar)
    
         Add some optimizations from jaymz. Also adds some compile
         warnings that will hopefully go awa y as we continue merging.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 072f8d8..660112c 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -105,6 +105,51 @@ fbIn (CARD32 x, CARD8 y)
     return m|n|o|p;
 }
 
+#define genericCombine24(a,b,c,d) (((a)*(c)+(b)*(d)))
+
+#define fastcombine32(alpha, source, destval, destptr, dstrb, dstag, drb, dag) \
+	dstrb=destval&0xFF00FF; dstag=(destval>>8)&0xFF00FF; \
+	drb=((source&0xFF00FF)-dstrb)*alpha; dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \
+	*destptr++=((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
+
+#define fastcombine32(alpha, source, destval, destptr, dstrb, dstag, drb, dag) \
+	dstrb=destval&0xFF00FF; dstag=(destval>>8)&0xFF00FF; \
+	drb=((source&0xFF00FF)-dstrb)*alpha; dag=(((source>>8)&0xFF00FF)-dstag)*alpha; \
+	*destptr++=((((drb>>8) + dstrb) & 0x00FF00FF) | ((((dag>>8) + dstag) << 8) & 0xFF00FF00)); \
+	
+// Note: this macro expects 6 bits of alpha, not 8!
+#define fastCombine0565(alpha, source, destval, destptr) { \
+	CARD16 dstrb = destval & 0xf81f; CARD16 dstg  = destval & 0x7e0; \
+	CARD32 drb = ((source&0xf81f)-dstrb)*alpha; CARD32 dg=((source & 0x7e0)-dstg)*alpha; \
+	destptr= ((((drb>>6) + dstrb)&0xf81f) | (((dg>>6)  + dstg) & 0x7e0)); \
+	}
+
+#if IMAGE_BYTE_ORDER == LSBFirst
+	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
+					temp=count&3; \
+					where-=temp; \
+					workingWhere=(CARD32 *)where; \
+					workingVal=*workingWhere++; \
+					count=4-temp; \
+					workingVal>>=(8*temp)
+	#define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)&0xff; (y)>>=8; (x)--;}
+	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
+	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
+	#define writePacked(what) workingoDest>>=8; workingoDest|=(what<<24); ww--; if(!ww) { ww=4; *wodst++=workingoDest; } 
+#else
+	#warning "I havn't tested fbCompositeTrans_0888xnx0888() on big endian yet!"
+	#define setupPackedReader(count,temp,where,workingWhere,workingVal) count=(int)where; \
+					temp=count&3; \
+					where-=temp; \
+					workingWhere=(CARD32 *)where; \
+					workingVal=*workingWhere++; \
+					count=4-temp; \
+					workingVal<<=(8*temp)
+	#define readPacked(where,x,y,z) {if(!(x)) { (x)=4; y=*z++; } where=(y)>>24; (y)<<=8; (x)--;}
+	#define readPackedSource(where) readPacked(where,ws,workingSource,wsrc)
+	#define readPackedDest(where) readPacked(where,wd,workingiDest,widst)
+	#define writePacked(what) workingoDest<<=8; workingoDest|=what; ww--; if(!ww) { ww=4; *wodst++=workingoDest; } 
+#endif
 /*
  * Naming convention:
  *
@@ -248,6 +293,7 @@ fbCompositeSolidMask_nx8888x8888C (CARD8
     fbFinishAccess (pDst->pDrawable);
 }
 
+#define srcAlphaCombine24(a,b) genericCombine24(a,b,srca,srcia)
 void
 fbCompositeSolidMask_nx8x0888 (CARD8      op,
 			       PicturePtr pSrc,
@@ -262,52 +308,86 @@ fbCompositeSolidMask_nx8x0888 (CARD8    
 			       CARD16     width,
 			       CARD16     height)
 {
-    CARD32	src, srca;
-    CARD8	*dstLine, *dst;
+    CARD32	src, srca, srcia;
+    CARD8	*dstLine, *dst, *edst;
     CARD32	d;
     CARD8	*maskLine, *mask, m;
     FbStride	dstStride, maskStride;
     CARD16	w;
+    CARD32 rs,gs,bs,rd,gd,bd;
 
     fbComposeGetSolid(pSrc, src, pDst->format);
 
     srca = src >> 24;
+    srcia = 255-srca;
     if (src == 0)
 	return;
 
+    rs=src&0xff;
+    gs=(src>>8)&0xff;
+    bs=(src>>16)&0xff;
+      
     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
     fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
 
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    m = READ(mask++);
-	    if (m == 0xff)
-	    {
-		if (srca == 0xff)
-		    d = src;
-		else
-		{
-		    d = Fetch24(dst);
-		    d = fbOver24 (src, d);
+     while (height--)
+  	{
+ 		// fixme: cleanup unused
+ 		unsigned int wt,wd;
+ 		CARD32 workingiDest;
+ 		CARD32 *widst;
+ 		
+ 		edst=dst = dstLine;
+ 		dstLine += dstStride;
+ 		mask = maskLine;
+ 		maskLine += maskStride;
+ 		w = width;
+ 		
+#ifndef NO_MASKED_PACKED_READ
+ 		setupPackedReader(wd,wt,edst,widst,workingiDest);
+#endif
+ 				
+ 		while (w--)
+ 		{
+#ifndef NO_MASKED_PACKED_READ
+ 			readPackedDest(rd);
+ 			readPackedDest(gd);
+ 			readPackedDest(bd);
+#else
+ 			rd= *edst++;
+ 			gd= *edst++;
+ 			bd= *edst++;
+#endif
+ 			m = *mask++;
+ 			if (m == 0xff)
+ 			{
+ 				if (srca == 0xff)
+ 				{
+ 					*dst++=rs;
+ 					*dst++=gs;
+ 					*dst++=bs;
+ 				}
+ 				else
+ 				{
+ 					*dst++=(srcAlphaCombine24(rs, rd)>>8);
+ 					*dst++=(srcAlphaCombine24(gs, gd)>>8);
+ 					*dst++=(srcAlphaCombine24(bs, bd)>>8);
+				}
+ 			}
+ 			else if (m)
+ 			{
+ 				int na=(srca*(int)m)>>8;
+ 				int nia=255-na;
+ 				*dst++=(genericCombine24(rs, rd, na, nia)>>8);
+ 				*dst++=(genericCombine24(gs, gd, na, nia)>>8);
+ 				*dst++=(genericCombine24(bs, bd, na, nia)>>8);
+ 			}
+ 			else
+ 			{
+ 				dst+=3;
+ 			}
 		}
-		Store24(dst,d);
-	    }
-	    else if (m)
-	    {
-		d = fbOver24 (fbIn(src,m), Fetch24(dst));
-		Store24(dst,d);
-	    }
-	    dst += 3;
 	}
-    }
 
     fbFinishAccess (pMask->pDrawable);
     fbFinishAccess (pDst->pDrawable);
@@ -327,54 +407,57 @@ fbCompositeSolidMask_nx8x0565 (CARD8    
 				  CARD16     width,
 				  CARD16     height)
 {
-    CARD32	src, srca;
-    CARD16	*dstLine, *dst;
-    CARD32	d;
-    CARD8	*maskLine, *mask, m;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    srca = src >> 24;
-    if (src == 0)
-	return;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    m = READ(mask++);
-	    if (m == 0xff)
-	    {
-		if (srca == 0xff)
-		    d = src;
-		else
-		{
-		    d = READ(dst);
-		    d = fbOver24 (src, cvt0565to8888(d));
-		}
-		WRITE(dst, cvt8888to0565(d));
-	    }
-	    else if (m)
-	    {
-		d = READ(dst);
-		d = fbOver24 (fbIn(src,m), cvt0565to8888(d));
-		WRITE(dst, cvt8888to0565(d));
-	    }
-	    dst++;
-	}
-    }
-
+     CARD32	src, srca,na, rsrca;
+     CARD16	*dstLine, *dst;
+     CARD16	d;
+     CARD8	*maskLine, *mask, m;
+     FbStride	dstStride, maskStride;
+     CARD16	w,src16;
+  
+     fbComposeGetSolid(pSrc, src, pDst->format);
+     src16 = cvt8888to0565(src);
+      
+     rsrca = src >> 24;
+     srca=rsrca>>2;
+      if (src == 0)
+ 		return;
+      
+      fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+      fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+    
+ 	while (height--)
+  	{
+ 		dst = dstLine;
+ 		dstLine += dstStride;
+ 		mask = maskLine;
+ 		maskLine += maskStride;
+ 		w = width;
+ 
+ 		while (w--)
+  		{
+ 			m = *mask++;
+ 			if (m == 0xff)
+ 			{
+ 				if (srca == 0xff)
+ 				{
+ 					*dst=src16;
+ 				}
+ 				else
+ 				{
+ 					d = *dst;
+ 					fastCombine0565(srca, src16, d, *dst++);
+ 				}
+ 			}
+ 			else if (m)
+ 			{
+ 				na=(rsrca*(int)m)>>10;
+ 				d = *dst;
+ 				fastCombine0565(na, src16, d, *dst++);
+ 			}
+ 			else
+ 				dst++;
+  		}
+  	}
     fbFinishAccess (pMask->pDrawable);
     fbFinishAccess (pDst->pDrawable);
 }
@@ -906,7 +989,7 @@ fbCompositeTrans_0565xnx0565(CARD8      
     CARD32	s_32, d_32, i_32, r_32;
     
     fbComposeGetSolid (pMask, mask, pDst->format);
-    maskAlpha = mask >> 24;
+    maskAlpha = mask >> 26;
     
     if (!maskAlpha)
 	return;
@@ -922,31 +1005,276 @@ fbCompositeTrans_0565xnx0565(CARD8      
     fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
 
     while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	src = srcLine;
-	srcLine += srcStride;
-	w = width;
-
-	while (w--)
-	{
-	    s_16 = READ(src++);
-	    s_32 = cvt0565to8888(s_16);
-	    d_16 = READ(dst);
-	    d_32 = cvt0565to8888(d_16);
-	    
-	    i_32 = fbIn24 (s_32, maskAlpha);
-	    r_32 = fbOver24 (i_32, d_32);
-	    r_16 = cvt8888to0565(r_32);
-	    WRITE(dst++, r_16);
-	}
-    }
+ 	{
+ 		CARD32 *isrc;
+ 		dst = dstLine;
+ 		dstLine += dstStride;
+ 		src = srcLine;
+ 		srcLine += srcStride;
+ 		w = width;
+ 		
+ 		if(((int)src&1)==1)
+ 		{
+ 			s_16 = *src++;
+ 			d_16 = *dst;
+ 			fastCombine0565(maskAlpha, s_16, d_16, *dst++);
+ 			w--;
+ 		}
+ 		isrc=(CARD32 *)src;
+ 		while (w>1)
+ 		{
+ 			s_32=*isrc++;
+#if IMAGE_BYTE_ORDER == LSBFirst
+ 			s_16=s_32&0xffff;
+#else
+			s_16=s_32>>16;
+#endif
+ 			d_16 = *dst;
+ 			fastCombine0565(maskAlpha, s_16, d_16, *dst++);
+ #if IMAGE_BYTE_ORDER == LSBFirst
+ 			s_16=s_32>>16;
+ #else
+ 			s_16=s_32&0xffff;
+ #endif
+ 			d_16 = *dst;
+ 			fastCombine0565(maskAlpha, s_16, d_16, *dst++);
+ 			w-=2;
+ 		}
+ 		src=(CARD16 *)isrc;
+ 		if(w!=0)
+ 		{
+ 			s_16 = *src;
+ 			d_16 = *dst;
+ 			fastCombine0565(maskAlpha, s_16, d_16, *dst);
+ 		}
+ 	}
 
     fbFinishAccess (pSrc->pDrawable);
     fbFinishAccess (pDst->pDrawable);
 }
 
+// macros for "i can't believe it's not fast" packed pixel handling
+#define alphamaskCombine24(a,b) genericCombine24(a,b,maskAlpha,maskiAlpha)
+static void
+fbCompositeTrans_0888xnx0888(CARD8      op,
+ 			     PicturePtr pSrc,
+ 			     PicturePtr pMask,
+ 			     PicturePtr pDst,
+ 			     INT16      xSrc,
+ 			     INT16      ySrc,
+ 			     INT16      xMask,
+ 			     INT16      yMask,
+ 			     INT16      xDst,
+ 			     INT16      yDst,
+ 			     CARD16     width,
+ 			     CARD16     height)
+ {
+     CARD8	*dstLine, *dst,*idst;
+     CARD8	*srcLine, *src;
+     FbStride	dstStride, srcStride;
+     CARD16	w;
+     FbBits	mask;
+     CARD16	maskAlpha,maskiAlpha;
+     
+     fbComposeGetSolid (pMask, mask, pDst->format);
+     maskAlpha = mask >> 24;
+ 	maskiAlpha= 255-maskAlpha;
+     
+     if (!maskAlpha)
+ 	return;
+     //if (maskAlpha == 0xff)
+     //{
+ 	//fbCompositeSrc_0888x0888 (op, pSrc, pMask, pDst,
+ 	//			  xSrc, ySrc, xMask, yMask, xDst, yDst, 
+ 	//			  width, height);
+ 	//return;
+     //}
+ 	
+     fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 3);
+     fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
+  
+  	{
+ 		unsigned int ws,wt,wd,ww;
+ 		CARD32 workingSource;
+ 		CARD32 *wsrc;
+ 		CARD32 rs,gs,bs;
+ 		CARD32 rd,gd,bd;
+ 
+ 		CARD32 workingiDest,workingoDest;
+ 		CARD32 *widst,*wodst;
+ 
+ 
+ 		// are xSrc and xDst at the same alignment?  if not, we need to be complicated :)
+ 		//if(0==0)
+ 		if( (((xSrc*3)&3)!=((xDst*3)&3)) || (srcStride&3)!=0 || (dstStride&3)!=0)
+ 		{
+ 			while (height--)
+ 			{
+ 				idst=dst = dstLine;
+ 				dstLine += dstStride;
+ 				src = srcLine;
+ 				srcLine += srcStride;
+ 				w = width*3;
+ 				
+ 				setupPackedReader(wd,wt,idst,widst,workingiDest);
+ 				ww=(int)dst;
+ 				wt=ww&3;
+ 				dst-=wt; 
+ 				wodst=(CARD32 *)dst; 
+ 				workingoDest=*wodst; 
+ 				ww=4-wt;
+#if IMAGE_BYTE_ORDER == LSBFirst
+ 				workingoDest<<=(8*(ww+1));
+#else
+ 				workingoDest>>=(8*(ww+1));
+#endif
+ 
+ 				// get to word aligned
+ 				switch(!(int)src&3)
+ 				{
+ 					case 1:
+ 						readPackedDest(rd);
+ 						rd=alphamaskCombine24(*src++, rd)>>8;
+ 						writePacked(rd);
+ 						w--; if(w==0) break;
+ 					case 2:
+ 						readPackedDest(rd);
+ 						rd=alphamaskCombine24(*src++, rd)>>8;
+ 						writePacked(rd);
+ 						w--; if(w==0) break;
+ 					case 3:
+ 						readPackedDest(rd);
+ 						rd=alphamaskCombine24(*src++, rd)>>8;
+ 						writePacked(rd);
+ 						w--; if(w==0) break;
+ 				}
+ 				wsrc=(CARD32 *)src;
+				while (w>3)
+				{
+ 					rs=*wsrc++;
+ 					// FIXME: write a version of readPackedDest() which
+ 					// can collect 4 bytes at once if we're on a boundry (which we're
+ 					// actually guarenteed not to be in this version, but do it anyhow), and can
+ 					// collect as 2 16bit words on a 2byte boundry, and then use the 32bit combine here
+ #if IMAGE_BYTE_ORDER == LSBFirst
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24(rs&0xff, rd)>>8;
+ 					writePacked(rd);
+ 
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24((rs>>8)&0xff, rd)>>8;
+ 					writePacked(rd);
+ 					
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24((rs>>16)&0xff, rd)>>8;
+ 					writePacked(rd);
+ 					
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24(rs>>24, rd)>>8;
+ 					writePacked(rd);
+ #else
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24(rs>>24, rd)>>8;
+ 					writePacked(rd);
+ 					
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24((rs>>16)&0xff, rd)>>8;
+ 					writePacked(rd);
+ 					
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24((rs>>8)&0xff, rd)>>8;
+ 					writePacked(rd);
+ 
+ 					readPackedDest(rd);
+ 					rd=alphamaskCombine24(rs&0xff, rd)>>8;
+ 					writePacked(rd);
+ #endif
+ 					w-=4;
+ 				}
+ 				src=(CARD8 *)wsrc;
+ 				switch(w)
+ 				{
+ 					case 3:
+ 						readPackedDest(rd);
+ 						rd=alphamaskCombine24(*src++, rd)>>8;
+ 						writePacked(rd);
+ 					case 2:
+ 						readPackedDest(rd);
+ 						rd=alphamaskCombine24(*src++, rd)>>8;
+ 						writePacked(rd);
+ 					case 1:
+ 						readPackedDest(rd);
+ 						rd=alphamaskCombine24(*src++, rd)>>8;
+ 						writePacked(rd);
+ 				}
+ 				dst=(CARD8 *)wodst;
+ 				switch(ww)
+ 				{
+ 					case 1:
+ 						dst[2]=(workingoDest>>8)&0xff;
+ 					case 2:
+ 						dst[1]=(workingoDest>>16)&0xff;
+ 					case 3:
+ 						dst[0]=workingoDest>>24;
+ 				}
+ 			}
+ 		}
+ 		else
+ 		{
+ 			while (height--)
+ 			{
+ 				idst=dst = dstLine;
+ 				dstLine += dstStride;
+ 				src = srcLine;
+ 				srcLine += srcStride;
+ 				w = width*3;
+ 				// get to word aligned
+ 				switch(!(int)src&3)
+ 				{
+					case 1:
+ 						rd=alphamaskCombine24(*src++, *dst)>>8;
+ 						*dst++=rd;
+ 						w--; if(w==0) break;
+ 					case 2:
+ 						rd=alphamaskCombine24(*src++, *dst)>>8;
+ 						*dst++=rd;
+ 						w--; if(w==0) break;
+					case 3:
+ 						rd=alphamaskCombine24(*src++, *dst)>>8;
+ 						*dst++=rd;
+ 						w--; if(w==0) break;
+ 				}
+ 				wsrc=(CARD32 *)src;
+ 				widst=(CARD32 *)dst;
+ 
+				register CARD32 t1, t2, t3, t4;
+ 				while(w>3)
+ 				{
+ 					rs = *wsrc++;
+ 					rd = *widst;
+ 					fastcombine32(maskAlpha, rs, rd, widst, t1, t2, t3, t4);
+ 					w-=4;
+ 				}
+				src=(CARD8 *)wsrc;
+ 				dst=(CARD8 *)widst;
+ 				switch(w)
+ 				{
+ 					case 3:
+ 						rd=alphamaskCombine24(*src++, *dst)>>8;
+ 						*dst++=rd;
+ 					case 2:
+						rd=alphamaskCombine24(*src++, *dst)>>8;
+ 						*dst++=rd;
+ 					case 1:
+ 						rd=alphamaskCombine24(*src++, *dst)>>8;
+ 						*dst++=rd;
+ 				}
+ 			}
+ 		}
+ 	}
+  }
+
+
 /*
  * Simple bitblt
  */
@@ -972,30 +1300,81 @@ fbCompositeSrcSrc_nxn  (CARD8	   op,
     int		dstXoff, dstYoff;
     int		srcBpp;
     int		dstBpp;
+    // these need to be signed now!
+    int 	iwidth=width;
+    int 	iheight=height;
     Bool	reverse = FALSE;
     Bool	upsidedown = FALSE;
+    int initialWidth=width;
+    int initialX=xDst;
+ 
+ 	// FIXME: this is possibly the worst piece of code I've ever written.
+ 	// My main objection to it, is that it is incrfedibly slow in a few cases, due to the
+ 	// call-per-repeat structure of it - the *correct* solution is to implement
+ 	// repeat into fbBlt(), but that's a nontrivial job, and it's far more 
+ 	// important to get the "requireRepeat" stuff implented functionally
+	// first, *then* make it fast.
+ 	//  -- jj
+    Bool srcRepeat=pSrc->repeat;
+    CARD32 srcHeight=pSrc->pDrawable->height;
+    CARD32 srcWidth=pSrc->pDrawable->width;
+ 
+ 	fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
+ 	fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
+
+ 	if(srcRepeat)
+ 	{
+ 		xSrc%=srcWidth;
+ 		ySrc%=srcHeight;
+ 	}
+ 	
+ 	while(iheight>0)
+	{
+ 		int wheight=iheight;
+ 		if(wheight>(srcHeight-ySrc))
+ 			wheight=(srcHeight-ySrc);
+ 		iwidth=initialWidth;
+ 		xDst=initialX;
+ 		while(iwidth>0)
+ 		{
+			int wwidth=iwidth;
+ 			if(wwidth>(srcWidth-xSrc))
+ 				wwidth=(srcWidth-xSrc);
+ 
+ 			fbBlt (src + (ySrc + srcYoff) * srcStride,
+ 					srcStride,
+ 					(xSrc + srcXoff) * srcBpp,
+ 
+					dst + (yDst + dstYoff) * dstStride,
+ 					dstStride,
+ 					(xDst + dstXoff) * dstBpp,
+ 
+ 					(wwidth) * dstBpp,
+ 					(wheight),
+ 
+ 					GXcopy,
+					FB_ALLONES,
+ 					dstBpp,
+ 
+ 					reverse,
+ 					upsidedown);
+ 			if(!srcRepeat)
+ 				iwidth=0;
+ 			else
+			{
+ 				xDst+=wwidth;
+ 				iwidth-=wwidth;
+ 			}
+ 		}
+ 		if(!srcRepeat)
+ 			iheight=0;
+ 		else
+ 		{
+ 			yDst+=wheight;
+ 			iheight-=wheight;
+ 		}
+ 	}
     
-    fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
-    fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
-
-    fbBlt (src + (ySrc + srcYoff) * srcStride,
-	   srcStride,
-	   (xSrc + srcXoff) * srcBpp,
-
-	   dst + (yDst + dstYoff) * dstStride,
-	   dstStride,
-	   (xDst + dstXoff) * dstBpp,
-
-	   (width) * dstBpp,
-	   (height),
-
-	   GXcopy,
-	   FB_ALLONES,
-	   dstBpp,
-
-	   reverse,
-	   upsidedown);
-
     fbFinishAccess(pSrc->pDrawable);
     fbFinishAccess(pDst->pDrawable);
 }
@@ -1294,6 +1673,11 @@ fbComposite (CARD8      op,
 		    if (pDst->format == pSrc->format)
 		        func = fbCompositeTrans_0565xnx0565;
 		    break;
+ 		case PICT_r8g8b8:
+ 		case PICT_b8g8r8:
+ 		    if (pDst->format == pSrc->format)
+ 		        func = fbCompositeTrans_0888xnx0888;
+ 		    break;
 		default:
 		    break;
 		}
@@ -1524,6 +1908,14 @@ fbComposite (CARD8      op,
 
     n = REGION_NUM_RECTS (&region);
     pbox = REGION_RECTS (&region);
+    // FIXME: this is bascially a "white list" of composites that work
+    // with repeat until they are all implented.  Once that's done, we
+    // remove the checks below entirely
+    if(func==fbCompositeSrcSrc_nxn)
+    {
+	    srcRepeat=maskRepeat=FALSE;
+    }
+
     while (n--)
     {
 	h = pbox->y2 - pbox->y1;
diff-tree 13e1d5ea55b0a3b7729316c8e37d3d8fca2075b5 (from 077a5d4555676d5775e990468a697b6890c6d609)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue Apr 24 12:59:18 2007 -0400

    Fix format vs formatCode in previous commit

diff --git a/fb/fbpict.c b/fb/fbpict.c
index bc737d8..072f8d8 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1085,7 +1085,7 @@ fbComposite (CARD8      op,
 #endif
 	    if (pMask == 0)
 	    {
-		if (pSrc->format_code == pDst->format_code)
+		if (pSrc->format == pDst->format)
 		    func = fbCompositeSrcSrc_nxn;
 	    }
 	break;
diff-tree 077a5d4555676d5775e990468a697b6890c6d609 (from 09436fb7c38a9819bde770c4c21143591671c4d7)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Tue Apr 24 12:57:55 2007 -0400

    Add functions fbCompositeSrcSrc_nxn() and fbCompositeTrans_0565xnx0565
    from xserver via pixman. Add READ/WRITE and fbFinishAccess as
    appropriate.

diff --git a/fb/fbpict.c b/fb/fbpict.c
index cd6cac2..bc737d8 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -64,6 +64,20 @@ fbOver (CARD32 x, CARD32 y)
     return m|n|o|p;
 }
 
+static CARD32
+fbIn24 (CARD32 x, CARD8 y)
+{
+    CARD16  a = y;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    m = FbInU(x,0,a,t);
+    n = FbInU(x,8,a,t);
+    o = FbInU(x,16,a,t);
+    p = (y << 24);
+    return m|n|o|p;
+}
+
 CARD32
 fbOver24 (CARD32 x, CARD32 y)
 {
@@ -864,6 +878,148 @@ fbCompositeSolidMask_nx1xn (CARD8      o
 
 # define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
+/*
+ * Apply a constant alpha value in an over computation
+ */
+
+static void
+fbCompositeTrans_0565xnx0565(CARD8      op,
+			     PicturePtr pSrc,
+			     PicturePtr pMask,
+			     PicturePtr pDst,
+			     INT16      xSrc,
+			     INT16      ySrc,
+			     INT16      xMask,
+			     INT16      yMask,
+			     INT16      xDst,
+			     INT16      yDst,
+			     CARD16     width,
+			     CARD16     height)
+{
+    CARD16	*dstLine, *dst;
+    CARD16	*srcLine, *src;
+    FbStride	dstStride, srcStride;
+    CARD16	w;
+    FbBits	mask;
+    CARD8	maskAlpha;
+    CARD16	s_16, d_16, r_16;
+    CARD32	s_32, d_32, i_32, r_32;
+    
+    fbComposeGetSolid (pMask, mask, pDst->format);
+    maskAlpha = mask >> 24;
+    
+    if (!maskAlpha)
+	return;
+    if (maskAlpha == 0xff)
+    {
+	fbCompositeSrc_0565x0565 (op, pSrc, pMask, pDst,
+				  xSrc, ySrc, xMask, yMask, xDst, yDst, 
+				  width, height);
+	return;
+    }
+
+    fbComposeGetStart (pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1);
+    fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	while (w--)
+	{
+	    s_16 = READ(src++);
+	    s_32 = cvt0565to8888(s_16);
+	    d_16 = READ(dst);
+	    d_32 = cvt0565to8888(d_16);
+	    
+	    i_32 = fbIn24 (s_32, maskAlpha);
+	    r_32 = fbOver24 (i_32, d_32);
+	    r_16 = cvt8888to0565(r_32);
+	    WRITE(dst++, r_16);
+	}
+    }
+
+    fbFinishAccess (pSrc->pDrawable);
+    fbFinishAccess (pDst->pDrawable);
+}
+
+/*
+ * Simple bitblt
+ */
+
+static void
+fbCompositeSrcSrc_nxn  (CARD8	   op,
+			PicturePtr pSrc,
+			PicturePtr pMask,
+			PicturePtr pDst,
+			INT16      xSrc,
+			INT16      ySrc,
+			INT16      xMask,
+			INT16      yMask,
+			INT16      xDst,
+			INT16      yDst,
+			CARD16     width,
+			CARD16     height)
+{
+    FbBits	*dst;
+    FbBits	*src;
+    FbStride	dstStride, srcStride;
+    int		srcXoff, srcYoff;
+    int		dstXoff, dstYoff;
+    int		srcBpp;
+    int		dstBpp;
+    Bool	reverse = FALSE;
+    Bool	upsidedown = FALSE;
+    
+    fbGetDrawable(pSrc->pDrawable,src,srcStride,srcBpp,srcXoff,srcYoff);
+    fbGetDrawable(pDst->pDrawable,dst,dstStride,dstBpp,dstXoff,dstYoff);
+
+    fbBlt (src + (ySrc + srcYoff) * srcStride,
+	   srcStride,
+	   (xSrc + srcXoff) * srcBpp,
+
+	   dst + (yDst + dstYoff) * dstStride,
+	   dstStride,
+	   (xDst + dstXoff) * dstBpp,
+
+	   (width) * dstBpp,
+	   (height),
+
+	   GXcopy,
+	   FB_ALLONES,
+	   dstBpp,
+
+	   reverse,
+	   upsidedown);
+
+    fbFinishAccess(pSrc->pDrawable);
+    fbFinishAccess(pDst->pDrawable);
+}
+
+/*
+ * Solid fill
+void
+fbCompositeSolidSrc_nxn  (CARD8	op,
+			  PicturePtr pSrc,
+			  PicturePtr pMask,
+			  PicturePtr pDst,
+			  INT16      xSrc,
+			  INT16      ySrc,
+			  INT16      xMask,
+			  INT16      yMask,
+			  INT16      xDst,
+			  INT16      yDst,
+			  CARD16     width,
+			  CARD16     height)
+{
+    
+}
+ */
+
 void
 fbComposite (CARD8      op,
 	     PicturePtr pSrc,
@@ -925,7 +1081,13 @@ fbComposite (CARD8      op,
 	{
 	    func = fbCompositeCopyAreammx;
 	}
+	else
 #endif
+	    if (pMask == 0)
+	    {
+		if (pSrc->format_code == pDst->format_code)
+		    func = fbCompositeSrcSrc_nxn;
+	    }
 	break;
     case PictOpOver:
 	if (pMask)
@@ -933,7 +1095,6 @@ fbComposite (CARD8      op,
 	    if (fbCanGetSolid(pSrc) &&
 		!maskRepeat)
 	    {
-		srcRepeat = FALSE;
 		if (PICT_FORMAT_COLOR(pSrc->format)) {
 		    switch (pMask->format) {
 		    case PICT_a8:
@@ -1120,6 +1281,24 @@ fbComposite (CARD8      op,
 			}
 		    }
 		}
+		if (func != fbCompositeGeneral)
+		    srcRepeat = FALSE;
+	    }
+	    else if (maskRepeat &&
+		     pMask->pDrawable->width == 1 &&
+		     pMask->pDrawable->height == 1)
+	    {
+		switch (pSrc->format) {
+		case PICT_r5g6b5:
+		case PICT_b5g6r5:
+		    if (pDst->format == pSrc->format)
+		        func = fbCompositeTrans_0565xnx0565;
+		    break;
+		default:
+		    break;
+		}
+		if (func != fbCompositeGeneral)
+		    maskRepeat = FALSE;
 	    }
 	}
 	else /* no mask */
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 434526e..76cab5b 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -123,6 +123,14 @@ fbCanGetSolid(PicturePtr pict)
 	(bits) = READ((CARD16 *) __bits__); \
 	(bits) = cvt0565to8888(bits); \
 	break; \
+    case 8: \
+	(bits) = READ((CARD8 *) __bits__); \
+	(bits) = (bits) << 24; \
+	break; \
+    case 1: \
+	(bits) = READ((CARD32 *) __bits__);			\
+	(bits) = FbLeftStipBits((bits),1) ? 0xff000000 : 0x00000000;\
+	break; \
     default: \
 	return; \
     } \
diff-tree 09436fb7c38a9819bde770c4c21143591671c4d7 (from c7e2ba0c9b9b1fc1aed8f91f86471c4c8e650b78)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Apr 24 22:52:33 2007 +0930

    Disable devices before removing, remove unrecoverable devices.

diff --git a/dix/devices.c b/dix/devices.c
index e8ca5df..e227617 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -577,6 +577,7 @@ RemoveDevice(DeviceIntPtr dev)
         return BadImplementation;
 
     deviceid = dev->id;
+    DisableDevice(dev);
 
     prev = NULL;
     for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 0af1c6a..2d0a376 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -771,11 +771,30 @@ xf86InitValuatorDefaults(DeviceIntPtr de
  * Device will be moved to the off_devices list, but it will still be there
  * until you really clean up after it.
  * Notifies the client about an inactive device.
+ * 
+ * @param panic True if device is unrecoverable and needs to be removed.
  */
 _X_EXPORT void
-xf86DisableDevice(DeviceIntPtr dev)
+xf86DisableDevice(DeviceIntPtr dev, Bool panic)
 {
-    DisableDevice(dev);
+    devicePresenceNotify ev;
+    DeviceIntRec dummyDev;
+
+    if(!panic)
+    {
+        DisableDevice(dev);
+    } else
+    {
+        ev.type = DevicePresenceNotify;
+        ev.time = currentTime.milliseconds;
+        ev.devchange = DeviceUnrecoverable;
+        ev.deviceid = dev->id;
+        dummyDev.id = 0;
+        SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
+                (xEvent *) &ev, 1);
+
+        DeleteInputDeviceRequest(dev);
+    }
 }
 
 /**
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index f5beb6c..7ef28ed 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -187,7 +187,7 @@ void xf86InitValuatorAxisStruct(DeviceIn
 void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
 void xf86AddEnabledDevice(InputInfoPtr pInfo);
 void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
-void xf86DisableDevice(DeviceIntPtr dev);
+void xf86DisableDevice(DeviceIntPtr dev, Bool panic);
 void xf86EnableDevice(DeviceIntPtr dev);
 
 /* xf86Helper.c */
diff-tree c7e2ba0c9b9b1fc1aed8f91f86471c4c8e650b78 (from ce099a9b78195540ec251a6a3dbe26019c1a686d)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Apr 24 21:34:47 2007 +0930

    Use DevicePresence events to tell the client about enabled/disabled devices.
    
    Include the device id in the event sent to the client.

diff --git a/dix/devices.c b/dix/devices.c
index 7d8fd03..e8ca5df 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -75,6 +75,7 @@ SOFTWARE.
 #include "swaprep.h"
 #include "dixevents.h"
 
+#include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 #include "exglobals.h"
 #include "exevents.h"
@@ -157,6 +158,8 @@ EnableDevice(DeviceIntPtr dev)
 {
     DeviceIntPtr *prev;
     int ret;
+    DeviceIntRec dummyDev;
+    devicePresenceNotify ev;
 
     for (prev = &inputInfo.off_devices;
 	 *prev && (*prev != dev);
@@ -175,6 +178,14 @@ EnableDevice(DeviceIntPtr dev)
     *prev = dev;
     dev->next = NULL;
 
+    ev.type = DevicePresenceNotify;
+    ev.time = currentTime.milliseconds;
+    ev.devchange = DeviceEnabled;
+    ev.deviceid = dev->id;
+    dummyDev.id = 0;
+    SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
+                          (xEvent *) &ev, 1);
+
     return TRUE;
 }
 
@@ -182,6 +193,8 @@ Bool
 DisableDevice(DeviceIntPtr dev)
 {
     DeviceIntPtr *prev;
+    DeviceIntRec dummyDev;
+    devicePresenceNotify ev;
 
     for (prev = &inputInfo.devices;
 	 *prev && (*prev != dev);
@@ -194,6 +207,15 @@ DisableDevice(DeviceIntPtr dev)
     *prev = dev->next;
     dev->next = inputInfo.off_devices;
     inputInfo.off_devices = dev;
+
+    ev.type = DevicePresenceNotify;
+    ev.time = currentTime.milliseconds;
+    ev.devchange = DeviceDisabled;
+    ev.deviceid = dev->id;
+    dummyDev.id = 0;
+    SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
+                          (xEvent *) &ev, 1);
+
     return TRUE;
 }
 
@@ -212,8 +234,8 @@ ActivateDevice(DeviceIntPtr dev)
     
     ev.type = DevicePresenceNotify;
     ev.time = currentTime.milliseconds;
-    ev.devchange = 0;
-    ev.deviceid = 0;
+    ev.devchange = DeviceAdded;
+    ev.deviceid = dev->id;
     dummyDev.id = 0;
     SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
                           (xEvent *) &ev, 1);
@@ -547,12 +569,15 @@ RemoveDevice(DeviceIntPtr dev)
     int ret = BadMatch;
     devicePresenceNotify ev;
     DeviceIntRec dummyDev;
+    int deviceid;
 
     DebugF("(dix) removing device %d\n", dev->id);
 
     if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer)
         return BadImplementation;
 
+    deviceid = dev->id;
+
     prev = NULL;
     for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
 	next = tmp->next;
@@ -587,8 +612,8 @@ RemoveDevice(DeviceIntPtr dev)
         inputInfo.numDevices--;
         ev.type = DevicePresenceNotify;
         ev.time = currentTime.milliseconds;
-        ev.devchange = 0;
-        ev.deviceid = 0;
+        ev.devchange = DeviceRemoved;
+        ev.deviceid = deviceid;
         dummyDev.id = 0;
         SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
                               (xEvent *) &ev, 1);
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 6ebb087..0af1c6a 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -764,4 +764,29 @@ xf86InitValuatorDefaults(DeviceIntPtr de
     }
 }
 
+
+/**
+ * Deactivate a device. Call this function from the driver if you receive a
+ * read error or something else that spoils your day.
+ * Device will be moved to the off_devices list, but it will still be there
+ * until you really clean up after it.
+ * Notifies the client about an inactive device.
+ */
+_X_EXPORT void
+xf86DisableDevice(DeviceIntPtr dev)
+{
+    DisableDevice(dev);
+}
+
+/**
+ * Reactivate a device. Call this function from the driver if you just found
+ * out that the read error wasn't quite that bad after all.
+ * Device will be re-activated, and an event sent to the client. 
+ */
+_X_EXPORT void
+xf86EnableDevice(DeviceIntPtr dev)
+{
+    EnableDevice(dev);
+}
+
 /* end of xf86Xinput.c */
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index b2bc8de..f5beb6c 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -187,6 +187,8 @@ void xf86InitValuatorAxisStruct(DeviceIn
 void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
 void xf86AddEnabledDevice(InputInfoPtr pInfo);
 void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
+void xf86DisableDevice(DeviceIntPtr dev);
+void xf86EnableDevice(DeviceIntPtr dev);
 
 /* xf86Helper.c */
 void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
@@ -204,6 +206,7 @@ int xf86GetMotionEvents(DeviceIntPtr dev
 void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
 			     pointer extraOpts);
 
+
 /* Legacy hatred */
 #define SendCoreEvents 59
 #define DontSendCoreEvents 60
diff-tree ce099a9b78195540ec251a6a3dbe26019c1a686d (from b5e1f7869b2f12a1c2baa7f699ae609fc9ad50aa)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 23 12:34:01 2007 -0600

    fix bug in which maxKeysPerModifier wasn't getting set

diff --git a/dix/devices.c b/dix/devices.c
index c2d4f22..7d8fd03 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1241,6 +1241,7 @@ DoSetModifierMapping(ClientPtr client, K
             }
             else {
                 pDev->key->modifierKeyMap = NULL;
+                pDev->key->maxKeysPerModifier = 0;
             }
         }
     }
diff-tree b5e1f7869b2f12a1c2baa7f699ae609fc9ad50aa (from 84838268b34661d598f8e4856fab355f414930d9)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Mon Apr 23 14:16:30 2007 -0400

    Remove #if 0'ed merge leftovers

diff --git a/render/picture.c b/render/picture.c
index 201ceb2..2022175 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -1051,23 +1051,6 @@ CreateRadialGradientPicture (Picture pid
     radial = &pPicture->pSourcePict->radial;
 
     radial->type = SourcePictTypeRadial;
-#if 0
-    {
-        double x = (double)innerRadius / (double)outerRadius;
-        radial->dx = (outer->x - inner->x);
-        radial->dy = (outer->y - inner->y);
-        radial->fx = (inner->x) - x*radial->dx;
-        radial->fy = (inner->y) - x*radial->dy;
-        radial->m = 1./(1+x);
-        radial->b = -x*radial->m;
-        radial->dx /= 65536.;
-        radial->dy /= 65536.;
-        radial->fx /= 65536.;
-        radial->fy /= 65536.;
-        x = outerRadius/65536.;
-        radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy;
-    }
-#endif
     radial->c1.x = inner->x;
     radial->c1.y = inner->y;
     radial->c1.radius = innerRadius;
diff-tree 84838268b34661d598f8e4856fab355f414930d9 (from 38d14e858980a1b0c087344d24bf6aebf755663c)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Mon Apr 23 13:19:54 2007 -0400

    Gradient fixes
    
    * Port fix for bug 7685 from pixman. Patch by Carl Worth
    
    * Add projective version of radial gradient code.
    
    * Make sure that all Pict*Gradient types have PictGradient as prefix,
      since code in various places relies on that.

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 0faf783..24b552e 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -3148,13 +3148,128 @@ static void fbFetchSourcePict(PicturePtr
             }
         }
     } else {
+
+/*
+ * In the radial gradient problem we are given two circles (c₁,r₁) and
+ * (câ‚‚,râ‚‚) that define the gradient itself. Then, for any point p, we
+ * must compute the value(s) of t within [0.0, 1.0] representing the
+ * circle(s) that would color the point.
+ *
+ * There are potentially two values of t since the point p can be
+ * colored by both sides of the circle, (which happens whenever one
+ * circle is not entirely contained within the other).
+ *
+ * If we solve for a value of t that is outside of [0.0, 1.0] then we
+ * use the extend mode (NONE, REPEAT, REFLECT, or PAD) to map to a
+ * value within [0.0, 1.0].
+ *
+ * Here is an illustration of the problem:
+ *
+ *              pâ‚‚
+ *           p  •
+ *           •   ╲
+ *        ·       ╲r₂
+ *  p₁ ·           ╲
+ *  •              θ╲
+ *   ╲             ╌╌•
+ *    ╲r₁        ·   c₂
+ *    θ╲    ·
+ *    ╌╌•
+ *      c₁
+ *
+ * Given (c₁,r₁), (c₂,r₂) and p, we must find an angle θ such that two
+ * points p₁ and p₂ on the two circles are collinear with p. Then, the
+ * desired value of t is the ratio of the length of p₁p to the length
+ * of p₁p₂.
+ *
+ * So, we have six unknown values: (p₁x, p₁y), (p₂x, p₂y), θ and t.
+ * We can also write six equations that constrain the problem:
+ *
+ * Point p₁ is a distance r₁ from c₁ at an angle of θ:
+ *
+ *	1. p₁x = c₁x + r₁·cos θ
+ *	2. p₁y = c₁y + r₁·sin θ
+ *
+ * Point p₂ is a distance r₂ from c₂ at an angle of θ:
+ *
+ *	3. p₂x = c₂x + r2·cos θ
+ *	4. p₂y = c₂y + r2·sin θ
+ *
+ * Point p lies at a fraction t along the line segment p₁p₂:
+ *
+ *	5. px = t·p₂x + (1-t)·p₁x
+ *	6. py = t·p₂y + (1-t)·p₁y
+ *
+ * To solve, first subtitute 1-4 into 5 and 6:
+ *
+ * px = t·(c₂x + r₂·cos θ) + (1-t)·(c₁x + r₁·cos θ)
+ * py = t·(c₂y + r₂·sin θ) + (1-t)·(c₁y + r₁·sin θ)
+ *
+ * Then solve each for cos θ and sin θ expressed as a function of t:
+ *
+ * cos θ = (-(c₂x - c₁x)·t + (px - c₁x)) / ((r₂-r₁)·t + r₁)
+ * sin θ = (-(c₂y - c₁y)·t + (py - c₁y)) / ((r₂-r₁)·t + r₁)
+ *
+ * To simplify this a bit, we define new variables for several of the
+ * common terms as shown below:
+ *
+ *              pâ‚‚
+ *           p  •
+ *           •   ╲
+ *        ·  ┆    ╲r₂
+ *  p₁ ·     ┆     ╲
+ *  •     pdy┆      ╲
+ *   ╲       ┆       •c₂
+ *    ╲r₁    ┆   ·   ┆
+ *     ╲    ·┆       ┆cdy
+ *      •╌╌╌╌┴╌╌╌╌╌╌╌┘
+ *    c₁  pdx   cdx
+ *
+ * cdx = (c₂x - c₁x)
+ * cdy = (c₂y - c₁y)
+ *  dr =  r₂-r₁
+ * pdx =  px - c₁x
+ * pdy =  py - c₁y
+ *
+ * Note that cdx, cdy, and dr do not depend on point p at all, so can
+ * be pre-computed for the entire gradient. The simplifed equations
+ * are now:
+ *
+ * cos θ = (-cdx·t + pdx) / (dr·t + r₁)
+ * sin θ = (-cdy·t + pdy) / (dr·t + r₁)
+ *
+ * Finally, to get a single function of t and eliminate the last
+ * unknown θ, we use the identity sin²θ + cos²θ = 1. First, square
+ * each equation, (we knew a quadratic was coming since it must be
+ * possible to obtain two solutions in some cases):
+ *
+ * cos²θ = (cdx²t² - 2·cdx·pdx·t + pdx²) / (dr²·t² + 2·r₁·dr·t + r₁²)
+ * sin²θ = (cdy²t² - 2·cdy·pdy·t + pdy²) / (dr²·t² + 2·r₁·dr·t + r₁²)
+ *
+ * Then add both together, set the result equal to 1, and express as a
+ * standard quadratic equation in t of the form At² + Bt + C = 0
+ *
+ * (cdx² + cdy² - dr²)·t² - 2·(cdx·pdx + cdy·pdy + r₁·dr)·t + (pdx² + pdy² - r₁²) = 0
+ *
+ * In other words:
+ *
+ * A = cdx² + cdy² - dr²
+ * B = -2·(pdx·cdx + pdy·cdy + r₁·dr)
+ * C = pdx² + pdy² - r₁²
+ *
+ * And again, notice that A does not depend on p, so can be
+ * precomputed. From here we just use the quadratic formula to solve
+ * for t:
+ *
+ * t = (-2·B ± ⎷(B² - 4·A·C)) / 2·A
+ */
         /* radial or conical */
         Bool affine = TRUE;
         double cx = 1.;
         double cy = 0.;
         double cz = 0.;
-        double rx = x;
-        double ry = y;
+	double rx = x + 0.5;
+	double ry = y + 0.5;
         double rz = 1.;
 
         if (pict->transform) {
@@ -3176,25 +3291,38 @@ static void fbFetchSourcePict(PicturePtr
         }
 
         if (pGradient->type == SourcePictTypeRadial) {
+	    PictRadialGradient *radial;
+	    radial = &pGradient->radial;
             if (affine) {
-                rx -= pGradient->radial.fx;
-                ry -= pGradient->radial.fy;
-
                 while (buffer < end) {
-		    double b, c, det, s;
-		    
 		    if (!mask || *mask++ & maskBits)
 		    {
-			xFixed_48_16  t;
+			double pdx, pdy;
+			double B, C;
+			double det;
+			double c1x = radial->c1.x / 65536.0;
+			double c1y = radial->c1.y / 65536.0;
+			double r1  = radial->c1.radius / 65536.0;
+                        xFixed_48_16 t;
+
+			pdx = rx - c1x;
+			pdy = ry - c1y;
+
+			B = -2 * (  pdx * radial->cdx
+				  + pdy * radial->cdy
+				  + r1 * radial->dr);
+			C = (pdx * pdx + pdy * pdy - r1 * r1);
+
+                        det = (B * B) - (4 * radial->A * C);
+			if (det < 0.0)
+			    det = 0.0;
+
+			if (radial->A < 0)
+			    t = (xFixed_48_16) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
+			else
+			    t = (xFixed_48_16) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
 			
-			b = 2*(rx*pGradient->radial.dx + ry*pGradient->radial.dy);
-			c = -(rx*rx + ry*ry);
-			det = (b * b) - (4 * pGradient->radial.a * c);
-			s = (-b + sqrt(det))/(2. * pGradient->radial.a);
-			
-			t = (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536);
-			
-			WRITE(buffer, _gradient_walker_pixel (&walker, t));
+ 			WRITE(buffer, _gradient_walker_pixel (&walker, t));
 		    }
 		    ++buffer;
 		    
@@ -3202,35 +3330,50 @@ static void fbFetchSourcePict(PicturePtr
                     ry += cy;
                 }
             } else {
+		/* projective */
                 while (buffer < end) {
-                    double x, y;
-                    double b, c, det, s;
-
 		    if (!mask || *mask++ & maskBits)
 		    {
-			xFixed_48_16  t;
-			
+			double pdx, pdy;
+			double B, C;
+			double det;
+			double c1x = radial->c1.x / 65536.0;
+			double c1y = radial->c1.y / 65536.0;
+			double r1  = radial->c1.radius / 65536.0;
+                        xFixed_48_16 t;
+			double x, y;
+
 			if (rz != 0) {
 			    x = rx/rz;
 			    y = ry/rz;
 			} else {
 			    x = y = 0.;
 			}
-			x -= pGradient->radial.fx;
-			y -= pGradient->radial.fy;
-			b = 2*(x*pGradient->radial.dx + y*pGradient->radial.dy);
-			c = -(x*x + y*y);
-			det = (b * b) - (4 * pGradient->radial.a * c);
-			s = (-b + sqrt(det))/(2. * pGradient->radial.a);
-			t = (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536);
 			
-			WRITE(buffer, _gradient_walker_pixel (&walker, t));
+			pdx = x - c1x;
+			pdy = y - c1y;
+
+			B = -2 * (  pdx * radial->cdx
+				  + pdy * radial->cdy
+				  + r1 * radial->dr);
+			C = (pdx * pdx + pdy * pdy - r1 * r1);
+
+                        det = (B * B) - (4 * radial->A * C);
+			if (det < 0.0)
+			    det = 0.0;
+
+			if (radial->A < 0)
+			    t = (xFixed_48_16) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
+			else
+			    t = (xFixed_48_16) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
+			
+ 			WRITE(buffer, _gradient_walker_pixel (&walker, t));
 		    }
 		    ++buffer;
 		    
                     rx += cx;
                     ry += cy;
-                    rz += cz;
+		    rz += cz;
                 }
             }
         } else /* SourcePictTypeConical */ {
diff --git a/render/picture.c b/render/picture.c
index 3f64182..201ceb2 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -1051,6 +1051,7 @@ CreateRadialGradientPicture (Picture pid
     radial = &pPicture->pSourcePict->radial;
 
     radial->type = SourcePictTypeRadial;
+#if 0
     {
         double x = (double)innerRadius / (double)outerRadius;
         radial->dx = (outer->x - inner->x);
@@ -1066,7 +1067,20 @@ CreateRadialGradientPicture (Picture pid
         x = outerRadius/65536.;
         radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy;
     }
-
+#endif
+    radial->c1.x = inner->x;
+    radial->c1.y = inner->y;
+    radial->c1.radius = innerRadius;
+    radial->c2.x = outer->x;
+    radial->c2.y = outer->y;
+    radial->c2.radius = outerRadius;
+    radial->cdx = (radial->c2.x - radial->c1.x) / 65536.;
+    radial->cdy = (radial->c2.y - radial->c1.y) / 65536.;
+    radial->dr = (radial->c2.radius - radial->c1.radius) / 65536.;
+    radial->A = (  radial->cdx * radial->cdx
+		   + radial->cdy * radial->cdy
+		   - radial->dr  * radial->dr);
+    
     initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
     if (*error) {
         xfree(pPicture);
diff --git a/render/picturestr.h b/render/picturestr.h
index 3f3c600..6268768 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -105,17 +105,26 @@ typedef struct _PictLinearGradient {
     xPointFixed p2;
 } PictLinearGradient, *PictLinearGradientPtr;
 
+typedef struct _PictCircle {
+    xFixed x;
+    xFixed y;
+    xFixed radius;
+} PictCircle, *PictCirclePtr;
+
 typedef struct _PictRadialGradient {
     unsigned int type;
+    unsigned int class;
     int nstops;
     PictGradientStopPtr stops;
-    double fx;
-    double fy;
-    double dx;
-    double dy;
-    double a;
-    double m;
-    double b;
+    int stopRange;
+    CARD32 *colorTable;
+    int colorTableSize;
+    PictCircle c1;
+    PictCircle c2;
+    double cdx;
+    double cdy;
+    double dr;
+    double A;
 } PictRadialGradient, *PictRadialGradientPtr;
 
 typedef struct _PictConicalGradient {
diff-tree 38d14e858980a1b0c087344d24bf6aebf755663c (from ca784df84e07227a4cc0a1add079884f557b7a00)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Sun Apr 22 18:04:27 2007 -0700

    Adjust the screen pixmap's dimensions in xf86RandR12ScreenSetSize.

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 90de585..db91274 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -337,6 +337,7 @@ xf86RandR12ScreenSetSize (ScreenPtr	pScr
     ScrnInfoPtr		pScrn = XF86SCRNINFO(pScreen);
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(pScrn);
     WindowPtr		pRoot = WindowTable[pScreen->myNum];
+    PixmapPtr		pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
     Bool		ret = FALSE;
 
     if (randrp->virtualX == -1 || randrp->virtualY == -1)
@@ -353,8 +354,8 @@ xf86RandR12ScreenSetSize (ScreenPtr	pScr
 
     ret = TRUE;
 
-    pScreen->width = width;
-    pScreen->height = height;
+    pScreen->width = pScrnPix->drawable.width = width;
+    pScreen->height = pScrnPix->drawable.height = height;
     pScreen->mmWidth = mmWidth;
     pScreen->mmHeight = mmHeight;
 
diff-tree ca784df84e07227a4cc0a1add079884f557b7a00 (from 55bd8668e7d4100579bcd6c16a804d9f25267070)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Sun Apr 22 16:26:01 2007 -0700

    Fix unbalanced fbGetDrawable added in commit 0a9239ec.

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 8b5700b..0faf783 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -4146,6 +4146,9 @@ fbCompositeRect (const FbComposeData *da
 	    }
 	}
     }
+
+    if (!store)
+	fbFinishAccess (data->dest->pDrawable);
 }
 
 void
diff-tree 55bd8668e7d4100579bcd6c16a804d9f25267070 (from 41dd7ab067adde8f66cd9f74c5a6570c325518a5)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 20 14:53:37 2007 -0400

    Remove #if 0'ed leftovers from merge

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 6b366f7..8b5700b 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -3019,10 +3019,6 @@ _gradient_walker_pixel (GradientWalker  
 
 static void fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
 {
-#if 0
-    SourcePictPtr pGradient = pict->pSourcePict;
-    CARD32 *end = buffer + width;
-#endif
      SourcePictPtr   pGradient = pict->pSourcePict;
      GradientWalker  walker;
      CARD32         *end = buffer + width;
diff-tree 41dd7ab067adde8f66cd9f74c5a6570c325518a5 (from c1b73f0f2acd56b423b91a04f1e1b3cdcad0069f)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 20 14:51:40 2007 -0400

     Fix gradient walker to not reset needlessly
    
        Previously the gradient walker was doing excessive resets, (such
        as on every pixel in constant-colored regions or outside the
        gradient with CAIRO_EXTEND_NONE). Don't do that.
    
        Carl Worth, from pixman

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 365a85f..6b366f7 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -2803,12 +2803,13 @@ typedef struct
     CARD32        right_rb;
     int32_t       left_x;
     int32_t       right_x;
-    int32_t       width_x;
     int32_t       stepper;
     
     PictGradientStopPtr      stops;
     int                      num_stops;
     unsigned int             spread;
+
+    int		  need_reset;
 } GradientWalker;
 
 static void
@@ -2820,13 +2821,14 @@ _gradient_walker_init (GradientWalker  *
     walker->stops     = pGradient->gradient.stops;
     walker->left_x    = 0;
     walker->right_x   = 0x10000;
-    walker->width_x   = 0;  /* will force a reset */
     walker->stepper   = 0;
     walker->left_ag   = 0;
     walker->left_rb   = 0;
     walker->right_ag  = 0;
     walker->right_rb  = 0;
     walker->spread    = spread;
+
+    walker->need_reset = TRUE;
 }
 
 static void
@@ -2958,27 +2960,29 @@ _gradient_walker_reset (GradientWalker  
     
     walker->left_x   = left_x;
     walker->right_x  = right_x;
-    walker->width_x  = right_x - left_x;
     walker->left_ag  = ((left_c->alpha >> 8) << 16)   | (left_c->green >> 8);
     walker->left_rb  = ((left_c->red & 0xff00) << 8)  | (left_c->blue >> 8);
     walker->right_ag = ((right_c->alpha >> 8) << 16)  | (right_c->green >> 8);
     walker->right_rb = ((right_c->red & 0xff00) << 8) | (right_c->blue >> 8);
     
-    if ( walker->width_x == 0                      ||
+    if ( walker->left_x == walker->right_x                ||
 	 ( walker->left_ag == walker->right_ag &&
 	   walker->left_rb == walker->right_rb )   )
     {
-	walker->width_x = 1;
 	walker->stepper = 0;
     }
     else
     {
-	walker->stepper = ((1 << 24) + walker->width_x/2)/walker->width_x;
+	int32_t width = right_x - left_x;
+	walker->stepper = ((1 << 24) + width/2)/width;
     }
+
+    walker->need_reset = FALSE;
 }
 
 #define  GRADIENT_WALKER_NEED_RESET(w,x)				\
-    ( (x) < (w)->left_x || (x) - (w)->left_x >= (w)->width_x )
+    ( (w)->need_reset || (x) < (w)->left_x || (x) >= (w)->right_x)
+
 
 /* the following assumes that GRADIENT_WALKER_NEED_RESET(w,x) is FALSE */
 static CARD32
diff-tree c1b73f0f2acd56b423b91a04f1e1b3cdcad0069f (from 38f718799c68995c2d9a1680355bd55fd925009e)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 20 14:34:13 2007 -0400

    Fixing gradient repeat mode computations in previous patch. From David
    
    Turner.

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 5ddff23..365a85f 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -2916,13 +2916,15 @@ _gradient_walker_reset (GradientWalker  
 	    xRenderColor  *tmp_c;
 	    int32_t          tmp_x;
 	    
-	    tmp_x   = 0x20000 - right_x;
-	    right_x = 0x20000 - left_x;
+	    tmp_x   = 0x10000 - right_x;
+	    right_x = 0x10000 - left_x;
 	    left_x  = tmp_x;
 	    
 	    tmp_c   = right_c;
 	    right_c = left_c;
 	    left_c  = tmp_c;
+
+	    x = 0x10000 - x;
 	}
 	left_x  += (pos - x);
 	right_x += (pos - x);
@@ -3074,14 +3076,14 @@ static void fbFetchSourcePict(PicturePtr
 
 		color = _gradient_walker_pixel( &walker, t );
 		while (buffer < end)
-		    *buffer++ = color;
+		    WRITE(buffer++, color);
 	    }
 	    else
 	    {
                 if (!mask) {
                     while (buffer < end)
                     {
-                        *buffer = _gradient_walker_pixel (&walker, t);
+                        WRITE(buffer, _gradient_walker_pixel (&walker, t));
                         buffer += 1;
                         t      += inc;
                     }
@@ -3089,7 +3091,7 @@ static void fbFetchSourcePict(PicturePtr
                     while (buffer < end) {
                         if (*mask++ & maskBits)
                         {
-                            *buffer = _gradient_walker_pixel (&walker, t);
+                            WRITE(buffer, _gradient_walker_pixel (&walker, t));
                         }
                         buffer += 1;
                         t      += inc;
@@ -3118,12 +3120,9 @@ static void fbFetchSourcePict(PicturePtr
 		    t = ((a * x + b * y) >> 16) + off;
 		}
 
-#if 0
-		color = gradientPixel (pGradient, t, pict->repeat);
-#endif
  		color = _gradient_walker_pixel( &walker, t );
 		while (buffer < end)
-		    *buffer++ = color;
+		    WRITE(buffer++, color);
 	    }
 	    else
 	    {
@@ -3139,7 +3138,7 @@ static void fbFetchSourcePict(PicturePtr
 			    y = ((xFixed_48_16)v.vector[1] << 16) / v.vector[2];
 			    t = ((a*x + b*y) >> 16) + off;
 			}
-			*buffer = _gradient_walker_pixel (&walker, t);
+			WRITE(buffer, _gradient_walker_pixel (&walker, t));
 		    }
 		    ++buffer;
 		    v.vector[0] += unit.vector[0];
@@ -3195,7 +3194,7 @@ static void fbFetchSourcePict(PicturePtr
 			
 			t = (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536);
 			
-			*buffer = _gradient_walker_pixel (&walker, t);
+			WRITE(buffer, _gradient_walker_pixel (&walker, t));
 		    }
 		    ++buffer;
 		    
@@ -3225,7 +3224,7 @@ static void fbFetchSourcePict(PicturePtr
 			s = (-b + sqrt(det))/(2. * pGradient->radial.a);
 			t = (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536);
 			
-			*buffer = _gradient_walker_pixel (&walker, t);
+			WRITE(buffer, _gradient_walker_pixel (&walker, t));
 		    }
 		    ++buffer;
 		    
@@ -3250,7 +3249,7 @@ static void fbFetchSourcePict(PicturePtr
                         angle = atan2(ry, rx) + a;
 			t     = (xFixed_48_16) (angle * (65536. / (2*M_PI)));
 			
-			*buffer = _gradient_walker_pixel (&walker, t);
+			WRITE(buffer, _gradient_walker_pixel (&walker, t));
 		    }
 
                     ++buffer;
@@ -3277,7 +3276,7 @@ static void fbFetchSourcePict(PicturePtr
 			angle = atan2(y, x) + a;
 			t     = (xFixed_48_16) (angle * (65536. / (2*M_PI)));
 			
-			*buffer = _gradient_walker_pixel (&walker, t);
+			WRITE(buffer, _gradient_walker_pixel (&walker, t));
 		    }
 		    
                     ++buffer;
@@ -3342,7 +3341,7 @@ static void fbFetchTransformed(PicturePt
 		    if (!mask || mask[i] & maskBits)
 		    {
 			if (!v.vector[2]) {
-			    buffer[i] = 0;
+			    WRITE(buffer + i, 0);
 			} else {
 			    if (!affine) {
 				y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
@@ -3351,7 +3350,7 @@ static void fbFetchTransformed(PicturePt
 				y = MOD(v.vector[1]>>16, pict->pDrawable->height);
 				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
 			    }
-			    buffer[i] = fetch(bits + (y + dy)*stride, x + dx, indexed);
+			    WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
 			}
 		    }
 
@@ -3364,7 +3363,7 @@ static void fbFetchTransformed(PicturePt
 		    if (!mask || mask[i] & maskBits)
 		    {
 			if (!v.vector[2]) {
-			    buffer[i] = 0;
+			    WRITE(buffer + i, 0);
 			} else {
 			    if (!affine) {
 				y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
@@ -3374,9 +3373,9 @@ static void fbFetchTransformed(PicturePt
 				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
 			    }
 			    if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
-				buffer[i] = fetch(bits + (y + dy)*stride, x + dx, indexed);
+				WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
 			    else
-				buffer[i] = 0;
+				WRITE(buffer + i, 0);
 			}
 		    }
 
diff-tree 38f718799c68995c2d9a1680355bd55fd925009e (from 9c4b14d4f6a1fe018acd64789434216cd1560a4a)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 20 13:59:11 2007 -0400

    Remove a few memory references in fbFetchTransformed

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 9b5af8e..5ddff23 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -3351,7 +3351,7 @@ static void fbFetchTransformed(PicturePt
 				y = MOD(v.vector[1]>>16, pict->pDrawable->height);
 				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
 			    }
-			    buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+			    buffer[i] = fetch(bits + (y + dy)*stride, x + dx, indexed);
 			}
 		    }
 
@@ -3374,7 +3374,7 @@ static void fbFetchTransformed(PicturePt
 				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
 			    }
 			    if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
-				buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+				buffer[i] = fetch(bits + (y + dy)*stride, x + dx, indexed);
 			    else
 				buffer[i] = 0;
 			}
diff-tree 9c4b14d4f6a1fe018acd64789434216cd1560a4a (from cd2c1714eb4946bf7b1fc194fe074f8024a2ec23)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 20 13:23:58 2007 -0400

    Integrate David Turner's gradient optimizations from pixman

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index de3a371..9b5af8e 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -2795,79 +2795,234 @@ static void fbFetch(PicturePtr pict, int
 #define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :		\
 		  ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
 
-static CARD32
-xRenderColorMultToCard32 (xRenderColor *c)
+typedef struct
 {
-    return
-	((((CARD32) c->red   * c->alpha) >> 24) << 16) |
-	((((CARD32) c->green * c->alpha) >> 24) <<  8) |
-	((((CARD32) c->blue  * c->alpha) >> 24) <<  0) |
-	((((CARD32) c->alpha		 ) >> 8)  << 24);
-}
+    CARD32        left_ag;
+    CARD32        left_rb;
+    CARD32        right_ag;
+    CARD32        right_rb;
+    int32_t       left_x;
+    int32_t       right_x;
+    int32_t       width_x;
+    int32_t       stepper;
+    
+    PictGradientStopPtr      stops;
+    int                      num_stops;
+    unsigned int             spread;
+} GradientWalker;
 
-static CARD32 gradientPixel(const SourcePictPtr pGradient, xFixed_48_16 pos, unsigned int spread)
+static void
+_gradient_walker_init (GradientWalker  *walker,
+		       SourcePictPtr    pGradient,
+		       unsigned int     spread)
 {
-    int ipos = (pos * pGradient->gradient.stopRange - 1) >> 16;
+    walker->num_stops = pGradient->gradient.nstops;
+    walker->stops     = pGradient->gradient.stops;
+    walker->left_x    = 0;
+    walker->right_x   = 0x10000;
+    walker->width_x   = 0;  /* will force a reset */
+    walker->stepper   = 0;
+    walker->left_ag   = 0;
+    walker->left_rb   = 0;
+    walker->right_ag  = 0;
+    walker->right_rb  = 0;
+    walker->spread    = spread;
+}
 
-    /* calculate the actual offset. */
-    if (ipos < 0 || ipos >= pGradient->gradient.stopRange)
+static void
+_gradient_walker_reset (GradientWalker  *walker,
+                        xFixed_32_32     pos)
+{
+    int32_t                  x, left_x, right_x;
+    xRenderColor          *left_c, *right_c;
+    int                      n, count = walker->num_stops;
+    PictGradientStopPtr      stops = walker->stops;
+    
+    static const xRenderColor   transparent_black = { 0, 0, 0, 0 };
+    
+    switch (walker->spread)
     {
-	if (pGradient->type == SourcePictTypeConical || spread == RepeatNormal)
-	{
-	    ipos = ipos % pGradient->gradient.stopRange;
-	    ipos = ipos < 0 ? pGradient->gradient.stopRange + ipos : ipos;
-
+    case RepeatNormal:
+	x = (int32_t)pos & 0xFFFF;
+	for (n = 0; n < count; n++)
+	    if (x < stops[n].x)
+		break;
+	if (n == 0) {
+	    left_x =  stops[count-1].x - 0x10000;
+	    left_c = &stops[count-1].color;
+	} else {
+	    left_x =  stops[n-1].x;
+	    left_c = &stops[n-1].color;
+	}
+	
+	if (n == count) {
+	    right_x =  stops[0].x + 0x10000;
+	    right_c = &stops[0].color;
+	} else {
+	    right_x =  stops[n].x;
+	    right_c = &stops[n].color;
+	}
+	left_x  += (pos - x);
+	right_x += (pos - x);
+	break;
+	
+    case RepeatPad:
+	for (n = 0; n < count; n++)
+	    if (pos < stops[n].x)
+		break;
+	
+	if (n == 0) {
+	    left_x =  INT_MIN;
+	    left_c = &stops[0].color;
+	} else {
+	    left_x =  stops[n-1].x;
+	    left_c = &stops[n-1].color;
 	}
-	else if (spread == RepeatReflect)
+	
+	if (n == count) {
+	    right_x =  INT_MAX;
+	    right_c = &stops[n-1].color;
+	} else {
+	    right_x =  stops[n].x;
+	    right_c = &stops[n].color;
+	}
+	break;
+	
+    case RepeatReflect:
+	x = (int32_t)pos & 0xFFFF;
+	if ((int32_t)pos & 0x10000)
+	    x = 0x10000 - x;
+	for (n = 0; n < count; n++)
+	    if (x < stops[n].x)
+		break;
+	
+	if (n == 0) {
+	    left_x =  -stops[0].x;
+	    left_c = &stops[0].color;
+	} else {
+	    left_x =  stops[n-1].x;
+	    left_c = &stops[n-1].color;
+	}
+	
+	if (n == count) {
+	    right_x = 0x20000 - stops[n-1].x;
+	    right_c = &stops[n-1].color;
+	} else {
+	    right_x =  stops[n].x;
+	    right_c = &stops[n].color;
+	}
+	
+	if ((int32_t)pos & 0x10000) {
+	    xRenderColor  *tmp_c;
+	    int32_t          tmp_x;
+	    
+	    tmp_x   = 0x20000 - right_x;
+	    right_x = 0x20000 - left_x;
+	    left_x  = tmp_x;
+	    
+	    tmp_c   = right_c;
+	    right_c = left_c;
+	    left_c  = tmp_c;
+	}
+	left_x  += (pos - x);
+	right_x += (pos - x);
+	break;
+	
+    default:  /* RepeatNone */
+	for (n = 0; n < count; n++)
+	    if (pos < stops[n].x)
+		break;
+	
+	if (n == 0)
 	{
-	    const int limit = pGradient->gradient.stopRange * 2 - 1;
-
-	    ipos = ipos % limit;
-	    ipos = ipos < 0 ? limit + ipos : ipos;
-	    ipos = ipos >= pGradient->gradient.stopRange ? limit - ipos : ipos;
-
+	    left_x  =  INT_MIN;
+	    right_x =  stops[0].x;
+	    left_c  = right_c = (xRenderColor*) &transparent_black;
 	}
-	else if (spread == RepeatPad)
+	else if (n == count)
 	{
-	    if (ipos < 0)
-		ipos = 0;
-	    else
-		ipos = pGradient->gradient.stopRange - 1;
+	    left_x  = stops[n-1].x;
+	    right_x = INT_MAX;
+	    left_c  = right_c = (xRenderColor*) &transparent_black;
 	}
-	else  /* RepeatNone */
+	else
 	{
-	    return 0;
+	    left_x  =  stops[n-1].x;
+	    right_x =  stops[n].x;
+	    left_c  = &stops[n-1].color;
+	    right_c = &stops[n].color;
 	}
     }
-
-    if (pGradient->gradient.colorTableSize)
+    
+    walker->left_x   = left_x;
+    walker->right_x  = right_x;
+    walker->width_x  = right_x - left_x;
+    walker->left_ag  = ((left_c->alpha >> 8) << 16)   | (left_c->green >> 8);
+    walker->left_rb  = ((left_c->red & 0xff00) << 8)  | (left_c->blue >> 8);
+    walker->right_ag = ((right_c->alpha >> 8) << 16)  | (right_c->green >> 8);
+    walker->right_rb = ((right_c->red & 0xff00) << 8) | (right_c->blue >> 8);
+    
+    if ( walker->width_x == 0                      ||
+	 ( walker->left_ag == walker->right_ag &&
+	   walker->left_rb == walker->right_rb )   )
     {
-	return pGradient->gradient.colorTable[ipos];
+	walker->width_x = 1;
+	walker->stepper = 0;
     }
     else
     {
-	int i;
-
-	if (ipos <= pGradient->gradient.stops->x)
-	    return xRenderColorMultToCard32 (&pGradient->gradient.stops->color);
+	walker->stepper = ((1 << 24) + walker->width_x/2)/walker->width_x;
+    }
+}
 
-	for (i = 1; i < pGradient->gradient.nstops; i++)
-	{
-	    if (pGradient->gradient.stops[i].x >= ipos)
-		return PictureGradientColor (&pGradient->gradient.stops[i - 1],
-					     &pGradient->gradient.stops[i],
-					     ipos);
-	}
+#define  GRADIENT_WALKER_NEED_RESET(w,x)				\
+    ( (x) < (w)->left_x || (x) - (w)->left_x >= (w)->width_x )
 
-	return xRenderColorMultToCard32 (&pGradient->gradient.stops[--i].color);
-    }
+/* the following assumes that GRADIENT_WALKER_NEED_RESET(w,x) is FALSE */
+static CARD32
+_gradient_walker_pixel (GradientWalker  *walker,
+                        xFixed_32_32     x)
+{
+    int  dist, idist;
+    CARD32  t1, t2, a, color;
+    
+    if (GRADIENT_WALKER_NEED_RESET (walker, x))
+        _gradient_walker_reset (walker, x);
+    
+    dist  = ((int)(x - walker->left_x)*walker->stepper) >> 16;
+    idist = 256 - dist;
+    
+    /* combined INTERPOLATE and premultiply */
+    t1 = walker->left_rb*idist + walker->right_rb*dist;
+    t1 = (t1 >> 8) & 0xff00ff;
+    
+    t2  = walker->left_ag*idist + walker->right_ag*dist;
+    t2 &= 0xff00ff00;
+    
+    color = t2 & 0xff000000;
+    a     = t2 >> 24;
+    
+    t1  = t1*a + 0x800080;
+    t1  = (t1 + ((t1 >> 8) & 0xff00ff)) >> 8;
+    
+    t2  = (t2 >> 8)*a + 0x800080;
+    t2  = (t2 + ((t2 >> 8) & 0xff00ff));
+    
+    return (color | (t1 & 0xff00ff) | (t2 & 0xff00));
 }
 
 static void fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
 {
+#if 0
     SourcePictPtr pGradient = pict->pSourcePict;
     CARD32 *end = buffer + width;
-
+#endif
+     SourcePictPtr   pGradient = pict->pSourcePict;
+     GradientWalker  walker;
+     CARD32         *end = buffer + width;
+ 
+     _gradient_walker_init (&walker, pGradient, pict->repeat);
+    
     if (pGradient->type == SourcePictTypeSolidFill) {
         register CARD32 color = pGradient->solidFill.color;
         while (buffer < end) {
@@ -2877,7 +3032,7 @@ static void fbFetchSourcePict(PicturePtr
         PictVector v, unit;
         xFixed_32_32 l;
         xFixed_48_16 dx, dy, a, b, off;
-
+	
         /* reference point is the center of the pixel */
         v.vector[0] = IntToxFixed(x) + xFixed1/2;
         v.vector[1] = IntToxFixed(y) + xFixed1/2;
@@ -2917,20 +3072,29 @@ static void fbFetchSourcePict(PicturePtr
 	    {
 		register CARD32 color;
 
-		color = gradientPixel (pGradient, t, pict->repeat);
+		color = _gradient_walker_pixel( &walker, t );
 		while (buffer < end)
 		    *buffer++ = color;
 	    }
 	    else
 	    {
-		while (buffer < end) {
-		    if (!mask || *mask++ & maskBits)
-		    {
-			*buffer = gradientPixel (pGradient, t, pict->repeat);
-		    }
-		    ++buffer;
-		    t += inc;
-		}
+                if (!mask) {
+                    while (buffer < end)
+                    {
+                        *buffer = _gradient_walker_pixel (&walker, t);
+                        buffer += 1;
+                        t      += inc;
+                    }
+                } else {
+                    while (buffer < end) {
+                        if (*mask++ & maskBits)
+                        {
+                            *buffer = _gradient_walker_pixel (&walker, t);
+                        }
+                        buffer += 1;
+                        t      += inc;
+                    }
+                }
 	    }
 	}
 	else /* projective transformation */
@@ -2954,7 +3118,10 @@ static void fbFetchSourcePict(PicturePtr
 		    t = ((a * x + b * y) >> 16) + off;
 		}
 
+#if 0
 		color = gradientPixel (pGradient, t, pict->repeat);
+#endif
+ 		color = _gradient_walker_pixel( &walker, t );
 		while (buffer < end)
 		    *buffer++ = color;
 	    }
@@ -2972,7 +3139,7 @@ static void fbFetchSourcePict(PicturePtr
 			    y = ((xFixed_48_16)v.vector[1] << 16) / v.vector[2];
 			    t = ((a*x + b*y) >> 16) + off;
 			}
-			*buffer = gradientPixel(pGradient, t, pict->repeat);
+			*buffer = _gradient_walker_pixel (&walker, t);
 		    }
 		    ++buffer;
 		    v.vector[0] += unit.vector[0];
@@ -3016,19 +3183,22 @@ static void fbFetchSourcePict(PicturePtr
 
                 while (buffer < end) {
 		    double b, c, det, s;
-
+		    
 		    if (!mask || *mask++ & maskBits)
 		    {
+			xFixed_48_16  t;
+			
 			b = 2*(rx*pGradient->radial.dx + ry*pGradient->radial.dy);
 			c = -(rx*rx + ry*ry);
 			det = (b * b) - (4 * pGradient->radial.a * c);
 			s = (-b + sqrt(det))/(2. * pGradient->radial.a);
-			WRITE(buffer, gradientPixel(pGradient,
-						    (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
-						    pict->repeatType));
+			
+			t = (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536);
+			
+			*buffer = _gradient_walker_pixel (&walker, t);
 		    }
 		    ++buffer;
-
+		    
                     rx += cx;
                     ry += cy;
                 }
@@ -3039,6 +3209,8 @@ static void fbFetchSourcePict(PicturePtr
 
 		    if (!mask || *mask++ & maskBits)
 		    {
+			xFixed_48_16  t;
+			
 			if (rz != 0) {
 			    x = rx/rz;
 			    y = ry/rz;
@@ -3051,12 +3223,12 @@ static void fbFetchSourcePict(PicturePtr
 			c = -(x*x + y*y);
 			det = (b * b) - (4 * pGradient->radial.a * c);
 			s = (-b + sqrt(det))/(2. * pGradient->radial.a);
-			*buffer = gradientPixel(pGradient,
-						(xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
-						pict->repeat);
+			t = (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536);
+			
+			*buffer = _gradient_walker_pixel (&walker, t);
 		    }
 		    ++buffer;
-
+		    
                     rx += cx;
                     ry += cy;
                     rz += cz;
@@ -3071,12 +3243,14 @@ static void fbFetchSourcePict(PicturePtr
                 while (buffer < end) {
 		    double angle;
 
-		    if (!mask || *mask++ & maskBits)
+                    if (!mask || *mask++ & maskBits)
 		    {
-			angle = atan2(ry, rx) + a;
-
-			*buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
-						pict->repeat);
+                        xFixed_48_16   t;
+			
+                        angle = atan2(ry, rx) + a;
+			t     = (xFixed_48_16) (angle * (65536. / (2*M_PI)));
+			
+			*buffer = _gradient_walker_pixel (&walker, t);
 		    }
 
                     ++buffer;
@@ -3085,9 +3259,13 @@ static void fbFetchSourcePict(PicturePtr
                 }
             } else {
                 while (buffer < end) {
-                    double x, y, angle;
-		    if (!mask || *mask++ & maskBits)
-		    {
+                    double x, y;
+                    double angle;
+		    
+                    if (!mask || *mask++ & maskBits)
+                    {
+			xFixed_48_16  t;
+			
 			if (rz != 0) {
 			    x = rx/rz;
 			    y = ry/rz;
@@ -3097,9 +3275,11 @@ static void fbFetchSourcePict(PicturePtr
 			x -= pGradient->conical.center.x/65536.;
 			y -= pGradient->conical.center.y/65536.;
 			angle = atan2(y, x) + a;
-			*buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
-						pict->repeat);
+			t     = (xFixed_48_16) (angle * (65536. / (2*M_PI)));
+			
+			*buffer = _gradient_walker_pixel (&walker, t);
 		    }
+		    
                     ++buffer;
                     rx += cx;
                     ry += cy;
diff-tree cd2c1714eb4946bf7b1fc194fe074f8024a2ec23 (from 67545333ec0b08db783e94e9e3ec55873dea19a3)
Author: Brian <brian at yutani.localnet.net>
Date:   Sat Apr 21 12:40:51 2007 -0600

    add slang_mem.c

diff --git a/GL/mesa/shader/slang/Makefile.am b/GL/mesa/shader/slang/Makefile.am
index 7f0cd64..71498ee 100644
--- a/GL/mesa/shader/slang/Makefile.am
+++ b/GL/mesa/shader/slang/Makefile.am
@@ -31,6 +31,7 @@ nodist_libslang_la_SOURCES = slang_built
 		      slang_library_noise.c \
 		      slang_link.c \
 		      slang_log.c \
+		      slang_mem.c \
 		      slang_preprocess.c \
 		      slang_print.c \
 		      slang_simplify.c \
diff-tree 67545333ec0b08db783e94e9e3ec55873dea19a3 (from 39bc8bb0fdc854dcf9bbc0857fec84d50fa4f3b2)
Author: Brian <brian at yutani.localnet.net>
Date:   Sat Apr 21 12:40:33 2007 -0600

    replace occlude.c w/ queryobj.c

diff --git a/GL/mesa/main/Makefile.am b/GL/mesa/main/Makefile.am
index 2b838e9..f8ce137 100644
--- a/GL/mesa/main/Makefile.am
+++ b/GL/mesa/main/Makefile.am
@@ -61,10 +61,10 @@ nodist_libmain_la_SOURCES = accum.c \
                     matrix.c \
                     mipmap.c \
                     mm.c \
-                    occlude.c \
                     pixel.c \
                     points.c \
                     polygon.c \
+		    queryobj.c \
                     rastpos.c \
                     rbadaptors.c \
                     renderbuffer.c \
diff-tree 39bc8bb0fdc854dcf9bbc0857fec84d50fa4f3b2 (from 3daa5c1a991d659b1386a09e33b044470d489cb3)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Fri Apr 20 14:22:42 2007 -0700

    Don't call xf86RandR12TellChanged if it doesn't exist. Add some exports to xf86Rename.h.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index ad0f5ff..00ec56c 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1903,7 +1903,9 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, Di
 	}
     }
     xf86DisableUnusedFunctions(pScrn);
+#if RANDR_12_INTERFACE
     xf86RandR12TellChanged (pScrn->pScreen);
+#endif
     return ok;
 }
 
diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h
index 9dcfef5..b8c1d70 100644
--- a/hw/xfree86/modes/xf86Rename.h
+++ b/hw/xfree86/modes/xf86Rename.h
@@ -25,6 +25,12 @@
 
 #include "local_xf86Rename.h"
 
+#define xf86_cursors_fini XF86NAME(xf86_cursors_fini)
+#define xf86_cursors_init XF86NAME(xf86_cursors_init)
+#define xf86_hide_cursors XF86NAME(xf86_hide_cursors)
+#define xf86_reload_cursors XF86NAME(xf86_reload_cursors)
+#define xf86_show_cursors XF86NAME(xf86_show_cursors)
+#define xf86ConnectorGetName XF86NAME(xf86ConnectorGetName)
 #define xf86CrtcConfigInit XF86NAME(xf86CrtcConfigInit)
 #define xf86CrtcConfigPrivateIndex XF86NAME(xf86CrtcConfigPrivateIndex)
 #define xf86CrtcCreate XF86NAME(xf86CrtcCreate)
@@ -35,6 +41,7 @@
 #define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode)
 #define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange)
 #define xf86CVTMode XF86NAME(xf86CVTMode)
+#define xf86DDCMonitorSet XF86NAME(xf86DDCMonitorSet)
 #define xf86DisableUnusedFunctions XF86NAME(xf86DisableUnusedFunctions)
 #define xf86DPMSSet XF86NAME(xf86DPMSSet)
 #define xf86DuplicateMode XF86NAME(xf86DuplicateMode)
@@ -52,9 +59,11 @@
 #define xf86OutputGetEDIDModes XF86NAME(xf86OutputGetEDIDModes)
 #define xf86OutputRename XF86NAME(xf86OutputRename)
 #define xf86OutputSetEDID XF86NAME(xf86OutputSetEDID)
+#define xf86OutputUseScreenMonitor XF86NAME(xf86OutputUseScreenMonitor)
 #define xf86PrintModeline XF86NAME(xf86PrintModeline)
 #define xf86ProbeOutputModes XF86NAME(xf86ProbeOutputModes)
 #define xf86PruneInvalidModes XF86NAME(xf86PruneInvalidModes)
+#define xf86RotateCloseScreen XF86NAME(xf86RotateCloseScreen)
 #define xf86SetModeCrtc XF86NAME(xf86SetModeCrtc)
 #define xf86SetModeDefaultName XF86NAME(xf86SetModeDefaultName)
 #define xf86SetScrnInfoModes XF86NAME(xf86SetScrnInfoModes)
diff-tree 3daa5c1a991d659b1386a09e33b044470d489cb3 (from 9c2e955f6792e80fb84f848ed9e6ebbfd79f7130)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Fri Apr 20 09:43:16 2007 -0400

    Fix pixman bug 5777, patch by David Reveman

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 3043637..de3a371 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -2064,114 +2064,116 @@ static CombineFuncU fbCombineFuncU[] = {
     fbCombineConjointXorU,
 };
 
-static FASTCALL void
-fbCombineMaskC (CARD32 *src, CARD32 *mask, int width)
+static INLINE void
+fbCombineMaskC (CARD32 *src, CARD32 *mask)
 {
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 a = READ(mask + i);
+    CARD32 a = *mask;
 
-        CARD32	x;
-        CARD16	xa;
-
-        if (!a)
-        {
-            WRITE(src + i, 0);
-            continue;
-        }
+    CARD32	x;
+    CARD16	xa;
 
-        x = READ(src + i);
-        if (a == 0xffffffff)
-        {
-            x = x >> 24;
-            x |= x << 8;
-            x |= x << 16;
-            WRITE(mask + i, x);
-            continue;
-        }
+    if (!a)
+    {
+	WRITE(src, 0);
+	return;
+    }
 
-        xa = x >> 24;
-        FbByteMulC(x, a);
-        WRITE(src + i, x);
-        FbByteMul(a, xa);
-        WRITE(mask + i, a);
+    x = READ(src);
+    if (a == 0xffffffff)
+    {
+	x = x >> 24;
+	x |= x << 8;
+	x |= x << 16;
+	WRITE(mask, x);
+	return;
     }
+
+    xa = x >> 24;
+    FbByteMulC(x, a);
+    WRITE(src, x);
+    FbByteMul(a, xa);
+    WRITE(mask, a);
 }
 
-static FASTCALL void
-fbCombineMaskValueC (CARD32 *src, const CARD32 *mask, int width)
+static INLINE void
+fbCombineMaskValueC (CARD32 *src, const CARD32 *mask)
 {
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 a = READ(mask + i);
-        CARD32	x;
+    CARD32 a = READ(mask);
+    CARD32	x;
 
-        if (!a)
-        {
-            WRITE(src + i, 0);
-            continue;
-        }
+    if (!a)
+    {
+	WRITE(src, 0);
+	return;
+    }
 
-        if (a == 0xffffffff)
-            continue;
+    if (a == 0xffffffff)
+	return;
 
-        x = READ(src + i);
-        FbByteMulC(x, a);
-        WRITE(src + i, x);
-    }
+    x = READ(src);
+    FbByteMulC(x, a);
+    WRITE(src,x);
 }
 
-
-static FASTCALL void
-fbCombineMaskAlphaC (const CARD32 *src, CARD32 *mask, int width)
+static INLINE void
+fbCombineMaskAlphaC (const CARD32 *src, CARD32 *mask)
 {
-    int i;
-    for (i = 0; i < width; ++i) {
-        CARD32 a = READ(mask + i);
-        CARD32	x;
-
-        if (!a)
-            continue;
+    CARD32 a = READ(mask);
+    CARD32	x;
 
-        x = READ(src + i) >> 24;
-        if (x == 0xff)
-            continue;
-        if (a == 0xffffffff)
-        {
-            x = x >> 24;
-            x |= x << 8;
-            x |= x << 16;
-            WRITE(mask + i, x);
-            continue;
-        }
+    if (!a)
+	return;
 
-        FbByteMul(a, x);
-        WRITE(mask + i, a);
+    x = READ(src) >> 24;
+    if (x == 0xff)
+	return;
+    if (a == 0xffffffff)
+    {
+	x = x >> 24;
+	x |= x << 8;
+	x |= x << 16;
+	WRITE(mask, x);
+	return;
     }
+
+    FbByteMul(a, x);
+    WRITE(mask, a);
 }
 
 static FASTCALL void
 fbCombineClearC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
-    memset(dest, 0, width*sizeof(CARD32));
+    MEMSET_WRAPPED(dest, 0, width*sizeof(CARD32));
 }
 
 static FASTCALL void
 fbCombineSrcC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
-    fbCombineMaskValueC(src, mask, width);
-    MEMCPY_WRAPPED(dest, src, width*sizeof(CARD32));
+    int i;
+
+    for (i = 0; i < width; ++i) {
+	CARD32 s = READ(src + i);
+	CARD32 m = READ(mask + i);
+
+	fbCombineMaskValueC (&s, &m);
+
+	WRITE(dest, s);
+    }
 }
 
 static FASTCALL void
 fbCombineOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
-        CARD32  s = READ(src + i);
-        CARD32  a = ~READ(mask + i);
+	CARD32 s = READ(src + i);
+	CARD32 m = READ(mask + i);
+	CARD32 a;
+
+	fbCombineMaskC (&s, &m);
 
+	a = ~m;
         if (a != 0xffffffff)
         {
             if (a)
@@ -2189,7 +2191,7 @@ static FASTCALL void
 fbCombineOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskValueC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32 d = READ(dest + i);
         CARD32 a = ~d >> 24;
@@ -2197,6 +2199,10 @@ fbCombineOverReverseC (CARD32 *dest, CAR
         if (a)
         {
             CARD32 s = READ(src + i);
+	    CARD32 m = READ(mask + i);
+
+	    fbCombineMaskValueC (&s, &m);
+
             if (a != 0xff)
             {
                 FbByteMulAdd(s, a, d);
@@ -2210,14 +2216,17 @@ static FASTCALL void
 fbCombineInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskValueC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32 d = READ(dest + i);
         CARD16 a = d >> 24;
         CARD32 s = 0;
         if (a)
         {
-            s = READ(src + i);
+	    CARD32 m = READ(mask + i);
+
+	    s = READ(src + i);
+	    fbCombineMaskValueC (&s, &m);
             if (a != 0xff)
             {
                 FbByteMul(s, a);
@@ -2231,10 +2240,15 @@ static FASTCALL void
 fbCombineInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskAlphaC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
-        CARD32 a = READ(mask + i);
+        CARD32 s = READ(src + i);
+        CARD32 m = READ(mask + i);
+        CARD32 a;
+
+	fbCombineMaskAlphaC (&s, &m);
 
+	a = m;
         if (a != 0xffffffff)
         {
             CARD32 d = 0;
@@ -2243,7 +2257,7 @@ fbCombineInReverseC (CARD32 *dest, CARD3
                 d = READ(dest + i);
                 FbByteMulC(d, a);
             }
-            WRITE(dest + i, d);
+            WRITE(dest + i, d); 
         }
     }
 }
@@ -2252,14 +2266,18 @@ static FASTCALL void
 fbCombineOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskValueC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32 d = READ(dest + i);
         CARD16 a = ~d >> 24;
         CARD32 s = 0;
         if (a)
         {
-            s = READ(src + i);
+	    CARD32 m = READ(mask + i);
+
+	    s = READ(src + i);
+	    fbCombineMaskValueC (&s, &m);
+
             if (a != 0xff)
             {
                 FbByteMul(s, a);
@@ -2273,10 +2291,15 @@ static FASTCALL void
 fbCombineOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskAlphaC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
-        CARD32 a = ~READ(mask + i);
+	CARD32 s = READ(src + i);
+	CARD32 m = READ(mask + i);
+	CARD32 a;
 
+	fbCombineMaskAlphaC (&s, &m);
+
+        a = ~m;
         if (a != 0xffffffff)
         {
             CARD32 d = 0;
@@ -2294,12 +2317,18 @@ static FASTCALL void
 fbCombineAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32 d = READ(dest + i);
         CARD32 s = READ(src + i);
-        CARD32 ad = ~READ(mask + i);
+        CARD32 m = READ(mask + i);
+        CARD32 ad;
         CARD16 as = d >> 24;
+
+	fbCombineMaskC (&s, &m);
+
+        ad = ~m;
+
         FbByteAddMulC(d, ad, s, as);
         WRITE(dest + i, d);
     }
@@ -2309,13 +2338,19 @@ static FASTCALL void
 fbCombineAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
 
         CARD32 d = READ(dest + i);
         CARD32 s = READ(src + i);
-        CARD32 ad = READ(mask + i);
+        CARD32 m = READ(mask + i);
+        CARD32 ad;
         CARD16 as = ~d >> 24;
+
+	fbCombineMaskC (&s, &m);
+
+	ad = m;
+
         FbByteAddMulC(d, ad, s, as);
         WRITE(dest + i, d);
     }
@@ -2325,12 +2360,18 @@ static FASTCALL void
 fbCombineXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32 d = READ(dest + i);
         CARD32 s = READ(src + i);
-        CARD32 ad = ~READ(mask + i);
+        CARD32 m = READ(mask + i);
+        CARD32 ad;
         CARD16 as = ~d >> 24;
+
+	fbCombineMaskC (&s, &m);
+
+	ad = ~m;
+
         FbByteAddMulC(d, ad, s, as);
         WRITE(dest + i, d);
     }
@@ -2340,10 +2381,14 @@ static FASTCALL void
 fbCombineAddC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskValueC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32 s = READ(src + i);
+        CARD32 m = READ(mask + i);
         CARD32 d = READ(dest + i);
+
+	fbCombineMaskValueC (&s, &m);
+
         FbByteAdd(d, s);
         WRITE(dest + i, d);
     }
@@ -2353,7 +2398,7 @@ static FASTCALL void
 fbCombineSaturateC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
 {
     int i;
-    fbCombineMaskC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32  s, d;
         CARD16  sa, sr, sg, sb, da;
@@ -2362,10 +2407,14 @@ fbCombineSaturateC (CARD32 *dest, CARD32
 
         d = READ(dest + i);
         s = READ(src + i);
-        sa = (READ(mask + i) >> 24);
-        sr = (READ(mask + i) >> 16) & 0xff;
-        sg = (READ(mask + i) >>  8) & 0xff;
-        sb = (READ(mask + i)      ) & 0xff;
+	m = READ(mask + i);
+
+	fbCombineMaskC (&s, &m);
+
+        sa = (m >> 24);
+        sr = (m >> 16) & 0xff;
+        sg = (m >>  8) & 0xff;
+        sb = (m      ) & 0xff;
         da = ~d >> 24;
 
         if (sb <= da)
@@ -2396,7 +2445,7 @@ static FASTCALL void
 fbCombineDisjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine)
 {
     int i;
-    fbCombineMaskC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32  s, d;
         CARD32  m,n,o,p;
@@ -2406,10 +2455,14 @@ fbCombineDisjointGeneralC (CARD32 *dest,
         CARD8   da;
 
         s = READ(src + i);
-        sa = READ(mask + i);
+        m = READ(mask + i);
         d = READ(dest + i);
         da = d >> 24;
 
+	fbCombineMaskC (&s, &m);
+
+	sa = m;
+
         switch (combine & CombineA) {
         default:
             Fa = 0;
@@ -2516,7 +2569,7 @@ static FASTCALL void
 fbCombineConjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine)
 {
     int i;
-    fbCombineMaskC(src, mask, width);
+
     for (i = 0; i < width; ++i) {
         CARD32  s, d;
         CARD32  m,n,o,p;
@@ -2526,10 +2579,14 @@ fbCombineConjointGeneralC (CARD32 *dest,
         CARD8   da;
 
         s = READ(src + i);
-        sa = READ(mask + i);
+        m = READ(mask + i);
         d = READ(dest + i);
         da = d >> 24;
 
+	fbCombineMaskC (&s, &m);
+
+        sa = m;
+
         switch (combine & CombineA) {
         default:
             Fa = 0;
diff-tree 9c2e955f6792e80fb84f848ed9e6ebbfd79f7130 (from 96ef0f78438b60436c3940817980a3ab4070c7e8)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Apr 20 07:21:19 2007 -0600

    regenerated to add GL_CLIENT_ATTRIB_STACK_DEPTH (bug 9823)

diff --git a/GL/glx/indirect_size_get.c b/GL/glx/indirect_size_get.c
index ccb25f8..f29ae47 100644
--- a/GL/glx/indirect_size_get.c
+++ b/GL/glx/indirect_size_get.c
@@ -370,6 +370,7 @@ __glGetBooleanv_size(GLenum e)
     case GL_PROJECTION_STACK_DEPTH:
     case GL_TEXTURE_STACK_DEPTH:
     case GL_ATTRIB_STACK_DEPTH:
+    case GL_CLIENT_ATTRIB_STACK_DEPTH:
     case GL_ALPHA_TEST:
     case GL_ALPHA_TEST_FUNC:
     case GL_ALPHA_TEST_REF:
@@ -448,6 +449,7 @@ __glGetBooleanv_size(GLenum e)
     case GL_MAX_NAME_STACK_DEPTH:
     case GL_MAX_PROJECTION_STACK_DEPTH:
     case GL_MAX_TEXTURE_STACK_DEPTH:
+    case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
     case GL_SUBPIXEL_BITS:
     case GL_INDEX_BITS:
     case GL_RED_BITS:
diff-tree 96ef0f78438b60436c3940817980a3ab4070c7e8 (from 7ca4baffb5569ea12b578a4a3f69e93d272d6c6d)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu Apr 19 17:39:51 2007 -0700

    Disable SourceValidate in rotation to capture cursor.
    
    SourceValidate is used exclusively by the software cursor code to pull the
    cursor off of the screen before using the screen as a source operand. This
    eliminates the software cursor from the frame buffer while painting the
    rotated image though. Disabling this function by temporarily setting the
    screen function pointer to NULL causes the cursor image to be captured.
    (cherry picked from commit 05e1c45ade9c558820685bfd2541617a2e8de816)

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 94f95a0..359501e 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -278,8 +278,18 @@ xf86RotateRedisplay(ScreenPtr pScreen)
     region = DamageRegion(damage);
     if (REGION_NOTEMPTY(pScreen, region)) 
     {
-	int		    c;
-	
+	int			c;
+	SourceValidateProcPtr	SourceValidate;
+
+	/*
+	 * SourceValidate is used by the software cursor code
+	 * to pull the cursor off of the screen when reading
+	 * bits from the frame buffer. Bypassing this function
+	 * leaves the software cursor in place
+	 */
+	SourceValidate = pScreen->SourceValidate;
+	pScreen->SourceValidate = NULL;
+
 	for (c = 0; c < xf86_config->num_crtc; c++)
 	{
 	    xf86CrtcPtr	    crtc = xf86_config->crtc[c];
@@ -304,6 +314,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 		REGION_UNINIT (pScreen, &crtc_damage);
 	    }
 	}
+	pScreen->SourceValidate = SourceValidate;
 	DamageEmpty(damage);
     }
 }
diff-tree 7ca4baffb5569ea12b578a4a3f69e93d272d6c6d (from 806a537e644d8cc9e53f3ac52efb49453e5aa1fb)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu Apr 19 17:37:18 2007 -0700

    Was accidentally disabling rotation updates in mode set.
    
    Setting a mode on an unrotated CRTC was causing all of the rotation updates
    to be disabled; the loop looking for active rotation wasn't actually looking
    at each crtc, it was looking at the modified crtc many times.
    (cherry picked from commit 8b217dee3a6c46b13fc9571a4a9a95bc55686cdb)

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index e8fafd0..94f95a0 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -284,7 +284,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 	{
 	    xf86CrtcPtr	    crtc = xf86_config->crtc[c];
 
-	    if (crtc->rotation != RR_Rotate_0)
+	    if (crtc->rotation != RR_Rotate_0 && crtc->enabled)
 	    {
 		BoxRec	    box;
 		RegionRec   crtc_damage;
@@ -338,7 +338,8 @@ xf86RotateDestroy (xf86CrtcPtr crtc)
     }
 
     for (c = 0; c < xf86_config->num_crtc; c++)
-	if (crtc->rotatedPixmap || crtc->rotatedData)
+	if (xf86_config->crtc[c]->rotatedPixmap ||
+	    xf86_config->crtc[c]->rotatedData)
 	    return;
 
     /*
diff-tree 806a537e644d8cc9e53f3ac52efb49453e5aa1fb (from 0a9239ec258828ec1da6c208634a55fc4053d7da)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu Apr 19 17:49:34 2007 -0700

    Revert "Suppress software cursor removal during rotated shadow buffer drawing."
    
    This reverts commit 999b681cf3973af4191506e49cde06963b11a774.
    Replacing this with simpler code that just disables SourceValidate
    during rotation redisplay.

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 5127c15..e8fafd0 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -39,7 +39,6 @@
 #include "xf86Crtc.h"
 #include "xf86Modes.h"
 #include "xf86RandR12.h"
-#include "misprite.h"
 #include "X11/extensions/render.h"
 #define DPMS_SERVER
 #include "X11/extensions/dpms.h"
@@ -280,11 +279,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
     if (REGION_NOTEMPTY(pScreen, region)) 
     {
 	int		    c;
-
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(7,2,0,0,dummy)
-	/* Disable software cursor removal for this drawing */
-	miSpriteDrawInternal(pScreen, TRUE);
-#endif
+	
 	for (c = 0; c < xf86_config->num_crtc; c++)
 	{
 	    xf86CrtcPtr	    crtc = xf86_config->crtc[c];
@@ -309,9 +304,6 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 		REGION_UNINIT (pScreen, &crtc_damage);
 	    }
 	}
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(7,2,0,0,dummy)
-	miSpriteDrawInternal(pScreen, FALSE);
-#endif
 	DamageEmpty(damage);
     }
 }
diff --git a/mi/misprite.c b/mi/misprite.c
index 71e6ab0..c0560a4 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -288,8 +288,7 @@ miSpriteGetImage (pDrawable, sx, sy, w, 
 
     pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
 
-    if (pScreenPriv->internalDraw == 0 &&
-	pDrawable->type == DRAWABLE_WINDOW &&
+    if (pDrawable->type == DRAWABLE_WINDOW &&
         pScreenPriv->isUp &&
 	ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h))
     {
@@ -319,8 +318,7 @@ miSpriteGetSpans (pDrawable, wMax, ppt, 
 
     pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
 
-    if (pScreenPriv->internalDraw == 0 &&
-	pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp)
+    if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp)
     {
 	DDXPointPtr    	pts;
 	int    		*widths;
@@ -362,8 +360,7 @@ miSpriteSourceValidate (pDrawable, x, y,
 
     pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
 
-    if (pScreenPriv->internalDraw == 0 &&
-	pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp &&
+    if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp &&
 	ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y,
 		    x, y, width, height))
     {
@@ -389,8 +386,7 @@ miSpriteCopyWindow (WindowPtr pWindow, D
     /*
      * Damage will take care of destination check
      */
-    if (pScreenPriv->internalDraw == 0 &&
-	pScreenPriv->isUp &&
+    if (pScreenPriv->isUp &&
 	RECT_IN_REGION (pScreen, prgnSrc, &pScreenPriv->saved) != rgnOUT)
     {
 	SPRITE_DEBUG (("CopyWindow remove\n"));
@@ -831,28 +827,3 @@ miSpriteComputeSaved (pScreen)
     pScreenPriv->saved.x2 = pScreenPriv->saved.x1 + w + wpad * 2;
     pScreenPriv->saved.y2 = pScreenPriv->saved.y1 + h + hpad * 2;
 }
-
-/**
- * Enables internal drawing support, which disables removal of the
- * cursor when the screen pixmap is sourced from.
- *
- * This can be used to allow software cursors to be read by RandR rotation
- * shadow code.
- */
-void
-miSpriteDrawInternal(ScreenPtr pScreen, Bool enable)
-{
-    miSpriteScreenPtr   pScreenPriv;
-
-    /* Check that miSprite has been set up this generation */
-    if (miSpriteGeneration != serverGeneration)
-	return;
-
-    pScreenPriv = (miSpriteScreenPtr)
-	pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
-    if (enable)
-	pScreenPriv->internalDraw++;
-    else
-	pScreenPriv->internalDraw--;
-}
diff --git a/mi/misprite.h b/mi/misprite.h
index 0a1bcc1..5173b77 100644
--- a/mi/misprite.h
+++ b/mi/misprite.h
@@ -92,5 +92,3 @@ extern Bool miSpriteInitialize(
     miSpriteCursorFuncPtr /*cursorFuncs*/,
     miPointerScreenFuncPtr /*screenFuncs*/
 );
-
-void miSpriteDrawInternal(ScreenPtr pScreen, Bool enable);
diff --git a/mi/mispritest.h b/mi/mispritest.h
index 2deaa45..5075f05 100644
--- a/mi/mispritest.h
+++ b/mi/mispritest.h
@@ -76,7 +76,6 @@ typedef struct {
     WindowPtr	    pCacheWin;		/* window the cursor last seen in */
     Bool	    isInCacheWin;
     Bool	    checkPixels;	/* check colormap collision */
-    int		    internalDraw;
     xColorItem	    colors[2];
     ColormapPtr	    pInstalledMap;
     ColormapPtr	    pColormap;
diff-tree 0a9239ec258828ec1da6c208634a55fc4053d7da (from d0e55774e0da641ba85c5173f27f68de27372747)
Author: Soren Sandmann Pedersen <ssp at dhcp83-218.boston.redhat.com>
Date:   Thu Apr 19 18:19:34 2007 -0400

    Merge David Reveman's gradient optimization patch from pixman

diff --git a/fb/fbcompose.c b/fb/fbcompose.c
index 6ea9483..3043637 100644
--- a/fb/fbcompose.c
+++ b/fb/fbcompose.c
@@ -40,6 +40,65 @@
 #include "mipict.h"
 #include "fbpict.h"
 
+static unsigned int
+SourcePictureClassify (PicturePtr pict,
+		       int	  x,
+		       int	  y,
+		       int	  width,
+		       int	  height)
+{
+    if (pict->pSourcePict->type == SourcePictTypeSolidFill)
+    {
+	pict->pSourcePict->solidFill.class = SourcePictClassHorizontal;
+    }
+    else if (pict->pSourcePict->type == SourcePictTypeLinear)
+    {
+	PictVector   v;
+	xFixed_32_32 l;
+	xFixed_48_16 dx, dy, a, b, off;
+	xFixed_48_16 factors[4];
+	int	     i;
+
+	dx = pict->pSourcePict->linear.p2.x - pict->pSourcePict->linear.p1.x;
+	dy = pict->pSourcePict->linear.p2.y - pict->pSourcePict->linear.p1.y;
+	l = dx * dx + dy * dy;
+	if (l)
+	{
+	    a = (dx << 32) / l;
+	    b = (dy << 32) / l;
+	}
+	else
+	{
+	    a = b = 0;
+	}
+
+	off = (-a * pict->pSourcePict->linear.p1.x
+	       -b * pict->pSourcePict->linear.p1.y) >> 16;
+
+	for (i = 0; i < 3; i++)
+	{
+	    v.vector[0] = IntToxFixed ((i % 2) * (width  - 1) + x);
+	    v.vector[1] = IntToxFixed ((i / 2) * (height - 1) + y);
+	    v.vector[2] = xFixed1;
+
+	    if (pict->transform)
+	    {
+		if (!PictureTransformPoint3d (pict->transform, &v))
+		    return SourcePictClassUnknown;
+	    }
+
+	    factors[i] = ((a * v.vector[0] + b * v.vector[1]) >> 16) + off;
+	}
+
+	if (factors[2] == factors[0])
+	    pict->pSourcePict->linear.class = SourcePictClassHorizontal;
+	else if (factors[1] == factors[0])
+	    pict->pSourcePict->linear.class = SourcePictClassVertical;
+    }
+
+    return pict->pSourcePict->solidFill.class;
+}
+
 #define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
 #define SCANLINE_BUFFER_LENGTH 2048
@@ -86,9 +145,9 @@ fbFetch_x8b8g8r8 (const FbBits *bits, in
     const CARD32 *end = pixel + width;
     while (pixel < end) {
         WRITE(buffer++, 0xff000000 |
-                        ((READ(pixel) & 0x0000ff00) |
-                         ((READ(pixel) >> 16) & 0xff) |
-                         ((READ(pixel) & 0xff) << 16)));
+	      ((READ(pixel) & 0x0000ff00) |
+	       ((READ(pixel) >> 16) & 0xff) |
+	       ((READ(pixel) & 0xff) << 16)));
         ++pixel;
     }
 }
@@ -132,8 +191,8 @@ fbFetch_r5g6b5 (const FbBits *bits, int 
     while (pixel < end) {
         CARD32  p = READ(pixel++);
         CARD32 r = (((p) << 3) & 0xf8) | 
-                   (((p) << 5) & 0xfc00) |
-                   (((p) << 8) & 0xf80000);
+	    (((p) << 5) & 0xfc00) |
+	    (((p) << 8) & 0xf80000);
         r |= (r >> 5) & 0x70007;
         r |= (r >> 6) & 0x300;
         WRITE(buffer++, 0xff000000 | r);
@@ -335,7 +394,7 @@ fbFetch_b2g3r3 (const FbBits *bits, int 
              ((p & 0x07) << 3) |
              ((p & 0x06) << 6)) << 16;
         WRITE(buffer++, (0xff000000 | r | g | b));
-	}
+    }
 }
 
 static FASTCALL void
@@ -558,7 +617,7 @@ static fetchProc fetchProcForPicture (Pi
     case PICT_c8: return  fbFetch_c8;
     case PICT_g8: return  fbFetch_c8;
     case PICT_x4a4: return fbFetch_x4a4;
-    
+
         /* 4bpp formats */
     case PICT_a4: return  fbFetch_a4;
     case PICT_r1g2b1: return fbFetch_r1g2b1;
@@ -1095,8 +1154,8 @@ fbStore_r5g6b5 (FbBits *bits, const CARD
     for (i = 0; i < width; ++i) {
         CARD32 s = READ(values + i);
         WRITE(pixel++, ((s >> 3) & 0x001f) |
-                       ((s >> 5) & 0x07e0) |
-                       ((s >> 8) & 0xf800));
+	      ((s >> 5) & 0x07e0) |
+	      ((s >> 8) & 0xf800));
     }
 }
 
@@ -1108,8 +1167,8 @@ fbStore_b5g6r5 (FbBits *bits, const CARD
     for (i = 0; i < width; ++i) {
         Split(READ(values + i));
         WRITE(pixel++, ((b << 8) & 0xf800) |
-                       ((g << 3) & 0x07e0) |
-                       ((r >> 3)         ));
+	      ((g << 3) & 0x07e0) |
+	      ((r >> 3)         ));
     }
 }
 
@@ -1121,9 +1180,9 @@ fbStore_a1r5g5b5 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Splita(READ(values + i));
         WRITE(pixel++, ((a << 8) & 0x8000) |
-                       ((r << 7) & 0x7c00) |
-                       ((g << 2) & 0x03e0) |
-                       ((b >> 3)         ));
+	      ((r << 7) & 0x7c00) |
+	      ((g << 2) & 0x03e0) |
+	      ((b >> 3)         ));
     }
 }
 
@@ -1135,8 +1194,8 @@ fbStore_x1r5g5b5 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Split(READ(values + i));
         WRITE(pixel++, ((r << 7) & 0x7c00) |
-                       ((g << 2) & 0x03e0) |
-                       ((b >> 3)         ));
+	      ((g << 2) & 0x03e0) |
+	      ((b >> 3)         ));
     }
 }
 
@@ -1148,10 +1207,10 @@ fbStore_a1b5g5r5 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Splita(READ(values + i));
         WRITE(pixel++, ((a << 8) & 0x8000) |
-                       ((b << 7) & 0x7c00) |
-                       ((g << 2) & 0x03e0) |
-                       ((r >> 3)         ));
-	}
+	      ((b << 7) & 0x7c00) |
+	      ((g << 2) & 0x03e0) |
+	      ((r >> 3)         ));
+    }
 }
 
 static FASTCALL void
@@ -1162,8 +1221,8 @@ fbStore_x1b5g5r5 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Split(READ(values + i));
         WRITE(pixel++, ((b << 7) & 0x7c00) |
-                       ((g << 2) & 0x03e0) |
-                       ((r >> 3)         ));
+	      ((g << 2) & 0x03e0) |
+	      ((r >> 3)         ));
     }
 }
 
@@ -1175,9 +1234,9 @@ fbStore_a4r4g4b4 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Splita(READ(values + i));
         WRITE(pixel++, ((a << 8) & 0xf000) |
-                       ((r << 4) & 0x0f00) |
-                       ((g     ) & 0x00f0) |
-                       ((b >> 4)         ));
+	      ((r << 4) & 0x0f00) |
+	      ((g     ) & 0x00f0) |
+	      ((b >> 4)         ));
     }
 }
 
@@ -1189,8 +1248,8 @@ fbStore_x4r4g4b4 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Split(READ(values + i));
         WRITE(pixel++, ((r << 4) & 0x0f00) |
-                       ((g     ) & 0x00f0) |
-                       ((b >> 4)         ));
+	      ((g     ) & 0x00f0) |
+	      ((b >> 4)         ));
     }
 }
 
@@ -1202,9 +1261,9 @@ fbStore_a4b4g4r4 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Splita(READ(values + i));
         WRITE(pixel++, ((a << 8) & 0xf000) |
-                       ((b << 4) & 0x0f00) |
-                       ((g     ) & 0x00f0) |
-                       ((r >> 4)         ));
+	      ((b << 4) & 0x0f00) |
+	      ((g     ) & 0x00f0) |
+	      ((r >> 4)         ));
     }
 }
 
@@ -1216,8 +1275,8 @@ fbStore_x4b4g4r4 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Split(READ(values + i));
         WRITE(pixel++, ((b << 4) & 0x0f00) |
-                       ((g     ) & 0x00f0) |
-                       ((r >> 4)         ));
+	      ((g     ) & 0x00f0) |
+	      ((r >> 4)         ));
     }
 }
 
@@ -1239,8 +1298,8 @@ fbStore_r3g3b2 (FbBits *bits, const CARD
     for (i = 0; i < width; ++i) {
         Split(READ(values + i));
         WRITE(pixel++, ((r     ) & 0xe0) |
-                       ((g >> 3) & 0x1c) |
-                       ((b >> 6)       ));
+	      ((g >> 3) & 0x1c) |
+	      ((b >> 6)       ));
     }
 }
 
@@ -1252,8 +1311,8 @@ fbStore_b2g3r3 (FbBits *bits, const CARD
     for (i = 0; i < width; ++i) {
         Split(READ(values + i));
         WRITE(pixel++, ((b     ) & 0xe0) |
-                       ((g >> 3) & 0x1c) |
-                       ((r >> 6)       ));
+	      ((g >> 3) & 0x1c) |
+	      ((r >> 6)       ));
     }
 }
 
@@ -1265,9 +1324,9 @@ fbStore_a2r2g2b2 (FbBits *bits, const CA
     for (i = 0; i < width; ++i) {
         Splita(READ(values + i));
         WRITE(pixel++, ((a     ) & 0xc0) |
-                       ((r >> 2) & 0x30) |
-                       ((g >> 4) & 0x0c) |
-                       ((b >> 6)       ));
+	      ((r >> 2) & 0x30) |
+	      ((g >> 4) & 0x0c) |
+	      ((b >> 6)       ));
     }
 }
 
@@ -1293,11 +1352,11 @@ fbStore_x4a4 (FbBits *bits, const CARD32
 
 #define Store8(l,o,v)  (((CARD8 *) l)[(o) >> 3] = (v))
 #if IMAGE_BYTE_ORDER == MSBFirst
-#define Store4(l,o,v)  Store8(l,o,((o) & 4 ? \
-				   (Fetch8(l,o) & 0xf0) | (v) : \
+#define Store4(l,o,v)  Store8(l,o,((o) & 4 ?			\
+				   (Fetch8(l,o) & 0xf0) | (v) :		\
 				   (Fetch8(l,o) & 0x0f) | ((v) << 4)))
 #else
-#define Store4(l,o,v)  Store8(l,o,((o) & 4 ? \
+#define Store4(l,o,v)  Store8(l,o,((o) & 4 ?			       \
 				   (Fetch8(l,o) & 0x0f) | ((v) << 4) : \
 				   (Fetch8(l,o) & 0xf0) | (v)))
 #endif
@@ -1655,22 +1714,22 @@ fbCombineSaturateU (CARD32 *dest, const 
  A nor B, areas covered only by A, areas covered only by B and finally
  areas covered by both A and B.
 
-		Disjoint			Conjoint
-		Fa		Fb		Fa		Fb
-(0,0,0,0)	0		0		0		0
-(0,A,0,A)	1		0		1		0
-(0,0,B,B)	0		1		0		1
-(0,A,B,A)	1		min((1-a)/b,1)	1		max(1-a/b,0)
-(0,A,B,B)	min((1-b)/a,1)	1		max(1-b/a,0)	1
-(0,0,0,A)	max(1-(1-b)/a,0) 0		min(1,b/a)	0
-(0,0,0,B)	0		max(1-(1-a)/b,0) 0		min(a/b,1)
-(0,A,0,0)	min(1,(1-b)/a)	0		max(1-b/a,0)	0
-(0,0,B,0)	0		min(1,(1-a)/b)	0		max(1-a/b,0)
-(0,0,B,A)	max(1-(1-b)/a,0) min(1,(1-a)/b)	 min(1,b/a)	max(1-a/b,0)
-(0,A,0,B)	min(1,(1-b)/a)	max(1-(1-a)/b,0) max(1-b/a,0)	min(1,a/b)
-(0,A,B,0)	min(1,(1-b)/a)	min(1,(1-a)/b)	max(1-b/a,0)	max(1-a/b,0)
+ Disjoint			Conjoint
+ Fa		Fb		Fa		Fb
+ (0,0,0,0)	0		0		0		0
+ (0,A,0,A)	1		0		1		0
+ (0,0,B,B)	0		1		0		1
+ (0,A,B,A)	1		min((1-a)/b,1)	1		max(1-a/b,0)
+ (0,A,B,B)	min((1-b)/a,1)	1		max(1-b/a,0)	1
+ (0,0,0,A)	max(1-(1-b)/a,0) 0		min(1,b/a)	0
+ (0,0,0,B)	0		max(1-(1-a)/b,0) 0		min(a/b,1)
+ (0,A,0,0)	min(1,(1-b)/a)	0		max(1-b/a,0)	0
+ (0,0,B,0)	0		min(1,(1-a)/b)	0		max(1-a/b,0)
+ (0,0,B,A)	max(1-(1-b)/a,0) min(1,(1-a)/b)	 min(1,b/a)	max(1-a/b,0)
+ (0,A,0,B)	min(1,(1-b)/a)	max(1-(1-a)/b,0) max(1-b/a,0)	min(1,a/b)
+ (0,A,B,0)	min(1,(1-b)/a)	min(1,(1-a)/b)	max(1-b/a,0)	max(1-a/b,0)
 
- */
+*/
 
 #define CombineAOut 1
 #define CombineAIn  2
@@ -2634,7 +2693,7 @@ FbComposeFunctions composeFunctions = {
 };
 
 
-static void fbFetchSolid(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+static void fbFetchSolid(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
 {
     FbBits *bits;
     FbStride stride;
@@ -2656,7 +2715,7 @@ static void fbFetchSolid(PicturePtr pict
     fbFinishAccess (pict->pDrawable);
 }
 
-static void fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+static void fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
 {
     FbBits *bits;
     FbStride stride;
@@ -2676,43 +2735,78 @@ static void fbFetch(PicturePtr pict, int
 }
 
 #define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
-#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :\
-        ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
+#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :		\
+		  ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
 
+static CARD32
+xRenderColorMultToCard32 (xRenderColor *c)
+{
+    return
+	((((CARD32) c->red   * c->alpha) >> 24) << 16) |
+	((((CARD32) c->green * c->alpha) >> 24) <<  8) |
+	((((CARD32) c->blue  * c->alpha) >> 24) <<  0) |
+	((((CARD32) c->alpha		 ) >> 8)  << 24);
+}
 
 static CARD32 gradientPixel(const SourcePictPtr pGradient, xFixed_48_16 pos, unsigned int spread)
 {
-    int ipos = (pos * PICT_GRADIENT_STOPTABLE_SIZE - 1) >> 16;
+    int ipos = (pos * pGradient->gradient.stopRange - 1) >> 16;
 
     /* calculate the actual offset. */
-    if (ipos < 0 || ipos >= PICT_GRADIENT_STOPTABLE_SIZE) {
-        if (pGradient->type == SourcePictTypeConical || spread == RepeatNormal) {
-            ipos = ipos % PICT_GRADIENT_STOPTABLE_SIZE;
-            ipos = ipos < 0 ? PICT_GRADIENT_STOPTABLE_SIZE + ipos : ipos;
+    if (ipos < 0 || ipos >= pGradient->gradient.stopRange)
+    {
+	if (pGradient->type == SourcePictTypeConical || spread == RepeatNormal)
+	{
+	    ipos = ipos % pGradient->gradient.stopRange;
+	    ipos = ipos < 0 ? pGradient->gradient.stopRange + ipos : ipos;
+
+	}
+	else if (spread == RepeatReflect)
+	{
+	    const int limit = pGradient->gradient.stopRange * 2 - 1;
 
-        } else if (spread == RepeatReflect) {
-            const int limit = PICT_GRADIENT_STOPTABLE_SIZE * 2 - 1;
-            ipos = ipos % limit;
-            ipos = ipos < 0 ? limit + ipos : ipos;
-            ipos = ipos >= PICT_GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;
+	    ipos = ipos % limit;
+	    ipos = ipos < 0 ? limit + ipos : ipos;
+	    ipos = ipos >= pGradient->gradient.stopRange ? limit - ipos : ipos;
 
-        } else if (spread == RepeatPad) {
-            if (ipos < 0)
-                ipos = 0;
-            else if (ipos >= PICT_GRADIENT_STOPTABLE_SIZE)
-                ipos = PICT_GRADIENT_STOPTABLE_SIZE-1;
-        } else { /* RepeatNone */
-            return 0;
-        }
+	}
+	else if (spread == RepeatPad)
+	{
+	    if (ipos < 0)
+		ipos = 0;
+	    else
+		ipos = pGradient->gradient.stopRange - 1;
+	}
+	else  /* RepeatNone */
+	{
+	    return 0;
+	}
+    }
+
+    if (pGradient->gradient.colorTableSize)
+    {
+	return pGradient->gradient.colorTable[ipos];
     }
+    else
+    {
+	int i;
 
-    assert(ipos >= 0);
-    assert(ipos < PICT_GRADIENT_STOPTABLE_SIZE);
+	if (ipos <= pGradient->gradient.stops->x)
+	    return xRenderColorMultToCard32 (&pGradient->gradient.stops->color);
 
-    return pGradient->linear.colorTable[ipos];
+	for (i = 1; i < pGradient->gradient.nstops; i++)
+	{
+	    if (pGradient->gradient.stops[i].x >= ipos)
+		return PictureGradientColor (&pGradient->gradient.stops[i - 1],
+					     &pGradient->gradient.stops[i],
+					     ipos);
+	}
+
+	return xRenderColorMultToCard32 (&pGradient->gradient.stops[--i].color);
+    }
 }
 
-static void fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+static void fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
 {
     SourcePictPtr pGradient = pict->pSourcePict;
     CARD32 *end = buffer + width;
@@ -2761,26 +2855,73 @@ static void fbFetchSourcePict(PicturePtr
                 t = ((a*v.vector[0] + b*v.vector[1]) >> 16) + off;
                 inc = (a * unit.vector[0] + b * unit.vector[1]) >> 16;
             }
-            while (buffer < end) {
-                WRITE(buffer++, gradientPixel(pGradient, t, pict->repeatType));
-                t += inc;
-            }
-        } else {
-            /* projective transformation */
-            while (buffer < end) {
-                xFixed_48_16 t;
-                if (v.vector[2] == 0) {
-                    t = 0;
-                } else {
-                    xFixed_48_16 x, y;
-                    x = ((xFixed_48_16)v.vector[0] << 16) / v.vector[2];
-                    y = ((xFixed_48_16)v.vector[1] << 16) / v.vector[2];
-                    t = ((a*x + b*y) >> 16) + off;
-                }
-                WRITE(buffer++, gradientPixel(pGradient, t, pict->repeatType));
-                v.vector[0] += unit.vector[0];
-                v.vector[1] += unit.vector[1];
-                v.vector[2] += unit.vector[2];
+
+	    if (pGradient->linear.class == SourcePictClassVertical)
+	    {
+		register CARD32 color;
+
+		color = gradientPixel (pGradient, t, pict->repeat);
+		while (buffer < end)
+		    *buffer++ = color;
+	    }
+	    else
+	    {
+		while (buffer < end) {
+		    if (!mask || *mask++ & maskBits)
+		    {
+			*buffer = gradientPixel (pGradient, t, pict->repeat);
+		    }
+		    ++buffer;
+		    t += inc;
+		}
+	    }
+	}
+	else /* projective transformation */
+	{
+	    xFixed_48_16 t;
+
+	    if (pGradient->linear.class == SourcePictClassVertical)
+	    {
+		register CARD32 color;
+
+		if (v.vector[2] == 0)
+		{
+		    t = 0;
+		}
+		else
+		{
+		    xFixed_48_16 x, y;
+
+		    x = ((xFixed_48_16) v.vector[0] << 16) / v.vector[2];
+		    y = ((xFixed_48_16) v.vector[1] << 16) / v.vector[2];
+		    t = ((a * x + b * y) >> 16) + off;
+		}
+
+		color = gradientPixel (pGradient, t, pict->repeat);
+		while (buffer < end)
+		    *buffer++ = color;
+	    }
+	    else
+	    {
+		while (buffer < end)
+		{
+		    if (!mask || *mask++ & maskBits)
+		    {
+			if (v.vector[2] == 0) {
+			    t = 0;
+			} else {
+			    xFixed_48_16 x, y;
+			    x = ((xFixed_48_16)v.vector[0] << 16) / v.vector[2];
+			    y = ((xFixed_48_16)v.vector[1] << 16) / v.vector[2];
+			    t = ((a*x + b*y) >> 16) + off;
+			}
+			*buffer = gradientPixel(pGradient, t, pict->repeat);
+		    }
+		    ++buffer;
+		    v.vector[0] += unit.vector[0];
+		    v.vector[1] += unit.vector[1];
+		    v.vector[2] += unit.vector[2];
+		}
             }
         }
     } else {
@@ -2817,14 +2958,20 @@ static void fbFetchSourcePict(PicturePtr
                 ry -= pGradient->radial.fy;
 
                 while (buffer < end) {
-                    double b = 2*(rx*pGradient->radial.dx + ry*pGradient->radial.dy);
-                    double c = -(rx*rx + ry*ry);
-                    double det = (b * b) - (4 * pGradient->radial.a * c);
-                    double s = (-b + sqrt(det))/(2. * pGradient->radial.a);
-                    WRITE(buffer, gradientPixel(pGradient,
-                                                (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
-                                                pict->repeatType));
-                    ++buffer;
+		    double b, c, det, s;
+
+		    if (!mask || *mask++ & maskBits)
+		    {
+			b = 2*(rx*pGradient->radial.dx + ry*pGradient->radial.dy);
+			c = -(rx*rx + ry*ry);
+			det = (b * b) - (4 * pGradient->radial.a * c);
+			s = (-b + sqrt(det))/(2. * pGradient->radial.a);
+			WRITE(buffer, gradientPixel(pGradient,
+						    (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
+						    pict->repeatType));
+		    }
+		    ++buffer;
+
                     rx += cx;
                     ry += cy;
                 }
@@ -2832,22 +2979,27 @@ static void fbFetchSourcePict(PicturePtr
                 while (buffer < end) {
                     double x, y;
                     double b, c, det, s;
-                    if (rz != 0) {
-                        x = rx/rz;
-                        y = ry/rz;
-                    } else {
-                        x = y = 0.;
-                    }
-                    x -= pGradient->radial.fx;
-                    y -= pGradient->radial.fy;
-                    b = 2*(x*pGradient->radial.dx + y*pGradient->radial.dy);
-                    c = -(x*x + y*y);
-                    det = (b * b) - (4 * pGradient->radial.a * c);
-                    s = (-b + sqrt(det))/(2. * pGradient->radial.a);
-                    WRITE(buffer, gradientPixel(pGradient,
-                                                (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
-                                                pict->repeatType));
-                    ++buffer;
+
+		    if (!mask || *mask++ & maskBits)
+		    {
+			if (rz != 0) {
+			    x = rx/rz;
+			    y = ry/rz;
+			} else {
+			    x = y = 0.;
+			}
+			x -= pGradient->radial.fx;
+			y -= pGradient->radial.fy;
+			b = 2*(x*pGradient->radial.dx + y*pGradient->radial.dy);
+			c = -(x*x + y*y);
+			det = (b * b) - (4 * pGradient->radial.a * c);
+			s = (-b + sqrt(det))/(2. * pGradient->radial.a);
+			*buffer = gradientPixel(pGradient,
+						(xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
+						pict->repeat);
+		    }
+		    ++buffer;
+
                     rx += cx;
                     ry += cy;
                     rz += cz;
@@ -2860,28 +3012,37 @@ static void fbFetchSourcePict(PicturePtr
                 ry -= pGradient->conical.center.y/65536.;
 
                 while (buffer < end) {
-                    double angle = atan2(ry, rx) + a;
-                    WRITE(buffer, gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
-                                                pict->repeatType));
+		    double angle;
+
+		    if (!mask || *mask++ & maskBits)
+		    {
+			angle = atan2(ry, rx) + a;
+
+			*buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
+						pict->repeat);
+		    }
+
                     ++buffer;
                     rx += cx;
                     ry += cy;
                 }
             } else {
-
                 while (buffer < end) {
                     double x, y, angle;
-                    if (rz != 0) {
-                        x = rx/rz;
-                        y = ry/rz;
-                    } else {
-                        x = y = 0.;
-                    }
-                    x -= pGradient->conical.center.x/65536.;
-                    y -= pGradient->conical.center.y/65536.;
-                    angle = atan2(y, x) + a;
-                    WRITE(buffer, gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
-                                                pict->repeatType));
+		    if (!mask || *mask++ & maskBits)
+		    {
+			if (rz != 0) {
+			    x = rx/rz;
+			    y = ry/rz;
+			} else {
+			    x = y = 0.;
+			}
+			x -= pGradient->conical.center.x/65536.;
+			y -= pGradient->conical.center.y/65536.;
+			angle = atan2(y, x) + a;
+			*buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
+						pict->repeat);
+		    }
                     ++buffer;
                     rx += cx;
                     ry += cy;
@@ -2892,9 +3053,7 @@ static void fbFetchSourcePict(PicturePtr
     }
 }
 
-
-
-static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
 {
     FbBits     *bits;
     FbStride    stride;
@@ -2943,39 +3102,47 @@ static void fbFetchTransformed(PicturePt
         if (pict->repeatType == RepeatNormal) {
             if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        if (!affine) {
-                            y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
-                            x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
-                        } else {
-                            y = MOD(v.vector[1]>>16, pict->pDrawable->height);
-                            x = MOD(v.vector[0]>>16, pict->pDrawable->width);
-                        }
-                        WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
-                    }
+		    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    buffer[i] = 0;
+			} else {
+			    if (!affine) {
+				y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
+				x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
+			    } else {
+				y = MOD(v.vector[1]>>16, pict->pDrawable->height);
+				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
+			    }
+			    buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+			}
+		    }
+
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
                 }
             } else {
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        if (!affine) {
-                            y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
-                            x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
-                        } else {
-                            y = MOD(v.vector[1]>>16, pict->pDrawable->height);
-                            x = MOD(v.vector[0]>>16, pict->pDrawable->width);
-                        }
-                        if (POINT_IN_REGION (0, pict->pCompositeClip, x + dx, y + dy, &box))
-                            WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
-                        else
-                            WRITE(buffer + i, 0);
-                    }
+		    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    buffer[i] = 0;
+			} else {
+			    if (!affine) {
+				y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
+				x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
+			    } else {
+				y = MOD(v.vector[1]>>16, pict->pDrawable->height);
+				x = MOD(v.vector[0]>>16, pict->pDrawable->width);
+			    }
+			    if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
+				buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+			    else
+				buffer[i] = 0;
+			}
+		    }
+
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
@@ -2985,40 +3152,46 @@ static void fbFetchTransformed(PicturePt
             if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 box = pict->pCompositeClip->extents;
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        if (!affine) {
-                            y = DIV(v.vector[1],v.vector[2]);
-                            x = DIV(v.vector[0],v.vector[2]);
-                        } else {
-                            y = v.vector[1]>>16;
-                            x = v.vector[0]>>16;
-                        }
-                        WRITE(buffer + i, ((x < box.x1-dx) | (x >= box.x2-dx) | (y < box.y1-dy) | (y >= box.y2-dy)) ?
-                                          0 : fetch(bits + (y + dy)*stride, x + dx, indexed));
-                    }
+		    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    WRITE(buffer + i, 0);
+			} else {
+			    if (!affine) {
+				y = DIV(v.vector[1],v.vector[2]);
+				x = DIV(v.vector[0],v.vector[2]);
+			    } else {
+				y = v.vector[1]>>16;
+				x = v.vector[0]>>16;
+			    }
+			    WRITE(buffer + i, ((x < box.x1-dx) | (x >= box.x2-dx) | (y < box.y1-dy) | (y >= box.y2-dy)) ?
+				  0 : fetch(bits + (y + dy)*stride, x + dx, indexed));
+			}
+		    }
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
                 }
             } else {
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        if (!affine) {
-                            y = DIV(v.vector[1],v.vector[2]);
-                            x = DIV(v.vector[0],v.vector[2]);
-                        } else {
-                            y = v.vector[1]>>16;
-                            x = v.vector[0]>>16;
-                        }
-                        if (POINT_IN_REGION (0, pict->pCompositeClip, x + dx, y + dy, &box))
-                            WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
-                        else
-                            WRITE(buffer + i, 0);
-                    }
+                    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    WRITE(buffer + i, 0);
+			} else {
+			    if (!affine) {
+				y = DIV(v.vector[1],v.vector[2]);
+				x = DIV(v.vector[0],v.vector[2]);
+			    } else {
+				y = v.vector[1]>>16;
+				x = v.vector[0]>>16;
+			    }
+			    if (POINT_IN_REGION (0, pict->pCompositeClip, x + dx, y + dy, &box))
+				WRITE(buffer + i, fetch(bits + (y + dy)*stride, x + dx, indexed));
+			    else
+				WRITE(buffer + i, 0);
+			}
+		    }
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
@@ -3035,126 +3208,133 @@ static void fbFetchTransformed(PicturePt
         if (pict->repeatType == RepeatNormal) {
             if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty;
-                        FbBits *b;
-                        CARD32 tl, tr, bl, br, r;
-                        CARD32 ft, fb;
-
-                        if (!affine) {
-                            xFixed_48_16 div;
-                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                            x1 = div >> 16;
-                            distx = ((xFixed)div >> 8) & 0xff;
-                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                            y1 = div >> 16;
-                            disty = ((xFixed)div >> 8) & 0xff;
-                        } else {
-                            x1 = v.vector[0] >> 16;
-                            distx = (v.vector[0] >> 8) & 0xff;
-                            y1 = v.vector[1] >> 16;
-                            disty = (v.vector[1] >> 8) & 0xff;
-                        }
-                        x2 = x1 + 1;
-                        y2 = y1 + 1;
-
-                        idistx = 256 - distx;
-                        idisty = 256 - disty;
-
-                        x1 = MOD (x1, pict->pDrawable->width);
-                        x2 = MOD (x2, pict->pDrawable->width);
-                        y1 = MOD (y1, pict->pDrawable->height);
-                        y2 = MOD (y2, pict->pDrawable->height);
-
-                        b = bits + (y1 + dy)*stride;
-
-                        tl = fetch(b, x1 + dx, indexed);
-                        tr = fetch(b, x2 + dx, indexed);
-                        b = bits + (y2 + dy)*stride;
-                        bl = fetch(b, x1 + dx, indexed);
-                        br = fetch(b, x2 + dx, indexed);
-
-                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
-                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-                        WRITE(buffer + i, r);
-                    }
+                    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    WRITE(buffer + i, 0);
+			} else {
+			    int x1, x2, y1, y2, distx, idistx, disty, idisty;
+			    FbBits *b;
+			    CARD32 tl, tr, bl, br, r;
+			    CARD32 ft, fb;
+
+			    if (!affine) {
+				xFixed_48_16 div;
+				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+				x1 = div >> 16;
+				distx = ((xFixed)div >> 8) & 0xff;
+				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+				y1 = div >> 16;
+				disty = ((xFixed)div >> 8) & 0xff;
+			    } else {
+				x1 = v.vector[0] >> 16;
+				distx = (v.vector[0] >> 8) & 0xff;
+				y1 = v.vector[1] >> 16;
+				disty = (v.vector[1] >> 8) & 0xff;
+			    }
+			    x2 = x1 + 1;
+			    y2 = y1 + 1;
+
+			    idistx = 256 - distx;
+			    idisty = 256 - disty;
+
+			    x1 = MOD (x1, pict->pDrawable->width);
+			    x2 = MOD (x2, pict->pDrawable->width);
+			    y1 = MOD (y1, pict->pDrawable->height);
+			    y2 = MOD (y2, pict->pDrawable->height);
+
+			    b = bits + (y1 + dy)*stride;
+
+			    tl = fetch(b, x1 + dx, indexed);
+			    tr = fetch(b, x2 + dx, indexed);
+			    b = bits + (y2 + dy)*stride;
+			    bl = fetch(b, x1 + dx, indexed);
+			    br = fetch(b, x2 + dx, indexed);
+
+			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
+			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+			    WRITE(buffer + i, r);
+			}
+		    }
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
                 }
             } else {
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty;
-                        FbBits *b;
-                        CARD32 tl, tr, bl, br, r;
-                        CARD32 ft, fb;
-
-                        if (!affine) {
-                            xFixed_48_16 div;
-                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                            x1 = div >> 16;
-                            distx = ((xFixed)div >> 8) & 0xff;
-                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                            y1 = div >> 16;
-                            disty = ((xFixed)div >> 8) & 0xff;
-                        } else {
-                            x1 = v.vector[0] >> 16;
-                            distx = (v.vector[0] >> 8) & 0xff;
-                            y1 = v.vector[1] >> 16;
-                            disty = (v.vector[1] >> 8) & 0xff;
-                        }
-                        x2 = x1 + 1;
-                        y2 = y1 + 1;
-
-                        idistx = 256 - distx;
-                        idisty = 256 - disty;
-
-                        x1 = MOD (x1, pict->pDrawable->width);
-                        x2 = MOD (x2, pict->pDrawable->width);
-                        y1 = MOD (y1, pict->pDrawable->height);
-                        y2 = MOD (y2, pict->pDrawable->height);
-
-                        b = bits + (y1 + dy)*stride;
-
-                        tl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y1 + dy, &box)
-                             ? fetch(b, x1 + dx, indexed) : 0;
-                        tr = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y1 + dy, &box)
-                             ? fetch(b, x2 + dx, indexed) : 0;
-                        b = bits + (y2 + dy)*stride;
-                        bl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y2 + dy, &box)
-                             ? fetch(b, x1 + dx, indexed) : 0;
-                        br = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y2 + dy, &box)
-                             ? fetch(b, x2 + dx, indexed) : 0;
-
-                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
-                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-                        WRITE(buffer + i, r);
-                    }
+		    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    WRITE(buffer + i, 0);
+			} else {
+			    int x1, x2, y1, y2, distx, idistx, disty, idisty;
+			    FbBits *b;
+			    CARD32 tl, tr, bl, br, r;
+			    CARD32 ft, fb;
+
+			    if (!affine) {
+				xFixed_48_16 div;
+				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+				x1 = div >> 16;
+				distx = ((xFixed)div >> 8) & 0xff;
+				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+				y1 = div >> 16;
+				disty = ((xFixed)div >> 8) & 0xff;
+			    } else {
+				x1 = v.vector[0] >> 16;
+				distx = (v.vector[0] >> 8) & 0xff;
+				y1 = v.vector[1] >> 16;
+				disty = (v.vector[1] >> 8) & 0xff;
+			    }
+			    x2 = x1 + 1;
+			    y2 = y1 + 1;
+
+			    idistx = 256 - distx;
+			    idisty = 256 - disty;
+
+			    x1 = MOD (x1, pict->pDrawable->width);
+			    x2 = MOD (x2, pict->pDrawable->width);
+			    y1 = MOD (y1, pict->pDrawable->height);
+			    y2 = MOD (y2, pict->pDrawable->height);
+
+			    b = bits + (y1 + dy)*stride;
+
+			    tl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y1 + dy, &box)
+				? fetch(b, x1 + dx, indexed) : 0;
+			    tr = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y1 + dy, &box)
+				? fetch(b, x2 + dx, indexed) : 0;
+			    b = bits + (y2 + dy)*stride;
+			    bl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y2 + dy, &box)
+				? fetch(b, x1 + dx, indexed) : 0;
+			    br = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y2 + dy, &box)
+				? fetch(b, x2 + dx, indexed) : 0;
+
+			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
+			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+			    WRITE(buffer + i, r);
+			}
+		    }
+
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
@@ -3164,124 +3344,132 @@ static void fbFetchTransformed(PicturePt
             if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 box = pict->pCompositeClip->extents;
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
-                        FbBits *b;
-                        CARD32 tl, tr, bl, br, r;
-                        Bool x1_out, x2_out, y1_out, y2_out;
-                        CARD32 ft, fb;
-
-                        if (!affine) {
-                            xFixed_48_16 div;
-                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                            x1 = div >> 16;
-                            distx = ((xFixed)div >> 8) & 0xff;
-                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                            y1 = div >> 16;
-                            disty = ((xFixed)div >> 8) & 0xff;
-                        } else {
-                            x1 = v.vector[0] >> 16;
-                            distx = (v.vector[0] >> 8) & 0xff;
-                            y1 = v.vector[1] >> 16;
-                            disty = (v.vector[1] >> 8) & 0xff;
-                        }
-                        x2 = x1 + 1;
-                        y2 = y1 + 1;
-
-                        idistx = 256 - distx;
-                        idisty = 256 - disty;
-
-                        b = bits + (y1 + dy)*stride;
-                        x_off = x1 + dx;
-
-                        x1_out = (x1 < box.x1-dx) | (x1 >= box.x2-dx);
-                        x2_out = (x2 < box.x1-dx) | (x2 >= box.x2-dx);
-                        y1_out = (y1 < box.y1-dy) | (y1 >= box.y2-dy);
-                        y2_out = (y2 < box.y1-dy) | (y2 >= box.y2-dy);
-
-                        tl = x1_out|y1_out ? 0 : fetch(b, x_off, indexed);
-                        tr = x2_out|y1_out ? 0 : fetch(b, x_off + 1, indexed);
-                        b += stride;
-                        bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed);
-                        br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed);
-
-                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
-                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-                        WRITE(buffer + i, r);
-                    }
+		    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    WRITE(buffer + i, 0);
+			} else {
+			    int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+			    FbBits *b;
+			    CARD32 tl, tr, bl, br, r;
+			    Bool x1_out, x2_out, y1_out, y2_out;
+			    CARD32 ft, fb;
+
+			    if (!affine) {
+				xFixed_48_16 div;
+				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+				x1 = div >> 16;
+				distx = ((xFixed)div >> 8) & 0xff;
+				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+				y1 = div >> 16;
+				disty = ((xFixed)div >> 8) & 0xff;
+			    } else {
+				x1 = v.vector[0] >> 16;
+				distx = (v.vector[0] >> 8) & 0xff;
+				y1 = v.vector[1] >> 16;
+				disty = (v.vector[1] >> 8) & 0xff;
+			    }
+			    x2 = x1 + 1;
+			    y2 = y1 + 1;
+
+			    idistx = 256 - distx;
+			    idisty = 256 - disty;
+
+			    b = bits + (y1 + dy)*stride;
+			    x_off = x1 + dx;
+
+			    x1_out = (x1 < box.x1-dx) | (x1 >= box.x2-dx);
+			    x2_out = (x2 < box.x1-dx) | (x2 >= box.x2-dx);
+			    y1_out = (y1 < box.y1-dy) | (y1 >= box.y2-dy);
+			    y2_out = (y2 < box.y1-dy) | (y2 >= box.y2-dy);
+
+			    tl = x1_out|y1_out ? 0 : fetch(b, x_off, indexed);
+			    tr = x2_out|y1_out ? 0 : fetch(b, x_off + 1, indexed);
+			    b += stride;
+			    bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed);
+			    br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed);
+
+			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
+			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+			    WRITE(buffer + i, r);
+			}
+		    }
+
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
                 }
             } else {
                 for (i = 0; i < width; ++i) {
-                    if (!v.vector[2]) {
-                        WRITE(buffer + i, 0);
-                    } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
-                        FbBits *b;
-                        CARD32 tl, tr, bl, br, r;
-                        CARD32 ft, fb;
-
-                        if (!affine) {
-                            xFixed_48_16 div;
-                            div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
-                            x1 = div >> 16;
-                            distx = ((xFixed)div >> 8) & 0xff;
-                            div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
-                            y1 = div >> 16;
-                            disty = ((xFixed)div >> 8) & 0xff;
-                        } else {
-                            x1 = v.vector[0] >> 16;
-                            distx = (v.vector[0] >> 8) & 0xff;
-                            y1 = v.vector[1] >> 16;
-                            disty = (v.vector[1] >> 8) & 0xff;
-                        }
-                        x2 = x1 + 1;
-                        y2 = y1 + 1;
-
-                        idistx = 256 - distx;
-                        idisty = 256 - disty;
-
-                        b = bits + (y1 + dy)*stride;
-                        x_off = x1 + dx;
-
-                        tl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y1 + dy, &box)
-                             ? fetch(b, x_off, indexed) : 0;
-                        tr = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y1 + dy, &box)
-                             ? fetch(b, x_off + 1, indexed) : 0;
-                        b += stride;
-                        bl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y2 + dy, &box)
-                             ? fetch(b, x_off, indexed) : 0;
-                        br = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y2 + dy, &box)
-                             ? fetch(b, x_off + 1, indexed) : 0;
-
-                        ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
-                        fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
-                        r = (((ft * idisty + fb * disty) >> 16) & 0xff);
-                        ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
-                        fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
-                        r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
-                        ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
-                        fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
-                        r |= (((ft * idisty + fb * disty)) & 0xff0000);
-                        ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
-                        fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
-                        r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
-                        WRITE(buffer + i, r);
-                    }
+                    if (!mask || mask[i] & maskBits)
+		    {
+			if (!v.vector[2]) {
+			    WRITE(buffer + i, 0);
+			} else {
+			    int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+			    FbBits *b;
+			    CARD32 tl, tr, bl, br, r;
+			    CARD32 ft, fb;
+
+			    if (!affine) {
+				xFixed_48_16 div;
+				div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+				x1 = div >> 16;
+				distx = ((xFixed)div >> 8) & 0xff;
+				div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+				y1 = div >> 16;
+				disty = ((xFixed)div >> 8) & 0xff;
+			    } else {
+				x1 = v.vector[0] >> 16;
+				distx = (v.vector[0] >> 8) & 0xff;
+				y1 = v.vector[1] >> 16;
+				disty = (v.vector[1] >> 8) & 0xff;
+			    }
+			    x2 = x1 + 1;
+			    y2 = y1 + 1;
+
+			    idistx = 256 - distx;
+			    idisty = 256 - disty;
+
+			    b = bits + (y1 + dy)*stride;
+			    x_off = x1 + dx;
+
+			    tl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y1 + dy, &box)
+				? fetch(b, x_off, indexed) : 0;
+			    tr = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y1 + dy, &box)
+				? fetch(b, x_off + 1, indexed) : 0;
+			    b += stride;
+			    bl = POINT_IN_REGION(0, pict->pCompositeClip, x1 + dx, y2 + dy, &box)
+				? fetch(b, x_off, indexed) : 0;
+			    br = POINT_IN_REGION(0, pict->pCompositeClip, x2 + dx, y2 + dy, &box)
+				? fetch(b, x_off + 1, indexed) : 0;
+
+			    ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+			    fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+			    r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+			    ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+			    fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+			    r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+			    ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+			    fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+			    r |= (((ft * idisty + fb * disty)) & 0xff0000);
+			    ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+			    fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+			    r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+			    WRITE(buffer + i, r);
+			}
+		    }
+
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
                     v.vector[2] += unit.vector[2];
@@ -3296,62 +3484,65 @@ static void fbFetchTransformed(PicturePt
 	int yoff = (params[1] - xFixed1) >> 1;
         params += 2;
         for (i = 0; i < width; ++i) {
-            if (!v.vector[2]) {
-                WRITE(buffer + i, 0);
-            } else {
-                int x1, x2, y1, y2, x, y;
-                INT32 srtot, sgtot, sbtot, satot;
-                xFixed *p = params;
-
-                if (!affine) {
-                    xFixed_48_16 tmp;
-                    tmp = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2] - xoff;
-                    x1 = xFixedToInt(tmp);
-                    tmp = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2] - yoff;
-                    y1 = xFixedToInt(tmp);
-                } else {
-                    x1 = xFixedToInt(v.vector[0] - xoff);
-                    y1 = xFixedToInt(v.vector[1] - yoff);
-                }
-                x2 = x1 + cwidth;
-                y2 = y1 + cheight;
-
-                srtot = sgtot = sbtot = satot = 0;
-
-                for (y = y1; y < y2; y++) {
-                    int ty = (pict->repeatType == RepeatNormal) ? MOD (y, pict->pDrawable->height) : y;
-                    for (x = x1; x < x2; x++) {
-                        if (*p) {
-                            int tx = (pict->repeatType == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x;
-                            if (POINT_IN_REGION (0, pict->pCompositeClip, tx + dx, ty + dy, &box)) {
-                                FbBits *b = bits + (ty + dy)*stride;
-                                CARD32 c = fetch(b, tx + dx, indexed);
-
-                                srtot += Red(c) * *p;
-                                sgtot += Green(c) * *p;
-                                sbtot += Blue(c) * *p;
-                                satot += Alpha(c) * *p;
-                            }
-                        }
-                        p++;
-                    }
-                }
-
-		satot >>= 16;
-		srtot >>= 16;
-		sgtot >>= 16;
-		sbtot >>= 16;
-
-                if (satot < 0) satot = 0; else if (satot > 0xff) satot = 0xff;
-                if (srtot < 0) srtot = 0; else if (srtot > 0xff) srtot = 0xff;
-                if (sgtot < 0) sgtot = 0; else if (sgtot > 0xff) sgtot = 0xff;
-                if (sbtot < 0) sbtot = 0; else if (sbtot > 0xff) sbtot = 0xff;
-
-                WRITE(buffer + i, ((satot << 24) |
-                                  (srtot << 16) |
-                                  (sgtot <<  8) |
-                                  (sbtot       )));
-            }
+	    if (!mask || mask[i] & maskBits)
+	    {
+		if (!v.vector[2]) {
+		    WRITE(buffer + i, 0);
+		} else {
+		    int x1, x2, y1, y2, x, y;
+		    INT32 srtot, sgtot, sbtot, satot;
+		    xFixed *p = params;
+
+		    if (!affine) {
+			xFixed_48_16 tmp;
+			tmp = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2] - xoff;
+			x1 = xFixedToInt(tmp);
+			tmp = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2] - yoff;
+			y1 = xFixedToInt(tmp);
+		    } else {
+			x1 = xFixedToInt(v.vector[0] - xoff);
+			y1 = xFixedToInt(v.vector[1] - yoff);
+		    }
+		    x2 = x1 + cwidth;
+		    y2 = y1 + cheight;
+
+		    srtot = sgtot = sbtot = satot = 0;
+
+		    for (y = y1; y < y2; y++) {
+			int ty = (pict->repeatType == RepeatNormal) ? MOD (y, pict->pDrawable->height) : y;
+			for (x = x1; x < x2; x++) {
+			    if (*p) {
+				int tx = (pict->repeatType == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x;
+				if (POINT_IN_REGION (0, pict->pCompositeClip, tx + dx, ty + dy, &box)) {
+				    FbBits *b = bits + (ty + dy)*stride;
+				    CARD32 c = fetch(b, tx + dx, indexed);
+
+				    srtot += Red(c) * *p;
+				    sgtot += Green(c) * *p;
+				    sbtot += Blue(c) * *p;
+				    satot += Alpha(c) * *p;
+				}
+			    }
+			    p++;
+			}
+		    }
+
+		    satot >>= 16;
+		    srtot >>= 16;
+		    sgtot >>= 16;
+		    sbtot >>= 16;
+
+		    if (satot < 0) satot = 0; else if (satot > 0xff) satot = 0xff;
+		    if (srtot < 0) srtot = 0; else if (srtot > 0xff) srtot = 0xff;
+		    if (sgtot < 0) sgtot = 0; else if (sgtot > 0xff) sgtot = 0xff;
+		    if (sbtot < 0) sbtot = 0; else if (sbtot > 0xff) sbtot = 0xff;
+
+		    WRITE(buffer + i, ((satot << 24) |
+				       (srtot << 16) |
+				       (sgtot <<  8) |
+				       (sbtot       )));
+		}
+	    }
             v.vector[0] += unit.vector[0];
             v.vector[1] += unit.vector[1];
             v.vector[2] += unit.vector[2];
@@ -3362,27 +3553,32 @@ static void fbFetchTransformed(PicturePt
 }
 
 
-static void fbFetchExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+static void fbFetchExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer, CARD32 *mask, CARD32 maskBits)
 {
     int i;
     CARD32 _alpha_buffer[SCANLINE_BUFFER_LENGTH];
     CARD32 *alpha_buffer = _alpha_buffer;
 
     if (!pict->alphaMap) {
-        fbFetchTransformed(pict, x, y, width, buffer);
+        fbFetchTransformed(pict, x, y, width, buffer, mask, maskBits);
 	return;
     }
     if (width > SCANLINE_BUFFER_LENGTH)
         alpha_buffer = (CARD32 *) malloc(width*sizeof(CARD32));
 
-    fbFetchTransformed(pict, x, y, width, buffer);
-    fbFetchTransformed(pict->alphaMap, x - pict->alphaOrigin.x, y - pict->alphaOrigin.y, width, alpha_buffer);
+    fbFetchTransformed(pict, x, y, width, buffer, mask, maskBits);
+    fbFetchTransformed(pict->alphaMap, x - pict->alphaOrigin.x,
+		       y - pict->alphaOrigin.y, width, alpha_buffer,
+		       mask, maskBits);
     for (i = 0; i < width; ++i) {
-        int a = alpha_buffer[i]>>24;
-        WRITE(buffer + i, (a << 24)
-                          | (div_255(Red(READ(buffer + i)) * a) << 16)
-                          | (div_255(Green(READ(buffer + i)) * a) << 8)
-                          | (div_255(Blue(READ(buffer + i)) * a)));
+        if (!mask || mask[i] & maskBits)
+	{
+	    int a = alpha_buffer[i]>>24;
+	    WRITE(buffer + i, (a << 24)
+		  | (div_255(Red(READ(buffer + i)) * a) << 16)
+		  | (div_255(Green(READ(buffer + i)) * a) << 8)
+		  | (div_255(Blue(READ(buffer + i)) * a)));
+	}
     }
 
     if (alpha_buffer != _alpha_buffer)
@@ -3450,7 +3646,7 @@ static void fbStoreExternalAlpha(Picture
 }
 
 typedef void (*scanStoreProc)(PicturePtr , int , int , int , CARD32 *);
-typedef void (*scanFetchProc)(PicturePtr , int , int , int , CARD32 *);
+typedef void (*scanFetchProc)(PicturePtr , int , int , int , CARD32 * , CARD32 *, CARD32);
 
 static void
 fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer)
@@ -3460,31 +3656,52 @@ fbCompositeRect (const FbComposeData *da
     int i;
     scanStoreProc store;
     scanFetchProc fetchSrc = NULL, fetchMask = NULL, fetchDest = NULL;
-
+    unsigned int srcClass = SourcePictClassUnknown;
+    unsigned int maskClass = SourcePictClassUnknown;
+    FbBits *bits;
+    FbStride stride;
+    int xoff, yoff;
+    
     if (data->op == PictOpClear)
         fetchSrc = NULL;
     else if (!data->src->pDrawable) {
         if (data->src->pSourcePict)
+	{
             fetchSrc = fbFetchSourcePict;
+	    srcClass = SourcePictureClassify (data->src,
+					      data->xSrc, data->ySrc,
+					      data->width, data->height);
+	}
     } else if (data->src->alphaMap)
         fetchSrc = fbFetchExternalAlpha;
     else if (data->src->repeatType == RepeatNormal &&
              data->src->pDrawable->width == 1 && data->src->pDrawable->height == 1)
+    {
         fetchSrc = fbFetchSolid;
+	srcClass = SourcePictClassHorizontal;
+    }
     else if (!data->src->transform && data->src->filter != PictFilterConvolution)
         fetchSrc = fbFetch;
     else
         fetchSrc = fbFetchTransformed;
-
+    
     if (data->mask && data->op != PictOpClear) {
         if (!data->mask->pDrawable) {
             if (data->mask->pSourcePict)
                 fetchMask = fbFetchSourcePict;
         } else if (data->mask->alphaMap)
+	{
             fetchMask = fbFetchExternalAlpha;
+	    maskClass = SourcePictureClassify (data->mask,
+					       data->xMask, data->yMask,
+					       data->width, data->height);
+	}
         else if (data->mask->repeatType == RepeatNormal
                  && data->mask->pDrawable->width == 1 && data->mask->pDrawable->height == 1)
-            fetchMask = fbFetchSolid;
+	{
+	    fetchMask = fbFetchSolid;
+	    maskClass = SourcePictClassHorizontal;
+	}
         else if (!data->mask->transform && data->mask->filter != PictFilterConvolution)
             fetchMask = fbFetch;
         else
@@ -3492,78 +3709,206 @@ fbCompositeRect (const FbComposeData *da
     } else {
         fetchMask = NULL;
     }
-
-    if (data->dest->alphaMap) {
-        fetchDest = fbFetchExternalAlpha;
-        store = fbStoreExternalAlpha;
-    } else {
-        fetchDest = fbFetch;
-        store = fbStore;
+    
+    if (data->dest->alphaMap)
+    {
+	fetchDest = fbFetchExternalAlpha;
+	store = fbStoreExternalAlpha;
+	
+	if (data->op == PictOpClear || data->op == PictOpSrc)
+	    fetchDest = NULL;
     }
-    if (data->op == PictOpClear || data->op == PictOpSrc)
-        fetchDest = NULL;
-
-    if (fetchSrc && fetchMask && data->mask && data->mask->componentAlpha && PICT_FORMAT_RGB(data->mask->format)) {
-        CARD32 *mask_buffer = dest_buffer + data->width;
-        CombineFuncC compose = composeFunctions.combineC[data->op];
-        if (!compose)
-            return;
-
-        for (i = 0; i < data->height; ++i)
-        {
-            /* fill first half of scanline with source */
-            fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width, src_buffer);
-            fetchMask(data->mask, data->xMask, data->yMask + i, data->width, mask_buffer);
-
-            /* fill dest into second half of scanline */
-            if (fetchDest)
-                fetchDest(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
-
-            /* blend */
-            compose(dest_buffer, src_buffer, mask_buffer, data->width);
-
-            /* write back */
-            store(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
-        }
-    } else {
-
-        CombineFuncU compose = composeFunctions.combineU[data->op];
-        if (!compose)
-            return;
-
-        if (fetchSrc == fbFetchSolid && (!fetchMask || fetchMask == fbFetchSolid)) {
-            fetchSrc(data->src, data->xSrc, data->ySrc, data->width, src_buffer);
-            if (fetchMask) {
-                fetchMask(data->mask, data->xMask, data->yMask, data->width, dest_buffer);
-                composeFunctions.combineMaskU(src_buffer, dest_buffer, data->width);
-            }
-            fetchSrc = NULL;
-            fetchMask = NULL;
-        }
-
-        for (i = 0; i < data->height; ++i)
-        {
-            /* fill first half of scanline with source */
-            if (fetchSrc) {
-                fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width, src_buffer);
-
-                /* add in mask */
-                if (fetchMask) {
-                    fetchMask(data->mask, data->xMask, data->yMask + i, data->width, dest_buffer);
-                    composeFunctions.combineMaskU(src_buffer, dest_buffer, data->width);
-                }
-            }
-
-            /* fill dest into second half of scanline */
-            if (fetchDest)
-                fetchDest(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
-
-            /* blend */
-            compose(dest_buffer, src_buffer, data->width);
-
-            /* write back */
-            store(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
-        }
+    else
+    {
+	fetchDest = fbFetch;
+	store = fbStore;
+	
+	switch (data->op) {
+	case PictOpClear:
+	case PictOpSrc:
+	    fetchDest = NULL;
+	    /* fall-through */
+	case PictOpAdd:
+	case PictOpOver:
+	    switch (data->dest->format) {
+	    case PICT_a8r8g8b8:
+	    case PICT_x8r8g8b8:
+		store = NULL;
+		break;
+	    default:
+		break;
+	    }
+	    break;
+	}
+    }
+    
+    if (!store)
+    {
+	int bpp;
+	
+	fbGetDrawable (data->dest->pDrawable, bits, stride, bpp, xoff, yoff);
+    }
+    else
+    {
+	bits = NULL;
+	stride = 0;
+	xoff = yoff = 0;
+    }
+    
+    if (fetchSrc		   &&
+	fetchMask		   &&
+	data->mask		   &&
+	data->mask->componentAlpha &&
+	PICT_FORMAT_RGB (data->mask->format))
+    {
+	CARD32 *mask_buffer = dest_buffer + data->width;
+	CombineFuncC compose = composeFunctions.combineC[data->op];
+	if (!compose)
+	    return;
+	
+	for (i = 0; i < data->height; ++i) {
+	    /* fill first half of scanline with source */
+	    if (fetchSrc)
+	    {
+		if (fetchMask)
+		{
+		    /* fetch mask before source so that fetching of
+		       source can be optimized */
+		    fetchMask (data->mask, data->xMask, data->yMask + i,
+			       data->width, mask_buffer, 0, 0);
+		    
+		    if (maskClass == SourcePictClassHorizontal)
+			fetchMask = NULL;
+		}
+		
+		if (srcClass == SourcePictClassHorizontal)
+		{
+		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
+			      data->width, src_buffer, 0, 0);
+		    fetchSrc = NULL;
+		}
+		else
+		{
+		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
+			      data->width, src_buffer, mask_buffer,
+			      0xffffffff);
+		}
+	    }
+	    else if (fetchMask)
+	    {
+		fetchMask (data->mask, data->xMask, data->yMask + i,
+			   data->width, mask_buffer, 0, 0);
+	    }
+	    
+	    if (store)
+	    {
+		/* fill dest into second half of scanline */
+		if (fetchDest)
+		    fetchDest (data->dest, data->xDest, data->yDest + i,
+			       data->width, dest_buffer, 0, 0);
+		
+		/* blend */
+		compose (dest_buffer, src_buffer, mask_buffer, data->width);
+		
+		/* write back */
+		store (data->dest, data->xDest, data->yDest + i, data->width,
+		       dest_buffer);
+	    }
+	    else
+	    {
+		/* blend */
+		compose (bits + (data->yDest + i+ yoff) * stride +
+			 data->xDest + xoff,
+			 src_buffer, mask_buffer, data->width);
+	    }
+	}
+    }
+    else
+    {
+	CARD32 *src_mask_buffer = 0, *mask_buffer = 0;
+	CombineFuncU compose = composeFunctions.combineU[data->op];
+	if (!compose)
+	    return;
+	
+	if (fetchMask)
+	    mask_buffer = dest_buffer + data->width;
+	
+	for (i = 0; i < data->height; ++i) {
+	    /* fill first half of scanline with source */
+	    if (fetchSrc)
+	    {
+		if (fetchMask)
+		{
+		    /* fetch mask before source so that fetching of
+		       source can be optimized */
+		    fetchMask (data->mask, data->xMask, data->yMask + i,
+			       data->width, mask_buffer, 0, 0);
+		    
+		    if (maskClass == SourcePictClassHorizontal)
+			fetchMask = NULL;
+		}
+		
+		if (srcClass == SourcePictClassHorizontal)
+		{
+		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
+			      data->width, src_buffer, 0, 0);
+		    
+		    if (mask_buffer)
+		    {
+			fbCombineInU (mask_buffer, src_buffer, data->width);
+			src_mask_buffer = mask_buffer;
+		    }
+		    else
+			src_mask_buffer = src_buffer;
+		    
+		    fetchSrc = NULL;
+		}
+		else
+		{
+		    fetchSrc (data->src, data->xSrc, data->ySrc + i,
+			      data->width, src_buffer, mask_buffer,
+			      0xff000000);
+		    
+		    if (mask_buffer)
+			composeFunctions.combineMaskU (src_buffer,
+						       mask_buffer,
+						       data->width);
+		    
+		    src_mask_buffer = src_buffer;
+		}
+	    }
+	    else if (fetchMask)
+	    {
+		fetchMask (data->mask, data->xMask, data->yMask + i,
+			   data->width, mask_buffer, 0, 0);
+		
+		fbCombineInU (mask_buffer, src_buffer, data->width);
+		
+		src_mask_buffer = mask_buffer;
+	    }
+	    
+	    if (store)
+	    {
+		/* fill dest into second half of scanline */
+		if (fetchDest)
+		    fetchDest (data->dest, data->xDest, data->yDest + i,
+			       data->width, dest_buffer, 0, 0);
+		
+		/* blend */
+		compose (dest_buffer, src_mask_buffer, data->width);
+		
+		/* write back */
+		store (data->dest, data->xDest, data->yDest + i, data->width,
+		       dest_buffer);
+	    }
+	    else
+	    {
+		/* blend */
+		compose (bits + (data->yDest + i+ yoff) * stride +
+			 data->xDest + xoff,
+			 src_mask_buffer, data->width);
+	    }
+	}
     }
 }
 
@@ -3593,11 +3938,11 @@ fbCompositeGeneral (CARD8	op,
     
     if (pSrc->pDrawable)
         srcRepeat = pSrc->repeatType == RepeatNormal && !pSrc->transform
-                    && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1);
+	    && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1);
 
     if (pMask && pMask->pDrawable)
 	maskRepeat = pMask->repeatType == RepeatNormal && !pMask->transform
-                     && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1);
+	    && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1);
 
     if (op == PictOpOver && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format) && !pSrc->alphaMap)
         op = PictOpSrc;
@@ -3614,7 +3959,7 @@ fbCompositeGeneral (CARD8	op,
 				   yDst,
 				   width,
 				   height))
-	    return;
+	return;
 
     compose_data.op = op;
     compose_data.src = pSrc;
@@ -3675,7 +4020,7 @@ fbCompositeGeneral (CARD8	op,
 	    compose_data.ySrc += compose_data.height;
 	    compose_data.yMask += compose_data.height;
 	    compose_data.yDest += compose_data.height;
-    }
+	}
 	pbox++;
     }
     REGION_UNINIT (pDst->pDrawable->pScreen, &region);
diff --git a/render/picture.c b/render/picture.c
index c30649c..3f64182 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -890,54 +890,22 @@ static unsigned int INTERPOLATE_PIXEL_25
     return x;
 }
 
-static void initGradientColorTable(SourcePictPtr pGradient, int *error)
-{
-    int begin_pos, end_pos;
-    xFixed incr, dpos;
-    int pos, current_stop;
-    PictGradientStopPtr stops = pGradient->linear.stops;
-    int nstops = pGradient->linear.nstops;
-
-    /* The position where the gradient begins and ends */
-    begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
-    end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
-
-    pos = 0; /* The position in the color table. */
-
-    /* Up to first point */
-    while (pos <= begin_pos) {
-        pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color);
-        ++pos;
-    }
-
-    incr =  (1<<16)/ PICT_GRADIENT_STOPTABLE_SIZE; /* the double increment. */
-    dpos = incr * pos; /* The position in terms of 0-1. */
-
-    current_stop = 0; /* We always interpolate between current and current + 1. */
-
-    /* Gradient area */
-    while (pos < end_pos) {
-        unsigned int current_color = xRenderColorToCard32(stops[current_stop].color);
-        unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color);
+CARD32
+PictureGradientColor (PictGradientStopPtr stop1,
+		      PictGradientStopPtr stop2,
+		      CARD32	          x)
+{
+     CARD32 current_color, next_color;
+     int	   dist, idist;
 
-        int dist = (int)(256*(dpos - stops[current_stop].x)
-                         / (stops[current_stop+1].x - stops[current_stop].x));
-        int idist = 256 - dist;
+     current_color = xRenderColorToCard32 (stop1->color);
+     next_color    = xRenderColorToCard32 (stop2->color);
 
-        pGradient->linear.colorTable[pos] = premultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist));
+     dist  = (int) (256 * (x - stop1->x) / (stop2->x - stop1->x));
+     idist = 256 - dist;
 
-        ++pos;
-        dpos += incr;
-
-        if (dpos > stops[current_stop + 1].x)
-            ++current_stop;
-    }
-
-    /* After last point */
-    while (pos < PICT_GRADIENT_STOPTABLE_SIZE) {
-        pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color);
-        ++pos;
-    }
+     return premultiply (INTERPOLATE_PIXEL_256 (current_color, idist,
+					       next_color, dist));
 }
 
 static void initGradient(SourcePictPtr pGradient, int stopCount,
@@ -953,26 +921,30 @@ static void initGradient(SourcePictPtr p
 
     dpos = -1;
     for (i = 0; i < stopCount; ++i) {
-        if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) {
+        if (stopPoints[i] < dpos || stopPoints[i] > (1<<16)) {
             *error = BadValue;
             return;
         }
         dpos = stopPoints[i];
     }
 
-    pGradient->linear.stops = xalloc(stopCount*sizeof(PictGradientStop));
-    if (!pGradient->linear.stops) {
+    pGradient->gradient.stops = xalloc(stopCount*sizeof(PictGradientStop));
+    if (!pGradient->gradient.stops) {
         *error = BadAlloc;
         return;
     }
 
-    pGradient->linear.nstops = stopCount;
+    pGradient->gradient.nstops = stopCount;
 
     for (i = 0; i < stopCount; ++i) {
-        pGradient->linear.stops[i].x = stopPoints[i];
-        pGradient->linear.stops[i].color = stopColors[i];
+        pGradient->gradient.stops[i].x = stopPoints[i];
+        pGradient->gradient.stops[i].color = stopColors[i];
     }
-    initGradientColorTable(pGradient, error);
+
+    pGradient->gradient.class	       = SourcePictClassUnknown;
+    pGradient->gradient.stopRange      = 0xffff;
+    pGradient->gradient.colorTable     = NULL;
+    pGradient->gradient.colorTableSize = 0;
 }
 
 static PicturePtr createSourcePicture(void)
@@ -980,9 +952,9 @@ static PicturePtr createSourcePicture(vo
     PicturePtr pPicture;
     pPicture = (PicturePtr) xalloc(sizeof(PictureRec));
     pPicture->pDrawable = 0;
-    pPicture->format = PICT_a8r8g8b8;
     pPicture->pFormat = 0;
     pPicture->pNext = 0;
+    pPicture->format = PICT_a8r8g8b8;
     pPicture->devPrivates = 0;
 
     SetPictureToDefaults(pPicture);
@@ -1027,10 +999,6 @@ CreateLinearGradientPicture (Picture pid
         *error = BadAlloc;
         return 0;
     }
-    if (p1->x == p2->x && p1->y == p2->y) {
-        *error = BadValue;
-        return 0;
-    }
 
     pPicture->id = pid;
     pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient));
@@ -1072,14 +1040,6 @@ CreateRadialGradientPicture (Picture pid
         *error = BadAlloc;
         return 0;
     }
-    {
-        double dx = (double)(inner->x - outer->x);
-        double dy = (double)(inner->y - outer->y);
-        if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) {
-            *error = BadValue;
-            return 0;
-        }
-    }
 
     pPicture->id = pid;
     pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient));
@@ -1627,13 +1587,17 @@ FreePicture (pointer	value,
     {
 	if (pPicture->transform)
 	    xfree (pPicture->transform);
-        if (!pPicture->pDrawable) {
-            if (pPicture->pSourcePict) {
-                if (pPicture->pSourcePict->type != SourcePictTypeSolidFill)
-                    xfree(pPicture->pSourcePict->linear.stops);
-                xfree(pPicture->pSourcePict);
-            }
-        } else {
+
+	if (pPicture->pSourcePict)
+	{
+	    if (pPicture->pSourcePict->type != SourcePictTypeSolidFill)
+		xfree(pPicture->pSourcePict->linear.stops);
+
+	    xfree(pPicture->pSourcePict);
+	}
+
+	if (pPicture->pDrawable)
+	{
             ScreenPtr	    pScreen = pPicture->pDrawable->pScreen;
             PictureScreenPtr    ps = GetPictureScreen(pScreen);
 	
diff --git a/render/picturestr.h b/render/picturestr.h
index f1617f6..3f3c600 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -68,8 +68,13 @@ typedef struct _PictTransform {
 #define SourcePictTypeRadial 2
 #define SourcePictTypeConical 3
 
+#define SourcePictClassUnknown    0
+#define SourcePictClassHorizontal 1
+#define SourcePictClassVertical   2
+
 typedef struct _PictSolidFill {
     unsigned int type;
+    unsigned int class;
     CARD32 color;
 } PictSolidFill, *PictSolidFillPtr;
 
@@ -80,16 +85,22 @@ typedef struct _PictGradientStop {
 
 typedef struct _PictGradient {
     unsigned int type;
+    unsigned int class;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+    int stopRange;
+    CARD32 *colorTable;
+    int colorTableSize;
 } PictGradient, *PictGradientPtr;
 
 typedef struct _PictLinearGradient {
     unsigned int type;
+    unsigned int class;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+    int stopRange;
+    CARD32 *colorTable;
+    int colorTableSize;
     xPointFixed p1;
     xPointFixed p2;
 } PictLinearGradient, *PictLinearGradientPtr;
@@ -98,7 +109,6 @@ typedef struct _PictRadialGradient {
     unsigned int type;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
     double fx;
     double fy;
     double dx;
@@ -110,9 +120,12 @@ typedef struct _PictRadialGradient {
 
 typedef struct _PictConicalGradient {
     unsigned int type;
+    unsigned int class;
     int nstops;
     PictGradientStopPtr stops;
-    CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+    int stopRange;
+    CARD32 *colorTable;
+    int colorTableSize;
     xPointFixed center;
     xFixed angle;
 } PictConicalGradient, *PictConicalGradientPtr;
@@ -624,6 +637,11 @@ Bool
 PictureTransformPoint3d (PictTransformPtr transform,
                          PictVectorPtr	vector);
 
+CARD32
+PictureGradientColor (PictGradientStopPtr stop1,
+		      PictGradientStopPtr stop2,
+		      CARD32	          x);
+
 void RenderExtensionInit (void);
 
 Bool
diff-tree d0e55774e0da641ba85c5173f27f68de27372747 (from e1f0b3e70b696d7ea4cf9e6ed30d751e7fdbc577)
Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date:   Thu Apr 19 11:39:53 2007 +0200

    libdri: Make sure the new DRIInfo keepFDOpen member is honoured.

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 35da8a6..355d281 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -473,6 +473,9 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
     pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount;
     pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext;
 
+    if (!pDRIEntPriv->keepFDOpen)
+	pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen;
+
     pDRIEntPriv->refCount++;
 
     return TRUE;
diff-tree e1f0b3e70b696d7ea4cf9e6ed30d751e7fdbc577 (from c6972c893359f8fa7631ae674330f3f4f7010ba0)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Apr 19 12:00:24 2007 +0930

    config: Return errors as negative numbers, device ids as positive numbers.
    Update dbus-api documentation.

diff --git a/config/config.c b/config/config.c
index 4861d9e..9b38faf 100644
--- a/config/config.c
+++ b/config/config.c
@@ -308,12 +308,15 @@ configMessage(DBusConnection *connection
 
         if (ret != BadDrawable && ret != BadAlloc) {
             if (!strlen(dbus_message_get_signature(reply)))
+            {
+                ret = -ret; /* return errors as negative numbers */
                 if (!dbus_message_iter_append_basic(&r_iter, DBUS_TYPE_INT32, &ret)) {
                     ErrorF("[config] couldn't append to iterator\n");
                     dbus_message_unref(reply);
                     dbus_error_free(&error);
                     return DBUS_HANDLER_RESULT_HANDLED;
                 }
+            }
 
             if (!dbus_connection_send(bus, reply, NULL))
                 ErrorF("[config] failed to send reply\n");
diff --git a/config/dbus-api b/config/dbus-api
index cada792..654c22b 100644
--- a/config/dbus-api
+++ b/config/dbus-api
@@ -15,25 +15,23 @@ org.x.config.input:
         Option names beginning with _ are not allowed; they are reserved
         for internal use.
 
-        Returns one int32, which is an X Status, as defined in X.h.  If
-        everything is successful, Success will be returned.  BadMatch will
-        be returned if the options given do not match any device.  BadValue
-        is returned for a malformed message.
+        Returns one signed int32, which is the device id of the new device.
+        If the return value is a negative number, it represents the X
+        Status, as defined in X.h. BadMatch will be returned if the options
+        given do not match any device.  BadValue is returned for a malformed
+        message.  (Example: 8 is new device id 8. -8 is BadMatch.)
 
         Notably, BadAlloc is never returned: the server internally signals
         to D-BUS that the attempt failed for lack of memory.
 
-        The return does not notify the client of which devices were created
-        or modified as a result of this request: clients are encouraged to
-        listen for the XInput DevicePresenceNotify event to monitor changes
-        in the device list.
-
     org.x.config.input.remove:
         Takes one int32 argument, which is the device ID to remove, i.e.:
          i
         is the signature.
-        Same return values as org.x.config.input.add.
+
+        Returns one signed int32 which represents an X status as defined in
+        X.h. See org.x.config.input.add. Error codes are negative numbers.
 
     org.x.config.input.listDevices:
-        Lists the currently active devices.
+        Lists the currently active devices. No argument. 
         Return value is sequence of <id> <name> <id> <name> ...
diff-tree c6972c893359f8fa7631ae674330f3f4f7010ba0 (from 999b681cf3973af4191506e49cde06963b11a774)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Apr 18 12:10:05 2007 +0930

    Change dbus 'listDevices' call to not require an argument.
    Update dbus-api documentation, plug memory leak on dbus reply error.

diff --git a/config/config.c b/config/config.c
index 9828091..4861d9e 100644
--- a/config/config.c
+++ b/config/config.c
@@ -280,11 +280,6 @@ configMessage(DBusConnection *connection
 
     if (strcmp(dbus_message_get_interface(message),
                "org.x.config.input") == 0) {
-        if (!dbus_message_iter_init(message, &iter)) {
-            ErrorF("[config] failed to init iterator\n");
-            dbus_error_free(&error);
-            return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
-        }
 
         if (!(reply = dbus_message_new_method_return(message))) {
             ErrorF("[config] failed to create the reply message\n");
@@ -292,18 +287,30 @@ configMessage(DBusConnection *connection
             return DBUS_HANDLER_RESULT_NEED_MEMORY;
         }
         dbus_message_iter_init_append(reply, &r_iter);
-        
-        if (strcmp(dbus_message_get_member(message), "add") == 0)
-            ret = configAddDevice(message, &iter, reply, &r_iter, &error);
-        else if (strcmp(dbus_message_get_member(message), "remove") == 0)
-            ret = configRemoveDevice(message, &iter, &error);
-        else if (strcmp(dbus_message_get_member(message), "listDevices") == 0)
-            ret = configListDevices(message, &iter, reply, &r_iter, &error);
-        if (ret != BadDrawable && ret != BadAlloc) {
 
+        /* listDevices doesn't take any arguments */
+        if (strcmp(dbus_message_get_member(message), "listDevices") == 0)
+            ret = configListDevices(message, NULL, reply, &r_iter, &error);
+        else 
+        {
+            if (!dbus_message_iter_init(message, &iter)) {
+                ErrorF("[config] failed to init iterator\n");
+                dbus_message_unref(reply);
+                dbus_error_free(&error);
+                return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
+            }
+
+            if (strcmp(dbus_message_get_member(message), "add") == 0)
+                ret = configAddDevice(message, &iter, reply, &r_iter, &error);
+            else if (strcmp(dbus_message_get_member(message), "remove") == 0)
+                ret = configRemoveDevice(message, &iter, &error);
+        }
+
+        if (ret != BadDrawable && ret != BadAlloc) {
             if (!strlen(dbus_message_get_signature(reply)))
                 if (!dbus_message_iter_append_basic(&r_iter, DBUS_TYPE_INT32, &ret)) {
                     ErrorF("[config] couldn't append to iterator\n");
+                    dbus_message_unref(reply);
                     dbus_error_free(&error);
                     return DBUS_HANDLER_RESULT_HANDLED;
                 }
diff --git a/config/dbus-api b/config/dbus-api
index 53bb3e4..cada792 100644
--- a/config/dbus-api
+++ b/config/dbus-api
@@ -33,3 +33,7 @@ org.x.config.input:
          i
         is the signature.
         Same return values as org.x.config.input.add.
+
+    org.x.config.input.listDevices:
+        Lists the currently active devices.
+        Return value is sequence of <id> <name> <id> <name> ...
diff-tree 999b681cf3973af4191506e49cde06963b11a774 (from 28bb34eec63bf3c98f38ba7fc044f6419aaa3307)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Apr 18 14:33:27 2007 -0700

    Suppress software cursor removal during rotated shadow buffer drawing.

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index e8fafd0..5127c15 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -39,6 +39,7 @@
 #include "xf86Crtc.h"
 #include "xf86Modes.h"
 #include "xf86RandR12.h"
+#include "misprite.h"
 #include "X11/extensions/render.h"
 #define DPMS_SERVER
 #include "X11/extensions/dpms.h"
@@ -279,7 +280,11 @@ xf86RotateRedisplay(ScreenPtr pScreen)
     if (REGION_NOTEMPTY(pScreen, region)) 
     {
 	int		    c;
-	
+
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(7,2,0,0,dummy)
+	/* Disable software cursor removal for this drawing */
+	miSpriteDrawInternal(pScreen, TRUE);
+#endif
 	for (c = 0; c < xf86_config->num_crtc; c++)
 	{
 	    xf86CrtcPtr	    crtc = xf86_config->crtc[c];
@@ -304,6 +309,9 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 		REGION_UNINIT (pScreen, &crtc_damage);
 	    }
 	}
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(7,2,0,0,dummy)
+	miSpriteDrawInternal(pScreen, FALSE);
+#endif
 	DamageEmpty(damage);
     }
 }
diff --git a/mi/misprite.c b/mi/misprite.c
index c0560a4..71e6ab0 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -288,7 +288,8 @@ miSpriteGetImage (pDrawable, sx, sy, w, 
 
     pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
 
-    if (pDrawable->type == DRAWABLE_WINDOW &&
+    if (pScreenPriv->internalDraw == 0 &&
+	pDrawable->type == DRAWABLE_WINDOW &&
         pScreenPriv->isUp &&
 	ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h))
     {
@@ -318,7 +319,8 @@ miSpriteGetSpans (pDrawable, wMax, ppt, 
 
     pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
 
-    if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp)
+    if (pScreenPriv->internalDraw == 0 &&
+	pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp)
     {
 	DDXPointPtr    	pts;
 	int    		*widths;
@@ -360,7 +362,8 @@ miSpriteSourceValidate (pDrawable, x, y,
 
     pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
 
-    if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp &&
+    if (pScreenPriv->internalDraw == 0 &&
+	pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp &&
 	ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y,
 		    x, y, width, height))
     {
@@ -386,7 +389,8 @@ miSpriteCopyWindow (WindowPtr pWindow, D
     /*
      * Damage will take care of destination check
      */
-    if (pScreenPriv->isUp &&
+    if (pScreenPriv->internalDraw == 0 &&
+	pScreenPriv->isUp &&
 	RECT_IN_REGION (pScreen, prgnSrc, &pScreenPriv->saved) != rgnOUT)
     {
 	SPRITE_DEBUG (("CopyWindow remove\n"));
@@ -827,3 +831,28 @@ miSpriteComputeSaved (pScreen)
     pScreenPriv->saved.x2 = pScreenPriv->saved.x1 + w + wpad * 2;
     pScreenPriv->saved.y2 = pScreenPriv->saved.y1 + h + hpad * 2;
 }
+
+/**
+ * Enables internal drawing support, which disables removal of the
+ * cursor when the screen pixmap is sourced from.
+ *
+ * This can be used to allow software cursors to be read by RandR rotation
+ * shadow code.
+ */
+void
+miSpriteDrawInternal(ScreenPtr pScreen, Bool enable)
+{
+    miSpriteScreenPtr   pScreenPriv;
+
+    /* Check that miSprite has been set up this generation */
+    if (miSpriteGeneration != serverGeneration)
+	return;
+
+    pScreenPriv = (miSpriteScreenPtr)
+	pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+    if (enable)
+	pScreenPriv->internalDraw++;
+    else
+	pScreenPriv->internalDraw--;
+}
diff --git a/mi/misprite.h b/mi/misprite.h
index 5173b77..0a1bcc1 100644
--- a/mi/misprite.h
+++ b/mi/misprite.h
@@ -92,3 +92,5 @@ extern Bool miSpriteInitialize(
     miSpriteCursorFuncPtr /*cursorFuncs*/,
     miPointerScreenFuncPtr /*screenFuncs*/
 );
+
+void miSpriteDrawInternal(ScreenPtr pScreen, Bool enable);
diff --git a/mi/mispritest.h b/mi/mispritest.h
index 5075f05..2deaa45 100644
--- a/mi/mispritest.h
+++ b/mi/mispritest.h
@@ -76,6 +76,7 @@ typedef struct {
     WindowPtr	    pCacheWin;		/* window the cursor last seen in */
     Bool	    isInCacheWin;
     Bool	    checkPixels;	/* check colormap collision */
+    int		    internalDraw;
     xColorItem	    colors[2];
     ColormapPtr	    pInstalledMap;
     ColormapPtr	    pColormap;
diff-tree 28bb34eec63bf3c98f38ba7fc044f6419aaa3307 (from 5d8e8a7f4b3226bffd9e4d6d9326688f475b0183)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Apr 18 13:48:28 2007 -0700

    Belatedly bump XORG_VERSION for 7.2.

diff --git a/configure.ac b/configure.ac
index edec92c..872f376 100644
--- a/configure.ac
+++ b/configure.ac
@@ -382,9 +382,9 @@ AC_DEFINE_UNQUOTED(OSNAME, "$OSNAME", 
 DEFAULT_VENDOR_NAME="The X.Org Foundation"
 DEFAULT_VENDOR_NAME_SHORT="X.Org"
 DEFAULT_VERSION_MAJOR=7
-DEFAULT_VERSION_MINOR=1
-DEFAULT_VERSION_PATCH=99
-DEFAULT_VERSION_SNAP=2
+DEFAULT_VERSION_MINOR=2
+DEFAULT_VERSION_PATCH=0
+DEFAULT_VERSION_SNAP=0
 DEFAULT_RELEASE_DATE="21 December 2005"
 DEFAULT_VENDOR_WEB="http://wiki.x.org"
 
diff-tree 5d8e8a7f4b3226bffd9e4d6d9326688f475b0183 (from 53fb42e65c2b2ff58a4a324b7f05cff8a587720a)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Apr 18 13:22:26 2007 -0700

    Remove libminimi build.
    
    It appears to have been a leftover of a previous incarnation of the build
    system that didn't handle miinitext.c well.

diff --git a/configure.ac b/configure.ac
index cb8b435..edec92c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -986,7 +986,6 @@ else
 fi
 CWRAP_LIB='$(top_builddir)/os/libcwrapper.la'
 MI_LIB='$(top_builddir)/mi/libmi.la'
-MINIMI_LIB='$(top_builddir)/mi/libminimi.la'
 MI_EXT_LIB='$(top_builddir)/mi/libmiext.la'
 MI_INC='-I$(top_srcdir)/mi'
 FB_LIB='$(top_builddir)/fb/libfb.la'
diff --git a/mi/Makefile.am b/mi/Makefile.am
index 42f75ae..f262f4b 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -1,4 +1,4 @@
-noinst_LTLIBRARIES = libminimi.la libmi.la
+noinst_LTLIBRARIES = libmi.la
 
 if XORG
 sdk_HEADERS = mibank.h micmap.h miline.h mipointer.h mi.h mibstore.h \
@@ -8,8 +8,7 @@ endif
 
 AM_CFLAGS = $(DIX_CFLAGS)
 
-# libminimi is for dmx - it has different defines for miinitext.c
-libminimi_la_SOURCES = 	\
+libmi_la_SOURCES = 	\
 	cbrt.c		\
 	mi.h		\
 	miarc.c		\
@@ -70,6 +69,4 @@ libminimi_la_SOURCES = 	\
 	mizerclip.c	\
 	mizerline.c
 
-libmi_la_SOURCES = $(libminimi_la_SOURCES)
-
 INCLUDES = -I$(top_srcdir)/mfb
diff-tree 53fb42e65c2b2ff58a4a324b7f05cff8a587720a (from fc162c6cfa06f0b012743d6d79cef45cf0166229)
Author: Erik Andrén <erik.andren at gmail.com>
Date:   Tue Apr 17 21:34:47 2007 -0700

    Syncmaster 226 monitor needs 60Hz refresh (#10545).
    
    I've managed to solve my own bug (#10545) by applying the following
    patch to the xserver.
    
    Please apply.
    
    <Conspiracy mode on>
    This monitor is "Vista Certified". I wonder if this is a pure coincidence...
    <Conspiracy mode off>
    
    With kind regards
    Erik Andrén
    (cherry picked from commit a63704f14a1d97b9a00fef6fa290e74e51b9732b)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 18e42dd..46cb6c4 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -86,6 +86,11 @@ static Bool quirk_prefer_large_60 (int s
     if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
 	DDC->vendor.prod_id == 44358)
 	return TRUE;
+
+    /* Samsung SyncMaster 226BW */
+    if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
+	DDC->vendor.prod_id == 638)
+	return TRUE;
     
     return FALSE;
 }
diff-tree fc162c6cfa06f0b012743d6d79cef45cf0166229 (from c41e3bd713206c0bbd8ab8cef4c83eb7ba7e1c3c)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 16 09:55:58 2007 -0700

    Allow outputs to be explicitly enabled in config, overriding detect.
    
    Option "Enable" "True" will force the server to enable an output at startup
    time, even if the output is not connected. This also causes the default
    modes to be added for this output, allowing even sync ranges to be used to
    pick out standard modes.
    (cherry picked from commit a3d73ba2cb7e13a6d129cd88d6a7f7d756e2ced2)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 87820de..ad0f5ff 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -436,15 +436,29 @@ xf86OutputSetMonitor (xf86OutputPtr outp
 }
 
 static Bool
-xf86OutputEnabled (xf86OutputPtr    output)
+xf86OutputEnabled (xf86OutputPtr output)
 {
-    /* Check to see if this output was disabled in the config file */
-    if (xf86ReturnOptValBool (output->options, OPTION_ENABLE, TRUE) == FALSE ||
-	xf86ReturnOptValBool (output->options, OPTION_DISABLE, FALSE) == TRUE)
+    Bool    enable, disable;
+
+    /* check to see if this output was enabled in the config file */
+    if (xf86GetOptValBool (output->options, OPTION_ENABLE, &enable) && enable)
+    {
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s enabled by config file\n", output->name);
+	return TRUE;
+    }
+    /* or if this output was disabled in the config file */
+    if (xf86GetOptValBool (output->options, OPTION_DISABLE, &disable) && disable)
     {
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s disabled by config file\n", output->name);
 	return FALSE;
     }
-    return TRUE;
+    /* otherwise, enable if it is not disconnected */
+    enable = output->status != XF86OutputStatusDisconnected;
+    xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+    	    "Output %s %sconnected\n", output->name, enable ? "" : "dis");
+    return enable;
 }
 
 static Bool
@@ -1232,7 +1246,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	 */
 	output->status = (*output->funcs->detect)(output);
 
-	if (output->status == XF86OutputStatusDisconnected)
+	if (!xf86OutputEnabled (output))
 	{
 	    xf86OutputSetEDID (output, NULL);
 	    continue;
@@ -1543,8 +1557,7 @@ xf86InitialConfiguration (ScrnInfoPtr sc
 	xf86OutputPtr output = config->output[o];
 	
 	modes[o] = NULL;
-	enabled[o] = (xf86OutputEnabled (output) &&
-		      output->status != XF86OutputStatusDisconnected);
+	enabled[o] = xf86OutputEnabled (output);
     }
     
     /*
@@ -1589,8 +1602,20 @@ xf86InitialConfiguration (ScrnInfoPtr sc
     {
 	xf86OutputPtr output = config->output[o];
 	
-	if (enabled[o] && !modes[o])
-	    modes[o] = xf86ClosestMode (output, target_mode, target_rotation, width, height);
+	if (enabled[o])
+	{
+	    if (!modes[o])
+		modes[o] = xf86ClosestMode (output, target_mode,
+					    target_rotation, width, height);
+	    if (!modes[o])
+		xf86DrvMsg (scrn->scrnIndex, X_ERROR,
+			    "Output %s enabled but has no modes\n",
+			    output->name);
+	    else
+		xf86DrvMsg (scrn->scrnIndex, X_INFO,
+			    "Output %s using initial mode %s\n",
+			    output->name, modes[o]->name);
+	}
     }
 
     /*
diff-tree c41e3bd713206c0bbd8ab8cef4c83eb7ba7e1c3c (from 97a2c2579c56c304705c934f3b536473645747df)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 16 09:53:42 2007 -0700

    Use default screen monitor for one of the outputs.
    
    By default, use the screen monitor section for output 0, however, a driver
    can change which output gets the screen monitor by calling
    xf86OutputUseScreenMonitor.
    (cherry picked from commit f4a8e54caf6b9431711383a39f55a18e7fd654f4)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 7e7c7e7..87820de 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -414,10 +414,25 @@ xf86OutputSetMonitor (xf86OutputPtr outp
     xfree (option_name);
     output->conf_monitor = xf86findMonitor (monitor,
 					    xf86configptr->conf_monitor_lst);
+    /*
+     * Find the monitor section of the screen and use that
+     */
+    if (!output->conf_monitor && output->use_screen_monitor)
+	output->conf_monitor = xf86findMonitor (output->scrn->monitor->id,
+						xf86configptr->conf_monitor_lst);
     if (output->conf_monitor)
+    {
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s using monitor section %s\n",
+		    output->name, output->conf_monitor->mon_identifier);
 	xf86ProcessOptions (output->scrn->scrnIndex,
 			    output->conf_monitor->mon_option_lst,
 			    output->options);
+    }
+    else
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s has no monitor section\n",
+		    output->name);
 }
 
 static Bool
@@ -463,7 +478,7 @@ xf86OutputInitialRotation (xf86OutputPtr
 
 xf86OutputPtr
 xf86OutputCreate (ScrnInfoPtr		    scrn,
-		  const xf86OutputFuncsRec *funcs,
+		  const xf86OutputFuncsRec  *funcs,
 		  const char		    *name)
 {
     xf86OutputPtr	output, *outputs;
@@ -486,6 +501,10 @@ xf86OutputCreate (ScrnInfoPtr		    scrn,
 	strcpy (output->name, name);
     }
     output->subpixel_order = SubPixelUnknown;
+    /*
+     * Use the old per-screen monitor section for the first output
+     */
+    output->use_screen_monitor = (xf86_config->num_output == 0);
 #ifdef RANDR_12_INTERFACE
     output->randr_output = NULL;
 #endif
@@ -537,6 +556,16 @@ xf86OutputRename (xf86OutputPtr output, 
 }
 
 void
+xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor)
+{
+    if (use_screen_monitor != output->use_screen_monitor)
+    {
+	output->use_screen_monitor = use_screen_monitor;
+	xf86OutputSetMonitor (output);
+    }
+}
+
+void
 xf86OutputDestroy (xf86OutputPtr output)
 {
     ScrnInfoPtr		scrn = output->scrn;
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 030f6bf..0c019e0 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -479,6 +479,9 @@ struct _xf86Output {
     /** driver private information */
     void		*driver_private;
     
+    /** Whether to use the old per-screen Monitor config section */
+    Bool		use_screen_monitor;
+
 #ifdef RANDR_12_INTERFACE
     /**
      * RandR 1.2 output structure.
@@ -618,9 +621,12 @@ xf86CrtcInUse (xf86CrtcPtr crtc);
  * Output functions
  */
 xf86OutputPtr
-xf86OutputCreate (ScrnInfoPtr		scrn,
-		      const xf86OutputFuncsRec *funcs,
-		      const char	*name);
+xf86OutputCreate (ScrnInfoPtr		    scrn,
+		  const xf86OutputFuncsRec  *funcs,
+		  const char		    *name);
+
+void
+xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor);
 
 Bool
 xf86OutputRename (xf86OutputPtr output, const char *name);
diff-tree 97a2c2579c56c304705c934f3b536473645747df (from deda7791dfa34d0563c8d7fa2a0660ac27e6858c)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 16 09:39:47 2007 -0700

    Using wrong log level in extension to built-in message
    
    was: typo in built-in module log message
    (cherry picked from commit 00cfd1f765895b4d1b2234f3203727a8871b64b0)

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index db12da4..6a1c65e 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -869,7 +869,7 @@ doLoadModule(const char *module, const c
     for (cim = compiled_in_modules; *cim; cim++)
 	if (!strcmp (module, *cim))
 	{
-	    xf86MsgVerb(X_INFO, 3, "Module already built-in\n");
+	    xf86MsgVerb(X_INFO, 0, "Module already built-in\n");
 	    return (ModuleDescPtr) 1;
 	}
 
diff-tree deda7791dfa34d0563c8d7fa2a0660ac27e6858c (from 02d42f344ce020c9b84723671cb9c68d5c064933)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 16 11:35:22 2007 -0600

    remove sources deleted in Mesa

diff --git a/GL/mesa/tnl/Makefile.am b/GL/mesa/tnl/Makefile.am
index 84301d3..b3c8206 100644
--- a/GL/mesa/tnl/Makefile.am
+++ b/GL/mesa/tnl/Makefile.am
@@ -21,8 +21,6 @@ INCLUDES = -I at MESA_SOURCE@/include \
 nodist_libtnl_la_SOURCES = t_context.c \
                       t_draw.c \
                       t_pipeline.c \
-                      t_vb_arbprogram.c \
-                      t_vb_arbprogram_sse.c \
                       t_vb_cull.c \
                       t_vb_fog.c \
                       t_vb_light.c \
diff-tree 02d42f344ce020c9b84723671cb9c68d5c064933 (from b5823ea3e1ed5a0449d44da05165a46719dcf287)
Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date:   Mon Apr 16 17:24:53 2007 +0200

    Changes for single-entity multi-screen DRI.
    
    The entity (device) has a locking SAREA and a master file descriptor
    that optionally isn't closed between server generation.
    
    The locking SAREA contains the device hardware lock.
    Each DRI screen creates an new SAREA containing the drawable lock,
    drawable-and private info, the drawable SAREA.
    
    The first screen optionally shares its drawable SAREA with the
    device SAREA.
    
    Default is to close the master descriptor between server generations,
    and to share the drawable SAREA of the first screen with the device locking
    SAREA. Thus we should (hopefully) have full backwards compatibility.
    
    Mesa changes to support single-device multiple screens are pending.

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 7bd07c0..35da8a6 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -43,6 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include <string.h>
 #include <stdio.h>
 #include <sys/ioctl.h>
+#include <errno.h>
 
 #define NEED_REPLIES
 #define NEED_EVENTS
@@ -77,6 +78,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 extern Bool noPanoramiXExtension;
 #endif
 
+static int DRIEntPrivIndex = -1;
 static int DRIScreenPrivIndex = -1;
 static int DRIWindowPrivIndex = -1;
 static unsigned long DRIGeneration = 0;
@@ -112,18 +114,203 @@ DRIDrvMsg(int scrnIndex, MessageType typ
 }
 
 
+static void
+DRIOpenDRMCleanup(DRIEntPrivPtr pDRIEntPriv)
+{
+    if (pDRIEntPriv->pLSAREA != NULL) {
+	drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize);
+	pDRIEntPriv->pLSAREA = NULL;
+    }
+    if (pDRIEntPriv->hLSAREA != 0) {
+	drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA);
+    }
+    if (pDRIEntPriv->drmFD >= 0) {
+	drmClose(pDRIEntPriv->drmFD);
+	pDRIEntPriv->drmFD = 0;
+    }
+}
+
+int
+DRIMasterFD(ScrnInfoPtr pScrn)
+{
+    return DRI_ENT_PRIV(pScrn)->drmFD;
+}
+
+void *
+DRIMasterSareaPointer(ScrnInfoPtr pScrn)
+{
+    return DRI_ENT_PRIV(pScrn)->pLSAREA;
+}
+
+drm_handle_t
+DRIMasterSareaHandle(ScrnInfoPtr pScrn)
+{
+    return DRI_ENT_PRIV(pScrn)->hLSAREA;
+}
+
+
+Bool
+DRIOpenDRMMaster(ScrnInfoPtr pScrn,
+		 unsigned long sAreaSize,
+		 const char *busID,
+		 const char *drmDriverName)
+{
+    drmSetVersion saveSv, sv;
+    Bool drmWasAvailable;
+    DRIEntPrivPtr pDRIEntPriv;
+    DRIEntPrivRec tmp;
+    drmVersionPtr drmlibv;
+    int drmlibmajor, drmlibminor;
+    const char *openBusID;
+    int count;
+    int err;
+
+    if (DRIEntPrivIndex == -1)
+	DRIEntPrivIndex = xf86AllocateEntityPrivateIndex();
+
+    pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+
+    if (pDRIEntPriv && pDRIEntPriv->drmFD != -1)
+	return TRUE;
+
+    drmWasAvailable = drmAvailable();
+
+    memset(&tmp, 0, sizeof(tmp));
+
+    /* Check the DRM lib version.
+     * drmGetLibVersion was not supported in version 1.0, so check for
+     * symbol first to avoid possible crash or hang.
+     */
+
+    drmlibmajor = 1;
+    drmlibminor = 0;
+    if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
+	drmlibv = drmGetLibVersion(-1);
+	if (drmlibv != NULL) {
+	    drmlibmajor = drmlibv->version_major;
+	    drmlibminor = drmlibv->version_minor;
+	    drmFreeVersion(drmlibv);
+	}
+    }
+
+    /* Check if the libdrm can handle falling back to loading based on name
+     * if a busid string is passed.
+     */
+    openBusID = (drmlibmajor == 1 && drmlibminor >= 2) ? busID : NULL;
+
+    tmp.drmFD = -1;
+    sv.drm_di_major = 1;
+    sv.drm_di_minor = 1;
+    sv.drm_dd_major = -1;
+
+    saveSv = sv;
+    count = 10;
+    while (count--) {
+	tmp.drmFD = drmOpen(drmDriverName, openBusID);
+
+	if (tmp.drmFD < 0) {
+	    DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n");
+	    goto out_err;
+	}
+
+	err = drmSetInterfaceVersion(tmp.drmFD, &sv);
+
+	if (err != -EPERM)
+	    break;
+
+	sv = saveSv;
+	drmClose(tmp.drmFD);
+	tmp.drmFD = -1;
+	usleep(100000);
+    }
+
+    if (tmp.drmFD <= 0) {
+	DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n");
+	goto out_err;
+    }
+
+    if (!drmWasAvailable) {
+	DRIDrvMsg(-1, X_INFO,
+		  "[drm] loaded kernel module for \"%s\" driver.\n",
+		  drmDriverName);
+    }
+
+    if (err != 0) {
+	sv.drm_di_major = 1;
+	sv.drm_di_minor = 0;
+    }
+
+    DRIDrvMsg(-1, X_INFO, "[drm] DRM interface version %d.%d\n",
+	      sv.drm_di_major, sv.drm_di_minor);
+
+    if (sv.drm_di_major == 1 && sv.drm_di_minor >= 1)
+	err = 0;
+    else
+	err = drmSetBusid(tmp.drmFD, busID);
+
+    if (err) {
+	DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n");
+	goto out_err;
+    }
+
+    /*
+     * Create a lock-containing sarea.
+     */
+
+    if (drmAddMap( tmp.drmFD, 0, sAreaSize, DRM_SHM,
+		   DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) {
+        DRIDrvMsg(-1, X_INFO, "[drm] Could not create SAREA for DRM lock.\n");
+	tmp.hLSAREA = 0;
+	goto out_err;
+    }
+
+    if (drmMap( tmp.drmFD, tmp.hLSAREA, sAreaSize,
+		(drmAddressPtr)(&tmp.pLSAREA)) < 0) {
+        DRIDrvMsg(-1, X_INFO, "[drm] Mapping SAREA for DRM lock failed.\n");
+	tmp.pLSAREA = NULL;
+	goto out_err;
+    }
+
+    memset(tmp.pLSAREA, 0, sAreaSize);
+
+    /*
+     * Reserved contexts are handled by the first opened screen.
+     */
+
+    tmp.resOwner = NULL;
+
+    if (!pDRIEntPriv)
+	pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1);
+
+    if (!pDRIEntPriv) {
+        DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for "
+		  "DRM device.\n");
+	goto out_err;
+    }
+    *pDRIEntPriv = tmp;
+    xf86GetEntityPrivate((pScrn)->entityList[0],DRIEntPrivIndex)->ptr =
+	pDRIEntPriv;
+
+    DRIDrvMsg(-1, X_INFO, "[drm] DRM open master succeeded.\n");
+    return TRUE;
+
+  out_err:
+
+    DRIOpenDRMCleanup(&tmp);
+    return FALSE;
+}
+
+
 Bool
 DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
 {
     DRIScreenPrivPtr    pDRIPriv;
     drm_context_t *       reserved;
     int                 reserved_count;
-    int                 i, fd, drmWasAvailable;
+    int                 i;
     Bool                xineramaInCore = FALSE;
-    int                 err = 0;
-    char                *openbusid;
-    drmVersionPtr       drmlibv;
-    int                 drmlibmajor, drmlibminor, drmdimajor, drmdiminor;
+    DRIEntPrivPtr       pDRIEntPriv;
+    ScrnInfoPtr         pScrn = xf86Screens[pScreen->myNum];
 
     if (DRIGeneration != serverGeneration) {
 	if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
@@ -153,47 +340,12 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
 	}
     }
 
-    drmWasAvailable = drmAvailable();
-
-    /* Check the DRM lib version.
-     * drmGetLibVersion was not supported in version 1.0, so check for
-     * symbol first to avoid possible crash or hang.
-     */
-    drmlibmajor = 1;
-    drmlibminor = 0;
-    if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
-	drmlibv = drmGetLibVersion(-1);
-	if (drmlibv != NULL) {
-	    drmlibmajor = drmlibv->version_major;
-	    drmlibminor = drmlibv->version_minor;
-	    drmFreeVersion(drmlibv);
-	}
-    }
-
-    /* Check if the libdrm can handle falling back to loading based on name
-     * if a busid string is passed.
-     */
-    if (drmlibmajor == 1 && drmlibminor >= 2)
-	openbusid = pDRIInfo->busIdString;
-    else
-	openbusid = NULL;
-
-    /* Note that drmOpen will try to load the kernel module, if needed. */
-    fd = drmOpen(pDRIInfo->drmDriverName, openbusid);
-    if (fd < 0) {
-        /* failed to open DRM */
-        pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmOpen failed\n");
-        return FALSE;
-    }
+    if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize,
+			  pDRIInfo->busIdString,
+			  pDRIInfo->drmDriverName))
+	return FALSE;
 
-    if (!drmWasAvailable) {
-       /* drmOpen loaded the kernel module, print a message to say so */
-       DRIDrvMsg(pScreen->myNum, X_INFO,
-                 "[drm] loaded kernel module for \"%s\" driver\n",
-                 pDRIInfo->drmDriverName);
-    }
+    pDRIEntPriv = DRI_ENT_PRIV(pScrn);
 
     pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
     if (!pDRIPriv) {
@@ -202,7 +354,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
     }
 
     pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
-    pDRIPriv->drmFD = fd;
+    pDRIPriv->drmFD = pDRIEntPriv->drmFD;
     pDRIPriv->directRenderingSupport = TRUE;
     pDRIPriv->pDriverInfo = pDRIInfo;
     pDRIPriv->nrWindows = 0;
@@ -214,89 +366,54 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
 
     pDRIPriv->grabbedDRILock = FALSE;
     pDRIPriv->drmSIGIOHandlerInstalled = FALSE;
+    *pDRMFD = pDRIPriv->drmFD;
 
-    if (drmlibmajor == 1 && drmlibminor >= 2) {
-	drmSetVersion sv;
+    if (pDRIEntPriv->sAreaGrabbed || pDRIInfo->allocSarea) {
 
-	/* Get the interface version, asking for 1.1. */
-	sv.drm_di_major = 1;
-	sv.drm_di_minor = 1;
-	sv.drm_dd_major = -1;
-	err = drmSetInterfaceVersion(pDRIPriv->drmFD, &sv);
-	if (err == 0) {
-	    drmdimajor = sv.drm_di_major;
-	    drmdiminor = sv.drm_di_minor;
-	} else {
-	    /* failure, so set it to 1.0.0. */
-	    drmdimajor = 1;
-	    drmdiminor = 0;
+	if (drmAddMap( pDRIPriv->drmFD,
+		       0,
+		       pDRIPriv->pDriverInfo->SAREASize,
+		       DRM_SHM,
+		       0,
+		       &pDRIPriv->hSAREA) < 0)
+	{
+	    pDRIPriv->directRenderingSupport = FALSE;
+	    pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+	    drmClose(pDRIPriv->drmFD);
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] drmAddMap failed\n");
+	    return FALSE;
 	}
-    }
-    else {
-	/* We can't check the DI DRM interface version, so set it to 1.0.0. */
-	drmdimajor = 1;
-	drmdiminor = 0;
-    }
-    DRIDrvMsg(pScreen->myNum, X_INFO,
-              "[drm] DRM interface version %d.%d\n", drmdimajor, drmdiminor);
-
-    /* If the interface minor number is 1.1, then we've opened a DRM device
-     * that already had the busid set through drmOpen.
-     */
-    if (drmdimajor == 1 && drmdiminor >= 1)
-	err = 0;
-    else
-	err = drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString);
-
-    if (err < 0) {
-	pDRIPriv->directRenderingSupport = FALSE;
-	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-	drmClose(pDRIPriv->drmFD);
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmSetBusid failed (%d, %s), %s\n",
-                  pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString, strerror(-err));
-	return FALSE;
-    }
-
-    *pDRMFD = pDRIPriv->drmFD;
-    DRIDrvMsg(pScreen->myNum, X_INFO,
-	      "[drm] created \"%s\" driver at busid \"%s\"\n",
-	      pDRIPriv->pDriverInfo->drmDriverName,
-	      pDRIPriv->pDriverInfo->busIdString);
+	DRIDrvMsg(pScreen->myNum, X_INFO,
+		  "[drm] added %d byte SAREA at %p\n",
+		  pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
 
-    if (drmAddMap( pDRIPriv->drmFD,
-		   0,
-		   pDRIPriv->pDriverInfo->SAREASize,
-		   DRM_SHM,
-		   DRM_CONTAINS_LOCK,
-		   &pDRIPriv->hSAREA) < 0)
-    {
-	pDRIPriv->directRenderingSupport = FALSE;
-	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-	drmClose(pDRIPriv->drmFD);
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmAddMap failed\n");
-	return FALSE;
+	/* Backwards compat. */
+	if (drmMap( pDRIPriv->drmFD,
+		    pDRIPriv->hSAREA,
+		    pDRIPriv->pDriverInfo->SAREASize,
+		    (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
+	{
+	    pDRIPriv->directRenderingSupport = FALSE;
+	    pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+	    drmClose(pDRIPriv->drmFD);
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] drmMap failed\n");
+	    return FALSE;
+	}
+	DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
+		  pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+	memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
+    } else {
+	DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock "
+		  "SAREA also for drawables.\n");
+	pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA;
+	pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA;
+	pDRIEntPriv->sAreaGrabbed = TRUE;
     }
-    DRIDrvMsg(pScreen->myNum, X_INFO,
-	      "[drm] added %d byte SAREA at %p\n",
-	      pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
 
-    if (drmMap( pDRIPriv->drmFD,
-		pDRIPriv->hSAREA,
-		pDRIPriv->pDriverInfo->SAREASize,
-		(drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
-    {
-	pDRIPriv->directRenderingSupport = FALSE;
-	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-	drmClose(pDRIPriv->drmFD);
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmMap failed\n");
-	return FALSE;
-    }
-    memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
-    DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
-	      pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+    pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA;
+    pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA;
 
     if (drmAddMap( pDRIPriv->drmFD,
 		   (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
@@ -316,22 +433,26 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
     DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
 	      pDRIPriv->hFrameBuffer);
 
-				/* Add tags for reserved contexts */
-    if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
-					      &reserved_count))) {
-	int  i;
-	void *tag;
-
-	for (i = 0; i < reserved_count; i++) {
-	    tag = DRICreateContextPrivFromHandle(pScreen,
-						 reserved[i],
-						 DRI_CONTEXT_RESERVED);
-	    drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+    if (pDRIEntPriv->resOwner == NULL) {
+	pDRIEntPriv->resOwner = pScreen;
+
+	/* Add tags for reserved contexts */
+	if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+						  &reserved_count))) {
+	    int  i;
+	    void *tag;
+
+	    for (i = 0; i < reserved_count; i++) {
+		tag = DRICreateContextPrivFromHandle(pScreen,
+						     reserved[i],
+						     DRI_CONTEXT_RESERVED);
+		drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+	    }
+	    drmFreeReservedContextList(reserved);
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] added %d reserved context%s for kernel\n",
+		      reserved_count, reserved_count > 1 ? "s" : "");
 	}
-	drmFreeReservedContextList(reserved);
-	DRIDrvMsg(pScreen->myNum, X_INFO,
-		  "[drm] added %d reserved context%s for kernel\n",
-		  reserved_count, reserved_count > 1 ? "s" : "");
     }
 
     /* validate max drawable table entry set by driver */
@@ -349,6 +470,11 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
 	pDRIPriv->pSAREA->drawableTable[i].flags = 0;
     }
 
+    pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount;
+    pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext;
+
+    pDRIEntPriv->refCount++;
+
     return TRUE;
 }
 
@@ -490,6 +616,9 @@ DRICloseScreen(ScreenPtr pScreen)
     DRIInfoPtr       pDRIInfo;
     drm_context_t *    reserved;
     int              reserved_count;
+    ScrnInfoPtr      pScrn = xf86Screens[pScreen->myNum];
+    DRIEntPrivPtr    pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+    Bool closeMaster;
 
     if (pDRIPriv && pDRIPriv->directRenderingSupport) {
 
@@ -542,38 +671,55 @@ DRICloseScreen(ScreenPtr pScreen)
 	}
 
 				/* Remove tags for reserved contexts */
-	if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+	if (pDRIEntPriv->resOwner == pScreen) {
+	    pDRIEntPriv->resOwner = NULL;
+
+	    if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
 						  &reserved_count))) {
-	    int  i;
+		int  i;
 
-	    for (i = 0; i < reserved_count; i++) {
-		DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
-						       reserved[i]));
+		for (i = 0; i < reserved_count; i++) {
+		    DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
+							   reserved[i]));
+		}
+		drmFreeReservedContextList(reserved);
+		DRIDrvMsg(pScreen->myNum, X_INFO,
+			  "[drm] removed %d reserved context%s for kernel\n",
+			  reserved_count, reserved_count > 1 ? "s" : "");
 	    }
-	    drmFreeReservedContextList(reserved);
-	    DRIDrvMsg(pScreen->myNum, X_INFO,
-		      "[drm] removed %d reserved context%s for kernel\n",
-		      reserved_count, reserved_count > 1 ? "s" : "");
 	}
 
 	/* Make sure signals get unblocked etc. */
 	drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
-	pDRIPriv->lockRefCount = 0;
-	DRIDrvMsg(pScreen->myNum, X_INFO,
-		  "[drm] unmapping %d bytes of SAREA %p at %p\n",
-		  pDRIInfo->SAREASize,
-		  pDRIPriv->hSAREA,
-		  pDRIPriv->pSAREA);
-	if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
-	    DRIDrvMsg(pScreen->myNum, X_ERROR,
-		      "[drm] unable to unmap %d bytes"
-		      " of SAREA %p at %p\n",
+	pDRIPriv->pLockRefCount = NULL;
+	closeMaster = (--pDRIEntPriv->refCount == 0) &&
+	    !pDRIEntPriv->keepFDOpen;
+	if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) {
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] unmapping %d bytes of SAREA %p at %p\n",
 		      pDRIInfo->SAREASize,
 		      pDRIPriv->hSAREA,
 		      pDRIPriv->pSAREA);
+	    if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
+		DRIDrvMsg(pScreen->myNum, X_ERROR,
+			  "[drm] unable to unmap %d bytes"
+			  " of SAREA %p at %p\n",
+			  pDRIInfo->SAREASize,
+			  pDRIPriv->hSAREA,
+			  pDRIPriv->pSAREA);
+	    }
+	} else {
+	    pDRIEntPriv->sAreaGrabbed = FALSE;
 	}
 
-	drmClose(pDRIPriv->drmFD);
+	if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) {
+	    drmClose(pDRIPriv->drmFD);
+	    if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) {
+		DRIDrvMsg(pScreen->myNum, X_INFO,
+			  "[drm] Closed DRM master.\n");
+		pDRIEntPriv->drmFD = -1;
+	    }
+	}
 
 	xfree(pDRIPriv);
 	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
@@ -2001,28 +2147,46 @@ void
 DRILock(ScreenPtr pScreen, int flags)
 {
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    if(!pDRIPriv) return;
 
-    if (!pDRIPriv->lockRefCount)
-        DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext, flags);
-    pDRIPriv->lockRefCount++;
+    if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+
+    if (!*pDRIPriv->pLockRefCount) {
+        DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, flags);
+	*pDRIPriv->pLockingContext = pDRIPriv->myContext;
+    } else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) {
+	DRIDrvMsg(pScreen->myNum, X_ERROR,
+		  "[DRI] Locking deadlock.\n"
+		  "\tAlready locked with context %d,\n"
+		  "\ttrying to lock with context %d.\n",
+		  pDRIPriv->pLockingContext,
+		  pDRIPriv->myContext);
+    }
+    (*pDRIPriv->pLockRefCount)++;
 }
 
 void
 DRIUnlock(ScreenPtr pScreen)
 {
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    if(!pDRIPriv) return;
 
-    if (pDRIPriv->lockRefCount > 0) {
-        pDRIPriv->lockRefCount--;
-    }
-    else {
-        ErrorF("DRIUnlock called when not locked\n");
+    if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+
+    if (*pDRIPriv->pLockRefCount > 0) {
+	if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) {
+	    DRIDrvMsg(pScreen->myNum, X_ERROR,
+		      "[DRI] Unlocking inconsistency:\n"
+		      "\tContext %d trying to unlock lock held by context %d\n",
+		      pDRIPriv->pLockingContext,
+		      pDRIPriv->myContext);
+	}
+	(*pDRIPriv->pLockRefCount)--;
+    } else {
+        DRIDrvMsg(pScreen->myNum, X_ERROR,
+		  "DRIUnlock called when not locked.\n");
         return;
     }
-    if (!pDRIPriv->lockRefCount)
-        DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext);
+    if (! *pDRIPriv->pLockRefCount)
+        DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext);
 }
 
 void *
diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h
index f65c571..a21338a 100644
--- a/hw/xfree86/dri/dri.h
+++ b/hw/xfree86/dri/dri.h
@@ -107,7 +107,7 @@ typedef struct {
  */
 
 #define DRIINFO_MAJOR_VERSION   5
-#define DRIINFO_MINOR_VERSION   1
+#define DRIINFO_MINOR_VERSION   2
 #define DRIINFO_PATCH_VERSION   0
 
 typedef struct {
@@ -176,9 +176,17 @@ typedef struct {
 
     /* New with DRI version 5.1.0 */
     void        (*ClipNotify)(ScreenPtr pScreen, WindowPtr *ppWin, int num);
+
+    /* New with DRI version 5.2.0 */
+    Bool                allocSarea;
+    Bool                keepFDOpen;
 } DRIInfoRec, *DRIInfoPtr;
 
 
+extern Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, unsigned long sAreaSize,
+			     const char *busID,
+			     const char *drmDriverName);
+
 extern Bool DRIScreenInit(ScreenPtr pScreen,
                           DRIInfoPtr pDRIInfo,
                           int *pDRMFD);
@@ -344,6 +352,14 @@ extern char *DRICreatePCIBusID(pciVideoP
 
 extern int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *));
 extern int drmRemoveSIGIOHandler(int fd);
+extern int DRIMasterFD(ScrnInfoPtr pScrn);
+
+extern void *DRIMasterSareaPointer(ScrnInfoPtr pScrn);
+
+extern drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn);
+
+
+
 #define _DRI_H_
 
 #endif
diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h
index 9c42ff9..a3bac85 100644
--- a/hw/xfree86/dri/dristruct.h
+++ b/hw/xfree86/dri/dristruct.h
@@ -73,6 +73,11 @@ struct _DRIContextPrivRec
 #define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
     (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
 
+#define DRI_ENT_PRIV(pScrn)  \
+    ((DRIEntPrivIndex < 0) ? \
+     NULL:		     \
+     ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
+					   DRIEntPrivIndex)->ptr)))
 
 typedef struct _DRIScreenPrivRec
 {
@@ -103,6 +108,25 @@ typedef struct _DRIScreenPrivRec
     Bool		wrapped;
     Bool		windowsTouched;
     int			lockRefCount;
+    drm_handle_t        hLSAREA;      /* Handle to SAREA containing lock, for mapping */
+    XF86DRILSAREAPtr    pLSAREA;      /* Mapped pointer to SAREA containing lock */
+    int*                pLockRefCount;
+    int*                pLockingContext;
 } DRIScreenPrivRec, *DRIScreenPrivPtr;
 
+
+typedef struct _DRIEntPrivRec {
+    int drmFD;
+    Bool drmOpened;
+    Bool sAreaGrabbed;
+    drm_handle_t hLSAREA;
+    XF86DRILSAREAPtr pLSAREA;
+    unsigned long sAreaSize;
+    int lockRefCount;
+    int lockingContext;
+    ScreenPtr resOwner;
+    Bool keepFDOpen;
+    int refCount;
+} DRIEntPrivRec, *DRIEntPrivPtr;
+
 #endif /* DRI_STRUCT_H */
diff --git a/hw/xfree86/dri/sarea.h b/hw/xfree86/dri/sarea.h
index a0d6084..1528cc1 100644
--- a/hw/xfree86/dri/sarea.h
+++ b/hw/xfree86/dri/sarea.h
@@ -89,4 +89,9 @@ typedef struct _XF86DRISAREA {
     drm_context_t			dummy_context;
 } XF86DRISAREARec, *XF86DRISAREAPtr;
 
+typedef struct _XF86DRILSAREA  {
+    drmLock                     lock;
+    drmLock                     otherLocks[31];
+} XF86DRILSAREARec, *XF86DRILSAREAPtr;
+
 #endif
diff-tree b5823ea3e1ed5a0449d44da05165a46719dcf287 (from cc4eb1c7ea1bace7ed69cfd80c99d22933282ae1)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Sun Apr 15 22:59:19 2007 -0300

    RandR 1.2 spec says CRTC info contains screen-relative geometry.
    
    Was reporting mode size instead of adjusting for rotation.
    (cherry picked from commit e2e7c47a528447e90cff6cf10d2ce457742ef48d)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 1dfc3bb..c8c2be2 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -518,6 +518,7 @@ ProcRRGetCrtcInfo (ClientPtr client)
     RROutput			*outputs;
     RROutput			*possible;
     int				i, j, k, n;
+    int				width, height;
     
     REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
     crtc = LookupCrtc(client, stuff->crtc, DixReadAccess);
@@ -540,8 +541,9 @@ ProcRRGetCrtcInfo (ClientPtr client)
     rep.timestamp = pScrPriv->lastSetTime.milliseconds;
     rep.x = crtc->x;
     rep.y = crtc->y;
-    rep.width = mode ? mode->mode.width : 0;
-    rep.height = mode ? mode->mode.height : 0;
+    RRCrtcGetScanoutSize (crtc, &width, &height);
+    rep.width = width;
+    rep.height = height;
     rep.mode = mode ? mode->mode.id : 0;
     rep.rotation = crtc->rotation;
     rep.rotations = crtc->rotations;
diff-tree cc4eb1c7ea1bace7ed69cfd80c99d22933282ae1 (from eba81a0a01f8a61151d8bf9f3d83bda85ca26e73)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Fri Apr 13 15:04:29 2007 -0300

    Add quirk for Acer AL1706 monitor to force 60hz refresh.
    
    This Acer monitor reports support for 75hz refresh via EDID, and yet when
    that rate is delivered, the monitor does not sync and reports out of range.
    Use the existing 60hz quirk for this monitor.
    (cherry picked from commit 1328a288e9030a472a915077160f090d1afd4126)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 7a8ec19..18e42dd 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -82,6 +82,11 @@ static Bool quirk_prefer_large_60 (int s
 	DDC->vendor.prod_id == 1516)
 	return TRUE;
     
+    /* Acer AL1706 */
+    if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
+	DDC->vendor.prod_id == 44358)
+	return TRUE;
+    
     return FALSE;
 }
 
diff-tree eba81a0a01f8a61151d8bf9f3d83bda85ca26e73 (from 6b040b79f0e247b6f2da8f7d239443743e96de67)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Apr 14 18:30:09 2007 +0300

    glx: move __glXMesaProvider from GLcore module to glx module.
    
    This treats the GLcore provider similar to DRI provider, using a subset of
    XMesa as the GLcore interface.

diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index cd1130d..c4141bc 100644
--- a/GL/glx/Makefile.am
+++ b/GL/glx/Makefile.am
@@ -46,12 +46,13 @@ libglx_la_SOURCES = \
         glxdrawable.h \
         glxext.c \
         glxext.h \
-	glxvisuals.c \
+        glxglcore.c \
         glxscreens.c \
         glxscreens.h \
         glxserver.h \
         glxutil.c \
         glxutil.h \
+        glxvisuals.c \
         indirect_dispatch.c \
         indirect_dispatch.h \
         indirect_dispatch_swap.c \
diff --git a/GL/glx/glxglcore.c b/GL/glx/glxglcore.c
new file mode 100644
index 0000000..ecfa4d7
--- /dev/null
+++ b/GL/glx/glxglcore.c
@@ -0,0 +1,409 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Kevin E. Martin <kevin at precisioninsight.com>
+ *   Brian E. Paul <brian at precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include <GL/xmesa.h>
+#include <GL/internal/glcore.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxutil.h>
+
+#include "glcontextmodes.h"
+#include "os.h"
+
+typedef struct __GLXMESAscreen   __GLXMESAscreen;
+typedef struct __GLXMESAcontext  __GLXMESAcontext;
+typedef struct __GLXMESAdrawable __GLXMESAdrawable;
+
+struct __GLXMESAscreen {
+    __GLXscreen   base;
+    int           index;
+    int		  num_vis;
+    XMesaVisual  *xm_vis;
+};
+
+struct __GLXMESAcontext {
+    __GLXcontext base;
+    XMesaContext xmesa;
+};
+
+struct __GLXMESAdrawable {
+    __GLXdrawable base;
+    XMesaBuffer   xm_buf;
+};
+
+static XMesaVisual find_mesa_visual(__GLXscreen *screen, VisualID vid);
+
+
+static void
+__glXMesaDrawableDestroy(__GLXdrawable *base)
+{
+    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+
+    if (glxPriv->xm_buf != NULL)
+      XMesaDestroyBuffer(glxPriv->xm_buf);
+    xfree(glxPriv);
+}
+
+static GLboolean
+__glXMesaDrawableResize(__GLXdrawable *base)
+{
+    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+
+    XMesaResizeBuffers(glxPriv->xm_buf);
+
+    return GL_TRUE;
+}
+
+static GLboolean
+__glXMesaDrawableSwapBuffers(__GLXdrawable *base)
+{
+    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+
+    /* This is terrifying: XMesaSwapBuffers() ends up calling CopyArea
+     * to do the buffer swap, but this assumes that the server holds
+     * the lock and has its context visible.  If another screen uses a
+     * DRI driver, that will have installed the DRI enter/leave server
+     * functions, which lifts the lock during GLX dispatch.  This is
+     * why we need to re-take the lock and swap in the server context
+     * before calling XMesaSwapBuffers() here.  /me shakes head. */
+
+    __glXenterServer();
+
+    XMesaSwapBuffers(glxPriv->xm_buf);
+
+    __glXleaveServer();
+
+    return GL_TRUE;
+}
+
+
+static __GLXdrawable *
+__glXMesaScreenCreateDrawable(__GLXscreen *screen,
+			      DrawablePtr pDraw,
+			      XID drawId,
+			      __GLcontextModes *modes)
+{
+    __GLXMESAdrawable *glxPriv;
+    XMesaVisual xm_vis;
+
+    glxPriv = xalloc(sizeof *glxPriv);
+    if (glxPriv == NULL)
+	return NULL;
+
+    memset(glxPriv, 0, sizeof *glxPriv);
+
+    if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
+        xfree(glxPriv);
+	return NULL;
+    }
+
+    glxPriv->base.destroy     = __glXMesaDrawableDestroy;
+    glxPriv->base.resize      = __glXMesaDrawableResize;
+    glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers;
+
+    xm_vis = find_mesa_visual(screen, modes->visualID);
+    if (xm_vis == NULL) {
+	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+	       modes->visualID);
+	xfree(glxPriv);
+	return NULL;
+    }
+
+    if (glxPriv->base.type == DRAWABLE_WINDOW) {
+	glxPriv->xm_buf = XMesaCreateWindowBuffer(xm_vis, (WindowPtr)pDraw);
+    } else {
+	glxPriv->xm_buf = XMesaCreatePixmapBuffer(xm_vis, (PixmapPtr)pDraw, 0);
+    }
+
+    return &glxPriv->base;
+}
+
+static void
+__glXMesaContextDestroy(__GLXcontext *baseContext)
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+
+    XMesaDestroyContext(context->xmesa);
+    __glXContextDestroy(&context->base);
+    xfree(context);
+}
+
+static int
+__glXMesaContextMakeCurrent(__GLXcontext *baseContext)
+
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+    __GLXMESAdrawable *drawPriv = (__GLXMESAdrawable *) context->base.drawPriv;
+    __GLXMESAdrawable *readPriv = (__GLXMESAdrawable *) context->base.readPriv;
+
+    return XMesaMakeCurrent2(context->xmesa,
+			     drawPriv->xm_buf,
+			     readPriv->xm_buf);
+}
+
+static int
+__glXMesaContextLoseCurrent(__GLXcontext *baseContext)
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+
+    return XMesaLoseCurrent(context->xmesa);
+}
+
+static int
+__glXMesaContextCopy(__GLXcontext *baseDst,
+		     __GLXcontext *baseSrc,
+		     unsigned long mask)
+{
+    __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst;
+    __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc;
+
+    return XMesaCopyContext(src->xmesa, dst->xmesa, mask);
+}
+
+static int
+__glXMesaContextForceCurrent(__GLXcontext *baseContext)
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+
+    /* GlxSetRenderTables() call for XGL moved in XMesaForceCurrent() */
+
+    return XMesaForceCurrent(context->xmesa);
+}
+
+static __GLXcontext *
+__glXMesaScreenCreateContext(__GLXscreen *screen,
+			     __GLcontextModes *modes,
+			     __GLXcontext *baseShareContext)
+{
+    __GLXMESAcontext *context;
+    __GLXMESAcontext *shareContext = (__GLXMESAcontext *) baseShareContext;
+    XMesaVisual xm_vis;
+    XMesaContext xm_share;
+
+    context = xalloc (sizeof (__GLXMESAcontext));
+    if (context == NULL)
+	return NULL;
+
+    memset(context, 0, sizeof *context);
+
+    context->base.pGlxScreen = screen;
+    context->base.modes      = modes;
+
+    context->base.destroy        = __glXMesaContextDestroy;
+    context->base.makeCurrent    = __glXMesaContextMakeCurrent;
+    context->base.loseCurrent    = __glXMesaContextLoseCurrent;
+    context->base.copy           = __glXMesaContextCopy;
+    context->base.forceCurrent   = __glXMesaContextForceCurrent;
+
+    xm_vis = find_mesa_visual(screen, modes->visualID);
+    if (!xm_vis) {
+	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+	       modes->visualID);
+	xfree(context);
+	return NULL;
+    }
+
+    xm_share = shareContext ? shareContext->xmesa : NULL;
+    context->xmesa = XMesaCreateContext(xm_vis, xm_share);
+    if (!context->xmesa) {
+	xfree(context);
+	return NULL;
+    }
+
+    return &context->base;
+}
+
+static void
+__glXMesaScreenDestroy(__GLXscreen *screen)
+{
+    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+    int i;
+
+    for (i = 0; i < mesaScreen->num_vis; i++) {
+	if (mesaScreen->xm_vis[i])
+	    XMesaDestroyVisual(mesaScreen->xm_vis[i]);
+    }
+
+    xfree(mesaScreen->xm_vis);
+
+    __glXScreenDestroy(screen);
+
+    xfree(screen);
+}
+
+static XMesaVisual
+find_mesa_visual(__GLXscreen *screen, VisualID vid)
+{
+    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+    const __GLcontextModes *modes;
+    unsigned i = 0;
+
+    for ( modes = screen->modes ; modes != NULL ; modes = modes->next ) {
+	if ( modes->visualID == vid ) {
+	    break;
+	}
+
+	i++;
+    }
+
+    return (modes != NULL) ? mesaScreen->xm_vis[i] : NULL;
+}
+
+static void init_screen_visuals(__GLXMESAscreen *screen)
+{
+    ScreenPtr pScreen = screen->base.pScreen;
+    __GLcontextModes *modes;
+    XMesaVisual *pXMesaVisual;
+    int *used;
+    int i, j, size;
+
+    /* Alloc space for the list of XMesa visuals */
+    size = screen->base.numVisuals * sizeof(XMesaVisual);
+    pXMesaVisual = (XMesaVisual *) xalloc(size);
+    memset(pXMesaVisual, 0, size);
+
+    /* FIXME: Change 'used' to be a array of bits (rather than of ints),
+     * FIXME: create a stack array of 8 or 16 bytes.  If 'numVisuals' is less
+     * FIXME: than 64 or 128 the stack array can be used instead of calling
+     * FIXME: __glXMalloc / __glXFree.  If nothing else, convert 'used' to
+     * FIXME: array of bytes instead of ints!
+     */
+    used = (int *) xalloc(pScreen->numVisuals * sizeof(int));
+    memset(used, 0, pScreen->numVisuals * sizeof(int));
+
+    i = 0;
+    for ( modes = screen->base.modes; modes != NULL; modes = modes->next ) {
+	const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+	const int nplanes = (modes->rgbBits - modes->alphaBits);
+	const VisualPtr pVis = pScreen->visuals;
+
+	for (j = 0; j < pScreen->numVisuals; j++) {
+	    if (pVis[j].class     == vis_class &&
+		pVis[j].nplanes   == nplanes &&
+		pVis[j].redMask   == modes->redMask &&
+		pVis[j].greenMask == modes->greenMask &&
+		pVis[j].blueMask  == modes->blueMask &&
+		!used[j]) {
+
+		/* Create the XMesa visual */
+		pXMesaVisual[i] =
+		    XMesaCreateVisual(pScreen,
+				      &pVis[j],
+				      modes->rgbMode,
+				      (modes->alphaBits > 0),
+				      modes->doubleBufferMode,
+				      modes->stereoMode,
+				      GL_TRUE, /* ximage_flag */
+				      modes->depthBits,
+				      modes->stencilBits,
+				      modes->accumRedBits,
+				      modes->accumGreenBits,
+				      modes->accumBlueBits,
+				      modes->accumAlphaBits,
+				      modes->samples,
+				      modes->level,
+				      modes->visualRating);
+		/* Set the VisualID */
+		modes->visualID = pVis[j].vid;
+
+		/* Mark this visual used */
+		used[j] = 1;
+		break;
+	    }
+	}
+
+	if ( j == pScreen->numVisuals ) {
+	    ErrorF("No matching visual for __GLcontextMode with "
+		   "visual class = %d (%d), nplanes = %u\n",
+		   vis_class, 
+		   modes->visualType,
+		   (modes->rgbBits - modes->alphaBits) );
+	}
+	else if ( modes->visualID == -1 ) {
+	    FatalError( "Matching visual found, but visualID still -1!\n" );
+	}
+
+	i++;
+    }
+
+    xfree(used);
+
+    screen->num_vis = pScreen->numVisuals;
+    screen->xm_vis = pXMesaVisual;
+}
+
+static __GLXscreen *
+__glXMesaScreenProbe(ScreenPtr pScreen)
+{
+    __GLXMESAscreen *screen;
+
+    screen = xalloc(sizeof *screen);
+    if (screen == NULL)
+	return NULL;
+
+    __glXScreenInit(&screen->base, pScreen);
+
+    screen->base.destroy        = __glXMesaScreenDestroy;
+    screen->base.createContext  = __glXMesaScreenCreateContext;
+    screen->base.createDrawable = __glXMesaScreenCreateDrawable;
+    screen->base.pScreen       = pScreen;
+
+    /*
+     * Find the GLX visuals that are supported by this screen and create
+     * XMesa's visuals.
+     */
+    init_screen_visuals(screen);
+
+    return &screen->base;
+}
+
+__GLXprovider __glXMesaProvider = {
+    __glXMesaScreenProbe,
+    "MESA",
+    NULL
+};
+
+__GLXprovider *
+GlxGetMesaProvider (void)
+{
+    return &__glXMesaProvider;
+}
diff --git a/GL/mesa/X/Makefile.am b/GL/mesa/X/Makefile.am
index f8f16c3..ace1181 100644
--- a/GL/mesa/X/Makefile.am
+++ b/GL/mesa/X/Makefile.am
@@ -22,8 +22,6 @@ AM_CFLAGS = \
 	-DXFree86Server \
 	@GLX_DEFINES@
 
-libX_la_SOURCES = xf86glx.c
-
 nodist_libX_la_SOURCES = \
                   xm_api.c \
 		  xm_buffer.c \
diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c
deleted file mode 100644
index ecfa4d7..0000000
--- a/GL/mesa/X/xf86glx.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin at precisioninsight.com>
- *   Brian E. Paul <brian at precisioninsight.com>
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include <GL/xmesa.h>
-#include <GL/internal/glcore.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxutil.h>
-
-#include "glcontextmodes.h"
-#include "os.h"
-
-typedef struct __GLXMESAscreen   __GLXMESAscreen;
-typedef struct __GLXMESAcontext  __GLXMESAcontext;
-typedef struct __GLXMESAdrawable __GLXMESAdrawable;
-
-struct __GLXMESAscreen {
-    __GLXscreen   base;
-    int           index;
-    int		  num_vis;
-    XMesaVisual  *xm_vis;
-};
-
-struct __GLXMESAcontext {
-    __GLXcontext base;
-    XMesaContext xmesa;
-};
-
-struct __GLXMESAdrawable {
-    __GLXdrawable base;
-    XMesaBuffer   xm_buf;
-};
-
-static XMesaVisual find_mesa_visual(__GLXscreen *screen, VisualID vid);
-
-
-static void
-__glXMesaDrawableDestroy(__GLXdrawable *base)
-{
-    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
-
-    if (glxPriv->xm_buf != NULL)
-      XMesaDestroyBuffer(glxPriv->xm_buf);
-    xfree(glxPriv);
-}
-
-static GLboolean
-__glXMesaDrawableResize(__GLXdrawable *base)
-{
-    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
-
-    XMesaResizeBuffers(glxPriv->xm_buf);
-
-    return GL_TRUE;
-}
-
-static GLboolean
-__glXMesaDrawableSwapBuffers(__GLXdrawable *base)
-{
-    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
-
-    /* This is terrifying: XMesaSwapBuffers() ends up calling CopyArea
-     * to do the buffer swap, but this assumes that the server holds
-     * the lock and has its context visible.  If another screen uses a
-     * DRI driver, that will have installed the DRI enter/leave server
-     * functions, which lifts the lock during GLX dispatch.  This is
-     * why we need to re-take the lock and swap in the server context
-     * before calling XMesaSwapBuffers() here.  /me shakes head. */
-
-    __glXenterServer();
-
-    XMesaSwapBuffers(glxPriv->xm_buf);
-
-    __glXleaveServer();
-
-    return GL_TRUE;
-}
-
-
-static __GLXdrawable *
-__glXMesaScreenCreateDrawable(__GLXscreen *screen,
-			      DrawablePtr pDraw,
-			      XID drawId,
-			      __GLcontextModes *modes)
-{
-    __GLXMESAdrawable *glxPriv;
-    XMesaVisual xm_vis;
-
-    glxPriv = xalloc(sizeof *glxPriv);
-    if (glxPriv == NULL)
-	return NULL;
-
-    memset(glxPriv, 0, sizeof *glxPriv);
-
-    if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
-        xfree(glxPriv);
-	return NULL;
-    }
-
-    glxPriv->base.destroy     = __glXMesaDrawableDestroy;
-    glxPriv->base.resize      = __glXMesaDrawableResize;
-    glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers;
-
-    xm_vis = find_mesa_visual(screen, modes->visualID);
-    if (xm_vis == NULL) {
-	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
-	       modes->visualID);
-	xfree(glxPriv);
-	return NULL;
-    }
-
-    if (glxPriv->base.type == DRAWABLE_WINDOW) {
-	glxPriv->xm_buf = XMesaCreateWindowBuffer(xm_vis, (WindowPtr)pDraw);
-    } else {
-	glxPriv->xm_buf = XMesaCreatePixmapBuffer(xm_vis, (PixmapPtr)pDraw, 0);
-    }
-
-    return &glxPriv->base;
-}
-
-static void
-__glXMesaContextDestroy(__GLXcontext *baseContext)
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-
-    XMesaDestroyContext(context->xmesa);
-    __glXContextDestroy(&context->base);
-    xfree(context);
-}
-
-static int
-__glXMesaContextMakeCurrent(__GLXcontext *baseContext)
-
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-    __GLXMESAdrawable *drawPriv = (__GLXMESAdrawable *) context->base.drawPriv;
-    __GLXMESAdrawable *readPriv = (__GLXMESAdrawable *) context->base.readPriv;
-
-    return XMesaMakeCurrent2(context->xmesa,
-			     drawPriv->xm_buf,
-			     readPriv->xm_buf);
-}
-
-static int
-__glXMesaContextLoseCurrent(__GLXcontext *baseContext)
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-
-    return XMesaLoseCurrent(context->xmesa);
-}
-
-static int
-__glXMesaContextCopy(__GLXcontext *baseDst,
-		     __GLXcontext *baseSrc,
-		     unsigned long mask)
-{
-    __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst;
-    __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc;
-
-    return XMesaCopyContext(src->xmesa, dst->xmesa, mask);
-}
-
-static int
-__glXMesaContextForceCurrent(__GLXcontext *baseContext)
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-
-    /* GlxSetRenderTables() call for XGL moved in XMesaForceCurrent() */
-
-    return XMesaForceCurrent(context->xmesa);
-}
-
-static __GLXcontext *
-__glXMesaScreenCreateContext(__GLXscreen *screen,
-			     __GLcontextModes *modes,
-			     __GLXcontext *baseShareContext)
-{
-    __GLXMESAcontext *context;
-    __GLXMESAcontext *shareContext = (__GLXMESAcontext *) baseShareContext;
-    XMesaVisual xm_vis;
-    XMesaContext xm_share;
-
-    context = xalloc (sizeof (__GLXMESAcontext));
-    if (context == NULL)
-	return NULL;
-
-    memset(context, 0, sizeof *context);
-
-    context->base.pGlxScreen = screen;
-    context->base.modes      = modes;
-
-    context->base.destroy        = __glXMesaContextDestroy;
-    context->base.makeCurrent    = __glXMesaContextMakeCurrent;
-    context->base.loseCurrent    = __glXMesaContextLoseCurrent;
-    context->base.copy           = __glXMesaContextCopy;
-    context->base.forceCurrent   = __glXMesaContextForceCurrent;
-
-    xm_vis = find_mesa_visual(screen, modes->visualID);
-    if (!xm_vis) {
-	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
-	       modes->visualID);
-	xfree(context);
-	return NULL;
-    }
-
-    xm_share = shareContext ? shareContext->xmesa : NULL;
-    context->xmesa = XMesaCreateContext(xm_vis, xm_share);
-    if (!context->xmesa) {
-	xfree(context);
-	return NULL;
-    }
-
-    return &context->base;
-}
-
-static void
-__glXMesaScreenDestroy(__GLXscreen *screen)
-{
-    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
-    int i;
-
-    for (i = 0; i < mesaScreen->num_vis; i++) {
-	if (mesaScreen->xm_vis[i])
-	    XMesaDestroyVisual(mesaScreen->xm_vis[i]);
-    }
-
-    xfree(mesaScreen->xm_vis);
-
-    __glXScreenDestroy(screen);
-
-    xfree(screen);
-}
-
-static XMesaVisual
-find_mesa_visual(__GLXscreen *screen, VisualID vid)
-{
-    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
-    const __GLcontextModes *modes;
-    unsigned i = 0;
-
-    for ( modes = screen->modes ; modes != NULL ; modes = modes->next ) {
-	if ( modes->visualID == vid ) {
-	    break;
-	}
-
-	i++;
-    }
-
-    return (modes != NULL) ? mesaScreen->xm_vis[i] : NULL;
-}
-
-static void init_screen_visuals(__GLXMESAscreen *screen)
-{
-    ScreenPtr pScreen = screen->base.pScreen;
-    __GLcontextModes *modes;
-    XMesaVisual *pXMesaVisual;
-    int *used;
-    int i, j, size;
-
-    /* Alloc space for the list of XMesa visuals */
-    size = screen->base.numVisuals * sizeof(XMesaVisual);
-    pXMesaVisual = (XMesaVisual *) xalloc(size);
-    memset(pXMesaVisual, 0, size);
-
-    /* FIXME: Change 'used' to be a array of bits (rather than of ints),
-     * FIXME: create a stack array of 8 or 16 bytes.  If 'numVisuals' is less
-     * FIXME: than 64 or 128 the stack array can be used instead of calling
-     * FIXME: __glXMalloc / __glXFree.  If nothing else, convert 'used' to
-     * FIXME: array of bytes instead of ints!
-     */
-    used = (int *) xalloc(pScreen->numVisuals * sizeof(int));
-    memset(used, 0, pScreen->numVisuals * sizeof(int));
-
-    i = 0;
-    for ( modes = screen->base.modes; modes != NULL; modes = modes->next ) {
-	const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
-	const int nplanes = (modes->rgbBits - modes->alphaBits);
-	const VisualPtr pVis = pScreen->visuals;
-
-	for (j = 0; j < pScreen->numVisuals; j++) {
-	    if (pVis[j].class     == vis_class &&
-		pVis[j].nplanes   == nplanes &&
-		pVis[j].redMask   == modes->redMask &&
-		pVis[j].greenMask == modes->greenMask &&
-		pVis[j].blueMask  == modes->blueMask &&
-		!used[j]) {
-
-		/* Create the XMesa visual */
-		pXMesaVisual[i] =
-		    XMesaCreateVisual(pScreen,
-				      &pVis[j],
-				      modes->rgbMode,
-				      (modes->alphaBits > 0),
-				      modes->doubleBufferMode,
-				      modes->stereoMode,
-				      GL_TRUE, /* ximage_flag */
-				      modes->depthBits,
-				      modes->stencilBits,
-				      modes->accumRedBits,
-				      modes->accumGreenBits,
-				      modes->accumBlueBits,
-				      modes->accumAlphaBits,
-				      modes->samples,
-				      modes->level,
-				      modes->visualRating);
-		/* Set the VisualID */
-		modes->visualID = pVis[j].vid;
-
-		/* Mark this visual used */
-		used[j] = 1;
-		break;
-	    }
-	}
-
-	if ( j == pScreen->numVisuals ) {
-	    ErrorF("No matching visual for __GLcontextMode with "
-		   "visual class = %d (%d), nplanes = %u\n",
-		   vis_class, 
-		   modes->visualType,
-		   (modes->rgbBits - modes->alphaBits) );
-	}
-	else if ( modes->visualID == -1 ) {
-	    FatalError( "Matching visual found, but visualID still -1!\n" );
-	}
-
-	i++;
-    }
-
-    xfree(used);
-
-    screen->num_vis = pScreen->numVisuals;
-    screen->xm_vis = pXMesaVisual;
-}
-
-static __GLXscreen *
-__glXMesaScreenProbe(ScreenPtr pScreen)
-{
-    __GLXMESAscreen *screen;
-
-    screen = xalloc(sizeof *screen);
-    if (screen == NULL)
-	return NULL;
-
-    __glXScreenInit(&screen->base, pScreen);
-
-    screen->base.destroy        = __glXMesaScreenDestroy;
-    screen->base.createContext  = __glXMesaScreenCreateContext;
-    screen->base.createDrawable = __glXMesaScreenCreateDrawable;
-    screen->base.pScreen       = pScreen;
-
-    /*
-     * Find the GLX visuals that are supported by this screen and create
-     * XMesa's visuals.
-     */
-    init_screen_visuals(screen);
-
-    return &screen->base;
-}
-
-__GLXprovider __glXMesaProvider = {
-    __glXMesaScreenProbe,
-    "MESA",
-    NULL
-};
-
-__GLXprovider *
-GlxGetMesaProvider (void)
-{
-    return &__glXMesaProvider;
-}
diff-tree 6b040b79f0e247b6f2da8f7d239443743e96de67 (from 2c833f60acb3dc358815a99cd295ef7fc695c45d)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Apr 14 18:29:52 2007 +0300

    glx: drop xmesaP.h include from xf86glx.c
    
    The declarations for the xfree86-specific XMesa functions were moved up to
    xmesa.h, requires Mesa as of 2007-04-13.

diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c
index 6fffdeb..ecfa4d7 100644
--- a/GL/mesa/X/xf86glx.c
+++ b/GL/mesa/X/xf86glx.c
@@ -45,7 +45,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include <glxdrawable.h>
 #include <glxcontext.h>
 #include <glxutil.h>
-#include "xmesaP.h"
 
 #include "glcontextmodes.h"
 #include "os.h"
diff-tree 2c833f60acb3dc358815a99cd295ef7fc695c45d (from 7ccebc50b98ac175fdbdfaab081bcead62e60ee3)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Apr 14 18:29:25 2007 +0300

    glx: drop stray CAPI define.
    
    SI imports/exports were dropped from Mesa.

diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h
index a54e323..eb10ee2 100644
--- a/GL/glx/glxcontext.h
+++ b/GL/glx/glxcontext.h
@@ -40,9 +40,6 @@
 **
 */
 
-/* XXX: should be defined somewhere globally */
-#define CAPI
-
 #include "GL/internal/glcore.h"
 
 typedef struct __GLXtextureFromPixmap __GLXtextureFromPixmap;
diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h
index a7700f6..bba4557 100644
--- a/GL/glx/glxscreens.h
+++ b/GL/glx/glxscreens.h
@@ -40,9 +40,6 @@
 **
 */
 
-/* XXX: should be defined somewhere globally */
-#define CAPI
-
 #include "GL/internal/glcore.h"
 
 /*
diff-tree 7ccebc50b98ac175fdbdfaab081bcead62e60ee3 (from 33a5d9605e3e282f6aa1921d7321a2a12ef02c42)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Fri Apr 13 13:08:44 2007 +0930

    Documentation for events.c.

diff --git a/dix/events.c b/dix/events.c
index 093a316..bc6b6ae 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -107,6 +107,10 @@ of the copyright holder.
 
 ******************************************************************/
 
+/** @file
+ * This file handles event delivery and a big part of the server-side protocol
+ * handling (the parts for input devices).
+ */
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
@@ -168,7 +172,9 @@ static xEvent *xeviexE;
 #include "dixevents.h"
 #include "dixgrabs.h"
 #include "dispatch.h"
-
+/**
+ * Extension events type numbering starts at EXTENSION_EVENT_BASE.
+ */
 #define EXTENSION_EVENT_BASE  64
 
 #define NoSuchEvent 0x80000000	/* so doesn't match NoEventMask */
@@ -214,6 +220,28 @@ _X_EXPORT CallbackListPtr DeviceEventCal
 Mask DontPropagateMasks[DNPMCOUNT];
 static int DontPropagateRefCnts[DNPMCOUNT];
 
+/**
+ * Main input device struct. 
+ *     inputInfo.pointer 
+ *     is the core pointer. Referred to as "virtual core pointer", "VCP",
+ *     "core pointer" or inputInfo.pointer. There is exactly one core pointer,
+ *     but multiple devices may send core events. If a device generates core
+ *     events, those events will appear to originate from the core pointer.
+ * 
+ *     inputInfo.keyboard
+ *     is the core keyboard ("virtual core keyboard", "VCK", "core keyboard").
+ *     See inputInfo.pointer.
+ * 
+ *     inputInfo.devices
+ *     linked list containing all devices including VCK and VCP. The VCK will
+ *     always be the first entry, the VCP the second entry in the device list.
+ *
+ *     inputInfo.off_devices
+ *     Devices that have not been initialized and are thus turned off.
+ *
+ *     inputInfo.numDevices
+ *     Total number of devices.
+ */
 _X_EXPORT InputInfo inputInfo;
 
 static struct {
@@ -228,12 +256,19 @@ static struct {
  * The window trace information is used to avoid having to compute all the
  * windows between the root and the current pointer window each time a button
  * or key goes down. The grabs on each of those windows must be checked.
+ * 
+ * @see XYToWindow() for a documentation on how the array is set up.
  */
 static WindowPtr *spriteTrace = (WindowPtr *)NULL;
 #define ROOT spriteTrace[0]
 static int spriteTraceSize = 0;
 static int spriteTraceGood;
 
+/**
+ * DIX sprite information. This is the sprite as seen from the DIX. It does
+ * not represent the actual sprite rendered to the screen.
+ * 
+ */
 static  struct {
     CursorPtr	current;
     BoxRec	hotLimits;	/* logical constraints of hot spot */
@@ -270,6 +305,9 @@ static WindowPtr XYToWindow(
     int y
 );
 
+/**
+ * Max event opcode.
+ */
 extern int lastEvent;
 
 static Mask lastEventMask;
@@ -849,6 +887,13 @@ PointerConfinedToScreen(void)
     return sprite.confined;
 }
 
+/**
+ * Update the sprite cursor to the given cursor.
+ *
+ * ChangeToCursor() will display the new cursor and free the old cursor (if
+ * applicable). If the provided cursor is already the updated cursor, nothing
+ * happens.
+ */
 static void
 ChangeToCursor(CursorPtr cursor)
 {
@@ -873,7 +918,9 @@ ChangeToCursor(CursorPtr cursor)
     }
 }
 
-/* returns true if b is a descendent of a */
+/**
+ * @returns true if b is a descendent of a 
+ */
 Bool
 IsParent(WindowPtr a, WindowPtr b)
 {
@@ -882,6 +929,11 @@ IsParent(WindowPtr a, WindowPtr b)
     return FALSE;
 }
 
+/**
+ * Update the cursor displayed on the screen.
+ *
+ * Called whenever a cursor may have changed shape or position.  
+ */
 static void
 PostNewCursor(void)
 {
@@ -912,24 +964,36 @@ PostNewCursor(void)
 	}
 }
 
+/**
+ * @return root window of current active screen.
+ */
 _X_EXPORT WindowPtr
 GetCurrentRootWindow(void)
 {
     return ROOT;
 }
 
+/**
+ * @return window underneath the cursor sprite.
+ */
 _X_EXPORT WindowPtr
 GetSpriteWindow(void)
 {
     return sprite.win;
 }
 
+/**
+ * @return current sprite cursor.
+ */
 _X_EXPORT CursorPtr
 GetSpriteCursor(void)
 {
     return sprite.current;
 }
 
+/**
+ * Set x/y current sprite position in screen coordinates.
+ */
 _X_EXPORT void
 GetSpritePosition(int *px, int *py)
 {
@@ -1231,6 +1295,19 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, 
     ComputeFreezes();
 }
 
+/**
+ * Activate a pointer grab on the given device. A pointer grab will cause all
+ * core pointer events to be delivered to the grabbing client only. Can cause
+ * the cursor to change if a grab cursor is set.
+ * 
+ * As a pointer grab can only be issued on the core devices, mouse is always
+ * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab().
+ * 
+ * @param mouse The device to grab.
+ * @param grab The grab structure, needs to be setup.
+ * @param autoGrab True if the grab was caused by a button down event and not
+ * explicitely by a client. 
+ */
 void
 ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, 
                     TimeStamp time, Bool autoGrab)
@@ -1259,6 +1336,12 @@ ActivatePointerGrab(DeviceIntPtr mouse, 
     CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
 }
 
+/**
+ * Delete grab on given device, update the sprite.
+ *
+ * As a pointer grab can only be issued on the core devices, mouse is always
+ * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab().
+ */
 void
 DeactivatePointerGrab(DeviceIntPtr mouse)
 {
@@ -1283,6 +1366,11 @@ DeactivatePointerGrab(DeviceIntPtr mouse
     ComputeFreezes();
 }
 
+/**
+ * Activate a keyboard grab on the given device. 
+ *
+ * Extension devices have ActivateKeyboardGrab() set as their grabbing proc.
+ */
 void
 ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive)
 {
@@ -1309,6 +1397,9 @@ ActivateKeyboardGrab(DeviceIntPtr keybd,
     CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
 }
 
+/**
+ * Delete keyboard grab for the given device. 
+ */
 void
 DeactivateKeyboardGrab(DeviceIntPtr keybd)
 {
@@ -1441,6 +1532,11 @@ AllowSome(ClientPtr client, TimeStamp ti
     }
 }
 
+/**
+ * Server-side protocol handling for AllowEvents request.
+ *
+ * Release some events from a frozen device. Only applicable for core devices.
+ */
 int
 ProcAllowEvents(ClientPtr client)
 {
@@ -1484,6 +1580,9 @@ ProcAllowEvents(ClientPtr client)
     return Success;
 }
 
+/**
+ * Deactivate grabs from any device that has been grabbed by the client.
+ */
 void
 ReleaseActiveGrabs(ClientPtr client)
 {
@@ -1510,6 +1609,30 @@ ReleaseActiveGrabs(ClientPtr client)
  *            The following procedures deal with delivering events        *
  **************************************************************************/
 
+/**
+ * Deliver the given events to the given client.
+ *
+ * More than one event may be delivered at a time. This is the case with
+ * DeviceMotionNotifies which may be followed by DeviceValuator events.
+ *
+ * TryClientEvents() is the last station before actually writing the events to
+ * the socket. Anything that is not filtered here, will get delivered to the
+ * client. 
+ * An event is only delivered if 
+ *   - mask and filter match up.
+ *   - no other client has a grab on the device that caused the event.
+ * 
+ *
+ * @param client The target client to deliver to.
+ * @param pEvents The events to be delivered.
+ * @param count Number of elements in pEvents.
+ * @param mask Event mask as set by the window.
+ * @param filter Mask based on event type.
+ * @param grab Possible grab on the device that caused the event. 
+ *
+ * @return 1 if event was delivered, 0 if not or -1 if grab was not set by the
+ * client.
+ */
 _X_EXPORT int
 TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, 
                  Mask filter, GrabPtr grab)
@@ -1588,6 +1711,23 @@ TryClientEvents (ClientPtr client, xEven
     }
 }
 
+/**
+ * Deliver events to a window. At this point, we do not yet know if the event
+ * actually needs to be delivered. May activate a grab if the event is a
+ * button press.
+ *
+ * More than one event may be delivered at a time. This is the case with
+ * DeviceMotionNotifies which may be followed by DeviceValuator events.
+ * 
+ * @param pWin The window that would get the event.
+ * @param pEvents The events to be delivered.
+ * @param count Number of elements in pEvents.
+ * @param filter Mask based on event type.
+ * @param grab Possible grab on the device that caused the event. 
+ * @param mskidx Mask index, depending on device that caused event.
+ *
+ * @return Number of events delivered to various clients.
+ */
 int
 DeliverEventsToWindow(WindowPtr pWin, xEvent *pEvents, int count, 
                       Mask filter, GrabPtr grab, int mskidx)
@@ -1707,6 +1847,15 @@ XineramaTryClientEventsResult(
 }
 #endif
 
+/**
+ * Try to deliver events to the interested parties.
+ *
+ * @param pWin The window that would get the event.
+ * @param pEvents The events to be delivered.
+ * @param count Number of elements in pEvents.
+ * @param filter Mask based on event type.
+ * @param dontClient Don't deliver to the dontClient.
+ */
 int
 MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents, 
                            int count, Mask filter, ClientPtr dontClient)
@@ -1744,6 +1893,14 @@ MaybeDeliverEventsToClient(WindowPtr pWi
     return 2;
 }
 
+/**
+ * Adjust event fields to comply with the window properties.
+ *
+ * @param xE Event to be modified in place
+ * @param pWin The window to get the information from.
+ * @param child Child window setting for event (if applicable)
+ * @param calcChild If True, calculate the child window.
+ */
 static void
 FixUpEventFromWindow(
     xEvent *xE,
@@ -1798,6 +1955,22 @@ FixUpEventFromWindow(
     }
 }
 
+/**
+ * Deliver events caused by input devices. Called for all core input events
+ * and XI events. No filtering of events happens before DeliverDeviceEvents(),
+ * it will be called for any event that comes out of the event queue.
+ * 
+ * For all core events, dev is either inputInfo.pointer or inputInfo.keyboard.
+ * For all extension events, dev is the device that caused the event.
+ *
+ * @param pWin Window to deliver event to.
+ * @param xE Events to deliver.
+ * @param grab Possible grab on a device.
+ * @param stopAt Don't recurse up to the root window.
+ * @param dev The device that is responsible for the event.
+ * @param count number of events in xE.
+ *
+ */
 int
 DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, 
                     WindowPtr stopAt, DeviceIntPtr dev, int count)
@@ -1861,7 +2034,19 @@ DeliverDeviceEvents(WindowPtr pWin, xEve
     return 0;
 }
 
-/* not useful for events that propagate up the tree or extension events */
+/**
+ * Deliver event to a window and it's immediate parent. Used for most window
+ * events (CreateNotify, ConfigureNotify, etc.). Not useful for events that
+ * propagate up the tree or extension events 
+ *
+ * In case of a ReparentNotify event, the event will be delivered to the
+ * otherParent as well.
+ *
+ * @param pWin Window to deliver events to.
+ * @param xE Events to deliver.
+ * @param count number of events in xE.
+ * @param otherParent Used for ReparentNotify events.
+ */
 _X_EXPORT int
 DeliverEvents(WindowPtr pWin, xEvent *xE, int count, 
               WindowPtr otherParent)
@@ -1926,6 +2111,17 @@ PointInBorderSize(WindowPtr pWin, int x,
     return FALSE;
 }
 
+/**
+ * Traversed from the root window to the window at the position x/y. While
+ * traversing, it sets up the traversal history in the spriteTrace array.
+ * After completing, the spriteTrace history is set in the following way:
+ *   spriteTrace[0] ... root window
+ *   spriteTrace[1] ... top level window that encloses x/y
+ *       ...
+ *   spriteTrace[spriteTraceGood - 1] ... window at x/y
+ *
+ * @returns the window at the given coordinates.
+ */
 static WindowPtr 
 XYToWindow(int x, int y)
 {
@@ -1974,6 +2170,12 @@ XYToWindow(int x, int y)
     return spriteTrace[spriteTraceGood-1];
 }
 
+/**
+ * Update the sprite coordinates based on the event. Update the cursor
+ * position, then update the event with the new coordinates that may have been
+ * changed. If the window underneath the sprite has changed, change to new
+ * cursor and send enter/leave events.
+ */
 static Bool
 CheckMotion(xEvent *xE)
 {
@@ -2046,6 +2248,10 @@ CheckMotion(xEvent *xE)
     return TRUE;
 }
 
+/**
+ * Windows have restructured, we need to update the sprite position and the
+ * sprite's cursor.
+ */
 _X_EXPORT void
 WindowsRestructured(void)
 {
@@ -2091,6 +2297,10 @@ void ReinitializeRootWindow(WindowPtr wi
 }
 #endif
 
+/**
+ * Set the given window to sane values, display the cursor in the center of
+ * the screen. Called from main() with the root window on the first screen.
+ */
 void
 DefineInitialRootWindow(WindowPtr win)
 {
@@ -2297,6 +2507,10 @@ XineramaWarpPointer(ClientPtr client)
 #endif
 
 
+/**
+ * Server-side protocol handling for WarpPointer request.
+ * Warps the cursor position to the coordinates given in the request.
+ */
 int
 ProcWarpPointer(ClientPtr client)
 {
@@ -2405,8 +2619,15 @@ BorderSizeNotEmpty(WindowPtr pWin)
      return FALSE;
 }
 
-/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
-	passive grab set on the window to be activated. */
+/** 
+ * "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
+ * passive grab set on the window to be activated. 
+ * 
+ * @param pWin The window that may be subject to a passive grab.
+ * @param device Device that caused the event.
+ * @param xE List of events (multiple ones for DeviceMotionNotify)
+ * @count number of elements in xE.
+ */
 
 static Bool
 CheckPassiveGrabsOnWindow(
@@ -2556,6 +2777,16 @@ CheckDeviceGrabs(DeviceIntPtr device, xE
     return FALSE;
 }
 
+/**
+ * Called for keyboard events to deliver event to whatever client owns the
+ * focus. Event is delivered to the keyboard's focus window, the root window
+ * or to the window owning the input focus.
+ *
+ * @param keybd The keyboard originating the event.
+ * @param xE The event list.
+ * @param window Window underneath the sprite.
+ * @param count number of events in xE.
+ */
 void
 DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count)
 {
@@ -2584,6 +2815,13 @@ DeliverFocusedEvent(DeviceIntPtr keybd, 
 				NullGrab, mskidx);
 }
 
+/**
+ * Deliver an event from a device that is currently grabbed. Uses
+ * DeliverDeviceEvents() for further delivery if a ownerEvents is set on the
+ * grab. If not, TryClientEvents() is used.
+ *
+ * @param deactivateGrab True if the device's grab should be deactivated.
+ */
 void
 DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, 
                     Bool deactivateGrab, int count)
@@ -2666,6 +2904,17 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIn
 	}
 }
 
+/**
+ * Main keyboard event processing function for core keyboard events. 
+ * Updates the events fields from the current pointer state and delivers the
+ * event.
+ *
+ * For key events, xE will always be a single event.
+ *
+ * @param xE Event list
+ * @param keybd The device that caused an event.
+ * @param count Number of elements in xE.
+ */
 void
 #ifdef XKB
 CoreProcessKeyboardEvent (xEvent *xE, DeviceIntPtr keybd, int count)
@@ -2861,6 +3110,18 @@ FixKeyState (xEvent *xE, DeviceIntPtr ke
 }
 #endif
 
+/** 
+ * Main pointer event processing function for core pointer events. 
+ * For motion events: update the sprite.
+ * For all other events: Update the event fields based on the current sprite
+ * state.
+ *
+ * For core pointer events, xE will always be a single event.
+ *
+ * @param xE Event list
+ * @param mouse The device that caused an event.
+ * @param count Number of elements in xE.
+ */
 void
 #ifdef XKB
 CoreProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
@@ -2974,6 +3235,18 @@ ProcessPointerEvent (xEvent *xE, DeviceI
 #define AtMostOneClient \
 	(SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask)
 
+/**
+ * Recalculate which events may be deliverable for the given window.
+ * Recalculated mask is used for quicker determination which events may be
+ * delivered to a window.
+ *
+ * The otherEventMasks on a WindowOptional is the combination of all event
+ * masks set by all clients on the window.
+ * deliverableEventMask is the combination of the eventMask and the
+ * otherEventMask.
+ *
+ * Traverses to siblings and parents of the window.
+ */
 void
 RecalculateDeliverableEvents(pWin)
     WindowPtr pWin;
@@ -3172,6 +3445,9 @@ EventSuppressForWindow(WindowPtr pWin, C
     return Success;
 }
 
+/**
+ * @return The window that is the first ancestor of both a and b.
+ */
 static WindowPtr 
 CommonAncestor(
     WindowPtr a,
@@ -3182,6 +3458,10 @@ CommonAncestor(
     return NullWindow;
 }
 
+/**
+ * Assembles an EnterNotify or LeaveNotify and sends it event to the client. 
+ * The core devices are used to fill in the event fields.
+ */
 static void
 EnterLeaveEvent(
     int type,
@@ -3264,6 +3544,10 @@ EnterLeaveEvent(
     }
 }
 
+/**
+ * Send enter notifies to all parent windows up to ancestor.
+ * This function recurses.
+ */
 static void
 EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail)
 {
@@ -3275,6 +3559,11 @@ EnterNotifies(WindowPtr ancestor, Window
     EnterLeaveEvent(EnterNotify, mode, detail, parent, child->drawable.id);
 }
 
+
+/**
+ * Send leave notifies to all parent windows up to ancestor.
+ * This function recurses.
+ */
 static void
 LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail)
 {
@@ -3289,6 +3578,13 @@ LeaveNotifies(WindowPtr child, WindowPtr
     }
 }
 
+/**
+ * Figure out if enter/leave events are necessary and send them to the
+ * appropriate windows.
+ * 
+ * @param fromWin Window the sprite moved out of.
+ * @param toWin Window the sprite moved into.
+ */
 static void
 DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode)
 {
@@ -3522,6 +3818,23 @@ DoFocusEvents(DeviceIntPtr dev, WindowPt
     }
 }
 
+/**
+ * Set the input focus to the given window. Subsequent keyboard events will be
+ * delivered to the given window.
+ * 
+ * Usually called from ProcSetInputFocus as result of a client request. If so,
+ * the device is the inputInfo.keyboard.
+ * If called from ProcXSetInputFocus as result of a client xinput request, the
+ * device is set to the device specified by the client.
+ *
+ * @param client Client that requested input focus change.
+ * @param dev Focus device. 
+ * @param focusID The window to obtain the focus. Can be PointerRoot or None.
+ * @param revertTo Specifies where the focus reverts to when window becomes
+ * unviewable.
+ * @param ctime Specifies the time.
+ * @param followOK True if pointer is allowed to follow the keyboard.
+ */
 int
 SetInputFocus(
     ClientPtr client,
@@ -3598,6 +3911,11 @@ SetInputFocus(
     return Success;
 }
 
+/**
+ * Server-side protocol handling for SetInputFocus request.
+ *
+ * Sets the input focus for the virtual core keyboard.
+ */
 int
 ProcSetInputFocus(client)
     ClientPtr client;
@@ -3613,6 +3931,12 @@ ProcSetInputFocus(client)
 			 stuff->revertTo, stuff->time, FALSE);
 }
 
+/**
+ * Server-side protocol handling for GetInputFocus request.
+ * 
+ * Sends the current input focus for the virtual core keyboard back to the
+ * client.
+ */
 int
 ProcGetInputFocus(ClientPtr client)
 {
@@ -3634,6 +3958,12 @@ ProcGetInputFocus(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for Grabpointer request.
+ *
+ * Sets an active grab on the inputInfo.pointer and returns success status to
+ * client.
+ */
 int
 ProcGrabPointer(ClientPtr client)
 {
@@ -3741,6 +4071,14 @@ ProcGrabPointer(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for ChangeActivePointerGrab request.
+ *
+ * Changes properties of the grab hold by the client. If the client does not
+ * hold an active grab on the device, nothing happens. 
+ *
+ * Works on the core pointer only.
+ */
 int
 ProcChangeActivePointerGrab(ClientPtr client)
 {
@@ -3787,6 +4125,11 @@ ProcChangeActivePointerGrab(ClientPtr cl
     return Success;
 }
 
+/**
+ * Server-side protocol handling for UngrabPointer request.
+ *
+ * Deletes the pointer grab on the core pointer device.
+ */
 int
 ProcUngrabPointer(ClientPtr client)
 {
@@ -3806,6 +4149,24 @@ ProcUngrabPointer(ClientPtr client)
     return Success;
 }
 
+/**
+ * Sets a grab on the given device.
+ * 
+ * Called from ProcGrabKeyboard to work on the inputInfo.keyboard.
+ * Called from ProcXGrabDevice to work on the device specified by the client.
+ * 
+ * The parameters this_mode and other_mode represent the keyboard_mode and
+ * pointer_mode parameters of XGrabKeyboard(). 
+ * See man page for details on all the parameters
+ * 
+ * @param client Client that owns the grab.
+ * @param dev The device to grab. 
+ * @param this_mode GrabModeSync or GrabModeAsync
+ * @param other_mode GrabModeSync or GrabModeAsync
+ * @param status Return code to be returned to the caller.
+ * 
+ * @returns Success or BadValue.
+ */
 int
 GrabDevice(ClientPtr client, DeviceIntPtr dev, 
            unsigned this_mode, unsigned other_mode, Window grabWindow, 
@@ -3864,6 +4225,11 @@ GrabDevice(ClientPtr client, DeviceIntPt
     return Success;
 }
 
+/**
+ * Server-side protocol handling for GrabKeyboard request.
+ *
+ * Grabs the inputInfo.keyboad and returns success status to client.
+ */
 int
 ProcGrabKeyboard(ClientPtr client)
 {
@@ -3892,6 +4258,11 @@ ProcGrabKeyboard(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for UngrabKeyboard request.
+ *
+ * Deletes a possible grab on the inputInfo.keyboard.
+ */
 int
 ProcUngrabKeyboard(ClientPtr client)
 {
@@ -3911,6 +4282,11 @@ ProcUngrabKeyboard(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for QueryPointer request.
+ *
+ * Returns the current state and position of the core pointer to the client. 
+ */
 int
 ProcQueryPointer(ClientPtr client)
 {
@@ -3969,6 +4345,10 @@ ProcQueryPointer(ClientPtr client)
     return(Success);    
 }
 
+/**
+ * Initializes the device list and the DIX sprite to sane values. Allocates
+ * trace memory used for quick window traversal.
+ */
 void
 InitEvents(void)
 {
@@ -4030,6 +4410,11 @@ CloseDownEvents(void)
   spriteTraceSize = 0;
 }
 
+/**
+ * Server-side protocol handling for SendEvent request.
+ *
+ * Locates the window to send the event to and forwards the event. 
+ */
 int
 ProcSendEvent(ClientPtr client)
 {
@@ -4117,6 +4502,12 @@ ProcSendEvent(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for UngrabKey request.
+ *
+ * Deletes a passive grab for the given key. Only works on the
+ * inputInfo.keyboard.
+ */
 int
 ProcUngrabKey(ClientPtr client)
 {
@@ -4159,6 +4550,12 @@ ProcUngrabKey(ClientPtr client)
     return(Success);
 }
 
+/**
+ * Server-side protocol handling for GrabKey request.
+ *
+ * Creates a grab for the inputInfo.keyboard and adds it to the list of
+ * passive grabs. 
+ */
 int
 ProcGrabKey(ClientPtr client)
 {
@@ -4214,6 +4611,12 @@ ProcGrabKey(ClientPtr client)
 }
 
 
+/**
+ * Server-side protocol handling for GrabButton request.
+ *
+ * Creates a grab for the inputInfo.pointer and adds it as a passive grab to
+ * the list.
+ */
 int
 ProcGrabButton(ClientPtr client)
 {
@@ -4287,6 +4690,11 @@ ProcGrabButton(ClientPtr client)
     return AddPassiveGrabToList(grab);
 }
 
+/**
+ * Server-side protocol handling for UngrabButton request.
+ *
+ * Deletes a passive grab on the inputInfo.pointer from the list.
+ */
 int
 ProcUngrabButton(ClientPtr client)
 {
@@ -4320,6 +4728,17 @@ ProcUngrabButton(ClientPtr client)
     return(Success);
 }
 
+/**
+ * Deactivate any grab that may be on the window, remove the focus.
+ * Delete any XInput extension events from the window too. Does not change the
+ * window mask. Use just before the window is deleted.
+ *
+ * If freeResources is set, passive grabs on the window are deleted.
+ *
+ * @param pWin The window to delete events from.
+ * @param freeResources True if resources associated with the window should be
+ * deleted.
+ */
 void
 DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
 {
@@ -4409,7 +4828,9 @@ DeleteWindowFromAnyEvents(WindowPtr pWin
 }
 
 /**
- * Call this whenever some window at or below pWin has changed geometry 
+ * Call this whenever some window at or below pWin has changed geometry. If
+ * there is a grab on the window, the cursor will be re-confined into the
+ * window.
  */
 _X_EXPORT void
 CheckCursorConfinement(WindowPtr pWin)
@@ -4445,6 +4866,9 @@ EventMaskForClient(WindowPtr pWin, Clien
     return 0;
 }
 
+/**
+ * Server-side protocol handling for RecolorCursor request.
+ */
 int
 ProcRecolorCursor(ClientPtr client)
 {
@@ -4486,6 +4910,20 @@ ProcRecolorCursor(ClientPtr client)
     return (Success);
 }
 
+/**
+ * Write the given events to a client, swapping the byte order if necessary.
+ * To swap the byte ordering, a callback is called that has to be set up for
+ * the given event type.
+ *
+ * In the case of DeviceMotionNotify trailed by DeviceValuators, the events
+ * can be more than one. Usually it's just one event. 
+ *
+ * Do not modify the event structure passed in. See comment below.
+ * 
+ * @param pClient Client to send events to.
+ * @param count Number of events.
+ * @param events The event list.
+ */
 _X_EXPORT void
 WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
 {
diff-tree 33a5d9605e3e282f6aa1921d7321a2a12ef02c42 (from 0910540e4322bba72a2fa0a907072eab2547a7b6)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Apr 11 18:28:57 2007 +0300

    XFree86: DGA: Don't call ProcessInputEvents from CloseScreen
    
    By the time CloseScreen gets called, we can't call ProcessInputEvents, as
    the event queue will get unhappy.  So just unregister our hooks instantly,
    and hope that they don't get called.

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 43db1ee..9474ec8 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -249,14 +249,11 @@ DGACloseScreen(int i, ScreenPtr pScreen)
    DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
 
    if (XDGAEventBase) {
-       OsBlockSignals();
-       ProcessInputEvents();
        mieqSetHandler(*XDGAEventBase + MotionNotify, NULL);
        mieqSetHandler(*XDGAEventBase + ButtonPress, NULL);
        mieqSetHandler(*XDGAEventBase + ButtonRelease, NULL);
        mieqSetHandler(*XDGAEventBase + KeyPress, NULL);
        mieqSetHandler(*XDGAEventBase + KeyRelease, NULL);
-       OsReleaseSignals();
     }
 
    FreeMarkedVisuals(pScreen);
diff-tree 0910540e4322bba72a2fa0a907072eab2547a7b6 (from aecbc712144dd1aaf462bd758821438b1d22d957)
Author: Remigiusz Marcinkiewicz <enleth at enleth.com>
Date:   Wed Apr 11 01:09:26 2007 +0300

    Config: Extend D-BUS API
    
    Return device ID where available.
    Add listDevices call, which does what it says on the box.

diff --git a/config/config.c b/config/config.c
index aae5c6e..9828091 100644
--- a/config/config.c
+++ b/config/config.c
@@ -92,12 +92,15 @@ configTeardown(void)
 }
 
 static int
-configAddDevice(DBusMessage *message, DBusMessageIter *iter, DBusError *error)
+configAddDevice(DBusMessage *message, DBusMessageIter *iter, 
+                DBusMessage *reply, DBusMessageIter *r_iter,
+                DBusError *error)
 {
     DBusMessageIter subiter;
     InputOption *tmpo = NULL, *options = NULL;
     char *tmp = NULL;
     int ret = BadMatch;
+    DeviceIntPtr dev = NULL;
 
     DebugF("[config] adding device\n");
 
@@ -165,12 +168,28 @@ configAddDevice(DBusMessage *message, DB
         dbus_message_iter_next(iter);
     }
 
-    ret = NewInputDeviceRequest(options);
-    if (ret != Success)
+    ret = NewInputDeviceRequest(options, &dev);
+    if (ret != Success) {
         DebugF("[config] NewInputDeviceRequest failed\n");
+        goto unwind;
+    }
+
+    if (!dev) {
+        DebugF("[config] NewInputDeviceRequest succeeded, without device\n"); 
+        ret = BadMatch;
+        goto unwind;
+    }
+
+    if (!dbus_message_iter_append_basic(r_iter, DBUS_TYPE_INT32, &(dev->id))) {
+        ErrorF("[config] couldn't append to iterator\n");
+        ret = BadAlloc;
+        goto unwind;
+    }
 
-    /* Fall through, must deallocate memory we've allocated */
 unwind:
+    if (dev && ret != Success)
+        RemoveDevice(dev);
+
     while (options) {
         tmpo = options;
         options = options->next;
@@ -218,17 +237,47 @@ unwind:
     return ret;
 }
 
+static int
+configListDevices(DBusMessage *message, DBusMessageIter *iter,
+                   DBusMessage *reply, DBusMessageIter *r_iter,
+                   DBusError *error)
+{
+    DeviceIntPtr d;
+    int ret = BadMatch;
+
+    for (d = inputInfo.devices; d; d = d->next) {
+        if (!dbus_message_iter_append_basic(r_iter, DBUS_TYPE_INT32,
+                                            &(d->id))) {
+            ErrorF("[config] couldn't append to iterator\n");
+            ret = BadAlloc;
+            goto unwind;
+        }
+        if (!dbus_message_iter_append_basic(r_iter, DBUS_TYPE_STRING,
+                                            &(d->name))) {
+            ErrorF("[config] couldn't append to iterator\n");
+            ret = BadAlloc;
+            goto unwind;
+        }
+    }
+
+unwind:
+    return ret;
+}
+
 static DBusHandlerResult
 configMessage(DBusConnection *connection, DBusMessage *message, void *closure)
 {
     DBusMessageIter iter;
     DBusError error;
     DBusMessage *reply;
+    DBusMessageIter r_iter;
     DBusConnection *bus = closure;
     int ret = BadDrawable; /* nonsensical value */
 
     dbus_error_init(&error);
 
+    DebugF("[config] received a message\n");
+
     if (strcmp(dbus_message_get_interface(message),
                "org.x.config.input") == 0) {
         if (!dbus_message_iter_init(message, &iter)) {
@@ -237,26 +286,33 @@ configMessage(DBusConnection *connection
             return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
         }
 
+        if (!(reply = dbus_message_new_method_return(message))) {
+            ErrorF("[config] failed to create the reply message\n");
+            dbus_error_free(&error);
+            return DBUS_HANDLER_RESULT_NEED_MEMORY;
+        }
+        dbus_message_iter_init_append(reply, &r_iter);
+        
         if (strcmp(dbus_message_get_member(message), "add") == 0)
-            ret = configAddDevice(message, &iter, &error);
+            ret = configAddDevice(message, &iter, reply, &r_iter, &error);
         else if (strcmp(dbus_message_get_member(message), "remove") == 0)
             ret = configRemoveDevice(message, &iter, &error);
+        else if (strcmp(dbus_message_get_member(message), "listDevices") == 0)
+            ret = configListDevices(message, &iter, reply, &r_iter, &error);
         if (ret != BadDrawable && ret != BadAlloc) {
-            reply = dbus_message_new_method_return(message);
-            dbus_message_iter_init_append(reply, &iter);
 
-            if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret)) {
-                ErrorF("[config] couldn't append to iterator\n");
-                dbus_error_free(&error);
-                return DBUS_HANDLER_RESULT_HANDLED;
-            }
+            if (!strlen(dbus_message_get_signature(reply)))
+                if (!dbus_message_iter_append_basic(&r_iter, DBUS_TYPE_INT32, &ret)) {
+                    ErrorF("[config] couldn't append to iterator\n");
+                    dbus_error_free(&error);
+                    return DBUS_HANDLER_RESULT_HANDLED;
+                }
 
             if (!dbus_connection_send(bus, reply, NULL))
                 ErrorF("[config] failed to send reply\n");
-            dbus_connection_flush(bus);
-
-            dbus_message_unref(reply);
         }
+        dbus_message_unref(reply);
+        dbus_connection_flush(bus);
     }
 
     dbus_error_free(&error);
diff-tree aecbc712144dd1aaf462bd758821438b1d22d957 (from 4f05f9591e5492c72f3856bd7a2ff13378f59f2b)
Author: Remigiusz Marcinkiewicz <enleth at enleth.com>
Date:   Wed Apr 11 00:38:16 2007 +0300

    Input: Allow a pointer to a device to be returned in NIDR
    
    Allow a pointer to the first device added to be returned, so we know which
    device(s) were added by the NIDR call.

diff --git a/Xi/stubs.c b/Xi/stubs.c
index d425fe9..40cd02f 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -226,7 +226,7 @@ ChangeDeviceControl(ClientPtr client, De
  *
  */
 int
-NewInputDeviceRequest(InputOption *options)
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
 {
     return BadValue;
 }
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index a9a743b..7edcc51 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2307,7 +2307,7 @@ ChangeDeviceControl(register ClientPtr c
 }
 
 int
-NewInputDeviceRequest(InputOption *options)
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
 {
     InputOption *option = NULL;
     KdPointerInfo *pi = NULL;
@@ -2372,6 +2372,12 @@ NewInputDeviceRequest(InputOption *optio
         }
     }
 
+    if (pi) {
+        *pdev = pi->dixdev;
+    } else if(ki) {
+        *pdev = ki->dixdev;
+    }
+
     return Success;
 }
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index f662c17..6ebb087 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -315,7 +315,7 @@ AddOtherInputDevices()
 #endif
 
 int
-NewInputDeviceRequest (InputOption *options)
+NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
 {
     IDevRec *idev = NULL;
     InputDriverPtr drv = NULL;
@@ -409,6 +409,7 @@ NewInputDeviceRequest (InputOption *opti
     if (dev->inited && dev->startup)
         EnableDevice(dev);
 
+    *pdev = dev;
     return Success;
 
 unwind:
diff --git a/include/input.h b/include/input.h
index 1e65709..b399d3a 100644
--- a/include/input.h
+++ b/include/input.h
@@ -445,7 +445,8 @@ extern DeviceIntPtr LookupDeviceIntRec(
 
 /* Implemented by the DDX. */
 extern int NewInputDeviceRequest(
-    InputOption *options);
+    InputOption *options,
+    DeviceIntPtr *dev);
 extern void DeleteInputDeviceRequest(
     DeviceIntPtr dev);
 
diff-tree 4f05f9591e5492c72f3856bd7a2ff13378f59f2b (from 20674dcbb2373a0af287883bc008fb6fb23d4466)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:57:48 2007 +0300

    Input: Always add devices with first available ID
    
    Scan the device list when adding a new device, and make sure we can use
    the first available ID, instead of always incrementing.

diff --git a/dix/devices.c b/dix/devices.c
index 004cb13..c2d4f22 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -86,15 +86,27 @@ DeviceIntPtr
 AddInputDevice(DeviceProc deviceProc, Bool autoStart)
 {
     DeviceIntPtr dev, *prev; /* not a typo */
+    DeviceIntPtr devtmp;
+    int devid;
+    char devind[MAX_DEVICES];
+
+    /* Find next available id */
+    memset(devind, 0, sizeof(char)*MAX_DEVICES);
+    for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next)
+	devind[devtmp->id]++;
+    for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next)
+	devind[devtmp->id]++;
+    for (devid = 0; devid < MAX_DEVICES && devind[devid]; devid++)
+	;
 
-    if (inputInfo.numDevices >= MAX_DEVICES)
+    if (devid >= MAX_DEVICES)
 	return (DeviceIntPtr)NULL;
     dev = (DeviceIntPtr) xcalloc(sizeof(DeviceIntRec), 1);
     if (!dev)
 	return (DeviceIntPtr)NULL;
     dev->name = (char *)NULL;
     dev->type = 0;
-    dev->id = inputInfo.numDevices;
+    dev->id = devid;
     inputInfo.numDevices++;
     dev->public.on = FALSE;
     dev->public.processInputProc = (ProcessInputProc)NoopDDA;
@@ -572,6 +584,7 @@ RemoveDevice(DeviceIntPtr dev)
     }
     
     if (ret == Success) {
+        inputInfo.numDevices--;
         ev.type = DevicePresenceNotify;
         ev.time = currentTime.milliseconds;
         ev.devchange = 0;
diff-tree 20674dcbb2373a0af287883bc008fb6fb23d4466 (from 82962bbae2b4fda274625d1712ef839ce1ab9dc8)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:55:36 2007 +0300

    Config: Fix memory leaks
    
    Fix memory leaks that could occur along the error path.

diff --git a/config/config.c b/config/config.c
index b8d2428..aae5c6e 100644
--- a/config/config.c
+++ b/config/config.c
@@ -110,6 +110,11 @@ configAddDevice(DBusMessage *message, DB
 
     options->key = xstrdup("_source");
     options->value = xstrdup("client/dbus");
+    if(!options->key || !options->value) {
+        ErrorF("[config] couldn't allocate first key/value pair\n");
+        ret = BadAlloc;
+        goto unwind;
+    }
 
     while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_ARRAY) {
         tmpo = (InputOption *) xcalloc(sizeof(InputOption), 1);
@@ -118,6 +123,8 @@ configAddDevice(DBusMessage *message, DB
             ret = BadAlloc;
             goto unwind;
         }
+        tmpo->next = options;
+        options = tmpo;
 
         dbus_message_iter_recurse(iter, &subiter);
 
@@ -132,8 +139,8 @@ configAddDevice(DBusMessage *message, DB
                    tmp);
             MALFORMED_MESSAGE();
         }
-        tmpo->key = xstrdup(tmp);
-        if (!tmpo->key) {
+        options->key = xstrdup(tmp);
+        if (!options->key) {
             ErrorF("[config] couldn't duplicate key!\n");
             ret = BadAlloc;
             goto unwind;
@@ -148,15 +155,13 @@ configAddDevice(DBusMessage *message, DB
         dbus_message_iter_get_basic(&subiter, &tmp);
         if (!tmp)
             MALFORMED_MESSAGE();
-        tmpo->value = xstrdup(tmp);
-        if (!tmpo->value) {
+        options->value = xstrdup(tmp);
+        if (!options->value) {
             ErrorF("[config] couldn't duplicate option!\n");
             ret = BadAlloc;
             goto unwind;
         }
 
-        tmpo->next = options;
-        options = tmpo;
         dbus_message_iter_next(iter);
     }
 
@@ -164,16 +169,8 @@ configAddDevice(DBusMessage *message, DB
     if (ret != Success)
         DebugF("[config] NewInputDeviceRequest failed\n");
 
-    return ret;
-
+    /* Fall through, must deallocate memory we've allocated */
 unwind:
-    if (tmpo->key)
-        xfree(tmpo->key);
-    if (tmpo->value)
-        xfree(tmpo->value);
-    if (tmpo)
-        xfree(tmpo);
-
     while (options) {
         tmpo = options;
         options = options->next;
diff-tree 82962bbae2b4fda274625d1712ef839ce1ab9dc8 (from 7b82a836c66ba88566255052caff63577e1a0384)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:54:32 2007 +0300

    Input: Add DeleteInputDeviceRequest
    
    Add DIDR, which asks the DDX to remove a device, analogous to
    NewInputDeviceRequest.  Only implemented for XFree86 at the moment.

diff --git a/Xi/stubs.c b/Xi/stubs.c
index ed041b8..d425fe9 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -230,3 +230,15 @@ NewInputDeviceRequest(InputOption *optio
 {
     return BadValue;
 }
+
+/****************************************************************************
+ *
+ * Caller: configRemoveDevice (and others)
+ *
+ * Remove the specified device previously added.
+ *
+ */
+void
+DeleteInputDeviceRequest(DeviceIntPtr dev)
+{
+}
diff --git a/config/config.c b/config/config.c
index d72b588..b8d2428 100644
--- a/config/config.c
+++ b/config/config.c
@@ -212,7 +212,7 @@ configRemoveDevice(DBusMessage *message,
      * already been removed. */
     OsBlockSignals();
     ProcessInputEvents();
-    RemoveDevice(pDev);
+    DeleteInputDeviceRequest(pDev);
     OsReleaseSignals();
 
     return Success;
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 857f04f..a9a743b 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2374,3 +2374,8 @@ NewInputDeviceRequest(InputOption *optio
 
     return Success;
 }
+
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+}
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 913735b..e0b758f 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -371,8 +371,11 @@ xf86DeleteInput(InputInfoPtr pInp, int f
     if (pInp->drv)
 	pInp->drv->refCount--;
 
+    /* This should *really* be handled in drv->UnInit(dev) call instead */
+#if 0
     if (pInp->private)
 	xfree(pInp->private);
+#endif
 
     /* Remove the entry from the list. */
     if (pInp == xf86InputDevs)
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 3800d9a..f662c17 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -427,6 +427,26 @@ unwind:
     return rval;
 }
 
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+    LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
+    InputDriverPtr drv = pInfo->drv;
+    IDevRec *idev = pInfo->conf_idev;
+
+    RemoveDevice(pDev);
+
+    if(drv->UnInit)
+        drv->UnInit(drv, pInfo, 0);
+    else
+        xf86DeleteInput(pInfo, 0);
+
+    xfree(idev->driver);
+    xfree(idev->identifier);
+    xf86optionListFree(idev->commonOptions);
+    xfree(idev);
+}
+
 /* 
  * convenient functions to post events
  */
diff --git a/include/input.h b/include/input.h
index fc607d3..1e65709 100644
--- a/include/input.h
+++ b/include/input.h
@@ -446,6 +446,8 @@ extern DeviceIntPtr LookupDeviceIntRec(
 /* Implemented by the DDX. */
 extern int NewInputDeviceRequest(
     InputOption *options);
+extern void DeleteInputDeviceRequest(
+    DeviceIntPtr dev);
 
 extern void DDXRingBell(
     int volume,
diff-tree 7b82a836c66ba88566255052caff63577e1a0384 (from 4771fa8747791498e504d73afccfb5833499a38b)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:52:08 2007 +0300

    XFree86: Fix memory leaks, option parsing, in NewInputDeviceRequest
    
    Plugged some possible memory leaks, and added some more checks on the
    options, particular for driver/identifier.  Added an unwind.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 17ffed8..3800d9a 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -322,6 +322,7 @@ NewInputDeviceRequest (InputOption *opti
     InputInfoPtr pInfo = NULL;
     InputOption *option = NULL;
     DeviceIntPtr dev = NULL;
+    int rval = Success;
 
     idev = xcalloc(sizeof(*idev), 1);
     if (!idev)
@@ -329,64 +330,101 @@ NewInputDeviceRequest (InputOption *opti
 
     for (option = options; option; option = option->next) {
         if (strcmp(option->key, "driver") == 0) {
-            if (!xf86LoadOneModule(option->value, NULL))
-                return BadName;
+            if (idev->driver) {
+                rval = BadRequest;
+                goto unwind;
+            }
+            /* Memory leak for every attached device if we don't
+             * test if the module is already loaded first */
             drv = xf86LookupInputDriver(option->value);
+            if (!drv)
+                if(xf86LoadOneModule(option->value, NULL))
+                    drv = xf86LookupInputDriver(option->value);
             if (!drv) {
                 xf86Msg(X_ERROR, "No input driver matching `%s'\n",
                         option->value);
-                return BadName;
+                rval = BadName;
+                goto unwind;
             }
             idev->driver = xstrdup(option->value);
             if (!idev->driver) {
-                xfree(idev);
-                return BadAlloc;
+                rval = BadAlloc;
+                goto unwind;
             }
         }
         if (strcmp(option->key, "name") == 0 ||
             strcmp(option->key, "identifier") == 0) {
+            if (idev->identifier) {
+                rval = BadRequest;
+                goto unwind;
+            }
             idev->identifier = xstrdup(option->value);
             if (!idev->identifier) {
-                xfree(idev);
-                return BadAlloc;
+                rval = BadAlloc;
+                goto unwind;
             }
         }
     }
+    if(!idev->driver || !idev->identifier) {
+        xf86Msg(X_ERROR, "No input driver/identifier specified (ignoring)\n");
+        rval = BadRequest;
+        goto unwind;
+    }
 
     if (!drv->PreInit) {
         xf86Msg(X_ERROR,
                 "Input driver `%s' has no PreInit function (ignoring)\n",
                 drv->driverName);
-        return BadImplementation;
+        rval = BadImplementation;
+        goto unwind;
     }
 
-    idev->commonOptions = NULL;
-    for (option = options; option; option = option->next)
+    for (option = options; option; option = option->next) {
+        /* Steal option key/value strings from the provided list.
+         * We need those strings, the InputOption list doesn't. */
         idev->commonOptions = xf86addNewOption(idev->commonOptions,
                                                option->key, option->value);
-    idev->extraOptions = NULL;
+        option->key = NULL;
+        option->value = NULL;
+    }
 
     pInfo = drv->PreInit(drv, idev, 0);
 
     if (!pInfo) {
         xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier);
-        return BadMatch;
+        rval = BadMatch;
+        goto unwind;
     }
     else if (!(pInfo->flags & XI86_CONFIGURED)) {
         xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
                 idev->identifier);
-        xf86DeleteInput(pInfo, 0);
-        return BadMatch;
+        rval = BadMatch;
+        goto unwind;
     }
 
     xf86ActivateDevice(pInfo);
 
     dev = pInfo->dev;
-    dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+    ActivateDevice(dev);
     if (dev->inited && dev->startup)
         EnableDevice(dev);
 
     return Success;
+
+unwind:
+    if(pInfo) {
+        if(drv->UnInit)
+            drv->UnInit(drv, pInfo, 0);
+        else
+            xf86DeleteInput(pInfo, 0);
+    }
+    if(idev->driver)
+        xfree(idev->driver);
+    if(idev->identifier)
+        xfree(idev->identifier);
+    xf86optionListFree(idev->commonOptions);
+    xfree(idev);
+    return rval;
 }
 
 /* 
diff-tree 4771fa8747791498e504d73afccfb5833499a38b (from 07c56abf84080c020a3e7b7703a447c7f996975c)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:48:00 2007 +0300

    XFree86: Fix memory leak in option parsing
    
    Fix option parsing functions and callers thereof to not leak memory.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index cbeda0b..0421bf9 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1271,7 +1271,7 @@ checkCoreInputDevices(serverLayoutPtr se
 			      (count + 1) * sizeof(IDevRec));
 	    indp[count - 1] = Pointer;
 	    indp[count - 1].extraOptions =
-				xf86addNewOption(NULL, "CorePointer", NULL);
+				xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL);
 	    indp[count].identifier = NULL;
 	    servlayoutp->inputs = indp;
 	}
@@ -1310,7 +1310,7 @@ checkCoreInputDevices(serverLayoutPtr se
 			      (count + 1) * sizeof(IDevRec));
 	    indp[count - 1] = Pointer;
 	    indp[count - 1].extraOptions =
-				xf86addNewOption(NULL, "AlwaysCore", NULL);
+				xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
 	    indp[count].identifier = NULL;
 	    servlayoutp->inputs = indp;
 	}
@@ -1401,7 +1401,7 @@ checkCoreInputDevices(serverLayoutPtr se
 			      (count + 1) * sizeof(IDevRec));
 	    indp[count - 1] = Keyboard;
 	    indp[count - 1].extraOptions =
-				xf86addNewOption(NULL, "CoreKeyboard", NULL);
+				xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL);
 	    indp[count].identifier = NULL;
 	    servlayoutp->inputs = indp;
 	}
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 4b482df..7b04bd6 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -309,13 +309,16 @@ configureInputSection (void)
     mouse->inp_identifier = "Mouse0";
     mouse->inp_driver = "mouse";
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO);
+		xf86addNewOption(mouse->inp_option_lst, xstrdup("Protocol"),
+				xstrdup(DFLT_MOUSE_PROTO));
 #ifndef __SCO__
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV);
+		xf86addNewOption(mouse->inp_option_lst, xstrdup("Device"),
+				xstrdup(DFLT_MOUSE_DEV));
 #endif
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, "ZAxisMapping", "4 5 6 7");
+		xf86addNewOption(mouse->inp_option_lst, xstrdup("ZAxisMapping"),
+				xstrdup("4 5 6 7"));
     ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
     return ptr;
 }
@@ -519,7 +522,7 @@ configureLayoutSection (void)
 	iptr->iref_option_lst = NULL;
 	iptr->iref_inputdev_str = "Mouse0";
 	iptr->iref_option_lst =
-		xf86addNewOption (iptr->iref_option_lst, "CorePointer", NULL);
+		xf86addNewOption (iptr->iref_option_lst, xstrdup("CorePointer"), NULL);
 	ptr->lay_input_lst = (XF86ConfInputrefPtr)
 		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
     }
@@ -532,7 +535,7 @@ configureLayoutSection (void)
 	iptr->iref_option_lst = NULL;
 	iptr->iref_inputdev_str = "Keyboard0";
 	iptr->iref_option_lst =
-		xf86addNewOption (iptr->iref_option_lst, "CoreKeyboard", NULL);
+		xf86addNewOption (iptr->iref_option_lst, xstrdup("CoreKeyboard"), NULL);
 	ptr->lay_input_lst = (XF86ConfInputrefPtr)
 		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
     }
@@ -751,7 +754,7 @@ configureDDCMonitorSection (int screennu
     }
 
     if (ConfiguredMonitor->features.dpms) {
-      ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, "DPMS", NULL);
+      ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, xstrdup("DPMS"), NULL);
     }
 
     return ptr;
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 7afb63a..50a7d9c 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -289,7 +289,7 @@ xf86CheckBoolOption(pointer optlist, con
 _X_EXPORT pointer
 xf86ReplaceIntOption(pointer optlist, const char *name, const int val)
 {
-    char *tmp = xnfalloc(16);
+    char tmp[16];
     sprintf(tmp,"%i",val);
     return xf86AddNewOption(optlist,name,tmp);
 }
@@ -297,7 +297,7 @@ xf86ReplaceIntOption(pointer optlist, co
 _X_EXPORT pointer
 xf86ReplaceRealOption(pointer optlist, const char *name, const double val)
 {
-    char *tmp = xnfalloc(32);
+    char tmp[32];
     snprintf(tmp,32,"%f",val);
     return xf86AddNewOption(optlist,name,tmp);
 }
diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index 4adea1a..5b60a51 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -198,21 +198,21 @@ addNewOption2 (XF86OptionPtr head, char 
 {
 	XF86OptionPtr new, old = NULL;
 
-	/* Don't allow duplicates */
- 	if (head != NULL && (old = xf86findOption(head, name)) != NULL)
- 		new = old;
- 	else {
+	/* Don't allow duplicates, free old strings */
+	if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+		new = old;
+		xf86conffree(new->opt_name);
+		xf86conffree(new->opt_val);
+	}
+	else
 		new = xf86confcalloc (1, sizeof (XF86OptionRec));
- 		new->list.next = NULL;
- 	}
- 	new->opt_name = name;
- 	new->opt_val = val;
- 	new->opt_used = used;
-	
-  	if (old == NULL)
-		return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
- 	else 
- 		return head;
+	new->opt_name = name;
+	new->opt_val = val;
+	new->opt_used = used;
+
+	if (old)
+		return head;
+	return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
 }
 
 XF86OptionPtr
diff --git a/hw/xfree86/utils/xorgcfg/text-mode.c b/hw/xfree86/utils/xorgcfg/text-mode.c
index 9797ca2..8800c29 100644
--- a/hw/xfree86/utils/xorgcfg/text-mode.c
+++ b/hw/xfree86/utils/xorgcfg/text-mode.c
@@ -2111,7 +2111,7 @@ LayoutConfig(void)
 		    else
 			iref->iref_option_lst =
 			    xf86addNewOption(iref->iref_option_lst,
-					  "CorePointer", NULL);
+					  XtNewString("CorePointer"), NULL);
 		    option = xf86findOption(mref->iref_option_lst,
 					    "CorePointer");
 		    XtFree(option->opt_name);
@@ -2209,7 +2209,7 @@ LayoutConfig(void)
 		    else
 			iref->iref_option_lst =
 			    xf86addNewOption(iref->iref_option_lst,
-					  "CoreKeyboard", NULL);
+					  XtNewString("CoreKeyboard"), NULL);
 		    option = xf86findOption(kref->iref_option_lst,
 					    "CoreKeyboard");
 		    XtFree(option->opt_name);
diff-tree 07c56abf84080c020a3e7b7703a447c7f996975c (from e92743bc9839c36914a44f3e5bc8cd85773ac794)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:43:58 2007 +0300

    Input: Plug memory leak in device free
    
    Remember to also free the motion history, if we're using the DIX-managed
    history.

diff --git a/dix/devices.c b/dix/devices.c
index 9631c86..004cb13 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -431,8 +431,13 @@ CloseDevice(DeviceIntPtr dev)
 	xfree(dev->key);
     }
 
-    if (dev->valuator)
+    if (dev->valuator) {
+        /* Counterpart to 'biggest hack ever' in init. */
+        if (dev->valuator->motion &&
+            dev->valuator->GetMotionProc == GetMotionHistory)
+            xfree(dev->valuator->motion);
         xfree(dev->valuator);
+    }
 
     if (dev->button) {
 #ifdef XKB
diff-tree e92743bc9839c36914a44f3e5bc8cd85773ac794 (from e49f836d6fa2768cd6d2a6d0227b5dbf516013dc)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Apr 8 14:02:02 2007 +0300

    getevents: Copy modifier state from extended to core devices
    
    Make core events carry the same modifier state as the extended events, so
    that holding down Ctrl on keyboard A and pressing Q on keyboard B won't
    cause your app to quit.

diff --git a/dix/getevents.c b/dix/getevents.c
index 62f3bcb..6969f78 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -714,6 +714,7 @@ _X_EXPORT void
 SwitchCoreKeyboard(DeviceIntPtr pDev)
 {
     KeyClassPtr ckeyc = inputInfo.keyboard->key;
+    int i = 0;
 
     if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) {
         memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
@@ -728,6 +729,25 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
         ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
         SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
 
+        /*
+         * Copy state from the extended keyboard to core.  If you omit this,
+         * holding Ctrl on keyboard one, and pressing Q on keyboard two, will
+         * cause your app to quit.  This feels wrong to me, hence the below
+         * code.
+         *
+         * XXX: If you synthesise core modifier events, the state will get
+         *      clobbered here.  You'll have to work out something sensible
+         *      to fix that.  Good luck.
+         */
+
+#define KEYBOARD_MASK (ShiftMask | LockMask | ControlMask | Mod1Mask | \
+                       Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
+        ckeyc->state &= ~(KEYBOARD_MASK);
+        ckeyc->state |= (pDev->key->state & KEYBOARD_MASK);
+#undef KEYBOARD_MASK
+        for (i = 0; i < 8; i++)
+            ckeyc->modifierKeyCount[i] = pDev->key->modifierKeyCount[i];
+
 #ifdef XKB
         if (!noXkbExtension && pDev->key->xkbInfo && pDev->key->xkbInfo->desc) {
             if (!XkbCopyKeymap(pDev->key->xkbInfo->desc, ckeyc->xkbInfo->desc,
diff-tree e49f836d6fa2768cd6d2a6d0227b5dbf516013dc (from 4aae2de74b9224bac2b2e2522637dac09abc3837)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Apr 8 13:56:41 2007 +0300

    mieq: Use larger default queue size
    
    Use a default queue size of 512 rather than 256, else Xephyr is too slow
    without a host cursor, so events get stuck in the queue.

diff --git a/mi/mieq.c b/mi/mieq.c
index 34509cd..a03fff1 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -58,7 +58,7 @@ in this Software without prior written a
 # include <X11/extensions/dpms.h>
 #endif
 
-#define QUEUE_SIZE  256
+#define QUEUE_SIZE  512
 
 typedef struct _Event {
     xEvent          event[7];
diff-tree 4aae2de74b9224bac2b2e2522637dac09abc3837 (from f77a8ea849d171a8ca00b2b7334866ace1ffbf73)
Author: Jared D. McNeill <jmcneill at netbsd.org>
Date:   Tue Apr 10 12:57:15 2007 -0700

    Add a real xf86EnableIO/xf86DisableIO for NetBSD/PPC.

diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index 0992404..0432ba9 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -38,8 +38,7 @@ ARCH_SOURCES = i386_video.c
 endif
 
 if PPC_VIDEO
-ARCH_SOURCES = ppc_video.c \
-	$(srcdir)/../shared/ioperm_noop.c
+ARCH_SOURCES = ppc_video.c
 endif
 
 if SPARC64_VIDEO
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index ae65c8f..6a23b4e 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -56,6 +56,9 @@
 static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags);
 static void ppcUnmapVidMem(int, pointer, unsigned long);
 
+Bool xf86EnableIO(void);
+void xf86DisableIO(void);
+
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
@@ -63,6 +66,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	pVidMem->mapMem = ppcMapVidMem;
 	pVidMem->unmapMem = ppcUnmapVidMem;
 	pVidMem->initialised = TRUE;
+	xf86EnableIO();
 }
 
 
@@ -138,3 +142,32 @@ xf86EnableInterrupts()
 
 	return;
 }
+
+Bool xf86EnableIO()
+{
+        int fd = xf86Info.screenFd;
+
+        xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd);
+        if (ioBase == MAP_FAILED)
+        {
+                ioBase=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
+                    0xf2000000);
+                xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase);
+                if (ioBase == MAP_FAILED) {
+                        xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n");
+			return FALSE;
+		}
+        }
+	return TRUE;
+}
+
+void xf86DisableIO()
+{
+
+        if (ioBase != MAP_FAILED)
+        {
+                munmap(__UNVOLATILE(ioBase), 0x10000);
+                ioBase = MAP_FAILED;
+        }
+}
+
diff-tree f77a8ea849d171a8ca00b2b7334866ace1ffbf73 (from bcf17df69a232e5e84609abacdca36274316e170)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 14:29:46 2007 -0700

    Rotate screen size as needed from RandR 1.1 change requests.
    
    Screen size must reflect rotated mode size when setting rotated mode using
    RandR 1.1 SetScreenConfig request.
    (cherry picked from commit efcec7dbd3c2736c7b421d29c4d37e231aa681d2)

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index f83fce3..d92a0ff 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -741,6 +741,7 @@ ProcRRSetScreenConfig (ClientPtr client)
     RRModePtr		    mode;
     RR10DataPtr		    pData = NULL;
     RRScreenSizePtr    	    pSize;
+    int			    width, height;
     
     UpdateCurrentTime ();
 
@@ -883,8 +884,14 @@ ProcRRSetScreenConfig (ClientPtr client)
      * If the screen size is changing, adjust all of the other outputs
      * to fit the new size, mirroring as much as possible
      */
-    if (mode->mode.width != pScreen->width || 
-	mode->mode.height != pScreen->height)
+    width = mode->mode.width;
+    height = mode->mode.height;
+    if (rotation & (RR_Rotate_90|RR_Rotate_270))
+    {
+	width = mode->mode.height;
+	height = mode->mode.width;
+    }
+    if (width != pScreen->width || height != pScreen->height)
     {
 	int	c;
 
@@ -898,7 +905,7 @@ ProcRRSetScreenConfig (ClientPtr client)
 		goto sendReply;
 	    }
 	}
-	if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height,
+	if (!RRScreenSizeSet (pScreen, width, height,
 			      pScreen->mmWidth, pScreen->mmHeight))
 	{
 	    rep.status = RRSetConfigFailed;
diff-tree bcf17df69a232e5e84609abacdca36274316e170 (from 67e1c98895a566f927e1ae2384d56cfca104f971)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 14:12:27 2007 -0700

    Disable CRTC when SetSingleMode has no matching mode. Update RandR as well.
    
    xf86SetSingleMode tries to resize all crtcs to match the selected mode. When
    a CRTC has no matching mode, it now disables the CRTC (instead of crashing).
    
    Also, poke the RandR extension when xf86SetSingleMode is done so that
    appropriate events can be delivered, and so that future RandR queries return
    correct information.
    (cherry picked from commit dc6c4f6989f87149d8605604f4514f5cbf11de67)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 0fe03d3..7e7c7e7 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -233,8 +233,6 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, Displ
     int			saved_x, saved_y;
     Rotation		saved_rotation;
 
-    adjusted_mode = xf86DuplicateMode(mode);
-
     crtc->enabled = xf86CrtcInUse (crtc);
     
     if (!crtc->enabled)
@@ -243,6 +241,8 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, Displ
 	return TRUE;
     }
 
+    adjusted_mode = xf86DuplicateMode(mode);
+
     didLock = crtc->funcs->lock (crtc);
 
     saved_mode = crtc->mode;
@@ -1833,6 +1833,11 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, Di
 	    else
 		crtc_mode = xf86OutputFindClosestMode (output, desired);
 	}
+	if (!crtc_mode)
+	{
+	    crtc->enabled = FALSE;
+	    continue;
+	}
 	if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0))
 	    ok = FALSE;
 	else
@@ -1844,6 +1849,7 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, Di
 	}
     }
     xf86DisableUnusedFunctions(pScrn);
+    xf86RandR12TellChanged (pScrn->pScreen);
     return ok;
 }
 
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 6f52ee2..90de585 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1048,6 +1048,28 @@ xf86RandR12CreateScreenResources12 (Scre
     return TRUE;
 }
 
+/*
+ * Something happened within the screen configuration due
+ * to DGA, VidMode or hot key. Tell RandR
+ */
+
+void
+xf86RandR12TellChanged (ScreenPtr pScreen)
+{
+    ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
+    xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
+    XF86RandRInfoPtr	randrp = XF86RANDRINFO(pScreen);
+    int			c;
+
+    if (!randrp)
+	return;
+    xf86RandR12SetInfo12 (pScreen);
+    for (c = 0; c < config->num_crtc; c++)
+	xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
+
+    RRTellChanged (pScreen);
+}
+
 static void
 xf86RandR12PointerMoved (int scrnIndex, int x, int y)
 {
diff --git a/hw/xfree86/modes/xf86RandR12.h b/hw/xfree86/modes/xf86RandR12.h
index 8a4668b..0d3346a 100644
--- a/hw/xfree86/modes/xf86RandR12.h
+++ b/hw/xfree86/modes/xf86RandR12.h
@@ -33,5 +33,6 @@ Bool xf86RandR12SetConfig(ScreenPtr pScr
 Rotation xf86RandR12GetRotation(ScreenPtr pScreen);
 void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y);
 Bool xf86RandR12PreInit (ScrnInfoPtr pScrn);
+void xf86RandR12TellChanged (ScreenPtr pScreen);
 
 #endif /* _XF86_RANDR_H_ */
diff-tree 67e1c98895a566f927e1ae2384d56cfca104f971 (from a08d5157f70567a0aa9583d4a15e62437340cf34)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Apr 9 19:08:52 2007 -0400

    Look for the PCI ROM file elsewhere in sysfs.
    
    /sys/devices reflects the bus topology, and we don't care that much.
    Easier (and more reliable) to just look in /sys/bus/pci/devices, which
    is a flat view.

diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 55ed878..2aaa89c 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -773,8 +773,8 @@ xf86ReadDomainMemory(PCITAG Tag, ADDRESS
     bus  = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(Tag));
     dev  = PCI_DEV_FROM_TAG(Tag);
     func = PCI_FUNC_FROM_TAG(Tag);
-    sprintf(file, "/sys/devices/pci%04x:%02x/%04x:%02x:%02x.%1x/rom",
-	    dom, bus, dom, bus, dev, func);
+    sprintf(file, "/sys/bus/pci/devices/%04x:%02x:%02x.%1x/rom",
+	    dom, bus, dev, func);
 
     /*
      * If the caller wants the ROM and the sysfs rom interface exists,
diff-tree a08d5157f70567a0aa9583d4a15e62437340cf34 (from 72b477f964c748a1ab668781643cc11877f19738)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Apr 9 19:04:56 2007 -0400

    VT activate or waitactive are fatal if they fail.
    
    Also, be sure to waitactive on the way down, to make sure we're off the VT
    before exiting.

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 85b6def..9775180 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -245,15 +245,15 @@ xf86OpenConsole(void)
 	    lnx_savefont();
 #endif
 	    /*
-	     * now get the VT
+	     * now get the VT.  This _must_ succeed, or else fail completely.
 	     */
 	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
-	        xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed: %s\n",
-		        strerror(errno));
+	        FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n",
+		           strerror(errno));
 
 	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
-	        xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
-		    strerror(errno));
+	        FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
+			   strerror(errno));
 
 	    if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
 	        FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
@@ -350,6 +350,10 @@ xf86CloseConsole()
 	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
 	        xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
 		        strerror(errno));
+	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0)
+		xf86Msg(X_WARNING,
+			"xf86CloseConsole: VT_WAITACTIVE failed: %s\n",
+			strerror(errno));
 	    activeVT = -1;
         }
 
diff-tree 72b477f964c748a1ab668781643cc11877f19738 (from 1f6741db19d4c91b1eacb497dff1814acb1bf0c3)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Apr 9 18:59:01 2007 -0400

    Don't write out empty sections from the parser.

diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c
index 1869f56..3924001 100644
--- a/hw/xfree86/parser/write.c
+++ b/hw/xfree86/parser/write.c
@@ -107,13 +107,19 @@ doWriteConfigFile (const char *filename,
 
 	xf86printLayoutSection (cf, cptr->conf_layout_lst);
 
-	fprintf (cf, "Section \"Files\"\n");
-	xf86printFileSection (cf, cptr->conf_files);
-	fprintf (cf, "EndSection\n\n");
-
-	fprintf (cf, "Section \"Module\"\n");
-	xf86printModuleSection (cf, cptr->conf_modules);
-	fprintf (cf, "EndSection\n\n");
+	if (cptr->conf_files != NULL)
+	{
+		fprintf (cf, "Section \"Files\"\n");
+		xf86printFileSection (cf, cptr->conf_files);
+		fprintf (cf, "EndSection\n\n");
+	}
+
+	if (cptr->conf_modules != NULL)
+	{
+		fprintf (cf, "Section \"Module\"\n");
+		xf86printModuleSection (cf, cptr->conf_modules);
+		fprintf (cf, "EndSection\n\n");
+	}
 
 	xf86printVendorSection (cf, cptr->conf_vendor_lst);
 
diff-tree 1f6741db19d4c91b1eacb497dff1814acb1bf0c3 (from f24391dbfd12a84253dfec794ee7884afd52e197)
Author: Stefan Huehner <stefan at huehner.org>
Date:   Mon Apr 9 14:33:15 2007 -0700

    Bug #10560: Code-Cleanup: function declarations () -> (void)
    
    X.Org Bugzilla #10560: <https://bugs.freedesktop.org/show_bug.cgi?id=10560>
    Patch #9511 <https://bugs.freedesktop.org/attachment.cgi?id=9511>

diff --git a/Xext/sync.c b/Xext/sync.c
index 531b48c..c5441a1 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2509,7 +2509,7 @@ ServertimeBracketValues(pCounter, pbrack
 }
 
 static void
-SyncInitServerTime()
+SyncInitServerTime(void)
 {
     CARD64 resolution;
 
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 2233901..ddf3d1d 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -153,7 +153,7 @@ static int XvdiSendVideoNotify(XvPortPtr
 */
 
 void 
-XvExtensionInit()
+XvExtensionInit(void)
 {
   ExtensionEntry *extEntry;
 
@@ -205,7 +205,7 @@ XvExtensionInit()
 }
 
 static Bool
-CreateResourceTypes()
+CreateResourceTypes(void)
 
 {
   
@@ -335,13 +335,13 @@ XvResetProc(ExtensionEntry* extEntry)
 }
 
 _X_EXPORT int
-XvGetScreenIndex()
+XvGetScreenIndex(void)
 {
   return XvScreenIndex;
 }
 
 _X_EXPORT unsigned long
-XvGetRTPort()
+XvGetRTPort(void)
 {
   return XvRTPort;
 }
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index 737fc5d..ae35893 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -675,7 +675,7 @@ SProcXvMCDispatch (ClientPtr client)
 }
 
 void 
-XvMCExtensionInit()
+XvMCExtensionInit(void)
 {
    ExtensionEntry *extEntry;
 
diff --git a/config/config.c b/config/config.c
index 6c40143..d72b588 100644
--- a/config/config.c
+++ b/config/config.c
@@ -410,13 +410,13 @@ configReconnect(OsTimerPtr timer, CARD32
 }
 
 void
-configInitialise()
+configInitialise(void)
 {
     TimerSet(NULL, 0, 1, configReconnect, NULL);
 }
 
 void
-configFini()
+configFini(void)
 {
     DBusError error;
 
diff --git a/dix/atom.c b/dix/atom.c
index bd3223c..6ae3e31 100644
--- a/dix/atom.c
+++ b/dix/atom.c
@@ -167,7 +167,7 @@ NameForAtom(Atom atom)
 }
 
 void
-AtomError()
+AtomError(void)
 {
     FatalError("initializing atoms");
 }
@@ -185,7 +185,7 @@ FreeAtom(NodePtr patom)
 }
 
 void
-FreeAllAtoms()
+FreeAllAtoms(void)
 {
     if(atomRoot == (NodePtr)NULL)
 	return;
@@ -197,7 +197,7 @@ FreeAllAtoms()
 }
 
 void
-InitAtoms()
+InitAtoms(void)
 {
     FreeAllAtoms();
     tableLength = InitialTableSize;
diff --git a/dix/devices.c b/dix/devices.c
index f622be7..9631c86 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -314,7 +314,7 @@ CorePointerProc(DeviceIntPtr pDev, int w
 }
 
 void
-InitCoreDevices()
+InitCoreDevices(void)
 {
     DeviceIntPtr dev;
 
@@ -373,7 +373,7 @@ InitCoreDevices()
 }
 
 int
-InitAndStartDevices()
+InitAndStartDevices(void)
 {
     DeviceIntPtr dev, next;
 
@@ -503,7 +503,7 @@ CloseDevice(DeviceIntPtr dev)
 }
 
 void
-CloseDownDevices()
+CloseDownDevices(void)
 {
     DeviceIntPtr dev, next;
 
@@ -580,7 +580,7 @@ RemoveDevice(DeviceIntPtr dev)
 }
 
 int
-NumMotionEvents()
+NumMotionEvents(void)
 {
     return inputInfo.pointer->valuator->numMotionEvents;
 }
@@ -598,13 +598,13 @@ RegisterKeyboardDevice(DeviceIntPtr devi
 }
 
 _X_EXPORT DevicePtr
-LookupKeyboardDevice()
+LookupKeyboardDevice(void)
 {
     return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL;
 }
 
 _X_EXPORT DevicePtr
-LookupPointerDevice()
+LookupPointerDevice(void)
 {
     return inputInfo.pointer ? &inputInfo.pointer->public : NULL;
 }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 490b29c..6aba9db 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -218,7 +218,7 @@ SetInputCheck(HWEventQueuePtr c0, HWEven
 }
 
 _X_EXPORT void
-UpdateCurrentTime()
+UpdateCurrentTime(void)
 {
     TimeStamp systime;
 
@@ -237,7 +237,7 @@ UpdateCurrentTime()
 
 /* Like UpdateCurrentTime, but can't call ProcessInputEvents */
 _X_EXPORT void
-UpdateCurrentTimeIf()
+UpdateCurrentTimeIf(void)
 {
     TimeStamp systime;
 
@@ -250,7 +250,7 @@ UpdateCurrentTimeIf()
 }
 
 void
-InitSelections()
+InitSelections(void)
 {
     if (CurrentSelections)
 	xfree(CurrentSelections);
@@ -3654,7 +3654,7 @@ CloseDownClient(ClientPtr client)
 }
 
 static void
-KillAllClients()
+KillAllClients(void)
 {
     int i;
     for (i=1; i<currentMaxClients; i++)
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 62ad575..c21b3ec 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1878,7 +1878,7 @@ DeleteClientFontStuff(ClientPtr client)
 }
 
 void
-InitFonts ()
+InitFonts (void)
 {
     patternCache = MakeFontPatternCache();
 
@@ -1997,7 +1997,7 @@ RegisterFPEFunctions(NameCheckFunc name_
 }
 
 void
-FreeFonts()
+FreeFonts(void)
 {
     if (patternCache) {
 	FreeFontPatternCache(patternCache);
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 44d82c9..30327d3 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -550,7 +550,7 @@ RemoveBlockAndWakeupHandlers (BlockHandl
 }
 
 void
-InitBlockAndWakeupHandlers ()
+InitBlockAndWakeupHandlers (void)
 {
     xfree (handlers);
     handlers = (BlockHandlerPtr) 0;
@@ -950,7 +950,7 @@ DeleteCallbackList(CallbackListPtr *pcbl
 }
 
 void 
-InitCallbackManager()
+InitCallbackManager(void)
 {
     int i;
 
diff --git a/dix/events.c b/dix/events.c
index e008e36..093a316 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -844,7 +844,7 @@ ConfineCursorToWindow(WindowPtr pWin, Bo
 }
 
 _X_EXPORT Bool
-PointerConfinedToScreen()
+PointerConfinedToScreen(void)
 {
     return sprite.confined;
 }
@@ -913,19 +913,19 @@ PostNewCursor(void)
 }
 
 _X_EXPORT WindowPtr
-GetCurrentRootWindow()
+GetCurrentRootWindow(void)
 {
     return ROOT;
 }
 
 _X_EXPORT WindowPtr
-GetSpriteWindow()
+GetSpriteWindow(void)
 {
     return sprite.win;
 }
 
 _X_EXPORT CursorPtr
-GetSpriteCursor()
+GetSpriteCursor(void)
 {
     return sprite.current;
 }
@@ -939,7 +939,7 @@ GetSpritePosition(int *px, int *py)
 
 #ifdef PANORAMIX
 _X_EXPORT int
-XineramaGetCursorScreen()
+XineramaGetCursorScreen(void)
 {
     if(!noPanoramiXExtension) {
 	return sprite.screen->myNum;
@@ -1114,7 +1114,7 @@ FreezeThaw(DeviceIntPtr dev, Bool frozen
 }
 
 void
-ComputeFreezes()
+ComputeFreezes(void)
 {
     DeviceIntPtr replayDev = syncEvents.replayDev;
     int i;
@@ -2047,7 +2047,7 @@ CheckMotion(xEvent *xE)
 }
 
 _X_EXPORT void
-WindowsRestructured()
+WindowsRestructured(void)
 {
     (void) CheckMotion((xEvent *)NULL);
 }
@@ -3970,7 +3970,7 @@ ProcQueryPointer(ClientPtr client)
 }
 
 void
-InitEvents()
+InitEvents(void)
 {
     int i;
 
diff --git a/dix/extension.c b/dix/extension.c
index 88dff15..186574d 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -278,7 +278,7 @@ MinorOpcodeOfRequest(ClientPtr client)
 }
 
 void
-CloseDownExtensions()
+CloseDownExtensions(void)
 {
     int i,j;
 
diff --git a/dix/getevents.c b/dix/getevents.c
index 3f636bc..62f3bcb 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -73,7 +73,7 @@ extern Bool XkbCopyKeymap(XkbDescPtr src
  * Pick some arbitrary size for Xi motion history.
  */
 _X_EXPORT int
-GetMotionHistorySize()
+GetMotionHistorySize(void)
 {
     return MOTION_HISTORY_SIZE;
 }
@@ -183,7 +183,7 @@ updateMotionHistory(DeviceIntPtr pDev, C
  * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
  */
 _X_EXPORT int
-GetMaximumEventsNum() {
+GetMaximumEventsNum(void) {
     /* Two base events -- core and device, plus valuator events.  Multiply
      * by two if we're doing key repeats. */
     int ret = 2 + MAX_VALUATOR_EVENTS;
diff --git a/dix/initatoms.c b/dix/initatoms.c
index a5972af..de101bd 100644
--- a/dix/initatoms.c
+++ b/dix/initatoms.c
@@ -11,7 +11,7 @@
 #include <X11/Xatom.h>
 #include "misc.h"
 #include "dix.h"
-void MakePredeclaredAtoms()
+void MakePredeclaredAtoms(void)
 {
     if (MakeAtom("PRIMARY", 7, 1) != XA_PRIMARY) AtomError();
     if (MakeAtom("SECONDARY", 9, 1) != XA_SECONDARY) AtomError();
diff --git a/dix/main.c b/dix/main.c
index 92c30b6..9a67ed9 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -544,7 +544,7 @@ static int padlength[4] = {0, 3, 2, 1};
 static
 #endif
 Bool
-CreateConnectionBlock()
+CreateConnectionBlock(void)
 {
     xConnSetup setup;
     xWindowRoot root;
diff --git a/dix/privates.c b/dix/privates.c
index a66fc3d..2465971 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -60,7 +60,7 @@ unsigned *extensionPrivateSizes;
 unsigned totalExtensionSize;
 
 void
-ResetExtensionPrivates()
+ResetExtensionPrivates(void)
 {
     extensionPrivateCount = 0;
     extensionPrivateLen = 0;
@@ -71,7 +71,7 @@ ResetExtensionPrivates()
 }
 
 _X_EXPORT int
-AllocateExtensionPrivateIndex()
+AllocateExtensionPrivateIndex(void)
 {
     return extensionPrivateCount++;
 }
@@ -117,7 +117,7 @@ unsigned *clientPrivateSizes;
 unsigned totalClientSize;
 
 void
-ResetClientPrivates()
+ResetClientPrivates(void)
 {
     clientPrivateCount = 0;
     clientPrivateLen = 0;
@@ -128,7 +128,7 @@ ResetClientPrivates()
 }
 
 _X_EXPORT int
-AllocateClientPrivateIndex()
+AllocateClientPrivateIndex(void)
 {
     return clientPrivateCount++;
 }
@@ -171,7 +171,7 @@ AllocateClientPrivate(int index2, unsign
 int  screenPrivateCount;
 
 void
-ResetScreenPrivates()
+ResetScreenPrivates(void)
 {
     screenPrivateCount = 0;
 }
@@ -180,7 +180,7 @@ ResetScreenPrivates()
  * so we have to worry about resizing existing devPrivates
  */
 _X_EXPORT int
-AllocateScreenPrivateIndex()
+AllocateScreenPrivateIndex(void)
 {
     int		idx;
     int		i;
@@ -213,13 +213,13 @@ AllocateScreenPrivateIndex()
 static int  windowPrivateCount;
 
 void
-ResetWindowPrivates()
+ResetWindowPrivates(void)
 {
     windowPrivateCount = 0;
 }
 
 _X_EXPORT int
-AllocateWindowPrivateIndex()
+AllocateWindowPrivateIndex(void)
 {
     return windowPrivateCount++;
 }
@@ -263,13 +263,13 @@ AllocateWindowPrivate(ScreenPtr pScreen,
 static int  gcPrivateCount;
 
 void
-ResetGCPrivates()
+ResetGCPrivates(void)
 {
     gcPrivateCount = 0;
 }
 
 _X_EXPORT int
-AllocateGCPrivateIndex()
+AllocateGCPrivateIndex(void)
 {
     return gcPrivateCount++;
 }
@@ -312,13 +312,13 @@ AllocateGCPrivate(ScreenPtr pScreen, int
 static int  pixmapPrivateCount;
 
 void
-ResetPixmapPrivates()
+ResetPixmapPrivates(void)
 {
     pixmapPrivateCount = 0;
 }
 
 _X_EXPORT int
-AllocatePixmapPrivateIndex()
+AllocatePixmapPrivateIndex(void)
 {
     return pixmapPrivateCount++;
 }
@@ -363,7 +363,7 @@ AllocatePixmapPrivate(ScreenPtr pScreen,
 int  colormapPrivateCount;
 
 void
-ResetColormapPrivates()
+ResetColormapPrivates(void)
 {
     colormapPrivateCount = 0;
 }
@@ -424,7 +424,7 @@ AllocateColormapPrivateIndex (InitCmapPr
 static int devicePrivateIndex = 0;
 
 _X_EXPORT int
-AllocateDevicePrivateIndex()
+AllocateDevicePrivateIndex(void)
 {
     return devicePrivateIndex++;
 }
diff --git a/dix/resource.c b/dix/resource.c
index a5a7eed..f4bf1fc 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -235,7 +235,7 @@ CreateNewResourceType(DeleteType deleteF
 }
 
 _X_EXPORT RESTYPE
-CreateNewResourceClass()
+CreateNewResourceClass(void)
 {
     RESTYPE next = lastResourceClass >> 1;
 
@@ -844,7 +844,7 @@ FreeClientResources(ClientPtr client)
 }
 
 void
-FreeAllResources()
+FreeAllResources(void)
 {
     int	i;
 
diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c
index 1ec0609..0129041 100644
--- a/hw/xnest/Display.c
+++ b/hw/xnest/Display.c
@@ -176,7 +176,7 @@ xnestOpenDisplay(int argc, char *argv[])
 }
 
 void
-xnestCloseDisplay()
+xnestCloseDisplay(void)
 {
   if (!xnestDoFullGeneration || !xnestDisplay) return;
 
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index a209241..38fefa7 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -52,7 +52,7 @@ ProcessInputEvents()
 }
 
 int
-TimeSinceLastInputEvent()
+TimeSinceLastInputEvent(void)
 {
     if (lastEventTime == 0)
         lastEventTime = GetTimeInMillis();
@@ -60,7 +60,7 @@ TimeSinceLastInputEvent()
 }
 
 void
-SetTimeSinceLastInputEvent()
+SetTimeSinceLastInputEvent(void)
 {
   lastEventTime = GetTimeInMillis();
 }
@@ -78,7 +78,7 @@ xnestNotExposurePredicate(Display *displ
 }
 
 void
-xnestCollectExposures()
+xnestCollectExposures(void)
 {
   XEvent X;
   WindowPtr pWin;
@@ -113,7 +113,7 @@ xnestQueueKeyEvent(int type, unsigned in
 }
 
 void
-xnestCollectEvents()
+xnestCollectEvents(void)
 {
   XEvent X;
   xEvent x;
diff --git a/mi/micmap.c b/mi/micmap.c
index 977c587..33d9481 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -385,7 +385,7 @@ static int  miVisualPriority[] = {
 static miVisualsPtr	miVisuals;
 
 _X_EXPORT void
-miClearVisualTypes()
+miClearVisualTypes(void)
 {
     miVisualsPtr v;
 
@@ -690,7 +690,7 @@ miDoInitVisuals(VisualPtr *visualp, Dept
 }
 
 void
-miResetInitVisuals()
+miResetInitVisuals(void)
 {
     miInitVisualsProc = miDoInitVisuals;
 }
diff --git a/mi/mieq.c b/mi/mieq.c
index 5bd87eb..34509cd 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -80,7 +80,7 @@ typedef struct _EventQueue {
 static EventQueueRec miEventQueue;
 
 Bool
-mieqInit()
+mieqInit(void)
 {
     int i;
 
@@ -195,7 +195,7 @@ mieqSetHandler(int event, mieqHandler ha
 
 /* Call this from ProcessInputEvents(). */
 void
-mieqProcessInputEvents()
+mieqProcessInputEvents(void)
 {
     EventRec *e = NULL;
     int x = 0, y = 0;
diff --git a/os/log.c b/os/log.c
index b1d628c..e8aa3fa 100644
--- a/os/log.c
+++ b/os/log.c
@@ -221,7 +221,7 @@ LogInit(const char *fname, const char *b
 }
 
 void
-LogClose()
+LogClose(void)
 {
     if (logFile) {
 	fclose(logFile);
@@ -616,7 +616,7 @@ Error(char *str)
 }
 
 void
-LogPrintMarkers()
+LogPrintMarkers(void)
 {
     /* Show what the message marker symbols mean. */
     ErrorF("Markers: ");
diff --git a/os/oscolor.c b/os/oscolor.c
index a13a3a6..d53e4d8 100644
--- a/os/oscolor.c
+++ b/os/oscolor.c
@@ -102,7 +102,7 @@ typedef struct _builtinColor {
 #define NUM_BUILTIN_COLORS  (sizeof (BuiltinColors) / sizeof (BuiltinColors[0]))
 
 Bool
-OsInitColors()
+OsInitColors(void)
 {
     return TRUE;
 }
diff --git a/render/glyph.c b/render/glyph.c
index 5987cbc..583a52b 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -86,13 +86,13 @@ static int	globalTotalGlyphPrivateSize =
 static int	glyphPrivateCount = 0;
 
 void
-ResetGlyphPrivates ()
+ResetGlyphPrivates (void)
 {
     glyphPrivateCount = 0;
 }
 
 int
-AllocateGlyphPrivateIndex ()
+AllocateGlyphPrivateIndex (void)
 {
     return glyphPrivateCount++;
 }
diff-tree f24391dbfd12a84253dfec794ee7884afd52e197 (from 4c2e28b0916b5f75cfefb6df9fa0a7a09675539a)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 12:30:31 2007 -0700

    In AIGLX EnterVT processing, invoke driver EnterVT before resuming glx.
    
    As the driver EnterVT function generally re-enables the hardware and
    prepares it for rendering, it must be called before any gl functions are
    called which could touch the hardware.

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index 5e683a8..c30f372 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -829,12 +829,16 @@ static Bool
 glxDRIEnterVT (int index, int flags)
 {
     __GLXDRIscreen *screen = (__GLXDRIscreen *) __glXgetActiveScreen(index);
+    Bool ret;
 
     LogMessage(X_INFO, "AIGLX: Resuming AIGLX clients after VT switch\n");
 
+    if (!(*screen->enterVT) (index, flags))
+	return FALSE;
+    
     glxResumeClients();
 
-    return (*screen->enterVT) (index, flags);
+    return TRUE;
 }
 
 static void
diff-tree 4c2e28b0916b5f75cfefb6df9fa0a7a09675539a (from 4beeab8424774ea4c3142f29b90e33f1fc7cb154)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 12:28:53 2007 -0700

    Add setrlimit call in -core option to make dumps occur.
    
    Default core size limit for most environments is 0, which disables core
    dumps. Add code in the -core option processing path to set the core limit to
    the maximum value.

diff --git a/os/utils.c b/os/utils.c
index e605a6c..5058285 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -64,6 +64,8 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xos.h>
 #include <stdio.h>
 #include <time.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 #include "misc.h"
 #include <X11/X.h>
 #define XSERV_t
@@ -795,7 +797,13 @@ ProcessCommandLine(int argc, char *argv[
 		UseMsg();
 	}
 	else if ( strcmp( argv[i], "-core") == 0)
+	{
+	    struct rlimit   core_limit;
 	    CoreDump = TRUE;
+	    getrlimit (RLIMIT_CORE, &core_limit);
+	    core_limit.rlim_cur = core_limit.rlim_max;
+	    setrlimit (RLIMIT_CORE, &core_limit);
+	}
 	else if ( strcmp( argv[i], "-dpi") == 0)
 	{
 	    if(++i < argc)
diff-tree 4beeab8424774ea4c3142f29b90e33f1fc7cb154 (from 0a6ac992363343487dfe0a0fc985ea55bd448382)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Apr 8 13:39:06 2007 +0300

    XFree86: Treat evdev and vmmouse as mouse drivers (bug #10512, #10559)
    
    When we see an evdev or vmmouse section, assume that it's a mouse, and
    don't add a default mouse device.  This will break users who have an
    evdev keyboard section but no mouse, and want the mouse to get added
    by default.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 4db844e..cbeda0b 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1287,9 +1287,13 @@ checkCoreInputDevices(serverLayoutPtr se
      * always synthesize a 'mouse' section configured to send core
      * events, unless a 'void' section is found, in which case the user
      * probably wants to run footless.
+     *
+     * If you're using an evdev keyboard and expect a default mouse
+     * section ... deal.
      */
     for (i = servlayoutp->inputs; i->identifier && i->driver; i++) {
-	if (!strcmp(i->driver, "void") || !strcmp(i->driver, "mouse")) {
+	if (!strcmp(i->driver, "void") || !strcmp(i->driver, "mouse") ||
+            !strcmp(i->driver, "vmmouse") || !strcmp(i->driver, "evdev")) {
 	    found = 1; break;
 	}
     }
diff-tree 0a6ac992363343487dfe0a0fc985ea55bd448382 (from 7e385598613778de14c0feea0d32f17d7aa66a8e)
Author: Brian <brian at yutani.localnet.net>
Date:   Sat Apr 7 12:41:57 2007 -0600

    regenerated to fix bug 10371

diff --git a/GL/glx/indirect_size_get.c b/GL/glx/indirect_size_get.c
index 150c6a1..ccb25f8 100644
--- a/GL/glx/indirect_size_get.c
+++ b/GL/glx/indirect_size_get.c
@@ -639,7 +639,7 @@ __glGetBooleanv_size(GLenum e)
     case GL_PROGRAM_ERROR_POSITION_ARB:
     case GL_DEPTH_CLAMP_NV:
     case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
-/*      case GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB:*/
+/*      case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:*/
     case GL_MAX_VERTEX_UNITS_ARB:
     case GL_ACTIVE_VERTEX_UNITS_ARB:
     case GL_WEIGHT_SUM_UNITY_ARB:
@@ -699,6 +699,8 @@ __glGetBooleanv_size(GLenum e)
 /*      case GL_POINT_SPRITE_NV:*/
     case GL_POINT_SPRITE_R_MODE_NV:
     case GL_MAX_VERTEX_ATTRIBS_ARB:
+    case GL_MAX_TEXTURE_COORDS_ARB:
+    case GL_MAX_TEXTURE_IMAGE_UNITS_ARB:
     case GL_DEPTH_BOUNDS_TEST_EXT:
     case GL_STENCIL_TEST_TWO_SIDE_EXT:
     case GL_ACTIVE_STENCIL_FACE_EXT:
@@ -1005,8 +1007,6 @@ __glGetProgramivARB_size(GLenum e)
     case GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
     case GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
     case GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
-    case GL_MAX_TEXTURE_COORDS_ARB:
-    case GL_MAX_TEXTURE_IMAGE_UNITS_ARB:
     case GL_PROGRAM_FORMAT_ARB:
     case GL_PROGRAM_INSTRUCTIONS_ARB:
     case GL_MAX_PROGRAM_INSTRUCTIONS_ARB:
diff-tree 7e385598613778de14c0feea0d32f17d7aa66a8e (from 5a804f2e97ab59745482660a635b801ac2b9e769)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Apr 6 13:38:12 2007 +0300

    GLcore: fix after moving xf86glx_util.[hc] to Mesa.

diff --git a/GL/mesa/.gitignore b/GL/mesa/.gitignore
index a00885d..6b92b24 100644
--- a/GL/mesa/.gitignore
+++ b/GL/mesa/.gitignore
@@ -1,6 +1,6 @@
 X/drivers
 X/glxheader.h
-X/xmesaP.h
+X/xm*.h
 X/xm*.c
 mesa/drivers
 mesa/glxheader.h
diff --git a/GL/mesa/X/Makefile.am b/GL/mesa/X/Makefile.am
index 056d31a..f8f16c3 100644
--- a/GL/mesa/X/Makefile.am
+++ b/GL/mesa/X/Makefile.am
@@ -22,14 +22,13 @@ AM_CFLAGS = \
 	-DXFree86Server \
 	@GLX_DEFINES@
 
-libX_la_SOURCES = xf86glx.c \
-                  xf86glx_util.c \
-                  xf86glx_util.h
+libX_la_SOURCES = xf86glx.c
 
 nodist_libX_la_SOURCES = \
                   xm_api.c \
 		  xm_buffer.c \
                   xm_dd.c \
+                  xm_image.c \
                   xm_line.c \
                   xm_span.c \
                   xm_tri.c \
diff --git a/GL/mesa/X/xf86glx_util.c b/GL/mesa/X/xf86glx_util.c
deleted file mode 100644
index 6af773f..0000000
--- a/GL/mesa/X/xf86glx_util.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin at precisioninsight.com>
- *   Brian Paul <brian at precisioninsight.com>
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "xf86glx_util.h"
-#include <X11/Xmd.h>
-
-#ifdef ROUNDUP
-#undef ROUNDUP
-#endif
-
-#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
-
-XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height, char *data)
-{
-    XMesaImage *image;
-
-    image = (XMesaImage *)xalloc(sizeof(XMesaImage));
-
-    if (image) {
-	image->width = width;
-	image->height = height;
-	image->data = data;
-	/* Always pad to 32 bits */
-	image->bytes_per_line = ROUNDUP((bitsPerPixel * width), 32);
-	image->bits_per_pixel = bitsPerPixel;
-    }
-
-    return image;
-}
-
-void XMesaDestroyImage(XMesaImage *image)
-{
-    if (image->data)
-	free(image->data);
-    xfree(image);
-}
-
-unsigned long XMesaGetPixel(XMesaImage *image, int x, int y)
-{
-    CARD8  *row = (CARD8 *)(image->data + y*image->bytes_per_line);
-    CARD8  *i8;
-    CARD16 *i16;
-    CARD32 *i32;
-    switch (image->bits_per_pixel) {
-    case 8:
-	i8 = (CARD8 *)row;
-	return i8[x];
-	break;
-    case 15:
-    case 16:
-	i16 = (CARD16 *)row;
-	return i16[x];
-	break;
-    case 24: /* WARNING: architecture specific code */
-	i8 = (CARD8 *)row;
-	return (((CARD32)i8[x*3]) |
-		(((CARD32)i8[x*3+1])<<8) |
-		(((CARD32)i8[x*3+2])<<16));
-	break;
-    case 32:
-	i32 = (CARD32 *)row;
-	return i32[x];
-	break;
-    }
-    return 0;
-}
-
-#ifndef XMESA_USE_PUTPIXEL_MACRO
-void XMesaPutPixel(XMesaImage *image, int x, int y, unsigned long pixel)
-{
-    CARD8  *row = (CARD8 *)(image->data + y*image->bytes_per_line);
-    CARD8  *i8;
-    CARD16 *i16;
-    CARD32 *i32;
-    switch (image->bits_per_pixel) {
-    case 8:
-	i8 = (CARD8 *)row;
-	i8[x] = (CARD8)pixel;
-	break;
-    case 15:
-    case 16:
-	i16 = (CARD16 *)row;
-	i16[x] = (CARD16)pixel;
-	break;
-    case 24: /* WARNING: architecture specific code */
-	i8 = (CARD8 *)__row;
-	i8[x*3]   = (CARD8)(p);
-	i8[x*3+1] = (CARD8)(p>>8);
-	i8[x*3+2] = (CARD8)(p>>16);
-    case 32:
-	i32 = (CARD32 *)row;
-	i32[x] = (CARD32)pixel;
-	break;
-    }
-}
-#endif
-
-void XMesaPutImageHelper(ScreenPtr display,
-			 DrawablePtr d, GCPtr gc,
-			 XMesaImage *image,
-			 int src_x, int src_y,
-			 int dest_x, int dest_y,
-			 unsigned int width, unsigned int height)
-{
-    /* NOT_DONE: Verify that the following works for all depths */
-    char *src = (image->data +
-		 src_y * image->bytes_per_line +
-		 ((src_x * image->bits_per_pixel) >> 3));
-
-    ValidateGC(d, gc);
-    (*gc->ops->PutImage)(d, gc, d->depth, dest_x, dest_y, width, height,
-			 0, ZPixmap, src);
-}
diff --git a/GL/mesa/X/xf86glx_util.h b/GL/mesa/X/xf86glx_util.h
deleted file mode 100644
index bb31412..0000000
--- a/GL/mesa/X/xf86glx_util.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin at precisioninsight.com>
- *   Brian Paul <brian at precisioninsight.com>
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _XF86GLX_UTIL_H_
-#define _XF86GLX_UTIL_H_
-
-#ifdef __CYGWIN__
-#undef WIN32
-#undef _WIN32
-#endif
-
-#include <screenint.h>
-#include <pixmap.h>
-#include <gc.h>
-#include "GL/xmesa.h"
-
-#define XMESA_USE_PUTPIXEL_MACRO
-
-struct _XMesaImageRec {
-    int width, height;
-    char *data;
-    int bytes_per_line; /* Padded to 32 bits */
-    int bits_per_pixel;
-};
-
-extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
-				    char *data);
-extern void XMesaDestroyImage(XMesaImage *image);
-extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
-#ifdef XMESA_USE_PUTPIXEL_MACRO
-#define XMesaPutPixel(__i,__x,__y,__p) \
-{ \
-    CARD8  *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
-    CARD8  *__i8; \
-    CARD16 *__i16; \
-    CARD32 *__i32; \
-    switch (__i->bits_per_pixel) { \
-    case 8: \
-	__i8 = (CARD8 *)__row; \
-	__i8[__x] = (CARD8)__p; \
-	break; \
-    case 15: \
-    case 16: \
-	__i16 = (CARD16 *)__row; \
-	__i16[__x] = (CARD16)__p; \
-	break; \
-    case 24: /* WARNING: architecture specific code */ \
-	__i8 = (CARD8 *)__row; \
-	__i8[__x*3]   = (CARD8)(__p); \
-	__i8[__x*3+1] = (CARD8)(__p>>8); \
-	__i8[__x*3+2] = (CARD8)(__p>>16); \
-	break; \
-    case 32: \
-	__i32 = (CARD32 *)__row; \
-	__i32[__x] = (CARD32)__p; \
-	break; \
-    } \
-}
-#else
-extern void XMesaPutPixel(XMesaImage *image, int x, int y,
-			  unsigned long pixel);
-#endif
-
-extern void XMesaPutImageHelper(ScreenPtr display,
-				DrawablePtr d, GCPtr gc,
-				XMesaImage *image,
-				int src_x, int src_y,
-				int dest_x, int dest_y,
-				unsigned int width, unsigned int height);
-
-#endif /* _XF86GLX_UTIL_H_ */
diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index 3d96716..0cfe1c9 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -168,6 +168,8 @@ symlink_mesa_x() {
     action xm_api.c
     action xm_buffer.c
     action xm_dd.c
+    action xm_image.c
+    action xm_image.h
     action xm_line.c
     action xm_span.c
     action xm_tri.c
diff-tree 5a804f2e97ab59745482660a635b801ac2b9e769 (from a4e2fc703484fffed8dd50c1b4b24c564be4d3cd)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Apr 5 19:14:31 2007 +0300

    configure: minor cosmetic, move GLX extension options together.

diff --git a/configure.ac b/configure.ac
index fde6a89..cb8b435 100644
--- a/configure.ac
+++ b/configure.ac
@@ -453,9 +453,6 @@ AC_ARG_WITH(os-vendor,       AS_HELP_STR
 AC_ARG_WITH(builderstring,   AS_HELP_STRING([--with-builderstring=BUILDERSTRING], [Additional builder string]),
 				[ BUILDERSTRING="$withval" ]
 				[ ])
-AC_ARG_WITH(mesa-source,     AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [Path to Mesa source tree]),
-                                [ MESA_SOURCE="$withval" ],
-                                [ MESA_SOURCE="" ])
 AC_ARG_WITH(fontdir,         AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to top level dir where fonts are installed (default: ${libdir}/X11/fonts)]),
                                 [ FONTDIR="$withval" ],
                                 [ FONTDIR="${libdir}/X11/fonts" ])
@@ -472,9 +469,6 @@ AC_ARG_WITH(xkb-output,       AS_HELP_ST
 AC_ARG_WITH(rgb-path,         AS_HELP_STRING([--with-rgb-path=PATH], [Path to RGB database (default: ${datadir}/X11/rgb)]),
 				[ RGBPATH="$withval" ],
 				[ RGBPATH="${datadir}/X11/rgb" ])
-AC_ARG_WITH(dri-driver-path,  AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to DRI drivers (default: ${libdir}/dri)]),
-				[ DRI_DRIVER_PATH="$withval" ],
-				[ DRI_DRIVER_PATH="${libdir}/dri" ])
 APPLE_APPLICATIONS_DIR="${bindir}/Applications"
 AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: ${bindir}/Applications)]),
                                [ APPLE_APPLICATIONS_DIR="${withval}" ].
@@ -494,6 +488,20 @@ AC_ARG_ENABLE(null-root-cursor, AS_HELP_
                                  [NULL_ROOT_CURSOR=$enableval],
                                  [NULL_ROOT_CURSOR=no])
 
+dnl GLX build options
+AC_ARG_WITH(mesa-source,     AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [Path to Mesa source tree]),
+                                [ MESA_SOURCE="$withval" ],
+                                [ MESA_SOURCE="" ])
+AC_ARG_WITH(dri-driver-path,  AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to DRI drivers (default: ${libdir}/dri)]),
+				[ DRI_DRIVER_PATH="$withval" ],
+				[ DRI_DRIVER_PATH="${libdir}/dri" ])
+AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
+                                [AIGLX=$enableval],
+                                [AIGLX=yes])
+AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]),
+                                [GLX_USE_TLS=$enableval],
+                                [GLX_USE_TLS=no])
+
 dnl Extensions.
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
 AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
@@ -508,13 +516,11 @@ AC_ARG_ENABLE(screensaver,    AS_HELP_ST
 AC_ARG_ENABLE(xdmcp,          AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
 AC_ARG_ENABLE(xdm-auth-1,     AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
 AC_ARG_ENABLE(glx,            AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
-AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]), [AIGLX=$enableval], [AIGLX=yes])
-AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), [GLX_USE_TLS=$enableval], [GLX_USE_TLS=no])
 AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
 AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
 AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
 AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
-AC_ARG_ENABLE(xace,     AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
+AC_ARG_ENABLE(xace,           AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
 AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=$XACE])
 AC_ARG_ENABLE(appgroup,       AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=$XCSECURITY])
 AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
diff-tree a4e2fc703484fffed8dd50c1b4b24c564be4d3cd (from 38ca7d388c47c4800c74442172d6595a9b3dfcc7)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Apr 5 19:13:47 2007 +0300

    glx: Remove stray __GLinterface.
    
    __GLinterface was droped from glcore.h

diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index 1f6c7f3..ca874e3 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -275,7 +275,7 @@ static GLboolean errorOccured = GL_FALSE
 /*
 ** The GL was will call this routine if an error occurs.
 */
-void __glXErrorCallBack(__GLinterface *gc, GLenum code)
+void __glXErrorCallBack(GLenum code)
 {
     errorOccured = GL_TRUE;
 }
diff --git a/GL/glx/glxext.h b/GL/glx/glxext.h
index edd66a8..dc4cd4a 100644
--- a/GL/glx/glxext.h
+++ b/GL/glx/glxext.h
@@ -66,7 +66,7 @@ typedef struct {
 extern GLboolean __glXFreeContext(__GLXcontext *glxc);
 extern void __glXFlushContextCache(void);
 
-extern void __glXErrorCallBack(__GLinterface *gc, GLenum code);
+extern void __glXErrorCallBack(GLenum code);
 extern void __glXClearErrorOccured(void);
 extern GLboolean __glXErrorOccured(void);
 extern void __glXResetLargeCommandStatus(__GLXclientState*);
diff-tree 38ca7d388c47c4800c74442172d6595a9b3dfcc7 (from f8482967ae8080f49dd1bbb0b79cc65020df679f)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Apr 5 19:13:14 2007 +0300

    glx: fix symlink, glcontextmodes.c was moved to mesa/src/glx/

diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index 7d1e06e..3d96716 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -225,9 +225,6 @@ symlink_glx() {
     dst_dir glx
 
     action indirect_size.h
-
-    src_dir src/mesa/drivers/dri/common
-
     action glcontextmodes.c
     action glcontextmodes.h
 
diff-tree f8482967ae8080f49dd1bbb0b79cc65020df679f (from c10df5b967d4da4e11786520317e2917de5541fa)
Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date:   Wed Apr 4 12:28:48 2007 +0200

    Add an EXA driver callback to determine whether a pixmap is
    
    "offscreen" in exa terms, which means accessible to the GPU.
    Bump exa minor. The change is backwards-compatible.

diff --git a/exa/exa.c b/exa/exa.c
index dd27d5e..23fe555 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -322,6 +322,9 @@ exaPixmapIsOffscreen(PixmapPtr p)
     if (p->devPrivate.ptr == NULL)
 	return TRUE;
 
+    if (pExaScr->info->PixmapIsOffscreen)
+	return pExaScr->info->PixmapIsOffscreen(p);
+
     return ((unsigned long) ((CARD8 *) p->devPrivate.ptr -
 			     (CARD8 *) pExaScr->info->memoryBase) <
 	    pExaScr->info->memorySize);
diff --git a/exa/exa.h b/exa/exa.h
index bf723f7..6c39a8f 100644
--- a/exa/exa.h
+++ b/exa/exa.h
@@ -39,7 +39,7 @@
 #include "fb.h"
 
 #define EXA_VERSION_MAJOR   2
-#define EXA_VERSION_MINOR   1
+#define EXA_VERSION_MINOR   2
 #define EXA_VERSION_RELEASE 0
 
 typedef struct _ExaOffscreenArea ExaOffscreenArea;
@@ -636,6 +636,23 @@ typedef struct _ExaDriver {
      */
     void	(*FinishAccess)(PixmapPtr pPix, int index);
 
+    /**
+     * PixmapIsOffscreen() is an optional driver replacement to
+     * exaPixmapIsOffscreen(). Set to NULL if you want the standard behaviour
+     * of exaPixmapIsOffscreen().
+     *
+     * @param pPix the pixmap
+     * @return TRUE if the given drawable is in framebuffer memory.
+     *
+     * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen
+     * memory, meaning that acceleration could probably be done to it, and that it
+     * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it
+     * with the CPU.
+     *
+     *
+     */
+    Bool	(*PixmapIsOffscreen)(PixmapPtr pPix);
+
 	/** @name PrepareAccess() and FinishAccess() indices
 	 * @{
 	 */
diff-tree c10df5b967d4da4e11786520317e2917de5541fa (from e1dea151db6405e12d991feacba9446320739ee8)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Apr 3 15:47:01 2007 -0700

    Swap RRScreenChangeNotifyEvent dimensions when the screen has one crtc and it's rotated.
    
    RandR 1.1 clients expect the size fields in this event to be the unrotated
    dimensions of the screen.  This behavior is "weird", but that's the way the old
    code worked so we need to be bug-compatible with it.

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index ad74ac3..f83fce3 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -116,11 +116,19 @@ RRDeliverScreenEvent (ClientPtr client, 
 
     se.sequenceNumber = client->sequence;
     se.sizeID = RR10CurrentSizeID (pScreen);
-    
-    se.widthInPixels = pScreen->width;
-    se.heightInPixels = pScreen->height;
-    se.widthInMillimeters = pScreen->mmWidth;
-    se.heightInMillimeters = pScreen->mmHeight;
+
+    if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+	se.widthInPixels = pScreen->height;
+	se.heightInPixels = pScreen->width;
+	se.widthInMillimeters = pScreen->mmHeight;
+	se.heightInMillimeters = pScreen->mmWidth;
+    } else {
+	se.widthInPixels = pScreen->width;
+	se.heightInPixels = pScreen->height;
+	se.widthInMillimeters = pScreen->mmWidth;
+	se.heightInMillimeters = pScreen->mmHeight;
+    }
+
     WriteEventsToClient (client, 1, (xEvent *) &se);
 }
 
diff-tree e1dea151db6405e12d991feacba9446320739ee8 (from 0ee40c935750e25a9e178cdd70f6b2c667e79344)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 11:21:50 2007 -0600

    Implement a minor hack in dmxCheckFunctionKeys() to detect special keys.
    
    Keep track of status of (left) alt/ctrl keys so that ctrl-alt-q to exit
    can be detected.  Not ideal, but works for now.

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index e4d556b..4810b17 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -103,17 +103,36 @@ static int dmxCheckFunctionKeys(DMXLocal
 {
     DMXInputInfo   *dmxInput = &dmxInputs[dmxLocal->inputIdx];
     unsigned short state = 0;
-    
+
+#if 1 /* hack to detect ctrl-alt-q, etc */
+    static int ctrl = 0, alt = 0;
+    /* keep track of ctrl/alt key status */
+    if (type == KeyPress && keySym == 0xffe3) {
+        ctrl = 1;
+    }
+    else if (type == KeyRelease && keySym == 0xffe3) {
+        ctrl = 0;
+    }
+    else if (type == KeyPress && keySym == 0xffe9) {
+        alt = 1;
+    }
+    else if (type == KeyRelease && keySym == 0xffe9) {
+        alt = 0;
+    }
+    if (!ctrl || !alt)
+        return 0;
+#else
     if (dmxLocal->sendsCore)
         state = dmxLocalCoreKeyboard->pDevice->key->state;
     else if (dmxLocal->pDevice->key)
         state = dmxLocal->pDevice->key->state;
     
-    ErrorF/*DMXDBG3*/("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
+    DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
             keySym, type == KeyPress ? "press" : "release", state);
 
     if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
         return 0;
+#endif
 
     switch (keySym) {
     case XK_g:
@@ -679,7 +698,7 @@ void dmxEnqueue(DevicePtr pDev, int type
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
 
         events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-        ErrorF("KEY %d  sym %d\n", detail, (int) keySym);
+        /*ErrorF("KEY %d  sym %d\n", detail, (int) keySym);*/
         nevents = GetKeyboardEvents(events, p, type, detail);
         for (i = 0; i < nevents; i++)
             mieqEnqueue(p, events + i);
diff-tree 0ee40c935750e25a9e178cdd70f6b2c667e79344 (from 23974f20bf0e0c2786cc75af026af5484f6dc331)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 09:31:00 2007 -0600

    s/intead/instead/

diff --git a/fb/fbcmap.c b/fb/fbcmap.c
index a8cfb79..c29a513 100644
--- a/fb/fbcmap.c
+++ b/fb/fbcmap.c
@@ -40,7 +40,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "fb.h"
 
 #ifdef XFree86Server
-#error "You should be compiling fbcmap_mi.c intead of fbcmap.c!"
+#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!"
 #endif
 
 
diff-tree 23974f20bf0e0c2786cc75af026af5484f6dc331 (from a240c039c47c0be22ea5e100692307b26d938747)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 09:30:24 2007 -0600

    add DDXRingBell() stub to solve link problem

diff --git a/hw/xprint/ddxInit.c b/hw/xprint/ddxInit.c
index 8e7ec2e..a465c4c 100644
--- a/hw/xprint/ddxInit.c
+++ b/hw/xprint/ddxInit.c
@@ -89,6 +89,12 @@ InitOutput(
 
 }
 
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+   /* dummy func; link fails without */
+}
+
 static void
 BellProc(
     int volume,
diff-tree a240c039c47c0be22ea5e100692307b26d938747 (from 1cc8db72816cd079f30255046e10043c350bf683)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 09:27:57 2007 -0600

    Split the xserver/fb/fbcmap.c file into two files.
    
    Now, fbcmap_mi.c contains the fb functions which just wrap mi functions.
    Previously, these were in fbcmap.c and compiled when XFree86Server was defined.
    Now, clients of fbcmap should either use fbcmap.c or fbcmap_mi.c and not worry
    about setting the XFree86Server symbol.

diff --git a/fb/Makefile.am b/fb/Makefile.am
index 1649669..ab135c9 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -78,4 +78,4 @@ libwfb_la_SOURCES = $(libfb_la_SOURCES)
 
 libfb_la_LIBADD = libfbmmx.la
 
-EXTRA_DIST = fbcmap.c
+EXTRA_DIST = fbcmap.c fbcmap_mi.c
diff --git a/fb/fbcmap.c b/fb/fbcmap.c
index 9cf5bcb..a8cfb79 100644
--- a/fb/fbcmap.c
+++ b/fb/fbcmap.c
@@ -39,7 +39,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "resource.h"
 #include "fb.h"
 
-#ifndef XFree86Server
+#ifdef XFree86Server
+#error "You should be compiling fbcmap_mi.c intead of fbcmap.c!"
+#endif
+
+
+
 ColormapPtr FbInstalledMaps[MAXSCREENS];
 
 int
@@ -584,87 +589,3 @@ fbInitVisuals (VisualPtr    *visualp, 
     *defaultVisp = depth[i].vids[j];
     return TRUE;
 }
-#else
-
-#include "micmap.h"
-
-int
-fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
-{
-    return miListInstalledColormaps(pScreen, pmaps);
-}
-
-void
-fbInstallColormap(ColormapPtr pmap)
-{
-    miInstallColormap(pmap);
-}
-
-void
-fbUninstallColormap(ColormapPtr pmap)
-{
-    miUninstallColormap(pmap);
-}
-
-void
-fbResolveColor(unsigned short   *pred,
-	       unsigned short   *pgreen,
-	       unsigned short   *pblue,
-	       VisualPtr	pVisual)
-{
-    miResolveColor(pred, pgreen, pblue, pVisual);
-}
-
-Bool
-fbInitializeColormap(ColormapPtr pmap)
-{
-    return miInitializeColormap(pmap);
-}
-
-int
-fbExpandDirectColors (ColormapPtr   pmap,
-		      int	    ndef,
-		      xColorItem    *indefs,
-		      xColorItem    *outdefs)
-{
-    return miExpandDirectColors(pmap, ndef, indefs, outdefs);
-}
-
-Bool
-fbCreateDefColormap(ScreenPtr pScreen)
-{
-    return miCreateDefColormap(pScreen);
-}
-
-void
-fbClearVisualTypes(void)
-{
-    miClearVisualTypes();
-}
-
-Bool
-fbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
-{
-    return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
-}
-
-/*
- * Given a list of formats for a screen, create a list
- * of visuals and depths for the screen which coorespond to
- * the set which can be used with this version of fb.
- */
-
-Bool
-fbInitVisuals (VisualPtr    *visualp, 
-	       DepthPtr	    *depthp,
-	       int	    *nvisualp,
-	       int	    *ndepthp,
-	       int	    *rootDepthp,
-	       VisualID	    *defaultVisp,
-	       unsigned long	sizes,
-	       int	    bitsPerRGB)
-{
-    return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
-			 defaultVisp, sizes, bitsPerRGB, -1);
-}
-#endif
diff --git a/fb/fbcmap_mi.c b/fb/fbcmap_mi.c
new file mode 100644
index 0000000..58bcae3
--- /dev/null
+++ b/fb/fbcmap_mi.c
@@ -0,0 +1,123 @@
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to 
+distribution  of  the software  without specific prior 
+written permission. Sun and X Consortium make no 
+representations about the suitability of this software for 
+any purpose. It is provided "as is" without any express or 
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+
+/**
+ * This version of fbcmap.c is implemented in terms of mi functions.
+ * These functions used to be in fbcmap.c and depended upon the symbol
+ * XFree86Server being defined.
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "fb.h"
+#include "micmap.h"
+
+int
+fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+{
+    return miListInstalledColormaps(pScreen, pmaps);
+}
+
+void
+fbInstallColormap(ColormapPtr pmap)
+{
+    miInstallColormap(pmap);
+}
+
+void
+fbUninstallColormap(ColormapPtr pmap)
+{
+    miUninstallColormap(pmap);
+}
+
+void
+fbResolveColor(unsigned short   *pred,
+	       unsigned short   *pgreen,
+	       unsigned short   *pblue,
+	       VisualPtr	pVisual)
+{
+    miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+Bool
+fbInitializeColormap(ColormapPtr pmap)
+{
+    return miInitializeColormap(pmap);
+}
+
+int
+fbExpandDirectColors (ColormapPtr   pmap,
+		      int	    ndef,
+		      xColorItem    *indefs,
+		      xColorItem    *outdefs)
+{
+    return miExpandDirectColors(pmap, ndef, indefs, outdefs);
+}
+
+Bool
+fbCreateDefColormap(ScreenPtr pScreen)
+{
+    return miCreateDefColormap(pScreen);
+}
+
+void
+fbClearVisualTypes(void)
+{
+    miClearVisualTypes();
+}
+
+Bool
+fbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
+{
+    return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which coorespond to
+ * the set which can be used with this version of fb.
+ */
+Bool
+fbInitVisuals (VisualPtr    *visualp, 
+	       DepthPtr	    *depthp,
+	       int	    *nvisualp,
+	       int	    *ndepthp,
+	       int	    *rootDepthp,
+	       VisualID	    *defaultVisp,
+	       unsigned long	sizes,
+	       int	    bitsPerRGB)
+{
+    return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+			 defaultVisp, sizes, bitsPerRGB, -1);
+}
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 3e28d32..b8641bb 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -26,12 +26,12 @@ libdarwinShared_a_SOURCES = darwin.c \
 
 bin_PROGRAMS = XDarwin Xquartz
 XDarwin_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap.c \
+                  $(top_srcdir)/fb/fbcmap_mi.c \
                   $(top_srcdir)/mi/miinitext.c \
                   $(top_srcdir)/Xi/stubs.c
 
 Xquartz_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap.c \
+                  $(top_srcdir)/fb/fbcmap_mi.c \
                   $(top_srcdir)/mi/miinitext.c \
                   $(top_srcdir)/Xi/stubs.c \
                   apple/X11Application.m \
@@ -115,7 +115,7 @@ x11app:
 	cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
 
 XDarwinApp_SOURCES = \
-                $(top_srcdir)/fb/fbcmap.c \
+                $(top_srcdir)/fb/fbcmap_mi.c \
                 $(top_srcdir)/mi/miinitext.c \
 		$(top_srcdir)/Xi/stubs.c 
 
diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index 41dc5d2..002ea11 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -16,9 +16,6 @@ GLX_INCS = -I$(top_srcdir)/hw/xfree86/di
 GLX_DEFS = @GL_CFLAGS@ 
 endif
 
-# It's essential that fbcmap.c be compiled with this flag for DMX to work!!
-DMX_CFLAGS = -DXFree86Server=1
-
 if BUILDDOCS
 SUBDIRS += doc
 endif
@@ -76,7 +73,7 @@ Xdmx_SOURCES = dmx.c \
                dmxwindow.c \
                dmxwindow.h \
                $(top_srcdir)/mi/miinitext.c \
-               $(top_srcdir)/fb/fbcmap.c \
+               $(top_srcdir)/fb/fbcmap_mi.c \
                $(GLX_SRCS) 
 
 
diff --git a/hw/vfb/Makefile.am b/hw/vfb/Makefile.am
index 40c3854..6842b45 100644
--- a/hw/vfb/Makefile.am
+++ b/hw/vfb/Makefile.am
@@ -14,8 +14,8 @@ SRCS =	InitInput.c \
 	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/mi/miinitext.c
 
-libfbcmap_a_CFLAGS = $(AM_CFLAGS) -DXFree86Server
-libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap.c
+libfbcmap_a_CFLAGS = $(AM_CFLAGS)
+libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap_mi.c
 
 Xvfb_SOURCES = $(SRCS)
 
diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index 58099bc..1581019 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -75,13 +75,13 @@ libdbe_la_SOURCES = dbemodule.c
 
 libfb_la_LDFLAGS = -avoid-version
 libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
-libfb_la_SOURCES = $(top_builddir)/fb/fbcmap.c fbmodule.c
-libfb_la_CFLAGS = -DXFree86Server $(AM_CFLAGS)
+libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
+libfb_la_CFLAGS = $(AM_CFLAGS)
 
 libwfb_la_LDFLAGS = -avoid-version
 libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
-libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap.c fbmodule.c
-libwfb_la_CFLAGS = -DXFree86Server $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
+libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
+libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
 
 libglx_la_LDFLAGS = -avoid-version
 if AIGLX
diff --git a/hw/xnest/Makefile.am b/hw/xnest/Makefile.am
index b897616..e958c0e 100644
--- a/hw/xnest/Makefile.am
+++ b/hw/xnest/Makefile.am
@@ -45,8 +45,8 @@ SRCS =	Args.c \
 	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/mi/miinitext.c
 
-libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap.c
-libfbcmap_a_CFLAGS = $(AM_CFLAGS) -DXFree86Server
+libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap_mi.c
+libfbcmap_a_CFLAGS = $(AM_CFLAGS)
 
 Xnest_SOURCES = $(SRCS)
 
diff --git a/hw/xprint/Makefile.am b/hw/xprint/Makefile.am
index d4f22d2..45168b1 100644
--- a/hw/xprint/Makefile.am
+++ b/hw/xprint/Makefile.am
@@ -38,6 +38,6 @@ Xprt_SOURCES =			\
 	Util.c			\
 	miinitext-wrapper.c	\
 	dpmsstubs-wrapper.c     \
-        $(top_srcdir)/fb/fbcmap.c
+        $(top_srcdir)/fb/fbcmap_mi.c
 
 EXTRA_DIST = ValTree.c
diff-tree 1cc8db72816cd079f30255046e10043c350bf683 (from parents)
Merge: 645d87cf8ef724d4591614f9994cdc4d7549a7a8 a39f297ada4fa87c858395ae2aacefac5f8fba05
Author: Matthieu Herrb <matthieu at roadrock.(none)>
Date:   Tue Apr 3 16:04:45 2007 +0200

    Merge branch 'master' of ssh://herrb@git.freedesktop.org/git/xorg/xserver

diff-tree 645d87cf8ef724d4591614f9994cdc4d7549a7a8 (from f2808005f4ee72c5fd7f5f3dcca181306485113e)
Author: Matthieu Herrb <matthieu at roadrock.(none)>
Date:   Tue Apr 3 15:47:18 2007 +0200

    CVE-2007-1003: XC-MISC Extension ProcXCMiscGetXIDList() Memory Corruption

diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c
index f26218e..8c7a86e 100644
--- a/Xext/xcmisc.c
+++ b/Xext/xcmisc.c
@@ -42,6 +42,12 @@ from The Open Group.
 #include <X11/extensions/xcmiscstr.h>
 #include "modinit.h"
 
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
 #if 0
 static unsigned char XCMiscCode;
 #endif
@@ -143,7 +149,10 @@ ProcXCMiscGetXIDList(client)
 
     REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
 
-    pids = (XID *)ALLOCATE_LOCAL(stuff->count * sizeof(XID));
+    if (stuff->count > UINT32_MAX / sizeof(XID))
+	    return BadAlloc;
+
+    pids = (XID *)Xalloc(stuff->count * sizeof(XID));
     if (!pids)
     {
 	return BadAlloc;
@@ -164,7 +173,7 @@ ProcXCMiscGetXIDList(client)
     	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
 	WriteSwappedDataToClient(client, count * sizeof(XID), pids);
     }
-    DEALLOCATE_LOCAL(pids);
+    Xfree(pids);
     return(client->noClientException);
 }
 
diff-tree a39f297ada4fa87c858395ae2aacefac5f8fba05 (from 11797ffdcc22160317a5ebbc9291472570a51c6d)
Author: Keith Packard <keithp at viola.jf.intel.com>
Date:   Mon Apr 2 14:15:36 2007 -0700

    Don't erase current crtc for outputs on CloseScreen
    
    Erasing this variable causes some outputs (SDVO on intel) to fail
    to be correctly reset at server reset time.
    (cherry picked from commit 56262a4ee943f328d089a8eb4aa70b9a4bd5d135)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 32bdcba..0fe03d3 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -598,7 +598,6 @@ xf86CrtcCloseScreen (int index, ScreenPt
     {
 	xf86OutputPtr	output = config->output[o];
 
-	output->crtc = NULL;
 	output->randr_output = NULL;
     }
     for (c = 0; c < config->num_crtc; c++)
diff-tree 11797ffdcc22160317a5ebbc9291472570a51c6d (from e44f106ffc796c025abdfb66717c06db8b12b4e4)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Apr 2 18:21:58 2007 -0700

    Move modes/ debugging output under Option "ModeDebug" in the Device section.

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index cc60d07..19315c0 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -958,6 +958,10 @@ the driver-specific documentation recomm
 This optional entry specifies the pixel clock frequency that is used
 for the regular text mode.  The frequency is specified in MHz.  This is
 rarely used.
+.TP 7
+.BI "Option \*qModeDebug\*q \*q" boolean \*q
+Enable printing of additional debugging information about modesetting to
+the server log.
 .ig
 .TP 7
 This optional entry allows an IRQ number to be specified.
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 7d86b66..32bdcba 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -377,6 +377,15 @@ static OptionInfoRec xf86OutputOptions[]
     {-1,		    NULL,		OPTV_NONE,    {0}, FALSE },
 };
 
+enum {
+    OPTION_MODEDEBUG,
+};
+
+static OptionInfoRec xf86DeviceOptions[] = {
+    {OPTION_MODEDEBUG,	    "ModeDebug",	OPTV_STRING,  {0}, FALSE },
+    {-1,		    NULL,		OPTV_NONE,    {0}, FALSE },
+};
+
 static void
 xf86OutputSetMonitor (xf86OutputPtr output)
 {
@@ -1160,8 +1169,6 @@ xf86SortModes (DisplayModePtr input)
     return output;
 }
 
-#define DEBUG_REPROBE 1
-
 void
 xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 {
@@ -1330,7 +1337,8 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	    if (mode->status == MODE_OK)
 		mode->status = (*output->funcs->mode_valid)(output, mode);
 	
-	xf86PruneInvalidModes(scrn, &output->probed_modes, TRUE);
+	xf86PruneInvalidModes(scrn, &output->probed_modes,
+			      config->debug_modes);
 	
 	output->probed_modes = xf86SortModes (output->probed_modes);
 	
@@ -1363,17 +1371,17 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	
 	output->initial_rotation = xf86OutputInitialRotation (output);
 
-#ifdef DEBUG_REPROBE
-	if (output->probed_modes != NULL) {
-	    xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		       "Printing probed modes for output %s\n",
-		       output->name);
-	} else {
-	    xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		       "No remaining probed modes for output %s\n",
-		       output->name);
+	if (config->debug_modes) {
+	    if (output->probed_modes != NULL) {
+		xf86DrvMsg(scrn->scrnIndex, X_INFO,
+			   "Printing probed modes for output %s\n",
+			   output->name);
+	    } else {
+		xf86DrvMsg(scrn->scrnIndex, X_INFO,
+			   "No remaining probed modes for output %s\n",
+			   output->name);
+	    }
 	}
-#endif
 	for (mode = output->probed_modes; mode != NULL; mode = mode->next)
 	{
 	    /* The code to choose the best mode per pipe later on will require
@@ -1382,9 +1390,8 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	    mode->VRefresh = xf86ModeVRefresh(mode);
 	    xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
 
-#ifdef DEBUG_REPROBE
-	    xf86PrintModeline(scrn->scrnIndex, mode);
-#endif
+	    if (config->debug_modes)
+		xf86PrintModeline(scrn->scrnIndex, mode);
 	}
     }
 }
@@ -1479,6 +1486,15 @@ xf86InitialConfiguration (ScrnInfoPtr sc
     int			width;
     int			height;
 
+    /* Set up the device options */
+    config->options = xnfalloc (sizeof (xf86DeviceOptions));
+    memcpy (config->options, xf86DeviceOptions, sizeof (xf86DeviceOptions));
+    xf86ProcessOptions (scrn->scrnIndex,
+			scrn->options,
+			config->options);
+    config->debug_modes = xf86ReturnOptValBool (config->options,
+						OPTION_MODEDEBUG, FALSE);
+
     if (scrn->display->virtualX)
 	width = scrn->display->virtualX;
     else
@@ -1962,10 +1978,12 @@ xf86OutputSetEDID (xf86OutputPtr output,
     
     output->MonInfo = edid_mon;
 
-    /* Debug info for now, at least */
-    xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n", output->name);
-    xf86PrintEDID(edid_mon);
-    
+    if (config->debug_modes) {
+	xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n",
+		   output->name);
+	xf86PrintEDID(edid_mon);
+    }
+
     /* Set the DDC properties for the 'compat' output */
     if (output == config->output[config->compat_output])
         xf86SetDDCproperties(scrn, edid_mon);
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 42daf60..030f6bf 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -552,6 +552,13 @@ typedef struct _xf86CrtcConfig {
     CARD8		*cursor_image;
     Bool		cursor_on;
     CARD32		cursor_fg, cursor_bg;
+
+    /**
+     * Options parsed from the related device section
+     */
+    OptionInfoPtr	options;
+
+    Bool		debug_modes;
 } xf86CrtcConfigRec, *xf86CrtcConfigPtr;
 
 extern int xf86CrtcConfigPrivateIndex;
diff-tree e44f106ffc796c025abdfb66717c06db8b12b4e4 (from 8d8bc8927760fad631bef83fa2841b455ff6d511)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 16:26:15 2007 -0600

    clean-up, debug code

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 288570d..e4d556b 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -109,11 +109,11 @@ static int dmxCheckFunctionKeys(DMXLocal
     else if (dmxLocal->pDevice->key)
         state = dmxLocal->pDevice->key->state;
     
-    DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
+    ErrorF/*DMXDBG3*/("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
             keySym, type == KeyPress ? "press" : "release", state);
 
     if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
-       return 0;
+        return 0;
 
     switch (keySym) {
     case XK_g:
@@ -679,7 +679,7 @@ void dmxEnqueue(DevicePtr pDev, int type
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
 
         events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-        ErrorF("KEY %d\n", detail);
+        ErrorF("KEY %d  sym %d\n", detail, (int) keySym);
         nevents = GetKeyboardEvents(events, p, type, detail);
         for (i = 0; i < nevents; i++)
             mieqEnqueue(p, events + i);
@@ -719,12 +719,12 @@ void dmxEnqueue(DevicePtr pDev, int type
                                  * modifier map on the backend/console
                                  * input device so that we have complete
                                  * control of the input device LEDs. */
-       ErrorF("Enter/Leave/Keymap/Mapping\n");
         return;
     default:
 #ifdef XINPUT
         if (type == ProximityIn || type == ProximityOut) {
-            if (dmxLocal->sendsCore) return; /* Not a core event */
+            if (dmxLocal->sendsCore)
+                return; /* Not a core event */
             break;
         }
 #endif
diff-tree 8d8bc8927760fad631bef83fa2841b455ff6d511 (from 3e482de7b145a5eed79b81c30c359fe43647824a)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 16:21:57 2007 -0600

    fix formatting

diff --git a/hw/dmx/input/dmxcommon.c b/hw/dmx/input/dmxcommon.c
index 278a74e..1dcc1e9 100644
--- a/hw/dmx/input/dmxcommon.c
+++ b/hw/dmx/input/dmxcommon.c
@@ -241,13 +241,15 @@ void dmxCommonKbdGetMap(DevicePtr pDev, 
 
                                 /* Compute pModMap  */
     modifier_mapping     = XGetModifierMapping(priv->display);
-    for (i = 0; i < MAP_LENGTH; i++) pModMap[i] = 0;
+    for (i = 0; i < MAP_LENGTH; i++)
+        pModMap[i] = 0;
     for (j = 0; j < 8; j++) {
         int max_keypermod = modifier_mapping->max_keypermod;
         
         for (i = 0; i < max_keypermod; i++) {
             CARD8 keycode = modifier_mapping->modifiermap[j*max_keypermod + i];
-            if (keycode) pModMap[keycode] |= 1 << j;
+            if (keycode)
+                pModMap[keycode] |= 1 << j;
         }
     }
     XFreeModifiermap(modifier_mapping);
@@ -611,6 +613,7 @@ void dmxCommonSaveState(pointer private)
                         &priv->dmxLocal->kctrl);
 
     priv->savedModMap                   = XGetModifierMapping(priv->display);
+
     modmap                              = XNewModifiermap(0);
     XSetModifierMapping(priv->display, modmap);
     if (dmxInput->scrnIdx != -1)
@@ -627,8 +630,10 @@ void dmxCommonRestoreState(pointer priva
     int retcode = -1;
     CARD32 start;
 
-    if (dmxInput->console) priv = dmxInput->devs[0]->private;
-    if (!priv->stateSaved) return;
+    if (dmxInput->console)
+        priv = dmxInput->devs[0]->private;
+    if (!priv->stateSaved)
+        return;
     priv->stateSaved = 0;
     
     DMXDBG0("dmxCommonRestoreState\n");
@@ -645,7 +650,8 @@ void dmxCommonRestoreState(pointer priva
         CARD32 tmp;
         
         retcode = XSetModifierMapping(priv->display, priv->savedModMap);
-        if (retcode == MappingSuccess) break;
+        if (retcode == MappingSuccess)
+            break;
         if (retcode == MappingBusy)
             dmxLogInput(dmxInput, "Keyboard busy, waiting\n");
         else
diff-tree 3e482de7b145a5eed79b81c30c359fe43647824a (from 76a7a5ca1f068c27c9b5fbd49d5a1da80ed6f488)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:38:15 2007 -0600

    checkpoint: more clean-up

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 17047f7..288570d 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -662,70 +662,56 @@ void dmxEnqueue(DevicePtr pDev, int type
 {
     GETDMXINPUTFROMPDEV;
     xEvent xE;
+    DeviceIntPtr p = dmxLocal->pDevice;
+    int i, nevents, valuators[3];
+    xEvent *events;
 
     DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
 
     switch (type) {
     case KeyPress:
     case KeyRelease:
-        if (!keySym) keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+        if (!keySym)
+            keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
         if (dmxCheckFunctionKeys(dmxLocal, type, keySym))
             return;
         if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
-        {
-           DeviceIntPtr p = dmxLocal->pDevice;
-           int i, nevents;
-           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           ErrorF("KEY %d\n", detail);
-           nevents = GetKeyboardEvents(events, p, type, detail);
-           for (i = 0; i < nevents; i++)
-              mieqEnqueue(p, events + i);
-           xfree(events);
-           return;
-        }
-        break;
+
+        events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+        ErrorF("KEY %d\n", detail);
+        nevents = GetKeyboardEvents(events, p, type, detail);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(p, events + i);
+        xfree(events);
+        return;
+
     case ButtonPress:
     case ButtonRelease:
         detail = dmxGetButtonMapping(dmxLocal, detail);
-        {
-           DeviceIntPtr p = dmxLocal->pDevice;
-           int i, nevents, valuators[3];
-           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           valuators[2] = e->xbutton.button;
-           nevents = GetPointerEvents(events, p, type, detail,
-                                      POINTER_ABSOLUTE,
-                                      0,   /* first_valuator = 0 */
-                                      0,   /* num_valuators = 0 */
-                                      valuators);
-
-           ErrorF("BUTTON %d, %d %d  n=%d\n",
-                  valuators[0], valuators[1], valuators[2], nevents);
-
-           for (i = 0; i < nevents; i++)
-              mieqEnqueue(p, events + i);
-           xfree(events);
-           return;
-        }
-        break;
+        events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+        nevents = GetPointerEvents(events, p, type, detail,
+                                   POINTER_ABSOLUTE,
+                                   0,   /* first_valuator = 0 */
+                                   0,   /* num_valuators = 0 */
+                                   valuators);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(p, events + i);
+        xfree(events);
+        return;
+
     case MotionNotify:
-        {
-           DeviceIntPtr p = dmxLocal->pDevice;
-           int i, nevents, valuators[3];
-           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           valuators[0] = e->xmotion.x;
-           valuators[1] = e->xmotion.y;
-           valuators[2] = e->xmotion.state;
-           nevents = GetPointerEvents(events, p, type, detail, 
-                                      POINTER_ABSOLUTE, 0, 3, valuators);
-           ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
-           for (i = 0; i < nevents; i++)
-              mieqEnqueue(p, events + i);
-           xfree(events);
-           return;
-        }
-        break;
-                                /* Always ignore these events */
+        events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+        valuators[0] = e->xmotion.x;
+        valuators[1] = e->xmotion.y;
+        valuators[2] = e->xmotion.state;
+        nevents = GetPointerEvents(events, p, type, detail, 
+                                   POINTER_ABSOLUTE, 0, 3, valuators);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(p, events + i);
+        xfree(events);
+        return;
+
     case EnterNotify:
     case LeaveNotify:
     case KeymapNotify:
@@ -754,25 +740,19 @@ void dmxEnqueue(DevicePtr pDev, int type
         return;
     }
 
+#if 00 /* dead code? */
     memset(&xE, 0, sizeof(xE));
     xE.u.u.type                = type;
     xE.u.u.detail              = detail;
     xE.u.keyButtonPointer.time = GetTimeInMillis();
 
 #ifdef XINPUT
-    if (!dmxLocal->sendsCore) dmxEnqueueExtEvent(dmxLocal, &xE, block);
+    if (!dmxLocal->sendsCore)
+        dmxEnqueueExtEvent(dmxLocal, &xE, block);
     else
 #endif
-#if 00 /*BP*/
         dmxeqEnqueue(&xE);
-#else
-    /* never get here! */
-    if (0) {
-       DeviceIntPtr p = dmxLocal->pDevice;
-       ErrorF("enque %d\n", type);
-       mieqEnqueue(p, &xE);
-    }
-#endif
+#endif /*00*/
 }
 
 /** A pointer to this routine is passed to low-level input drivers so
diff-tree 76a7a5ca1f068c27c9b5fbd49d5a1da80ed6f488 (from 69baad321d35dae0bfa535be0c6ed2131fed1e60)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:24:05 2007 -0600

    formatting fixes

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index bca1a10..17047f7 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -112,7 +112,8 @@ static int dmxCheckFunctionKeys(DMXLocal
     DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
             keySym, type == KeyPress ? "press" : "release", state);
 
-    if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask)) return 0;
+    if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
+       return 0;
 
     switch (keySym) {
     case XK_g:
@@ -147,16 +148,25 @@ static void dmxEnqueueExtEvent(DMXLocalI
     int                    type      = e->u.u.type;
 
     switch (e->u.u.type) {
-    case KeyPress:      type = DeviceKeyPress;      break;
-    case KeyRelease:    type = DeviceKeyRelease;    break;
-    case ButtonPress:   type = DeviceButtonPress;   break;
-    case ButtonRelease: type = DeviceButtonRelease; break;
+    case KeyPress:
+        type = DeviceKeyPress;
+        break;
+    case KeyRelease:
+        type = DeviceKeyRelease;
+        break;
+    case ButtonPress:
+        type = DeviceButtonPress;
+        break;
+    case ButtonRelease:
+        type = DeviceButtonRelease;
+        break;
     case MotionNotify:
         dmxLog(dmxError,
                "dmxEnqueueExtEvent: MotionNotify not allowed here\n");
         return;
     default:
-        if (e->u.u.type == ProximityIn || e->u.u.type == ProximityOut) break;
+        if (e->u.u.type == ProximityIn || e->u.u.type == ProximityOut)
+            break;
         dmxLogInput(dmxInput,
                     "dmxEnqueueExtEvent: Unhandled %s event (%d)\n",
                     e->u.u.type >= LASTEvent ? "extension" : "non-extension",
@@ -174,9 +184,11 @@ static void dmxEnqueueExtEvent(DMXLocalI
     xv->num_valuators  = 0;
     xv->first_valuator = 0;
 
-    if (block) dmxSigioBlock();
+    if (block)
+        dmxSigioBlock();
     dmxeqEnqueue(xE);
-    if (block) dmxSigioUnblock();
+    if (block)
+        dmxSigioUnblock();
 }
 #endif
 
@@ -186,7 +198,8 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
 
     for (i = 0; i < dmxNumScreens; i++) {
         DMXScreenInfo *dmxScreen = &dmxScreens[i];
-        if (dmxOnScreen(x, y, dmxScreen)) return dmxScreen;
+        if (dmxOnScreen(x, y, dmxScreen))
+            return dmxScreen;
     }
     return NULL;
 }
@@ -223,7 +236,8 @@ dmxCoreMotion(DevicePtr pDev, int x, int
     int           localY;
     int           i;
 
-    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y) return;
+    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y)
+        return;
     
     DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
             x, y, delta, dmxGlobalX, dmxGlobalY);
@@ -232,10 +246,14 @@ dmxCoreMotion(DevicePtr pDev, int x, int
     dmxGlobalX       = x;
     dmxGlobalY       = y;
 
-    if (dmxGlobalX < 0)                dmxGlobalX = 0;
-    if (dmxGlobalY < 0)                dmxGlobalY = 0;
-    if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
-    if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
+    if (dmxGlobalX < 0)
+        dmxGlobalX = 0;
+    if (dmxGlobalY < 0)
+        dmxGlobalY = 0;
+    if (dmxGlobalX >= dmxGlobalWidth)
+        dmxGlobalX = dmxGlobalWidth  + delta -1;
+    if (dmxGlobalY >= dmxGlobalHeight)
+        dmxGlobalY = dmxGlobalHeight + delta -1;
     
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
@@ -283,7 +301,6 @@ dmxCoreMotion(DevicePtr pDev, int x, int
                                  * drivers */
     for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
         int j;
-
         for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
             if (!dmxInput->detached
                 && dmxInput->devs[j]->sendsCore
@@ -386,10 +403,12 @@ static void dmxExtMotion(DMXLocalInputIn
         }
     }
 
-    if (block) dmxSigioBlock();
+    if (block)
+        dmxSigioBlock();
     dmxPointerPutMotionEvent(pDevice, firstAxis, axesCount, v, xev->time);
     dmxeqEnqueue(xE);
-    if (block) dmxSigioUnblock();
+    if (block)
+        dmxSigioUnblock();
 }
 
 static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
@@ -403,7 +422,8 @@ static int dmxTranslateAndEnqueueExtEven
     XDeviceKeyEvent        *ke     = (XDeviceKeyEvent *)e;
     XDeviceMotionEvent     *me     = (XDeviceMotionEvent *)e;
 
-    if (!e) return -1;          /* No extended event passed, cannot handle */
+    if (!e)
+        return -1;          /* No extended event passed, cannot handle */
     
     if ((XID)dmxLocal->deviceId != ke->deviceid) {
                                 /* Search for the correct dmxLocal,
@@ -414,7 +434,8 @@ static int dmxTranslateAndEnqueueExtEven
         DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
         for (i = 0; i < dmxInput->numDevs; i++) {
             dmxLocal = dmxInput->devs[i];
-            if ((XID)dmxLocal->deviceId == ke->deviceid) break;
+            if ((XID)dmxLocal->deviceId == ke->deviceid)
+                break;
         }
     }
 
@@ -463,9 +484,11 @@ static int dmxTranslateAndEnqueueExtEven
         xv->valuator4      = ke->axis_data[4];
         xv->valuator5      = ke->axis_data[5];
 
-        if (block) dmxSigioBlock();
+        if (block)
+            dmxSigioBlock();
         dmxeqEnqueue(xE);
-        if (block) dmxSigioUnblock();
+        if (block)
+            dmxSigioUnblock();
         break;
 
     case XI_DeviceMotionNotify:
@@ -568,7 +591,8 @@ static KeySym dmxKeyCodeToKeySym(DMXLoca
     if (!dmxLocal || !dmxLocal->pDevice || !dmxLocal->pDevice->key)
         return NoSymbol;
     pKeySyms = &dmxLocal->pDevice->key->curKeySyms;
-    if (!pKeySyms) return NoSymbol;
+    if (!pKeySyms)
+        return NoSymbol;
     
     if (keyCode > pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
         DMXDBG2("dmxKeyCodeToKeySym: Translated keyCode=%d to keySym=0x%04x\n",
@@ -617,8 +641,10 @@ static int dmxFixup(DevicePtr pDev, int 
                dmxLocal->pDevice->name);
         return NoSymbol;
     }
-    if (!keySym) keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
-    if (keySym == NoSymbol) return detail;
+    if (!keySym)
+        keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+    if (keySym == NoSymbol)
+        return detail;
     keyCode = dmxKeySymToKeyCode(dmxLocalCoreKeyboard, keySym, detail);
 
     return keyCode ? keyCode : detail;
diff-tree 69baad321d35dae0bfa535be0c6ed2131fed1e60 (from 44eb15adeee3b299677070f39625daa53679bd13)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:21:22 2007 -0600

    clean-up dmxCoreMotion() dmxCoreMotion2()

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 3634324..bca1a10 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -192,8 +192,6 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
 }
 
 
-#if 11/*BP*/
-
 /**
  * Enqueue a motion event.
  */
@@ -215,8 +213,8 @@ static void enqueueMotion(DevicePtr pDev
 }
 
 
-static void
-dmxCoreMotion2(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
+void
+dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
 {
     DMXScreenInfo *dmxScreen;
     DMXInputInfo  *dmxInput;
@@ -239,8 +237,6 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
     if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
     if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
     
-    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
-
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
         localY = dmxGlobalY - dmxScreen->rootYOrigin;
@@ -249,13 +245,8 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
                                 /* Screen is old screen */
             if (block)
                 dmxSigioBlock();
-#if 000
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#else
             if (pDev)
                enqueueMotion(pDev, localX, localY);
-#endif
             if (block)
                 dmxSigioUnblock();
         } else {
@@ -267,13 +258,8 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
             dmxeqProcessInputEvents();
             miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
                                localX, localY);
-#if 000
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#else
             if (pDev)
                enqueueMotion(pDev, localX, localY);
-#endif
             if (block)
                 dmxSigioUnblock();
         }
@@ -307,105 +293,6 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
     }
     if (!dmxScreen) ProcessInputEvents();
 }
-#endif
-
-void dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
-{
-    DMXScreenInfo *dmxScreen;
-    DMXInputInfo  *dmxInput;
-    ScreenPtr     pScreen;
-    int           localX;
-    int           localY;
-    int           i;
-
-#if 11/*BP*/
-    dmxCoreMotion2(pDev, x, y, delta, block);
-    return;
-#endif
-
-    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y) return;
-    
-    DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
-            x, y, delta, dmxGlobalX, dmxGlobalY);
-
-    dmxGlobalInvalid = 0;
-    dmxGlobalX       = x;
-    dmxGlobalY       = y;
-
-    if (dmxGlobalX < 0)                dmxGlobalX = 0;
-    if (dmxGlobalY < 0)                dmxGlobalY = 0;
-    if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
-    if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
-    
-    if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
-        localX = dmxGlobalX - dmxScreen->rootXOrigin;
-        localY = dmxGlobalY - dmxScreen->rootYOrigin;
-#if 00 /*BP*/
-        if ((pScreen = miPointerCurrentScreen())
-#else
-        if ((pScreen = miPointerGetScreen(inputInfo.pointer))
-#endif
-            && pScreen->myNum == dmxScreen->index) {
-                                /* Screen is old screen */
-            if (block) dmxSigioBlock();
-#if 00 /*BP*/
-            miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
-#else
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#endif
-            if (block) dmxSigioUnblock();
-        } else {
-                                /* Screen is new */
-            DMXDBG4("   New screen: old=%d new=%d localX=%d localY=%d\n",
-                    pScreen->myNum, dmxScreen->index, localX, localY);
-            if (block) dmxSigioBlock();
-            dmxeqProcessInputEvents();
-#if 00 /*BP*/
-            miPointerSetNewScreen(dmxScreen->index, localX, localY);
-            miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
-#else
-            miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
-                               localX, localY);
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#endif
-            if (block) dmxSigioUnblock();
-        }
-#if 00 /*BP*/
-        miPointerPosition(&localX, &localY);
-#else
-        miPointerGetPosition(inputInfo.pointer, &localX, &localY);
-#endif
-
-#if 00 /*BP*/
-        if ((pScreen = miPointerCurrentScreen())) {
-#else
-        if ((pScreen = miPointerGetScreen(inputInfo.pointer))) {
-#endif
-            dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
-            dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
-            DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
-                    " on screen index=%d/%d localX=%d localY=%d\n",
-                    dmxGlobalX, dmxGlobalY,
-                    dmxScreen ? dmxScreen->index : -1, pScreen->myNum,
-                    localX, localY);
-        }
-    }
-                                /* Send updates down to all core input
-                                 * drivers */
-    for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
-        int j;
-
-        for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
-            if (!dmxInput->detached
-                && dmxInput->devs[j]->sendsCore
-                && dmxInput->devs[j]->update_position)
-                dmxInput->devs[j]->update_position(dmxInput->devs[j]->private,
-                                                   dmxGlobalX, dmxGlobalY);
-    }
-    if (!dmxScreen) ProcessInputEvents();
-}
 
 
 
@@ -760,25 +647,20 @@ void dmxEnqueue(DevicePtr pDev, int type
             return;
         if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
-#if 11/*BP*/
         {
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents;
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+           ErrorF("KEY %d\n", detail);
            nevents = GetKeyboardEvents(events, p, type, detail);
-           ErrorF("KEY %d  n=%d\n", detail, nevents);
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
            return;
         }
-#endif
         break;
     case ButtonPress:
     case ButtonRelease:
-#if 00 /*BP*/
-        detail = dmxGetButtonMapping(dmxLocal, detail);
-#else
         detail = dmxGetButtonMapping(dmxLocal, detail);
         {
            DeviceIntPtr p = dmxLocal->pDevice;
@@ -799,15 +681,8 @@ void dmxEnqueue(DevicePtr pDev, int type
            xfree(events);
            return;
         }
-#endif
         break;
     case MotionNotify:
-        /* All MotionNotify events should be sent via dmxCoreMotion and
-         * dmxExtMotion -- no input driver should build motion events by
-         * hand. */
-#if 00 /*BP*/
-        dmxLog(dmxError, "dmxEnqueueXEvent: MotionNotify not allowed here\n");
-#else
         {
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
@@ -815,25 +690,14 @@ void dmxEnqueue(DevicePtr pDev, int type
            valuators[0] = e->xmotion.x;
            valuators[1] = e->xmotion.y;
            valuators[2] = e->xmotion.state;
-           nevents = GetPointerEvents(events,
-                                      /*pDev*/p,
-                                      /*KeyPress*/type,
-                                      detail,
-                                      POINTER_ABSOLUTE,
-                                      0, 3, valuators);
+           nevents = GetPointerEvents(events, p, type, detail, 
+                                      POINTER_ABSOLUTE, 0, 3, valuators);
            ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
-           /*
-           ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
-                  detail, e->xmotion.state,
-                  valuators[0], valuators[1], valuators[2],
-                  nevents);
-           */
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
            return;
         }
-#endif
         break;
                                 /* Always ignore these events */
     case EnterNotify:
diff-tree 44eb15adeee3b299677070f39625daa53679bd13 (from 0f873a9d4f02b399c37b4058c6a9a2e21aa205e8)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:12:04 2007 -0600

    checkpoint clean-up

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 315979e..7aa8510 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -242,11 +242,7 @@ static int dmxBackendOffscreen(int scree
 void dmxBackendUpdatePosition(pointer private, int x, int y)
 {
     GETPRIVFROMPRIVATE;
-#if 00 /*BP*/
-    int           screen      = miPointerCurrentScreen()->myNum;
-#else
     int           screen      = miPointerGetScreen(inputInfo.pointer)->myNum;
-#endif
     DMXScreenInfo *dmxScreen  = &dmxScreens[priv->myScreen];
     int           oldRelative = priv->relative;
     int           topscreen   = dmxBackendFindOverlapping(priv, screen, x, y);
@@ -397,7 +393,6 @@ void dmxBackendCollectEvents(DevicePtr p
             }
             break;
 	case MotionNotify:
-#if 001 /*BP*/
             DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)"
                     " newscreen=%d: %d %d (e=%d; last=%d,%d)\n",
                     dmxScreen->index, priv->myScreen,
@@ -451,25 +446,15 @@ void dmxBackendCollectEvents(DevicePtr p
                         (dmxScreen->rootYOrigin + X.xmotion.y
                          - dmxScreen->rootY));
             }
-#else
-            /*
-            ErrorF("motion %d, %d, %d\n",
-                   X.xmotion.x, X.xmotion.y, X.xmotion.state);
-            */
-            enqueue(priv->mou, X.type, 0/*X.xbutton.button*/, 0, &X, block);
-#endif
 	    break;
 
         case KeyPress:
         case KeyRelease:
             enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block);
             break;
-#if 11/*BP*/
         case ButtonPress:
         case ButtonRelease:
-           ErrorF("press/release at %d, %d\n", X.xbutton.x, X.xbutton.y);
-           /* fall-through */
-#endif
+            /* fall-through */
 	default:
                                 /* Pass the whole event here, because
                                  * this may be an extension event. */
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index d174a59..3634324 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -194,30 +194,20 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
 
 #if 11/*BP*/
 
+/**
+ * Enqueue a motion event.
+ */
 static void enqueueMotion(DevicePtr pDev, int x, int y)
 {
-    GETDMXINPUTFROMPDEV;
+    GETDMXLOCALFROMPDEV;
     DeviceIntPtr p = dmxLocal->pDevice;
     int i, nevents, valuators[3];
     xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-    int detail = 0;
-
+    int detail = 0;  /* XXX should this be mask of pressed buttons? */
     valuators[0] = x;
     valuators[1] = y;
-    valuators[2] = detail;
-    nevents = GetPointerEvents(events,
-                               /*pDev*/p,
-                               MotionNotify,
-                               detail,
-                               POINTER_ABSOLUTE,
-                               0, 2, valuators);
-    ErrorF("MOTION2 %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
-    /*
-      ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
-      detail, e->xmotion.state,
-      valuators[0], valuators[1], valuators[2],
-      nevents);
-    */
+    nevents = GetPointerEvents(events, p, MotionNotify, detail,
+                               POINTER_ABSOLUTE, 0, 2, valuators);
     for (i = 0; i < nevents; i++)
        mieqEnqueue(p, events + i);
     xfree(events);
@@ -347,8 +337,6 @@ void dmxCoreMotion(DevicePtr pDev, int x
     if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
     if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
     
-    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
-
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
         localY = dmxGlobalY - dmxScreen->rootYOrigin;
@@ -397,7 +385,6 @@ void dmxCoreMotion(DevicePtr pDev, int x
 #endif
             dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
             dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
-           ErrorF("Global is now %d, %d\n", dmxGlobalX, dmxGlobalY);
             DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
                     " on screen index=%d/%d localX=%d localY=%d\n",
                     dmxGlobalX, dmxGlobalY,
@@ -750,7 +737,7 @@ static int dmxFixup(DevicePtr pDev, int 
     return keyCode ? keyCode : detail;
 }
 
-/** Enqueue a non-motion event from the \a pDev device with the
+/** Enqueue an event from the \a pDev device with the
  * specified \a type and \a detail.  If the event is a KeyPress or
  * KeyRelease event, then the \a keySym is also specified.
  *
@@ -778,10 +765,7 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents;
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           nevents = GetKeyboardEvents(events,
-                                       /*pDev*/p,
-                                       /*KeyPress*/type,
-                                       /*n*/detail);
+           nevents = GetKeyboardEvents(events, p, type, detail);
            ErrorF("KEY %d  n=%d\n", detail, nevents);
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
@@ -795,6 +779,7 @@ void dmxEnqueue(DevicePtr pDev, int type
 #if 00 /*BP*/
         detail = dmxGetButtonMapping(dmxLocal, detail);
 #else
+        detail = dmxGetButtonMapping(dmxLocal, detail);
         {
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
diff-tree 0f873a9d4f02b399c37b4058c6a9a2e21aa205e8 (from 3a0ce1084a18e17a3c8a009d99c228652b8763a9)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 14:51:38 2007 -0600

    remove some debug code

diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index d14aeb7..a9d902e 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -505,7 +505,6 @@ static int dmxDeviceOnOff(DeviceIntPtr p
                                               GetMaximumEventsNum(),
 #endif
                                               Relative);
-                ErrorF("MOTION BUFFER SIZE %d\n", GetMaximumEventsNum());
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
@@ -588,10 +587,6 @@ static void dmxProcessInputEvents(DMXInp
 {
     int i;
 
-    /*
-    ErrorF("%s\n", __FUNCTION__);
-    */
-
     dmxeqProcessInputEvents();
 #if 00 /*BP*/
     miPointerUpdate();
diff-tree 3a0ce1084a18e17a3c8a009d99c228652b8763a9 (from 12016f20f7f5365f30cfbeb05568b3fb89759e5a)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 14:51:21 2007 -0600

    for completeness, init dummy's min/maxval[1] values (vertical axis)

diff --git a/hw/dmx/input/dmxdummy.c b/hw/dmx/input/dmxdummy.c
index d6e614e..b9c72b0 100644
--- a/hw/dmx/input/dmxdummy.c
+++ b/hw/dmx/input/dmxdummy.c
@@ -79,7 +79,9 @@ void dmxDummyMouGetInfo(DevicePtr pDev, 
     info->valuatorClass    = 1;
     info->numRelAxes       = 2;
     info->minval[0]        = 0;
+    info->minval[1]        = 0;
     info->maxval[0]        = 0;
+    info->maxval[1]        = 0;
     info->res[0]           = 1;
     info->minres[0]        = 0;
     info->maxres[0]        = 1;
diff-tree 12016f20f7f5365f30cfbeb05568b3fb89759e5a (from 0aaf28e5633a59563b89a2e42d19fabc84adc3ed)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 14:50:48 2007 -0600

    As for normal mouse device, init valuator maxval[] to real values, not zero.

diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index 835909e..aac5e08 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -860,12 +860,17 @@ void dmxConsoleInit(DevicePtr pDev)
  * for pointers. */
 void dmxConsoleMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
 {
+    GETPRIVFROMPDEV;
+
     info->buttonClass      = 1;
     dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
     info->valuatorClass    = 1;
     info->numRelAxes       = 2;
-    info->minval[0]        = 0;
-    info->maxval[0]        = 0;
+    info->minval[0] = 0;
+    info->minval[1] = 0;
+    /* max possible console window size: */
+    info->maxval[0] = DisplayWidth(priv->display, DefaultScreen(priv->display));
+    info->maxval[1] = DisplayHeight(priv->display, DefaultScreen(priv->display));
     info->res[0]           = 1;
     info->minres[0]        = 0;
     info->maxres[0]        = 1;
diff-tree 0aaf28e5633a59563b89a2e42d19fabc84adc3ed (from 0013bf6ddb3867c9a504603434d8c2ec83f3f3bc)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:41:30 2007 -0600

    In dmxBackendMouGetInfo() initialize the info->minval[], maxval[] arrays to the size of the backend display.
    
    It seems that the changes to X input exposed a problem that wasn't detected
    before.  The axis clipping code in GetPointerEvents() uses those limits to
    constrain the pointer's coordinate range.  The max was zero so the pointer
    couldn't move.

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 09a2a32..315979e 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -592,12 +592,16 @@ void dmxBackendInit(DevicePtr pDev)
 /** Get information about the backend pointer (for initialization). */
 void dmxBackendMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
 {
+    const DMXScreenInfo *dmxScreen = dmxBackendInitPrivate(pDev);
+
     info->buttonClass      = 1;
     dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
     info->valuatorClass    = 1;
     info->numRelAxes       = 2;
     info->minval[0]        = 0;
-    info->maxval[0]        = 0;
+    info->minval[1]        = 0;
+    info->maxval[0]        = dmxScreen->beWidth;
+    info->maxval[1]        = dmxScreen->beHeight;
     info->res[0]           = 1;
     info->minres[0]        = 0;
     info->maxres[0]        = 1;
diff-tree 0013bf6ddb3867c9a504603434d8c2ec83f3f3bc (from 08a88d1803f672555141011e082fbc0edeedcf05)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:39:04 2007 -0600

    undo 1280 valuator hack

diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index cf68051..d14aeb7 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -509,7 +509,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           1280/*info.maxval[0]*/, info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -520,7 +520,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           1280/*info.maxval[0]*/, info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -531,7 +531,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], 1280/*info.maxval[i+1]*/,
+                                           info.minval[i+1], info.maxval[i+1],
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif
diff-tree 08a88d1803f672555141011e082fbc0edeedcf05 (from 70683e338dacc48e3adf489d66ec33b29dfc3b77)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:28:14 2007 -0600

    Pass num_valuators=0 for ButtonPress/Release. This seems to fix the button coordinate problem

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index fae2049..d174a59 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -799,20 +799,12 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-
-           valuators[0] = e->xbutton.x;
-           valuators[1] = e->xbutton.y;
-           /*
-           valuators[0] = dmxGlobalX;
-           valuators[1] = dmxGlobalY;
-           */
            valuators[2] = e->xbutton.button;
-           nevents = GetPointerEvents(events,
-                                      /*pDev*/p,
-                                      /*KeyPress*/type,
-                                      detail,
+           nevents = GetPointerEvents(events, p, type, detail,
                                       POINTER_ABSOLUTE,
-                                      0, 2/*3*/, valuators);
+                                      0,   /* first_valuator = 0 */
+                                      0,   /* num_valuators = 0 */
+                                      valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
diff-tree 70683e338dacc48e3adf489d66ec33b29dfc3b77 (from f2808005f4ee72c5fd7f5f3dcca181306485113e)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:26:27 2007 -0600

    formatting fixes

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 7efb2ee..09a2a32 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -358,7 +358,8 @@ void dmxBackendCollectEvents(DevicePtr p
 	switch (X.type) {
         case EnterNotify:
             dmxCommonSaveState(priv);
-            if (entered++) continue;
+            if (entered++)
+                continue;
             priv->entered = 1;
             ignoreLeave   = 1;
             DMXDBG5("dmxBackendCollectEvents: Enter %lu %d,%d; GRAB %s %p\n",
@@ -382,7 +383,8 @@ void dmxBackendCollectEvents(DevicePtr p
                 continue;
             }
             dmxCommonRestoreState(priv);
-            if (left++) continue;
+            if (left++)
+                continue;
             DMXDBG7("dmxBackendCollectEvents: Leave %lu %d,%d %d %d %s %s\n",
                     X.xcrossing.root, X.xcrossing.x, X.xcrossing.y,
                     X.xcrossing.detail, X.xcrossing.focus,
@@ -403,7 +405,8 @@ void dmxBackendCollectEvents(DevicePtr p
                     priv->newscreen,
                     X.xmotion.x, X.xmotion.y,
                     entered, priv->lastX, priv->lastY);
-            if (dmxBackendPendingMotionEvent(priv, TRUE)) continue;
+            if (dmxBackendPendingMotionEvent(priv, TRUE))
+                continue;
             if (!(dmxScreen = dmxBackendFindWindow(priv, X.xmotion.window)))
                 dmxLog(dmxFatal,
                        "   Event on non-existant window %lu\n",
diff-tree f2808005f4ee72c5fd7f5f3dcca181306485113e (from 5257b32e492bd2082bef6a4cd0fea03ce093c0f8)
Author: Alberto Mardegan <mardy at users.sourceforge.net>
Date:   Sat Mar 31 16:51:24 2007 +0200

    Bug #6620: Fixed a missing 'else' in ATIPseudoDMAInit().
    
    Before this, we'd write some registers twice on R200 hardware and also
    possibly end up with a bad value in atis->cce_pri_size.

diff --git a/hw/kdrive/ati/ati_dma.c b/hw/kdrive/ati/ati_dma.c
index f75ff12..70b86d3 100644
--- a/hw/kdrive/ati/ati_dma.c
+++ b/hw/kdrive/ati/ati_dma.c
@@ -788,7 +788,7 @@ ATIPseudoDMAInit(ScreenPtr pScreen)
 		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
 		    R200_CSQ_CNT_PRIMARY_MASK;
 		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
-	} if (atic->is_radeon) {
+	} else if (atic->is_radeon) {
 		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
 		    RADEON_CSQ_PRIPIO_INDDIS);
 		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
diff-tree 5257b32e492bd2082bef6a4cd0fea03ce093c0f8 (from 73fdc16bc4f4e21ff604b3f9ded23b40398fb1b6)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Wed Mar 28 15:51:24 2007 -0700

    Bump video driver ABI to 2.0 for cw change (commit 6ed08949af4f7ac09170d3d9581e4092b24a84ee).

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 2811839..8e644c4 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -84,7 +84,7 @@ typedef enum {
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 3)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(1, 2)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(2, 0)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(1, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 5)
diff-tree 73fdc16bc4f4e21ff604b3f9ded23b40398fb1b6 (from ebdc8ce5c108dc3b6b0004e7c7939d1a5bef8676)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 16:07:26 2007 -0600

    formatting fixes

diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index d76dd9b..cf68051 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -472,8 +472,10 @@ static int dmxDeviceOnOff(DeviceIntPtr p
     memset(&info, 0, sizeof(info));
     switch (what) {
     case DEVICE_INIT:
-        if (dmxLocal->init) dmxLocal->init(pDev);
-        if (dmxLocal->get_info) dmxLocal->get_info(pDev, &info);
+        if (dmxLocal->init)
+            dmxLocal->init(pDev);
+        if (dmxLocal->get_info)
+            dmxLocal->get_info(pDev, &info);
         if (info.keyboard) {    /* XKEYBOARD makes this a special case */
             dmxKeyboardOn(pDevice, &info);
             break;
@@ -594,7 +596,8 @@ static void dmxProcessInputEvents(DMXInp
 #if 00 /*BP*/
     miPointerUpdate();
 #endif
-    if (dmxInput->detached) return;
+    if (dmxInput->detached)
+        return;
     for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
         if (dmxInput->devs[i]->process_input) {
 #if 11 /*BP*/
@@ -633,7 +636,8 @@ static void dmxUpdateWindowInformation(D
     }
 #endif
 
-    if (dmxInput->detached) return;
+    if (dmxInput->detached)
+        return;
     for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
         if (dmxInput->devs[i]->update_info)
             dmxInput->devs[i]->update_info(dmxInput->devs[i]->private,
@@ -644,7 +648,8 @@ static void dmxCollectAll(DMXInputInfo *
 {
     int i;
 
-    if (dmxInput->detached) return;
+    if (dmxInput->detached)
+        return;
     for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
         if (dmxInput->devs[i]->collect_events)
             dmxInput->devs[i]->collect_events(&dmxInput->devs[i]
@@ -741,7 +746,8 @@ static DeviceIntPtr dmxAddDevice(DMXLoca
     char         *devname;
     DMXInputInfo *dmxInput;
 
-    if (!dmxLocal) return NULL;
+    if (!dmxLocal)
+        return NULL;
     dmxInput = &dmxInputs[dmxLocal->inputIdx];
 
     if (dmxLocal->sendsCore) {
diff-tree ebdc8ce5c108dc3b6b0004e7c7939d1a5bef8676 (from 3c7413e0c2f87e154aa8aa4a83bd585a6d1091e8)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 16:05:46 2007 -0600

    Checkpoint DMX updates: things are working much better now, but still not 100% right.
    
    Use new dmxCoreMotion2() function which enqueues motion events with
    GetPointerEvents()/mieqEnqueue().
    The clipAxis() code in GetPointerEvents() is causing some grief.  The
    limits seem to have always been (0,0) according to the original calls
    to InitValuatorAxisStruct() in dmxinputinit.c.
    Terrible hack for now: Call InitValuatorAxisStruct() with hard-coded max
    values of 1280 (my screen width).

diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index 11c89d8..a7d9378 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -889,7 +889,7 @@ static void dmxSetCursor(ScreenPtr pScre
     gx = start->rootXOrigin + x;
     gy = start->rootYOrigin + y;
     if (x && y && (GX != gx || GY != gy))
-        dmxCoreMotion(gx, gy, 0, DMX_NO_BLOCK);
+        dmxCoreMotion(NULL, gx, gy, 0, DMX_NO_BLOCK);
     
     if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared) {
         _dmxSetCursor(pScreen, pCursor, x, y);
diff --git a/hw/dmx/dmxinput.h b/hw/dmx/dmxinput.h
index 59fa823..3fb5870 100644
--- a/hw/dmx/dmxinput.h
+++ b/hw/dmx/dmxinput.h
@@ -154,7 +154,7 @@ typedef enum {
 
 extern void          dmxGetGlobalPosition(int *x, int *y);
 extern DMXScreenInfo *dmxFindFirstScreen(int x, int y);
-extern void          dmxCoreMotion(int x, int y, int delta,
+extern void          dmxCoreMotion(DevicePtr pDev, int x, int y, int delta,
                                    DMXBlockType block);
 
 /* Support for dynamic addition of inputs.  This functions is defined in
diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 61d1bfe..7efb2ee 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -395,7 +395,7 @@ void dmxBackendCollectEvents(DevicePtr p
             }
             break;
 	case MotionNotify:
-#if 00 /*BP*/
+#if 001 /*BP*/
             DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)"
                     " newscreen=%d: %d %d (e=%d; last=%d,%d)\n",
                     dmxScreen->index, priv->myScreen,
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 0cc3054..fae2049 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -191,7 +191,42 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
     return NULL;
 }
 
-void dmxCoreMotion(int x, int y, int delta, DMXBlockType block)
+
+#if 11/*BP*/
+
+static void enqueueMotion(DevicePtr pDev, int x, int y)
+{
+    GETDMXINPUTFROMPDEV;
+    DeviceIntPtr p = dmxLocal->pDevice;
+    int i, nevents, valuators[3];
+    xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    int detail = 0;
+
+    valuators[0] = x;
+    valuators[1] = y;
+    valuators[2] = detail;
+    nevents = GetPointerEvents(events,
+                               /*pDev*/p,
+                               MotionNotify,
+                               detail,
+                               POINTER_ABSOLUTE,
+                               0, 2, valuators);
+    ErrorF("MOTION2 %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
+    /*
+      ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
+      detail, e->xmotion.state,
+      valuators[0], valuators[1], valuators[2],
+      nevents);
+    */
+    for (i = 0; i < nevents; i++)
+       mieqEnqueue(p, events + i);
+    xfree(events);
+    return;
+}
+
+
+static void
+dmxCoreMotion2(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
 {
     DMXScreenInfo *dmxScreen;
     DMXInputInfo  *dmxInput;
@@ -214,6 +249,106 @@ void dmxCoreMotion(int x, int y, int del
     if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
     if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
     
+    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
+
+    if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
+        localX = dmxGlobalX - dmxScreen->rootXOrigin;
+        localY = dmxGlobalY - dmxScreen->rootYOrigin;
+        if ((pScreen = miPointerGetScreen(inputInfo.pointer))
+            && pScreen->myNum == dmxScreen->index) {
+                                /* Screen is old screen */
+            if (block)
+                dmxSigioBlock();
+#if 000
+            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
+                                 GetTimeInMillis());
+#else
+            if (pDev)
+               enqueueMotion(pDev, localX, localY);
+#endif
+            if (block)
+                dmxSigioUnblock();
+        } else {
+                                /* Screen is new */
+            DMXDBG4("   New screen: old=%d new=%d localX=%d localY=%d\n",
+                    pScreen->myNum, dmxScreen->index, localX, localY);
+            if (block)
+                dmxSigioBlock();
+            dmxeqProcessInputEvents();
+            miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
+                               localX, localY);
+#if 000
+            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
+                                 GetTimeInMillis());
+#else
+            if (pDev)
+               enqueueMotion(pDev, localX, localY);
+#endif
+            if (block)
+                dmxSigioUnblock();
+        }
+#if 00
+        miPointerGetPosition(inputInfo.pointer, &localX, &localY);
+
+        if ((pScreen = miPointerGetScreen(inputInfo.pointer))) {
+            dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
+            dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
+            ErrorF("Global is now %d, %d  %d, %d\n", dmxGlobalX, dmxGlobalY,
+                   localX, localY);
+            DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
+                    " on screen index=%d/%d localX=%d localY=%d\n",
+                    dmxGlobalX, dmxGlobalY,
+                    dmxScreen ? dmxScreen->index : -1, pScreen->myNum,
+                    localX, localY);
+        }
+#endif
+    }
+                                /* Send updates down to all core input
+                                 * drivers */
+    for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
+        int j;
+
+        for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
+            if (!dmxInput->detached
+                && dmxInput->devs[j]->sendsCore
+                && dmxInput->devs[j]->update_position)
+                dmxInput->devs[j]->update_position(dmxInput->devs[j]->private,
+                                                   dmxGlobalX, dmxGlobalY);
+    }
+    if (!dmxScreen) ProcessInputEvents();
+}
+#endif
+
+void dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
+{
+    DMXScreenInfo *dmxScreen;
+    DMXInputInfo  *dmxInput;
+    ScreenPtr     pScreen;
+    int           localX;
+    int           localY;
+    int           i;
+
+#if 11/*BP*/
+    dmxCoreMotion2(pDev, x, y, delta, block);
+    return;
+#endif
+
+    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y) return;
+    
+    DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
+            x, y, delta, dmxGlobalX, dmxGlobalY);
+
+    dmxGlobalInvalid = 0;
+    dmxGlobalX       = x;
+    dmxGlobalY       = y;
+
+    if (dmxGlobalX < 0)                dmxGlobalX = 0;
+    if (dmxGlobalY < 0)                dmxGlobalY = 0;
+    if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
+    if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
+    
+    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
+
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
         localY = dmxGlobalY - dmxScreen->rootYOrigin;
@@ -285,6 +420,8 @@ void dmxCoreMotion(int x, int y, int del
     if (!dmxScreen) ProcessInputEvents();
 }
 
+
+
 #ifdef XINPUT
 #define DMX_MAX_AXES 32         /* Max axes reported by this routine */
 static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
@@ -534,12 +671,18 @@ void dmxMotion(DevicePtr pDev, int *v, i
         return;
     }
 #endif
-    if (axesCount == 2) switch (type) {
-      case DMX_RELATIVE:          dmxCoreMotion(dmxGlobalX - v[0],
-                                                dmxGlobalY - v[1],
-                                                0, block);              break;
-      case DMX_ABSOLUTE:          dmxCoreMotion(v[0], v[1], 0, block);  break;
-      case DMX_ABSOLUTE_CONFINED: dmxCoreMotion(v[0], v[1], -1, block); break;
+    if (axesCount == 2) {
+        switch (type) {
+        case DMX_RELATIVE:
+            dmxCoreMotion(pDev, dmxGlobalX - v[0], dmxGlobalY - v[1], 0, block);
+            break;
+        case DMX_ABSOLUTE:
+            dmxCoreMotion(pDev, v[0], v[1], 0, block);
+            break;
+        case DMX_ABSOLUTE_CONFINED:
+            dmxCoreMotion(pDev, v[0], v[1], -1, block);
+            break;
+        }
     }
 }
 
@@ -669,7 +812,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 3, valuators);
+                                      0, 2/*3*/, valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 1465ade..d76dd9b 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -507,7 +507,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           1280/*info.maxval[0]*/, info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -518,7 +518,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           1280/*info.maxval[0]*/, info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -529,7 +529,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], info.maxval[i+1],
+                                           info.minval[i+1], 1280/*info.maxval[i+1]*/,
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif
diff-tree 3c7413e0c2f87e154aa8aa4a83bd585a6d1091e8 (from 7989dacdcb1449b10d7733dda11cd96e260e9fae)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 14:07:04 2007 -0600

    Tweak some parameters, etc.  Things seem a little better now, but still a ways to go.

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 3027457..0cc3054 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -262,6 +262,7 @@ void dmxCoreMotion(int x, int y, int del
 #endif
             dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
             dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
+           ErrorF("Global is now %d, %d\n", dmxGlobalX, dmxGlobalY);
             DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
                     " on screen index=%d/%d localX=%d localY=%d\n",
                     dmxGlobalX, dmxGlobalY,
@@ -655,19 +656,20 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           /*
+
            valuators[0] = e->xbutton.x;
            valuators[1] = e->xbutton.y;
-           */
+           /*
            valuators[0] = dmxGlobalX;
            valuators[1] = dmxGlobalY;
+           */
            valuators[2] = e->xbutton.button;
            nevents = GetPointerEvents(events,
                                       /*pDev*/p,
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 1, valuators);
+                                      0, 3, valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
@@ -698,7 +700,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 1, valuators);
+                                      0, 3, valuators);
            ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
            /*
            ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index c098c46..1465ade 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -507,7 +507,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           /*1280*/info.maxval[0], info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -518,7 +518,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           /*1280*/info.maxval[0], info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -529,7 +529,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], /*1280*/info.maxval[i+1],
+                                           info.minval[i+1], info.maxval[i+1],
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif
diff-tree 7989dacdcb1449b10d7733dda11cd96e260e9fae (from 1ea842960fddbc6363cc6e7f914d70ba45525a6b)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 13:44:24 2007 -0600

    num_valuators=1 for GetPointerEvents(), hack ButtonPress/Release position

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 9a31ba6..3027457 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -655,19 +655,19 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+           /*
            valuators[0] = e->xbutton.x;
            valuators[1] = e->xbutton.y;
-           /*
+           */
            valuators[0] = dmxGlobalX;
            valuators[1] = dmxGlobalY;
-           */
            valuators[2] = e->xbutton.button;
            nevents = GetPointerEvents(events,
                                       /*pDev*/p,
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 0, valuators);
+                                      0, 1, valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
@@ -698,7 +698,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 0, valuators);
+                                      0, 1, valuators);
            ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
            /*
            ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
diff-tree 1ea842960fddbc6363cc6e7f914d70ba45525a6b (from 92e8cdbd32b0d86cabd4ad88e3240bf90c018b9a)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 13:43:15 2007 -0600

    more debug

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 48de4c9..61d1bfe 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -464,9 +464,8 @@ void dmxBackendCollectEvents(DevicePtr p
 #if 11/*BP*/
         case ButtonPress:
         case ButtonRelease:
-           /*
            ErrorF("press/release at %d, %d\n", X.xbutton.x, X.xbutton.y);
-           */
+           /* fall-through */
 #endif
 	default:
                                 /* Pass the whole event here, because
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 90b45a9..9a31ba6 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -638,9 +638,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                        /*pDev*/p,
                                        /*KeyPress*/type,
                                        /*n*/detail);
-           /*
-           ErrorF("NEW KEY EVENT %d  n=%d\n", detail, nevents);
-           */
+           ErrorF("KEY %d  n=%d\n", detail, nevents);
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
@@ -659,6 +657,10 @@ void dmxEnqueue(DevicePtr pDev, int type
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
            valuators[0] = e->xbutton.x;
            valuators[1] = e->xbutton.y;
+           /*
+           valuators[0] = dmxGlobalX;
+           valuators[1] = dmxGlobalY;
+           */
            valuators[2] = e->xbutton.button;
            nevents = GetPointerEvents(events,
                                       /*pDev*/p,
@@ -666,11 +668,10 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       detail,
                                       POINTER_ABSOLUTE,
                                       0, 0, valuators);
-           /*
-           ErrorF("NEW PTR EVENT %d (%d,%d,%d) n=%d\n",
-                  detail, valuators[0], valuators[1], valuators[2],
-                  nevents);
-           */
+
+           ErrorF("BUTTON %d, %d %d  n=%d\n",
+                  valuators[0], valuators[1], valuators[2], nevents);
+
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
@@ -698,6 +699,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       detail,
                                       POINTER_ABSOLUTE,
                                       0, 0, valuators);
+           ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
            /*
            ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
                   detail, e->xmotion.state,
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 7c0ae58..c098c46 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -503,10 +503,11 @@ static int dmxDeviceOnOff(DeviceIntPtr p
                                               GetMaximumEventsNum(),
 #endif
                                               Relative);
+                ErrorF("MOTION BUFFER SIZE %d\n", GetMaximumEventsNum());
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           /*1280*/info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -517,7 +518,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           /*1280*/info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -528,7 +529,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], info.maxval[i+1],
+                                           info.minval[i+1], /*1280*/info.maxval[i+1],
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif


More information about the xorg-commit mailing list